Skip to content
Permalink
Browse files

Move sia2045 xml conversion from request handler to wms server class

  • Loading branch information
mhugent committed Oct 26, 2012
1 parent 8505295 commit 73a5cc91bdb74f59ee96b1c3d08d86e4a3e56a3f
Showing with 70 additions and 75 deletions.
  1. +0 −8 src/mapserver/qgis_map_serv.cpp
  2. +0 −67 src/mapserver/qgshttprequesthandler.cpp
  3. +70 −0 src/mapserver/qgswmsserver.cpp
@@ -523,15 +523,7 @@ int main( int argc, char * argv[] )
continue;
}

//info format for GetFeatureInfo

//additionally support text/xml; format=sia2045
QString infoFormat = parameterMap.value( "INFO_FORMAT" );
if ( infoFormat.compare( "text/xml", Qt::CaseInsensitive ) == 0 && adminConfigParser->featureInfoFormatSIA2045() )
{
infoFormat = "text/xml; format=sia2045";
}

theRequestHandler->sendGetFeatureInfoResponse( featureInfoDoc, infoFormat );
delete theRequestHandler;
delete theServer;
@@ -147,73 +147,6 @@ void QgsHttpRequestHandler::sendGetFeatureInfoResponse( const QDomDocument& info
{
ba = infoDoc.toByteArray();
}
else if ( infoFormat == "text/xml; format=sia2045" )
{
QDomDocument outFeatureInfoDoc;
QDomElement infoDocElement = infoDoc.documentElement();
QDomElement outInfoDocElement = outFeatureInfoDoc.importNode( infoDocElement, false ).toElement();
outFeatureInfoDoc.appendChild( outInfoDocElement );

QString currentAttributeName;
QString currentAttributeValue;
QDomElement currentAttributeElem;
QString currentLayerName;
QDomElement currentLayerElem;
QDomNodeList layerNodeList = infoDocElement.elementsByTagName( "Layer" );
for ( int i = 0; i < layerNodeList.size(); ++i )
{
currentLayerElem = layerNodeList.at( i ).toElement();
currentLayerName = currentLayerElem.attribute( "name" );
QDomElement currentFeatureElem;

QDomNodeList featureList = currentLayerElem.elementsByTagName( "Feature" );
if ( featureList.size() < 1 )
{
//raster?
QDomNodeList attributeList = currentLayerElem.elementsByTagName( "Attribute" );
QDomElement rasterLayerElem;
if ( attributeList.size() > 0 )
{
rasterLayerElem = outFeatureInfoDoc.createElement( currentLayerName );
}
for ( int j = 0; j < attributeList.size(); ++j )
{
currentAttributeElem = attributeList.at( j ).toElement();
currentAttributeName = currentAttributeElem.attribute( "name" );
currentAttributeValue = currentAttributeElem.attribute( "value" );
QDomElement outAttributeElem = outFeatureInfoDoc.createElement( currentAttributeName );
QDomText outAttributeText = outFeatureInfoDoc.createTextNode( currentAttributeValue );
outAttributeElem.appendChild( outAttributeText );
rasterLayerElem.appendChild( outAttributeElem );
}
if ( attributeList.size() > 0 )
{
outInfoDocElement.appendChild( rasterLayerElem );
}
}
else //vector
{
for ( int j = 0; j < featureList.size(); ++j )
{
QDomElement outFeatureElem = outFeatureInfoDoc.createElement( currentLayerName );
currentFeatureElem = featureList.at( j ).toElement();
QDomNodeList attributeList = currentFeatureElem.elementsByTagName( "Attribute" );
for ( int k = 0; k < attributeList.size(); ++k )
{
currentAttributeElem = attributeList.at( k ).toElement();
currentAttributeName = currentAttributeElem.attribute( "name" );
currentAttributeValue = currentAttributeElem.attribute( "value" );
QDomElement outAttributeElem = outFeatureInfoDoc.createElement( currentAttributeName );
QDomText outAttributeText = outFeatureInfoDoc.createTextNode( currentAttributeValue );
outAttributeElem.appendChild( outAttributeText );
outFeatureElem.appendChild( outAttributeElem );
}
outInfoDocElement.appendChild( outFeatureElem );
}
}
}
ba = outFeatureInfoDoc.toByteArray();
}
else if ( infoFormat == "text/plain" || infoFormat == "text/html" )
{
//create string
@@ -845,6 +845,76 @@ int QgsWMSServer::getFeatureInfo( QDomDocument& result, QString version )
getFeatureInfoElement.insertBefore( bBoxElem, QDomNode() ); //insert as first child
}

if ( mConfigParser->featureInfoFormatSIA2045()
&& mParameterMap.value( "INFO_FORMAT" ).compare( "text/xml", Qt::CaseInsensitive ) == 0 )
{
//infoFormat = "text/xml; format=sia2045";
QDomDocument outFeatureInfoDoc;
QDomElement infoDocElement = result.documentElement();
QDomElement outInfoDocElement = outFeatureInfoDoc.importNode( infoDocElement, false ).toElement();
outFeatureInfoDoc.appendChild( outInfoDocElement );

QString currentAttributeName;
QString currentAttributeValue;
QDomElement currentAttributeElem;
QString currentLayerName;
QDomElement currentLayerElem;
QDomNodeList layerNodeList = infoDocElement.elementsByTagName( "Layer" );
for ( int i = 0; i < layerNodeList.size(); ++i )
{
currentLayerElem = layerNodeList.at( i ).toElement();
currentLayerName = currentLayerElem.attribute( "name" );
QDomElement currentFeatureElem;

QDomNodeList featureList = currentLayerElem.elementsByTagName( "Feature" );
if ( featureList.size() < 1 )
{
//raster?
QDomNodeList attributeList = currentLayerElem.elementsByTagName( "Attribute" );
QDomElement rasterLayerElem;
if ( attributeList.size() > 0 )
{
rasterLayerElem = outFeatureInfoDoc.createElement( currentLayerName );
}
for ( int j = 0; j < attributeList.size(); ++j )
{
currentAttributeElem = attributeList.at( j ).toElement();
currentAttributeName = currentAttributeElem.attribute( "name" );
currentAttributeValue = currentAttributeElem.attribute( "value" );
QDomElement outAttributeElem = outFeatureInfoDoc.createElement( currentAttributeName );
QDomText outAttributeText = outFeatureInfoDoc.createTextNode( currentAttributeValue );
outAttributeElem.appendChild( outAttributeText );
rasterLayerElem.appendChild( outAttributeElem );
}
if ( attributeList.size() > 0 )
{
outInfoDocElement.appendChild( rasterLayerElem );
}
}
else //vector
{
for ( int j = 0; j < featureList.size(); ++j )
{
QDomElement outFeatureElem = outFeatureInfoDoc.createElement( currentLayerName );
currentFeatureElem = featureList.at( j ).toElement();
QDomNodeList attributeList = currentFeatureElem.elementsByTagName( "Attribute" );
for ( int k = 0; k < attributeList.size(); ++k )
{
currentAttributeElem = attributeList.at( k ).toElement();
currentAttributeName = currentAttributeElem.attribute( "name" );
currentAttributeValue = currentAttributeElem.attribute( "value" );
QDomElement outAttributeElem = outFeatureInfoDoc.createElement( currentAttributeName );
QDomText outAttributeText = outFeatureInfoDoc.createTextNode( currentAttributeValue );
outAttributeElem.appendChild( outAttributeText );
outFeatureElem.appendChild( outAttributeElem );
}
outInfoDocElement.appendChild( outFeatureElem );
}
}
}
result = outFeatureInfoDoc;
}

restoreLayerFilters( originalLayerFilters );
delete featuresRect;
delete infoPoint;

0 comments on commit 73a5cc9

Please sign in to comment.
You can’t perform that action at this time.