Skip to content

Commit 73a5cc9

Browse files
committed
Move sia2045 xml conversion from request handler to wms server class
1 parent 8505295 commit 73a5cc9

File tree

3 files changed

+70
-75
lines changed

3 files changed

+70
-75
lines changed

src/mapserver/qgis_map_serv.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -523,15 +523,7 @@ int main( int argc, char * argv[] )
523523
continue;
524524
}
525525

526-
//info format for GetFeatureInfo
527-
528-
//additionally support text/xml; format=sia2045
529526
QString infoFormat = parameterMap.value( "INFO_FORMAT" );
530-
if ( infoFormat.compare( "text/xml", Qt::CaseInsensitive ) == 0 && adminConfigParser->featureInfoFormatSIA2045() )
531-
{
532-
infoFormat = "text/xml; format=sia2045";
533-
}
534-
535527
theRequestHandler->sendGetFeatureInfoResponse( featureInfoDoc, infoFormat );
536528
delete theRequestHandler;
537529
delete theServer;

src/mapserver/qgshttprequesthandler.cpp

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -147,73 +147,6 @@ void QgsHttpRequestHandler::sendGetFeatureInfoResponse( const QDomDocument& info
147147
{
148148
ba = infoDoc.toByteArray();
149149
}
150-
else if ( infoFormat == "text/xml; format=sia2045" )
151-
{
152-
QDomDocument outFeatureInfoDoc;
153-
QDomElement infoDocElement = infoDoc.documentElement();
154-
QDomElement outInfoDocElement = outFeatureInfoDoc.importNode( infoDocElement, false ).toElement();
155-
outFeatureInfoDoc.appendChild( outInfoDocElement );
156-
157-
QString currentAttributeName;
158-
QString currentAttributeValue;
159-
QDomElement currentAttributeElem;
160-
QString currentLayerName;
161-
QDomElement currentLayerElem;
162-
QDomNodeList layerNodeList = infoDocElement.elementsByTagName( "Layer" );
163-
for ( int i = 0; i < layerNodeList.size(); ++i )
164-
{
165-
currentLayerElem = layerNodeList.at( i ).toElement();
166-
currentLayerName = currentLayerElem.attribute( "name" );
167-
QDomElement currentFeatureElem;
168-
169-
QDomNodeList featureList = currentLayerElem.elementsByTagName( "Feature" );
170-
if ( featureList.size() < 1 )
171-
{
172-
//raster?
173-
QDomNodeList attributeList = currentLayerElem.elementsByTagName( "Attribute" );
174-
QDomElement rasterLayerElem;
175-
if ( attributeList.size() > 0 )
176-
{
177-
rasterLayerElem = outFeatureInfoDoc.createElement( currentLayerName );
178-
}
179-
for ( int j = 0; j < attributeList.size(); ++j )
180-
{
181-
currentAttributeElem = attributeList.at( j ).toElement();
182-
currentAttributeName = currentAttributeElem.attribute( "name" );
183-
currentAttributeValue = currentAttributeElem.attribute( "value" );
184-
QDomElement outAttributeElem = outFeatureInfoDoc.createElement( currentAttributeName );
185-
QDomText outAttributeText = outFeatureInfoDoc.createTextNode( currentAttributeValue );
186-
outAttributeElem.appendChild( outAttributeText );
187-
rasterLayerElem.appendChild( outAttributeElem );
188-
}
189-
if ( attributeList.size() > 0 )
190-
{
191-
outInfoDocElement.appendChild( rasterLayerElem );
192-
}
193-
}
194-
else //vector
195-
{
196-
for ( int j = 0; j < featureList.size(); ++j )
197-
{
198-
QDomElement outFeatureElem = outFeatureInfoDoc.createElement( currentLayerName );
199-
currentFeatureElem = featureList.at( j ).toElement();
200-
QDomNodeList attributeList = currentFeatureElem.elementsByTagName( "Attribute" );
201-
for ( int k = 0; k < attributeList.size(); ++k )
202-
{
203-
currentAttributeElem = attributeList.at( k ).toElement();
204-
currentAttributeName = currentAttributeElem.attribute( "name" );
205-
currentAttributeValue = currentAttributeElem.attribute( "value" );
206-
QDomElement outAttributeElem = outFeatureInfoDoc.createElement( currentAttributeName );
207-
QDomText outAttributeText = outFeatureInfoDoc.createTextNode( currentAttributeValue );
208-
outAttributeElem.appendChild( outAttributeText );
209-
outFeatureElem.appendChild( outAttributeElem );
210-
}
211-
outInfoDocElement.appendChild( outFeatureElem );
212-
}
213-
}
214-
}
215-
ba = outFeatureInfoDoc.toByteArray();
216-
}
217150
else if ( infoFormat == "text/plain" || infoFormat == "text/html" )
218151
{
219152
//create string

src/mapserver/qgswmsserver.cpp

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,76 @@ int QgsWMSServer::getFeatureInfo( QDomDocument& result, QString version )
845845
getFeatureInfoElement.insertBefore( bBoxElem, QDomNode() ); //insert as first child
846846
}
847847

848+
if ( mConfigParser->featureInfoFormatSIA2045()
849+
&& mParameterMap.value( "INFO_FORMAT" ).compare( "text/xml", Qt::CaseInsensitive ) == 0 )
850+
{
851+
//infoFormat = "text/xml; format=sia2045";
852+
QDomDocument outFeatureInfoDoc;
853+
QDomElement infoDocElement = result.documentElement();
854+
QDomElement outInfoDocElement = outFeatureInfoDoc.importNode( infoDocElement, false ).toElement();
855+
outFeatureInfoDoc.appendChild( outInfoDocElement );
856+
857+
QString currentAttributeName;
858+
QString currentAttributeValue;
859+
QDomElement currentAttributeElem;
860+
QString currentLayerName;
861+
QDomElement currentLayerElem;
862+
QDomNodeList layerNodeList = infoDocElement.elementsByTagName( "Layer" );
863+
for ( int i = 0; i < layerNodeList.size(); ++i )
864+
{
865+
currentLayerElem = layerNodeList.at( i ).toElement();
866+
currentLayerName = currentLayerElem.attribute( "name" );
867+
QDomElement currentFeatureElem;
868+
869+
QDomNodeList featureList = currentLayerElem.elementsByTagName( "Feature" );
870+
if ( featureList.size() < 1 )
871+
{
872+
//raster?
873+
QDomNodeList attributeList = currentLayerElem.elementsByTagName( "Attribute" );
874+
QDomElement rasterLayerElem;
875+
if ( attributeList.size() > 0 )
876+
{
877+
rasterLayerElem = outFeatureInfoDoc.createElement( currentLayerName );
878+
}
879+
for ( int j = 0; j < attributeList.size(); ++j )
880+
{
881+
currentAttributeElem = attributeList.at( j ).toElement();
882+
currentAttributeName = currentAttributeElem.attribute( "name" );
883+
currentAttributeValue = currentAttributeElem.attribute( "value" );
884+
QDomElement outAttributeElem = outFeatureInfoDoc.createElement( currentAttributeName );
885+
QDomText outAttributeText = outFeatureInfoDoc.createTextNode( currentAttributeValue );
886+
outAttributeElem.appendChild( outAttributeText );
887+
rasterLayerElem.appendChild( outAttributeElem );
888+
}
889+
if ( attributeList.size() > 0 )
890+
{
891+
outInfoDocElement.appendChild( rasterLayerElem );
892+
}
893+
}
894+
else //vector
895+
{
896+
for ( int j = 0; j < featureList.size(); ++j )
897+
{
898+
QDomElement outFeatureElem = outFeatureInfoDoc.createElement( currentLayerName );
899+
currentFeatureElem = featureList.at( j ).toElement();
900+
QDomNodeList attributeList = currentFeatureElem.elementsByTagName( "Attribute" );
901+
for ( int k = 0; k < attributeList.size(); ++k )
902+
{
903+
currentAttributeElem = attributeList.at( k ).toElement();
904+
currentAttributeName = currentAttributeElem.attribute( "name" );
905+
currentAttributeValue = currentAttributeElem.attribute( "value" );
906+
QDomElement outAttributeElem = outFeatureInfoDoc.createElement( currentAttributeName );
907+
QDomText outAttributeText = outFeatureInfoDoc.createTextNode( currentAttributeValue );
908+
outAttributeElem.appendChild( outAttributeText );
909+
outFeatureElem.appendChild( outAttributeElem );
910+
}
911+
outInfoDocElement.appendChild( outFeatureElem );
912+
}
913+
}
914+
}
915+
result = outFeatureInfoDoc;
916+
}
917+
848918
restoreLayerFilters( originalLayerFilters );
849919
delete featuresRect;
850920
delete infoPoint;

0 commit comments

Comments
 (0)