Skip to content
Permalink
Browse files

DescribeFeatureType improvement

  • Loading branch information
rldhont committed Nov 15, 2012
1 parent b89d0e2 commit b1e02ee52100ddb93ca7ab0326a98db654dbece2
Showing with 41 additions and 11 deletions.
  1. +10 −4 src/mapserver/qgsprojectparser.cpp
  2. +31 −7 src/mapserver/qgswfsserver.cpp
@@ -250,6 +250,11 @@ void QgsProjectParser::describeFeatureType( const QString& aTypeName, QDomElemen
}

QStringList wfsLayersId = wfsLayers();
QStringList typeNameList;
if ( aTypeName != "" )
{
typeNameList = aTypeName.split( "," );
}

foreach ( const QDomElement &elem, mProjectLayerElements )
{
@@ -258,7 +263,11 @@ void QgsProjectParser::describeFeatureType( const QString& aTypeName, QDomElemen
{
QgsMapLayer *mLayer = createLayerFromElement( elem );
QgsVectorLayer* layer = dynamic_cast<QgsVectorLayer*>( mLayer );
if ( layer && wfsLayersId.contains( layer->id() ) && ( aTypeName == "" || layer->name() == aTypeName ) )

QString typeName = layer->name();
typeName = typeName.replace( QString( " " ), QString( "_" ) );

if ( layer && wfsLayersId.contains( layer->id() ) && ( aTypeName == "" || typeNameList.contains( typeName ) ) )
{
//do a select with searchRect and go through all the features
QgsVectorDataProvider* provider = layer->dataProvider();
@@ -270,9 +279,6 @@ void QgsProjectParser::describeFeatureType( const QString& aTypeName, QDomElemen
//hidden attributes for this layer
const QSet<QString>& layerExcludedAttributes = layer->excludeAttributesWFS();

QString typeName = layer->name();
typeName = typeName.replace( QString( " " ), QString( "_" ) );

//xsd:element
QDomElement elementElem = doc.createElement( "element"/*xsd:element*/ );
elementElem.setAttribute( "name", typeName );
@@ -284,18 +284,42 @@ QDomDocument QgsWFSServer::describeFeatureType()
importElement.setAttribute( "schemaLocation", "http://schemas.opengis.net/gml/2.1.2/feature.xsd" );
schemaElement.appendChild( importElement );

//read TYPENAME
QString typeName;
QMap<QString, QString>::const_iterator type_name_it = mParameterMap.find( "TYPENAME" );
if ( type_name_it != mParameterMap.end() )
//defining typename
QString typeName = "";

QDomDocument queryDoc;
QString errorMsg;
if ( queryDoc.setContent( mParameterMap.value( "REQUEST_BODY" ), true, &errorMsg ) )
{
typeName = type_name_it.value();
//read doc
QDomElement queryDocElem = queryDoc.documentElement();
QDomNodeList docChildNodes = queryDocElem.childNodes();
if ( docChildNodes.size() )
{
for ( int i = 0; i < docChildNodes.size(); i++ )
{
QDomElement docChildElem = docChildNodes.at( i ).toElement();
if ( docChildElem.tagName() == "TypeName" )
{
if ( typeName == "" )
typeName = docChildElem.text();
else
typeName += "," + docChildElem.text();
}
}
}
mConfigParser->describeFeatureType( typeName, schemaElement, doc );
}
else
{
typeName = "";
//read TYPENAME
QMap<QString, QString>::const_iterator type_name_it = mParameterMap.find( "TYPENAME" );
if ( type_name_it != mParameterMap.end() )
{
typeName = type_name_it.value();
}
mConfigParser->describeFeatureType( typeName, schemaElement, doc );
}
mConfigParser->describeFeatureType( typeName, schemaElement, doc );
return doc;
}

0 comments on commit b1e02ee

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