Skip to content

Commit

Permalink
Possibility to manually enter a project property to have WMS feature …
Browse files Browse the repository at this point in the history
…info in sia2045 format
  • Loading branch information
mhugent committed Oct 22, 2012
1 parent 7357864 commit feec5f0
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/mapserver/qgis_map_serv.cpp
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/mapserver/qgsconfigparser.h
Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions src/mapserver/qgshttprequesthandler.cpp
Expand Up @@ -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();
Expand Down
27 changes: 27 additions & 0 deletions src/mapserver/qgsprojectparser.cpp
Expand Up @@ -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( "../" ) )
Expand Down
3 changes: 3 additions & 0 deletions src/mapserver/qgsprojectparser.h
Expand Up @@ -108,6 +108,9 @@ class QgsProjectParser: public QgsConfigParser

virtual QString featureInfoDocumentElementNS() const;

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

private:

//forbidden
Expand Down
9 changes: 9 additions & 0 deletions src/mapserver/qgssldparser.cpp
Expand Up @@ -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
{
Expand Down
3 changes: 3 additions & 0 deletions src/mapserver/qgssldparser.h
Expand Up @@ -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();
Expand Down

0 comments on commit feec5f0

Please sign in to comment.