Skip to content

Commit 33b4582

Browse files
committedMay 20, 2017
[Server] WMS GetCapabilities refactoring - Part 2
Part 2 (the last) for removing QgsWMSProjectParser from GetCapabilities
1 parent 258c872 commit 33b4582

File tree

7 files changed

+1131
-6
lines changed

7 files changed

+1131
-6
lines changed
 

‎src/server/qgsserver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "qgsrequesthandler.h"
3232
#include "qgsapplication.h"
3333
#include "qgsconfigcache.h"
34+
#include "qgsconfigparserutils.h"
3435
#include "qgscapabilitiescache.h"
3536
#include "qgsmapsettings.h"
3637
#include "qgsmessagelog.h"

‎src/server/qgsserverprojectutils.cpp

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,70 @@ QStringList QgsServerProjectUtils::wmsRestrictedComposers( const QgsProject &pro
139139
return project.readListEntry( QStringLiteral( "WMSRestrictedComposers" ), QStringLiteral( "/" ), QStringList() );
140140
}
141141

142+
QStringList QgsServerProjectUtils::wmsOutputCrsList( const QgsProject &project )
143+
{
144+
QStringList crsList = project.readListEntry( QStringLiteral( "WMSCrsList" ), QStringLiteral( "/" ), QStringList() );
145+
if ( crsList.isEmpty() )
146+
{
147+
QStringList valueList = project.readListEntry( QStringLiteral( "WMSEpsgList" ), QStringLiteral( "/" ), QStringList() );
148+
bool conversionOk;
149+
for ( int i = 0; i < valueList.size(); ++i )
150+
{
151+
int epsgNr = valueList.at( i ).toInt( &conversionOk );
152+
if ( conversionOk )
153+
{
154+
crsList.append( QStringLiteral( "EPSG:%1" ).arg( epsgNr ) );
155+
}
156+
}
157+
}
158+
if ( crsList.isEmpty() )
159+
{
160+
//no CRS restriction defined in the project. Provide project CRS, wgs84 and pseudo mercator
161+
QString projectCrsId = project.crs().authid();
162+
crsList.append( projectCrsId );
163+
if ( projectCrsId.compare( QLatin1String( "EPSG:4326" ), Qt::CaseInsensitive ) != 0 )
164+
{
165+
crsList.append( QStringLiteral( "EPSG:%1" ).arg( 4326 ) );
166+
}
167+
if ( projectCrsId.compare( QLatin1String( "EPSG:3857" ), Qt::CaseInsensitive ) != 0 )
168+
{
169+
crsList.append( QStringLiteral( "EPSG:%1" ).arg( 3857 ) );
170+
}
171+
}
172+
return crsList;
173+
}
174+
142175
QString QgsServerProjectUtils::wmsServiceUrl( const QgsProject &project )
143176
{
144177
return project.readEntry( QStringLiteral( "WMSUrl" ), QStringLiteral( "/" ), "" );
145178
}
146179

180+
QString QgsServerProjectUtils::wmsRootName( const QgsProject &project )
181+
{
182+
return project.readEntry( QStringLiteral( "WMSRootName" ), QStringLiteral( "/" ), "" );
183+
}
184+
185+
QStringList QgsServerProjectUtils::wmsRestrictedLayers( const QgsProject &project )
186+
{
187+
return project.readListEntry( QStringLiteral( "WMSRestrictedLayers" ), QStringLiteral( "/" ), QStringList() );
188+
}
189+
190+
QgsRectangle QgsServerProjectUtils::wmsExtent( const QgsProject &project )
191+
{
192+
bool ok = false;
193+
QStringList values = project.readListEntry( QStringLiteral( "WMSExtent" ), QStringLiteral( "/" ), QStringList(), &ok );
194+
if ( !ok || values.size() != 4 )
195+
{
196+
return QgsRectangle();
197+
}
198+
//order of value elements must be xmin, ymin, xmax, ymax
199+
double xmin = values[ 0 ].toDouble();
200+
double ymin = values[ 1 ].toDouble();
201+
double xmax = values[ 2 ].toDouble();
202+
double ymax = values[ 3 ].toDouble();
203+
return QgsRectangle( xmin, ymin, xmax, ymax );
204+
}
205+
147206
QString QgsServerProjectUtils::wfsServiceUrl( const QgsProject &project )
148207
{
149208
return project.readEntry( QStringLiteral( "WFSUrl" ), QStringLiteral( "/" ), "" );

‎src/server/qgsserverprojectutils.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,30 @@ namespace QgsServerProjectUtils
173173
*/
174174
SERVER_EXPORT QString wmsServiceUrl( const QgsProject &project );
175175

176+
/** Returns the WMS root layer name defined in a QGIS project.
177+
* \param project the QGIS project
178+
* \returns root layer name if defined in project, an empty string otherwise.
179+
*/
180+
SERVER_EXPORT QString wmsRootName( const QgsProject &project );
181+
182+
/** Returns the restricted layer name list.
183+
* \param project the QGIS project
184+
* \returns the restricted layer name list if defined in project.
185+
*/
186+
SERVER_EXPORT QStringList wmsRestrictedLayers( const QgsProject &project );
187+
188+
/** Returns the WMS output CRS list.
189+
* \param project the QGIS project
190+
* \returns the WMS output CRS list.
191+
*/
192+
SERVER_EXPORT QStringList wmsOutputCrsList( const QgsProject &project );
193+
194+
/** Returns the WMS Extent restriction.
195+
* \param project the QGIS project
196+
* \returns the WMS Extent restriction.
197+
*/
198+
SERVER_EXPORT QgsRectangle wmsExtent( const QgsProject &project );
199+
176200
/** Returns the WFS service url defined in a QGIS project.
177201
* \param project the QGIS project
178202
* \returns url if defined in project, an empty string otherwise.

0 commit comments

Comments
 (0)
Please sign in to comment.