Skip to content

Commit 2b39c1e

Browse files
authoredMay 22, 2017
Merge pull request #4597 from rldhont/server-wms-configparser-getcapabilities-part2
[Server] WMS GetCapabilities refactoring - Part 2
2 parents d93d0a8 + 087e7f7 commit 2b39c1e

File tree

8 files changed

+1220
-9
lines changed

8 files changed

+1220
-9
lines changed
 

‎python/server/qgsserverprojectutils.sip

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,90 @@ namespace QgsServerProjectUtils
111111
*/
112112
int wmsMaxHeight( const QgsProject &project );
113113

114+
/** Returns if layer ids are used as name in WMS.
115+
* \param project the QGIS project
116+
* \returns if layer ids are used as name.
117+
*/
118+
bool wmsUseLayerIds( const QgsProject &project );
119+
120+
/** Returns if the info format is SIA20145.
121+
* \param project the QGIS project
122+
* \returns if the info format is SIA20145.
123+
*/
124+
bool wmsInfoFormatSia2045( const QgsProject &project );
125+
126+
/** Returns if Inspire is activated.
127+
* \param project the QGIS project
128+
* \returns if Inspire is activated.
129+
*/
130+
bool wmsInspireActivated( const QgsProject &project );
131+
132+
/** Returns the Inspire language.
133+
* \param project the QGIS project
134+
* \returns the Inspire language if defined in project.
135+
*/
136+
QString wmsInspireLanguage( const QgsProject &project );
137+
138+
/** Returns the Inspire metadata URL.
139+
* \param project the QGIS project
140+
* \returns the Inspire metadata URL if defined in project.
141+
*/
142+
QString wmsInspireMetadataUrl( const QgsProject &project );
143+
144+
/** Returns the Inspire metadata URL type.
145+
* \param project the QGIS project
146+
* \returns the Inspire metadata URL type if defined in project.
147+
*/
148+
QString wmsInspireMetadataUrlType( const QgsProject &project );
149+
150+
/** Returns the Inspire temporal reference.
151+
* \param project the QGIS project
152+
* \returns the Inspire temporal reference if defined in project.
153+
*/
154+
QString wmsInspireTemporalReference( const QgsProject &project );
155+
156+
/** Returns the Inspire metadata date.
157+
* \param project the QGIS project
158+
* \returns the Inspire metadata date if defined in project.
159+
*/
160+
QString wmsInspireMetadataDate( const QgsProject &project );
161+
162+
/** Returns the restricted composer list.
163+
* \param project the QGIS project
164+
* \returns the restricted composer list if defined in project.
165+
*/
166+
QStringList wmsRestrictedComposers( const QgsProject &project );
167+
114168
/** Returns the WMS ervice url defined in a QGIS project.
115169
* @param project the QGIS project
116170
* @return url if defined in project, an empty string otherwise.
117171
*/
118172
QString wmsServiceUrl( const QgsProject &project );
119173

174+
/** Returns the WMS root layer name defined in a QGIS project.
175+
* \param project the QGIS project
176+
* \returns root layer name if defined in project, an empty string otherwise.
177+
*/
178+
QString wmsRootName( const QgsProject &project );
179+
180+
/** Returns the restricted layer name list.
181+
* \param project the QGIS project
182+
* \returns the restricted layer name list if defined in project.
183+
*/
184+
QStringList wmsRestrictedLayers( const QgsProject &project );
185+
186+
/** Returns the WMS output CRS list.
187+
* \param project the QGIS project
188+
* \returns the WMS output CRS list.
189+
*/
190+
QStringList wmsOutputCrsList( const QgsProject &project );
191+
192+
/** Returns the WMS Extent restriction.
193+
* \param project the QGIS project
194+
* \returns the WMS Extent restriction.
195+
*/
196+
QgsRectangle wmsExtent( const QgsProject &project );
197+
120198
/** Returns the WFS service url defined in a QGIS project.
121199
* @param project the QGIS project
122200
* @return url if defined in project, an empty string otherwise.
@@ -129,6 +207,14 @@ namespace QgsServerProjectUtils
129207
*/
130208
QStringList wfsLayerIds( const QgsProject &project );
131209

210+
/** Returns the Layer precision defined in a QGIS project for the WFS GetFeature.
211+
* @param project the QGIS project
212+
* @param layerId the layer id in the project
213+
* @return the layer precision for WFS GetFeature.
214+
*/
215+
216+
int wfsLayerPrecision( const QgsProject &project, const QString &layerId );
217+
132218
/** Returns the Layer ids list defined in a QGIS project as published as WFS-T with update capabilities.
133219
* @param project the QGIS project
134220
* @return the Layer ids list.

‎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: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ bool QgsServerProjectUtils::wmsUseLayerIds( const QgsProject &project )
9292
return project.readBoolEntry( QStringLiteral( "WMSUseLayerIDs" ), QStringLiteral( "/" ) );
9393
}
9494

95-
bool QgsServerProjectUtils::wmsInfoFormatSIA2045( const QgsProject &project )
95+
bool QgsServerProjectUtils::wmsInfoFormatSia2045( const QgsProject &project )
9696
{
9797
QString sia2045 = project.readEntry( QStringLiteral( "WMSInfoFormatSIA2045" ), QStringLiteral( "/" ), "" );
9898

@@ -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: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ namespace QgsServerProjectUtils
123123
* \param project the QGIS project
124124
* \returns if the info format is SIA20145.
125125
*/
126-
SERVER_EXPORT bool wmsInfoFormatSIA2045( const QgsProject &project );
126+
SERVER_EXPORT bool wmsInfoFormatSia2045( const QgsProject &project );
127127

128128
/** Returns if Inspire is activated.
129129
* \param project the QGIS project
@@ -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.