Skip to content

Commit feec5f0

Browse files
committed
Possibility to manually enter a project property to have WMS feature info in sia2045 format
1 parent 7357864 commit feec5f0

File tree

7 files changed

+58
-3
lines changed

7 files changed

+58
-3
lines changed

src/mapserver/qgis_map_serv.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,15 @@ int main( int argc, char * argv[] )
398398
}
399399

400400
//info format for GetFeatureInfo
401-
theRequestHandler->sendGetFeatureInfoResponse( featureInfoDoc, parameterMap.value( "INFO_FORMAT" ) );
401+
402+
//additionally support text/xml; format=sia2045
403+
QString infoFormat = parameterMap.value( "INFO_FORMAT" );
404+
if ( infoFormat.compare( "text/xml", Qt::CaseInsensitive ) == 0 && adminConfigParser->featureInfoFormatSIA2045() )
405+
{
406+
infoFormat = "text/xml; format=sia2045";
407+
}
408+
409+
theRequestHandler->sendGetFeatureInfoResponse( featureInfoDoc, infoFormat );
402410
delete theRequestHandler;
403411
delete theServer;
404412
continue;

src/mapserver/qgsconfigparser.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ class QgsConfigParser
121121
/**Returns document element namespace in GetFeatureInfo response or empty string*/
122122
virtual QString featureInfoDocumentElementNS() const { return ""; }
123123

124+
/**Return feature info in format SIA2045?*/
125+
virtual bool featureInfoFormatSIA2045() const { return false; }
126+
124127
protected:
125128
/**Parser to forward not resolved requests (e.g. SLD parser based on user request might have a fallback parser with admin configuration)*/
126129
QgsConfigParser* mFallbackParser;

src/mapserver/qgshttprequesthandler.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,10 @@ void QgsHttpRequestHandler::sendGetFeatureInfoResponse( const QDomDocument& info
133133

134134
if ( infoFormat == "text/xml" )
135135
{
136-
//ba = infoDoc.toByteArray();
137-
//Modifications for SIA2045
136+
ba = infoDoc.toByteArray();
137+
}
138+
else if ( infoFormat == "text/xml; format=sia2045" )
139+
{
138140
QDomDocument outFeatureInfoDoc;
139141
QDomElement infoDocElement = infoDoc.documentElement();
140142
QDomElement outInfoDocElement = outFeatureInfoDoc.importNode( infoDocElement, false ).toElement();

src/mapserver/qgsprojectparser.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,6 +1427,33 @@ QString QgsProjectParser::featureInfoDocumentElementNS() const
14271427
return featureInfoDocumentNSElem.text();
14281428
}
14291429

1430+
bool QgsProjectParser::featureInfoFormatSIA2045() const
1431+
{
1432+
if ( !mXMLDoc )
1433+
{
1434+
return false;
1435+
}
1436+
1437+
QDomElement propertiesElem = mXMLDoc->documentElement().firstChildElement( "properties" );
1438+
if ( propertiesElem.isNull() )
1439+
{
1440+
return false;
1441+
}
1442+
1443+
QDomElement sia2045Elem = propertiesElem.firstChildElement( "WMSInfoFormatSIA2045" );
1444+
if ( sia2045Elem.isNull() )
1445+
{
1446+
return false;
1447+
}
1448+
1449+
if ( sia2045Elem.text().compare( "enabled", Qt::CaseInsensitive ) == 0
1450+
|| sia2045Elem.text().compare( "true", Qt::CaseInsensitive ) == 0 )
1451+
{
1452+
return true;
1453+
}
1454+
return false;
1455+
}
1456+
14301457
QString QgsProjectParser::convertToAbsolutePath( const QString& file ) const
14311458
{
14321459
if ( !file.startsWith( "./" ) && !file.startsWith( "../" ) )

src/mapserver/qgsprojectparser.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ class QgsProjectParser: public QgsConfigParser
108108

109109
virtual QString featureInfoDocumentElementNS() const;
110110

111+
/**Return feature info in format SIA2045?*/
112+
bool featureInfoFormatSIA2045() const;
113+
111114
private:
112115

113116
//forbidden

src/mapserver/qgssldparser.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,6 +1573,15 @@ QHash<QString, QString> QgsSLDParser::featureInfoLayerAliasMap() const
15731573
return QHash<QString, QString>();
15741574
}
15751575

1576+
bool QgsSLDParser::featureInfoFormatSIA2045() const
1577+
{
1578+
if ( mFallbackParser )
1579+
{
1580+
return mFallbackParser->featureInfoFormatSIA2045();
1581+
}
1582+
return false;
1583+
}
1584+
15761585
#ifdef DIAGRAMSERVER
15771586
int QgsSLDParser::overlaysFromUserStyle( const QDomElement& userStyleElement, QgsVectorLayer* vec ) const
15781587
{

src/mapserver/qgssldparser.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ class QgsSLDParser: public QgsConfigParser
8282
/**Returns map with layer aliases for GetFeatureInfo (or 0 pointer if not supported). Key: layer name, Value: layer alias*/
8383
virtual QHash<QString, QString> featureInfoLayerAliasMap() const;
8484

85+
/**Return feature info in format SIA2045?*/
86+
bool featureInfoFormatSIA2045() const;
87+
8588
private:
8689
/**Don't use the default constructor*/
8790
QgsSLDParser();

0 commit comments

Comments
 (0)