Skip to content

Commit f926033

Browse files
committed
[Server] WMS GetFeatureInfo refactoring
1 parent e61daed commit f926033

File tree

10 files changed

+725
-225
lines changed

10 files changed

+725
-225
lines changed

python/server/qgsserverprojectutils.sip

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,62 @@ namespace QgsServerProjectUtils
145145
:rtype: bool
146146
%End
147147

148+
bool wmsFeatureInfoAddWktGeometry( const QgsProject &project );
149+
%Docstring
150+
Returns if the geometry is displayed as Well Known Text in GetFeatureInfo request.
151+
\param project the QGIS project
152+
:return: if the geometry is displayed as Well Known Text in GetFeatureInfo request.
153+
:rtype: bool
154+
%End
155+
156+
bool wmsFeatureInfoSegmentizeWktGeometry( const QgsProject &project );
157+
%Docstring
158+
Returns if the geometry has to be segmentize in GetFeatureInfo request.
159+
\param project the QGIS project
160+
:return: if the geometry has to be segmentize in GetFeatureInfo request.
161+
:rtype: bool
162+
%End
163+
164+
int wmsFeatureInfoPrecision( const QgsProject &project );
165+
%Docstring
166+
Returns the geometry precision for GetFeatureInfo request.
167+
\param project the QGIS project
168+
:return: the geometry precision for GetFeatureInfo request.
169+
:rtype: int
170+
%End
171+
172+
QString wmsFeatureInfoDocumentElement( const QgsProject &project );
173+
%Docstring
174+
Returns the document element name for XML GetFeatureInfo request.
175+
\param project the QGIS project
176+
:return: the document element name for XML GetFeatureInfo request.
177+
:rtype: str
178+
%End
179+
180+
QString wmsFeatureInfoDocumentElementNs( const QgsProject &project );
181+
%Docstring
182+
Returns the document element namespace for XML GetFeatureInfo request.
183+
\param project the QGIS project
184+
:return: the document element namespace for XML GetFeatureInfo request.
185+
:rtype: str
186+
%End
187+
188+
QString wmsFeatureInfoSchema( const QgsProject &project );
189+
%Docstring
190+
Returns the schema URL for XML GetFeatureInfo request.
191+
\param project the QGIS project
192+
:return: the schema URL for XML GetFeatureInfo request.
193+
:rtype: str
194+
%End
195+
196+
QHash<QString, QString> wmsFeatureInfoLayerAliasMap( const QgsProject &project );
197+
%Docstring
198+
Returns the mapping between layer name and wms layer name for GetFeatureInfo request.
199+
\param project the QGIS project
200+
:return: the mapping between layer name and wms layer name for GetFeatureInfo request.
201+
:rtype: QHash<str, QString>
202+
%End
203+
148204
bool wmsInspireActivate( const QgsProject &project );
149205
%Docstring
150206
Returns if Inspire is activated.

src/server/qgsserverprojectutils.cpp

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,77 @@ bool QgsServerProjectUtils::wmsInfoFormatSia2045( const QgsProject &project )
117117
return false;
118118
}
119119

120+
bool QgsServerProjectUtils::wmsFeatureInfoAddWktGeometry( const QgsProject &project )
121+
{
122+
QString wktGeom = project.readEntry( QStringLiteral( "WMSAddWktGeometry" ), QStringLiteral( "/" ), "" );
123+
124+
if ( wktGeom.compare( QLatin1String( "enabled" ), Qt::CaseInsensitive ) == 0
125+
|| wktGeom.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0 )
126+
{
127+
return true;
128+
}
129+
return false;
130+
}
131+
132+
bool QgsServerProjectUtils::wmsFeatureInfoSegmentizeWktGeometry( const QgsProject &project )
133+
{
134+
QString segmGeom = project.readEntry( QStringLiteral( "WMSSegmentizeFeatureInfoGeometry" ), QStringLiteral( "/" ), "" );
135+
136+
if ( segmGeom.compare( QLatin1String( "enabled" ), Qt::CaseInsensitive ) == 0
137+
|| segmGeom.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0 )
138+
{
139+
return true;
140+
}
141+
return false;
142+
}
143+
144+
int QgsServerProjectUtils::wmsFeatureInfoPrecision( const QgsProject &project )
145+
{
146+
return project.readNumEntry( QStringLiteral( "WMSPrecision" ), QStringLiteral( "/" ), 6 );
147+
}
148+
149+
QString QgsServerProjectUtils::wmsFeatureInfoDocumentElement( const QgsProject &project )
150+
{
151+
return project.readEntry( QStringLiteral( "WMSFeatureInfoDocumentElement" ), QStringLiteral( "/" ), "" );
152+
}
153+
154+
QString QgsServerProjectUtils::wmsFeatureInfoDocumentElementNs( const QgsProject &project )
155+
{
156+
return project.readEntry( QStringLiteral( "WMSFeatureInfoDocumentElementNS" ), QStringLiteral( "/" ), "" );
157+
}
158+
159+
QString QgsServerProjectUtils::wmsFeatureInfoSchema( const QgsProject &project )
160+
{
161+
return project.readEntry( QStringLiteral( "WMSFeatureInfoSchema" ), QStringLiteral( "/" ), "" );
162+
}
163+
164+
QHash<QString, QString> QgsServerProjectUtils::wmsFeatureInfoLayerAliasMap( const QgsProject &project )
165+
{
166+
QHash<QString, QString> aliasMap;
167+
168+
//WMSFeatureInfoAliasLayers
169+
QStringList aliasLayerStringList = project.readListEntry( QStringLiteral( "WMSFeatureInfoAliasLayers" ), QStringLiteral( "/value" ), QStringList() );
170+
if ( aliasLayerStringList.isEmpty() )
171+
{
172+
return aliasMap;
173+
}
174+
175+
//WMSFeatureInfoLayerAliases
176+
QStringList layerAliasStringList = project.readListEntry( QStringLiteral( "WMSFeatureInfoLayerAliases" ), QStringLiteral( "/value" ), QStringList() );
177+
if ( layerAliasStringList.isEmpty() )
178+
{
179+
return aliasMap;
180+
}
181+
182+
int nMapEntries = qMin( aliasLayerStringList.size(), layerAliasStringList.size() );
183+
for ( int i = 0; i < nMapEntries; ++i )
184+
{
185+
aliasMap.insert( aliasLayerStringList.at( i ), layerAliasStringList.at( i ) );
186+
}
187+
188+
return aliasMap;
189+
}
190+
120191
bool QgsServerProjectUtils::wmsInspireActivate( const QgsProject &project )
121192
{
122193
return project.readBoolEntry( QStringLiteral( "WMSInspire" ), QStringLiteral( "/activated" ) );

src/server/qgsserverprojectutils.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,48 @@ namespace QgsServerProjectUtils
132132
*/
133133
SERVER_EXPORT bool wmsInfoFormatSia2045( const QgsProject &project );
134134

135+
/** Returns if the geometry is displayed as Well Known Text in GetFeatureInfo request.
136+
* \param project the QGIS project
137+
* \returns if the geometry is displayed as Well Known Text in GetFeatureInfo request.
138+
*/
139+
SERVER_EXPORT bool wmsFeatureInfoAddWktGeometry( const QgsProject &project );
140+
141+
/** Returns if the geometry has to be segmentize in GetFeatureInfo request.
142+
* \param project the QGIS project
143+
* \returns if the geometry has to be segmentize in GetFeatureInfo request.
144+
*/
145+
SERVER_EXPORT bool wmsFeatureInfoSegmentizeWktGeometry( const QgsProject &project );
146+
147+
/** Returns the geometry precision for GetFeatureInfo request.
148+
* \param project the QGIS project
149+
* \returns the geometry precision for GetFeatureInfo request.
150+
*/
151+
SERVER_EXPORT int wmsFeatureInfoPrecision( const QgsProject &project );
152+
153+
/** Returns the document element name for XML GetFeatureInfo request.
154+
* \param project the QGIS project
155+
* \returns the document element name for XML GetFeatureInfo request.
156+
*/
157+
SERVER_EXPORT QString wmsFeatureInfoDocumentElement( const QgsProject &project );
158+
159+
/** Returns the document element namespace for XML GetFeatureInfo request.
160+
* \param project the QGIS project
161+
* \returns the document element namespace for XML GetFeatureInfo request.
162+
*/
163+
SERVER_EXPORT QString wmsFeatureInfoDocumentElementNs( const QgsProject &project );
164+
165+
/** Returns the schema URL for XML GetFeatureInfo request.
166+
* \param project the QGIS project
167+
* \returns the schema URL for XML GetFeatureInfo request.
168+
*/
169+
SERVER_EXPORT QString wmsFeatureInfoSchema( const QgsProject &project );
170+
171+
/** Returns the mapping between layer name and wms layer name for GetFeatureInfo request.
172+
* \param project the QGIS project
173+
* \returns the mapping between layer name and wms layer name for GetFeatureInfo request.
174+
*/
175+
SERVER_EXPORT QHash<QString, QString> wmsFeatureInfoLayerAliasMap( const QgsProject &project );
176+
135177
/** Returns if Inspire is activated.
136178
* \param project the QGIS project
137179
* \returns if Inspire is activated.

0 commit comments

Comments
 (0)