Skip to content

Commit

Permalink
Merge pull request #4597 from rldhont/server-wms-configparser-getcapa…
Browse files Browse the repository at this point in the history
…bilities-part2

[Server] WMS GetCapabilities refactoring - Part 2
  • Loading branch information
rldhont committed May 22, 2017
2 parents d93d0a8 + 087e7f7 commit 2b39c1e
Show file tree
Hide file tree
Showing 8 changed files with 1,220 additions and 9 deletions.
86 changes: 86 additions & 0 deletions python/server/qgsserverprojectutils.sip
Expand Up @@ -111,12 +111,90 @@ namespace QgsServerProjectUtils
*/
int wmsMaxHeight( const QgsProject &project );

/** Returns if layer ids are used as name in WMS.
* \param project the QGIS project
* \returns if layer ids are used as name.
*/
bool wmsUseLayerIds( const QgsProject &project );

/** Returns if the info format is SIA20145.
* \param project the QGIS project
* \returns if the info format is SIA20145.
*/
bool wmsInfoFormatSia2045( const QgsProject &project );

/** Returns if Inspire is activated.
* \param project the QGIS project
* \returns if Inspire is activated.
*/
bool wmsInspireActivated( const QgsProject &project );

/** Returns the Inspire language.
* \param project the QGIS project
* \returns the Inspire language if defined in project.
*/
QString wmsInspireLanguage( const QgsProject &project );

/** Returns the Inspire metadata URL.
* \param project the QGIS project
* \returns the Inspire metadata URL if defined in project.
*/
QString wmsInspireMetadataUrl( const QgsProject &project );

/** Returns the Inspire metadata URL type.
* \param project the QGIS project
* \returns the Inspire metadata URL type if defined in project.
*/
QString wmsInspireMetadataUrlType( const QgsProject &project );

/** Returns the Inspire temporal reference.
* \param project the QGIS project
* \returns the Inspire temporal reference if defined in project.
*/
QString wmsInspireTemporalReference( const QgsProject &project );

/** Returns the Inspire metadata date.
* \param project the QGIS project
* \returns the Inspire metadata date if defined in project.
*/
QString wmsInspireMetadataDate( const QgsProject &project );

/** Returns the restricted composer list.
* \param project the QGIS project
* \returns the restricted composer list if defined in project.
*/
QStringList wmsRestrictedComposers( const QgsProject &project );

/** Returns the WMS ervice url defined in a QGIS project.
* @param project the QGIS project
* @return url if defined in project, an empty string otherwise.
*/
QString wmsServiceUrl( const QgsProject &project );

/** Returns the WMS root layer name defined in a QGIS project.
* \param project the QGIS project
* \returns root layer name if defined in project, an empty string otherwise.
*/
QString wmsRootName( const QgsProject &project );

/** Returns the restricted layer name list.
* \param project the QGIS project
* \returns the restricted layer name list if defined in project.
*/
QStringList wmsRestrictedLayers( const QgsProject &project );

/** Returns the WMS output CRS list.
* \param project the QGIS project
* \returns the WMS output CRS list.
*/
QStringList wmsOutputCrsList( const QgsProject &project );

/** Returns the WMS Extent restriction.
* \param project the QGIS project
* \returns the WMS Extent restriction.
*/
QgsRectangle wmsExtent( const QgsProject &project );

/** Returns the WFS service url defined in a QGIS project.
* @param project the QGIS project
* @return url if defined in project, an empty string otherwise.
Expand All @@ -129,6 +207,14 @@ namespace QgsServerProjectUtils
*/
QStringList wfsLayerIds( const QgsProject &project );

/** Returns the Layer precision defined in a QGIS project for the WFS GetFeature.
* @param project the QGIS project
* @param layerId the layer id in the project
* @return the layer precision for WFS GetFeature.
*/

int wfsLayerPrecision( const QgsProject &project, const QString &layerId );

/** Returns the Layer ids list defined in a QGIS project as published as WFS-T with update capabilities.
* @param project the QGIS project
* @return the Layer ids list.
Expand Down
1 change: 1 addition & 0 deletions src/server/qgsserver.h
Expand Up @@ -31,6 +31,7 @@
#include "qgsrequesthandler.h"
#include "qgsapplication.h"
#include "qgsconfigcache.h"
#include "qgsconfigparserutils.h"
#include "qgscapabilitiescache.h"
#include "qgsmapsettings.h"
#include "qgsmessagelog.h"
Expand Down
61 changes: 60 additions & 1 deletion src/server/qgsserverprojectutils.cpp
Expand Up @@ -92,7 +92,7 @@ bool QgsServerProjectUtils::wmsUseLayerIds( const QgsProject &project )
return project.readBoolEntry( QStringLiteral( "WMSUseLayerIDs" ), QStringLiteral( "/" ) );
}

bool QgsServerProjectUtils::wmsInfoFormatSIA2045( const QgsProject &project )
bool QgsServerProjectUtils::wmsInfoFormatSia2045( const QgsProject &project )
{
QString sia2045 = project.readEntry( QStringLiteral( "WMSInfoFormatSIA2045" ), QStringLiteral( "/" ), "" );

Expand Down Expand Up @@ -139,11 +139,70 @@ QStringList QgsServerProjectUtils::wmsRestrictedComposers( const QgsProject &pro
return project.readListEntry( QStringLiteral( "WMSRestrictedComposers" ), QStringLiteral( "/" ), QStringList() );
}

QStringList QgsServerProjectUtils::wmsOutputCrsList( const QgsProject &project )
{
QStringList crsList = project.readListEntry( QStringLiteral( "WMSCrsList" ), QStringLiteral( "/" ), QStringList() );
if ( crsList.isEmpty() )
{
QStringList valueList = project.readListEntry( QStringLiteral( "WMSEpsgList" ), QStringLiteral( "/" ), QStringList() );
bool conversionOk;
for ( int i = 0; i < valueList.size(); ++i )
{
int epsgNr = valueList.at( i ).toInt( &conversionOk );
if ( conversionOk )
{
crsList.append( QStringLiteral( "EPSG:%1" ).arg( epsgNr ) );
}
}
}
if ( crsList.isEmpty() )
{
//no CRS restriction defined in the project. Provide project CRS, wgs84 and pseudo mercator
QString projectCrsId = project.crs().authid();
crsList.append( projectCrsId );
if ( projectCrsId.compare( QLatin1String( "EPSG:4326" ), Qt::CaseInsensitive ) != 0 )
{
crsList.append( QStringLiteral( "EPSG:%1" ).arg( 4326 ) );
}
if ( projectCrsId.compare( QLatin1String( "EPSG:3857" ), Qt::CaseInsensitive ) != 0 )
{
crsList.append( QStringLiteral( "EPSG:%1" ).arg( 3857 ) );
}
}
return crsList;
}

QString QgsServerProjectUtils::wmsServiceUrl( const QgsProject &project )
{
return project.readEntry( QStringLiteral( "WMSUrl" ), QStringLiteral( "/" ), "" );
}

QString QgsServerProjectUtils::wmsRootName( const QgsProject &project )
{
return project.readEntry( QStringLiteral( "WMSRootName" ), QStringLiteral( "/" ), "" );
}

QStringList QgsServerProjectUtils::wmsRestrictedLayers( const QgsProject &project )
{
return project.readListEntry( QStringLiteral( "WMSRestrictedLayers" ), QStringLiteral( "/" ), QStringList() );
}

QgsRectangle QgsServerProjectUtils::wmsExtent( const QgsProject &project )
{
bool ok = false;
QStringList values = project.readListEntry( QStringLiteral( "WMSExtent" ), QStringLiteral( "/" ), QStringList(), &ok );
if ( !ok || values.size() != 4 )
{
return QgsRectangle();
}
//order of value elements must be xmin, ymin, xmax, ymax
double xmin = values[ 0 ].toDouble();
double ymin = values[ 1 ].toDouble();
double xmax = values[ 2 ].toDouble();
double ymax = values[ 3 ].toDouble();
return QgsRectangle( xmin, ymin, xmax, ymax );
}

QString QgsServerProjectUtils::wfsServiceUrl( const QgsProject &project )
{
return project.readEntry( QStringLiteral( "WFSUrl" ), QStringLiteral( "/" ), "" );
Expand Down
26 changes: 25 additions & 1 deletion src/server/qgsserverprojectutils.h
Expand Up @@ -123,7 +123,7 @@ namespace QgsServerProjectUtils
* \param project the QGIS project
* \returns if the info format is SIA20145.
*/
SERVER_EXPORT bool wmsInfoFormatSIA2045( const QgsProject &project );
SERVER_EXPORT bool wmsInfoFormatSia2045( const QgsProject &project );

/** Returns if Inspire is activated.
* \param project the QGIS project
Expand Down Expand Up @@ -173,6 +173,30 @@ namespace QgsServerProjectUtils
*/
SERVER_EXPORT QString wmsServiceUrl( const QgsProject &project );

/** Returns the WMS root layer name defined in a QGIS project.
* \param project the QGIS project
* \returns root layer name if defined in project, an empty string otherwise.
*/
SERVER_EXPORT QString wmsRootName( const QgsProject &project );

/** Returns the restricted layer name list.
* \param project the QGIS project
* \returns the restricted layer name list if defined in project.
*/
SERVER_EXPORT QStringList wmsRestrictedLayers( const QgsProject &project );

/** Returns the WMS output CRS list.
* \param project the QGIS project
* \returns the WMS output CRS list.
*/
SERVER_EXPORT QStringList wmsOutputCrsList( const QgsProject &project );

/** Returns the WMS Extent restriction.
* \param project the QGIS project
* \returns the WMS Extent restriction.
*/
SERVER_EXPORT QgsRectangle wmsExtent( const QgsProject &project );

/** Returns the WFS service url defined in a QGIS project.
* \param project the QGIS project
* \returns url if defined in project, an empty string otherwise.
Expand Down

0 comments on commit 2b39c1e

Please sign in to comment.