Skip to content

Commit

Permalink
Clean GetStyle
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed Mar 6, 2021
1 parent c6eec9d commit 159d961
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 69 deletions.
6 changes: 1 addition & 5 deletions src/server/services/wms/qgswms.cpp
Expand Up @@ -125,11 +125,7 @@ namespace QgsWms
{
writeGetSchemaExtension( response );
}
else if ( QSTR_COMPARE( req, "GetStyle" ) )
{
writeGetStyle( mServerIface, project, version, request, response );
}
else if ( QSTR_COMPARE( req, "GetStyles" ) )
else if ( QSTR_COMPARE( req, "GetStyle" ) or QSTR_COMPARE( req, "GetStyles" ) )
{
writeGetStyles( mServerIface, project, version, request, response );
}
Expand Down
44 changes: 0 additions & 44 deletions src/server/services/wms/qgswmsgetstyles.cpp
Expand Up @@ -78,44 +78,6 @@ namespace QgsWms
return getStyledLayerDescriptorDocument( serverIface, project, layerList );
}

//GetStyle for compatibility with earlier QGIS versions
void writeGetStyle( QgsServerInterface *serverIface, const QgsProject *project, const QString &version,
const QgsServerRequest &request, QgsServerResponse &response )
{
QDomDocument doc = getStyle( serverIface, project, version, request );
response.setHeader( QStringLiteral( "Content-Type" ), QStringLiteral( "text/xml; charset=utf-8" ) );
response.write( doc.toByteArray() );
}

QDomDocument getStyle( QgsServerInterface *serverIface, const QgsProject *project, const QString &version,
const QgsServerRequest &request )
{
Q_UNUSED( version )

QgsServerRequest::Parameters parameters = request.parameters();

QDomDocument doc;

QString styleName = parameters.value( QStringLiteral( "STYLE" ) );
QString layerName = parameters.value( QStringLiteral( "LAYER" ) );

if ( styleName.isEmpty() )
{
throw QgsBadRequestException( QgsServiceException::QGIS_MissingParameterValue,
QgsWmsParameter::STYLE );
}

if ( layerName.isEmpty() )
{
throw QgsBadRequestException( QgsServiceException::QGIS_MissingParameterValue,
QgsWmsParameter::LAYERS );
}

QStringList layerList;
layerList.append( layerName );
return getStyledLayerDescriptorDocument( serverIface, project, layerList );
}

namespace
{
QDomDocument getStyledLayerDescriptorDocument( QgsServerInterface *serverIface, const QgsProject *project,
Expand Down Expand Up @@ -224,10 +186,4 @@ namespace QgsWms
return myDocument;
}
}


} // namespace QgsWms




20 changes: 0 additions & 20 deletions src/server/services/wms/qgswmsgetstyles.h
Expand Up @@ -35,24 +35,4 @@ namespace QgsWms
QDomDocument getStyles( QgsServerInterface *serverIface, const QgsProject *project, const QString &version,
const QgsServerRequest &request );

//GetStyle for compatibility with earlier QGIS versions

/**
* Output GetStyle response
*/
void writeGetStyle( QgsServerInterface *serverIface, const QgsProject *project, const QString &version,
const QgsServerRequest &request, QgsServerResponse &response );

/**
* Returns an SLD file with the style of the requested layer
*/
QDomDocument getStyle( QgsServerInterface *serverIface, const QgsProject *project, const QString &version,
const QgsServerRequest &request );



} // namespace QgsWms




0 comments on commit 159d961

Please sign in to comment.