Skip to content
Permalink
Browse files

[BUGFIX][Server] DescribeFeature does not clean attribute name

In GML, the attributes have to be cleaned to be used as an XML name.
  • Loading branch information
rldhont committed Mar 16, 2018
1 parent decb722 commit 8b37bab62256d33de2293857ccc680b7a2c66579
Showing with 10 additions and 4 deletions.
  1. +1 −1 src/server/qgswfsprojectparser.cpp
  2. +9 −3 src/server/qgswfsserver.cpp
@@ -464,7 +464,7 @@ void QgsWFSProjectParser::describeFeatureType( const QString& aTypeName, QDomEle

//xsd:element
QDomElement attElem = doc.createElement( "element"/*xsd:element*/ );
attElem.setAttribute( "name", attributeName );
attElem.setAttribute( "name", attributeName.replace( " ", "_" ) );
QVariant::Type attributeType = fields[idx].type();
if ( attributeType == QVariant::Int )
attElem.setAttribute( "type", "integer" );
@@ -522,6 +522,12 @@ int QgsWFSServer::getFeature( QgsRequestHandler& request, const QString& format
QStringList::const_iterator alstIt;
QList<int> idxList;
QgsFields fields = layer->pendingFields();
// build corresponding propertyname
QList<QString> propertynames;
for ( int idx = 0; idx < fields.count(); ++idx )
{
propertynames.append( fields[idx].name().replace( " ", "_" ) );
}
QString fieldName;
QDomElement propertyElem;
for ( int q = 0; q < queryChildNodes.size(); q++ )
@@ -534,7 +540,7 @@ int QgsWFSServer::getFeature( QgsRequestHandler& request, const QString& format
{
fieldName = fieldName.section( ":", 1, 1 );
}
int fieldNameIdx = fields.fieldNameIndex( fieldName );
int fieldNameIdx = propertynames.indexOf( fieldName );
if ( fieldNameIdx > -1 )
{
idxList.append( fieldNameIdx );
@@ -2047,7 +2053,7 @@ QDomElement QgsWFSServer::createFeatureGML2( QgsFeature* feat, QDomDocument& doc
continue;
}

QDomElement fieldElem = doc.createElement( "qgs:" + attributeName.replace( QString( " " ), QString( "_" ) ) );
QDomElement fieldElem = doc.createElement( "qgs:" + attributeName.replace( " ", "_" ) );
QDomText fieldText = doc.createTextNode( featureAttributes[idx].toString() );
fieldElem.appendChild( fieldText );
typeNameElement.appendChild( fieldElem );
@@ -2129,7 +2135,7 @@ QDomElement QgsWFSServer::createFeatureGML3( QgsFeature* feat, QDomDocument& doc
continue;
}

QDomElement fieldElem = doc.createElement( "qgs:" + attributeName.replace( QString( " " ), QString( "_" ) ) );
QDomElement fieldElem = doc.createElement( "qgs:" + attributeName.replace( " ", "_" ) );
QDomText fieldText = doc.createTextNode( featureAttributes[idx].toString() );
fieldElem.appendChild( fieldText );
typeNameElement.appendChild( fieldElem );

0 comments on commit 8b37bab

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