Skip to content
Permalink
Browse files

Possibility to manually enter a project property to have WMS feature …

…info in sia2045 format
  • Loading branch information
mhugent committed Oct 22, 2012
1 parent 7357864 commit feec5f050cd03486432f212bebbf83639eebfddd
@@ -398,7 +398,15 @@ int main( int argc, char * argv[] )
}

//info format for GetFeatureInfo
theRequestHandler->sendGetFeatureInfoResponse( featureInfoDoc, parameterMap.value( "INFO_FORMAT" ) );

//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;
continue;
@@ -121,6 +121,9 @@ class QgsConfigParser
/**Returns document element namespace in GetFeatureInfo response or empty string*/
virtual QString featureInfoDocumentElementNS() const { return ""; }

/**Return feature info in format SIA2045?*/
virtual bool featureInfoFormatSIA2045() const { return false; }

protected:
/**Parser to forward not resolved requests (e.g. SLD parser based on user request might have a fallback parser with admin configuration)*/
QgsConfigParser* mFallbackParser;
@@ -133,8 +133,10 @@ void QgsHttpRequestHandler::sendGetFeatureInfoResponse( const QDomDocument& info

if ( infoFormat == "text/xml" )
{
//ba = infoDoc.toByteArray();
//Modifications for SIA2045
ba = infoDoc.toByteArray();
}
else if ( infoFormat == "text/xml; format=sia2045" )
{
QDomDocument outFeatureInfoDoc;
QDomElement infoDocElement = infoDoc.documentElement();
QDomElement outInfoDocElement = outFeatureInfoDoc.importNode( infoDocElement, false ).toElement();
@@ -1427,6 +1427,33 @@ QString QgsProjectParser::featureInfoDocumentElementNS() const
return featureInfoDocumentNSElem.text();
}

bool QgsProjectParser::featureInfoFormatSIA2045() const
{
if ( !mXMLDoc )
{
return false;
}

QDomElement propertiesElem = mXMLDoc->documentElement().firstChildElement( "properties" );
if ( propertiesElem.isNull() )
{
return false;
}

QDomElement sia2045Elem = propertiesElem.firstChildElement( "WMSInfoFormatSIA2045" );
if ( sia2045Elem.isNull() )
{
return false;
}

if ( sia2045Elem.text().compare( "enabled", Qt::CaseInsensitive ) == 0
|| sia2045Elem.text().compare( "true", Qt::CaseInsensitive ) == 0 )
{
return true;
}
return false;
}

QString QgsProjectParser::convertToAbsolutePath( const QString& file ) const
{
if ( !file.startsWith( "./" ) && !file.startsWith( "../" ) )
@@ -108,6 +108,9 @@ class QgsProjectParser: public QgsConfigParser

virtual QString featureInfoDocumentElementNS() const;

/**Return feature info in format SIA2045?*/
bool featureInfoFormatSIA2045() const;

private:

//forbidden
@@ -1573,6 +1573,15 @@ QHash<QString, QString> QgsSLDParser::featureInfoLayerAliasMap() const
return QHash<QString, QString>();
}

bool QgsSLDParser::featureInfoFormatSIA2045() const
{
if ( mFallbackParser )
{
return mFallbackParser->featureInfoFormatSIA2045();
}
return false;
}

#ifdef DIAGRAMSERVER
int QgsSLDParser::overlaysFromUserStyle( const QDomElement& userStyleElement, QgsVectorLayer* vec ) const
{
@@ -82,6 +82,9 @@ class QgsSLDParser: public QgsConfigParser
/**Returns map with layer aliases for GetFeatureInfo (or 0 pointer if not supported). Key: layer name, Value: layer alias*/
virtual QHash<QString, QString> featureInfoLayerAliasMap() const;

/**Return feature info in format SIA2045?*/
bool featureInfoFormatSIA2045() const;

private:
/**Don't use the default constructor*/
QgsSLDParser();

0 comments on commit feec5f0

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