@@ -845,6 +845,76 @@ int QgsWMSServer::getFeatureInfo( QDomDocument& result, QString version )
845
845
getFeatureInfoElement.insertBefore ( bBoxElem, QDomNode () ); // insert as first child
846
846
}
847
847
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
+
848
918
restoreLayerFilters ( originalLayerFilters );
849
919
delete featuresRect;
850
920
delete infoPoint;
0 commit comments