Skip to content

Commit

Permalink
Version number negociation in parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed Mar 9, 2021
1 parent ab8d645 commit 19348b8
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
2 changes: 1 addition & 1 deletion python/server/auto_generated/qgsserverparameters.sip.in
Expand Up @@ -348,7 +348,7 @@ defined.
:return: filename
%End

QString version() const;
virtual QString version() const;
%Docstring
Returns VERSION parameter as a string or an empty string if not
defined.
Expand Down
2 changes: 1 addition & 1 deletion src/server/qgsserverparameters.h
Expand Up @@ -323,7 +323,7 @@ class SERVER_EXPORT QgsServerParameters
* defined.
* \returns version
*/
QString version() const;
virtual QString version() const;

protected:

Expand Down
34 changes: 28 additions & 6 deletions src/server/services/wms/qgswmsparameters.cpp
Expand Up @@ -753,22 +753,44 @@ namespace QgsWms
return mWmsParameters[ QgsWmsParameter::DPI ].toDouble();
}

QgsProjectVersion QgsWmsParameters::versionAsNumber() const
QString QgsWmsParameters::version() const
{
const QString vStr = version();
QString vStr = QgsServerParameters::version();

QgsProjectVersion version;

if ( vStr.isEmpty() )
{
version = QgsProjectVersion( 1, 3, 0 ); // default value
if ( ! wmtver().isEmpty() )
{
vStr = wmtver();
}
else
{
vStr = QStringLiteral( "1.3.0" );
}
}
else if ( mVersions.contains( QgsProjectVersion( vStr ) ) )
else if ( !mVersions.contains( QgsProjectVersion( vStr ) ) )
{
version = QgsProjectVersion( vStr );
// WMS 1.3.0 specification: If a version lower than any of those
// known to the server is requested, then the server shall send the
// lowest version it supports.
if ( QgsProjectVersion( 1, 1, 1 ) > QgsProjectVersion( vStr ) )
{
vStr = QStringLiteral( "1.1.1" );
}
else
{
vStr = QStringLiteral( "1.3.0" );
}
}

return version;
return vStr;
}

QgsProjectVersion QgsWmsParameters::versionAsNumber() const
{
return QgsProjectVersion( version() );
}

bool QgsWmsParameters::versionIsValid( const QString version ) const
Expand Down
2 changes: 2 additions & 0 deletions src/server/services/wms/qgswmsparameters.h
Expand Up @@ -1327,6 +1327,8 @@ namespace QgsWms
*/
bool isForce2D() const;

QString version() const override;

private:
static bool isExternalLayer( const QString &name );

Expand Down

0 comments on commit 19348b8

Please sign in to comment.