Skip to content

Commit a622d1b

Browse files
committed
Possibility to set url for a feature info schema
1 parent 1a092f9 commit a622d1b

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

src/mapserver/qgsconfigparser.h

+2
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ class QgsConfigParser
136136
virtual QString featureInfoDocumentElement( const QString& defaultValue ) const { return defaultValue; }
137137
/**Returns document element namespace in GetFeatureInfo response or empty string*/
138138
virtual QString featureInfoDocumentElementNS() const { return ""; }
139+
/**Returns schema url for feature info xsd (or an empty string if there is no schema)*/
140+
virtual QString featureInfoSchema() const { return ""; }
139141

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

src/mapserver/qgsprojectparser.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -1929,6 +1929,21 @@ QString QgsProjectParser::featureInfoDocumentElementNS() const
19291929
return featureInfoDocumentNSElem.text();
19301930
}
19311931

1932+
QString QgsProjectParser::featureInfoSchema() const
1933+
{
1934+
QDomElement propertiesElem = mXMLDoc->documentElement().firstChildElement( "properties" );
1935+
if ( propertiesElem.isNull() )
1936+
{
1937+
return "";
1938+
}
1939+
QDomElement featureInfoSchemaElem = propertiesElem.firstChildElement( "WMSFeatureInfoSchema" );
1940+
if ( featureInfoSchemaElem.isNull() )
1941+
{
1942+
return "";
1943+
}
1944+
return featureInfoSchemaElem.text();
1945+
}
1946+
19321947
bool QgsProjectParser::featureInfoFormatSIA2045() const
19331948
{
19341949
if ( !mXMLDoc )

src/mapserver/qgsprojectparser.h

+2
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ class QgsProjectParser: public QgsConfigParser
118118

119119
virtual QString featureInfoDocumentElementNS() const;
120120

121+
virtual QString featureInfoSchema() const;
122+
121123
/**Return feature info in format SIA2045?*/
122124
bool featureInfoFormatSIA2045() const;
123125

src/mapserver/qgswmsserver.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,14 @@ int QgsWMSServer::getFeatureInfo( QDomDocument& result, QString version )
740740
{
741741
getFeatureInfoElement = result.createElementNS( featureInfoElemNS, featureInfoElemName );
742742
}
743+
//feature info schema
744+
QString featureInfoSchema = mConfigParser->featureInfoSchema();
745+
if ( !featureInfoSchema.isEmpty() )
746+
{
747+
getFeatureInfoElement.setAttribute( "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance" );
748+
getFeatureInfoElement.setAttribute( "xsi:schemaLocation", featureInfoSchema );
749+
}
750+
743751
result.appendChild( getFeatureInfoElement );
744752

745753
QStringList nonIdentifiableLayers = mConfigParser->identifyDisabledLayers();

0 commit comments

Comments
 (0)