Skip to content

Commit

Permalink
Merge pull request #4630 from rldhont/server-wms-configparser-getcontext
Browse files Browse the repository at this point in the history
[Server] WMS GetContext refactoring
  • Loading branch information
rldhont committed May 26, 2017
2 parents 8c873b1 + ce3cbeb commit c05d779
Show file tree
Hide file tree
Showing 9 changed files with 488 additions and 17 deletions.
2 changes: 1 addition & 1 deletion python/server/qgsserverprojectutils.sip
Expand Up @@ -127,7 +127,7 @@ namespace QgsServerProjectUtils
* \param project the QGIS project
* \returns if Inspire is activated.
*/
bool wmsInspireActivated( const QgsProject &project );
bool wmsInspireActivate( const QgsProject &project );

/** Returns the Inspire language.
* \param project the QGIS project
Expand Down
31 changes: 28 additions & 3 deletions src/server/qgsserverprojectutils.cpp
Expand Up @@ -34,7 +34,20 @@ QString QgsServerProjectUtils::owsServiceAbstract( const QgsProject &project )

QStringList QgsServerProjectUtils::owsServiceKeywords( const QgsProject &project )
{
return project.readListEntry( QStringLiteral( "WMSKeywordList" ), QStringLiteral( "/" ) );
QStringList keywordList;
QStringList list = project.readListEntry( QStringLiteral( "WMSKeywordList" ), QStringLiteral( "/" ), QStringList() );
if ( !list.isEmpty() )
{
for ( int i = 0; i < list.size(); ++i )
{
QString keyword = list.at( i );
if ( !keyword.isEmpty() )
{
keywordList.append( keyword );
}
}
}
return keywordList;
}

QString QgsServerProjectUtils::owsServiceOnlineResource( const QgsProject &project )
Expand Down Expand Up @@ -104,7 +117,7 @@ bool QgsServerProjectUtils::wmsInfoFormatSia2045( const QgsProject &project )
return false;
}

bool QgsServerProjectUtils::wmsInspireActivated( const QgsProject &project )
bool QgsServerProjectUtils::wmsInspireActivate( const QgsProject &project )
{
return project.readBoolEntry( QStringLiteral( "WMSInspire" ), QStringLiteral( "/activated" ) );
}
Expand Down Expand Up @@ -141,7 +154,19 @@ QStringList QgsServerProjectUtils::wmsRestrictedComposers( const QgsProject &pro

QStringList QgsServerProjectUtils::wmsOutputCrsList( const QgsProject &project )
{
QStringList crsList = project.readListEntry( QStringLiteral( "WMSCrsList" ), QStringLiteral( "/" ), QStringList() );
QStringList crsList;
QStringList wmsCrsList = project.readListEntry( QStringLiteral( "WMSCrsList" ), QStringLiteral( "/" ), QStringList() );
if ( !wmsCrsList.isEmpty() )
{
for ( int i = 0; i < wmsCrsList.size(); ++i )
{
QString crs = wmsCrsList.at( i );
if ( !crs.isEmpty() )
{
crsList.append( crs );
}
}
}
if ( crsList.isEmpty() )
{
QStringList valueList = project.readListEntry( QStringLiteral( "WMSEpsgList" ), QStringLiteral( "/" ), QStringList() );
Expand Down
2 changes: 1 addition & 1 deletion src/server/qgsserverprojectutils.h
Expand Up @@ -129,7 +129,7 @@ namespace QgsServerProjectUtils
* \param project the QGIS project
* \returns if Inspire is activated.
*/
SERVER_EXPORT bool wmsInspireActivated( const QgsProject &project );
SERVER_EXPORT bool wmsInspireActivate( const QgsProject &project );

/** Returns the Inspire language.
* \param project the QGIS project
Expand Down
10 changes: 5 additions & 5 deletions src/server/services/wms/qgswmsgetcapabilities.cpp
Expand Up @@ -34,10 +34,10 @@
#include "qgslayertreelayer.h"
#include "qgslayertreemodel.h"
#include "qgslayertree.h"
#include "qgsmaplayerstylemanager.h"

#include "qgscsexception.h"
#include "qgsexpressionnodeimpl.h"
#include "qgsmaplayerstylemanager.h"


namespace QgsWms
Expand Down Expand Up @@ -180,7 +180,7 @@ namespace QgsWms
schemaLocation += QLatin1String( " http://www.opengis.net/sld" );
schemaLocation += QLatin1String( " http://schemas.opengis.net/sld/1.1.0/sld_capabilities.xsd" );
schemaLocation += QLatin1String( " http://www.qgis.org/wms" );
if ( QgsServerProjectUtils::wmsInspireActivated( *project ) )
if ( QgsServerProjectUtils::wmsInspireActivate( *project ) )
{
wmsCapabilitiesElement.setAttribute( QStringLiteral( "xmlns:inspire_common" ), QStringLiteral( "http://inspire.ec.europa.eu/schemas/common/1.0" ) );
wmsCapabilitiesElement.setAttribute( QStringLiteral( "xmlns:inspire_vs" ), QStringLiteral( "http://inspire.ec.europa.eu/schemas/inspire_vs/1.0" ) );
Expand Down Expand Up @@ -533,7 +533,7 @@ namespace QgsWms
elem.setAttribute( QStringLiteral( "RemoteWCS" ), QStringLiteral( "0" ) );
capabilityElem.appendChild( elem );

if ( QgsServerProjectUtils::wmsInspireActivated( *project ) )
if ( QgsServerProjectUtils::wmsInspireActivate( *project ) )
{
capabilityElem.appendChild( getInspireCapabilitiesElement( doc, project ) );
}
Expand All @@ -546,7 +546,7 @@ namespace QgsWms
{
QDomElement inspireCapabilitiesElem;

if ( !QgsServerProjectUtils::wmsInspireActivated( *project ) )
if ( !QgsServerProjectUtils::wmsInspireActivate( *project ) )
return inspireCapabilitiesElem;

inspireCapabilitiesElem = doc.createElement( QStringLiteral( "inspire_vs:ExtendedCapabilities" ) );
Expand Down Expand Up @@ -993,7 +993,7 @@ namespace QgsWms
// add details about supported styles of the layer
appendLayerStyles( doc, layerElem, l, project, version, request );

//min/max scale denominatormScaleBasedVisibility
//min/max scale denominatorScaleBasedVisibility
if ( l->hasScaleBasedVisibility() )
{
if ( version == QLatin1String( "1.1.1" ) )
Expand Down

0 comments on commit c05d779

Please sign in to comment.