Skip to content

Commit

Permalink
Operations element has to be before OutputFormats
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed Sep 18, 2018
1 parent dea3b75 commit e295eb6
Showing 1 changed file with 40 additions and 39 deletions.
79 changes: 40 additions & 39 deletions src/server/services/wfs/qgswfsgetcapabilities.cpp
Expand Up @@ -525,6 +525,45 @@ namespace QgsWfs
layerElem.appendChild( otherSrsElem );
}

//wfs:Operations element
QDomElement operationsElement = doc.createElement( QStringLiteral( "Operations" )/*wfs:Operations*/ );
//wfs:Query element
// QDomElement queryElement = doc.createElement( QStringLiteral( "Query" )/*wfs:Query*/ );
// operationsElement.appendChild( queryElement );
QDomElement operationElement = doc.createElement( QStringLiteral( "Operation" ) );
QDomText queryText = doc.createTextNode( "Query" );
operationElement.appendChild( queryText );
operationsElement.appendChild( operationElement );
if ( wfstUpdateLayersId.contains( layer->id() ) ||
wfstInsertLayersId.contains( layer->id() ) ||
wfstDeleteLayersId.contains( layer->id() ) )
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
QgsVectorDataProvider *provider = vlayer->dataProvider();
if ( ( provider->capabilities() & QgsVectorDataProvider::AddFeatures ) && wfstInsertLayersId.contains( layer->id() ) )
{
//wfs:Insert element
QDomElement insertElement = doc.createElement( QStringLiteral( "Insert" )/*wfs:Insert*/ );
operationsElement.appendChild( insertElement );
}
if ( ( provider->capabilities() & QgsVectorDataProvider::ChangeAttributeValues ) &&
( provider->capabilities() & QgsVectorDataProvider::ChangeGeometries ) &&
wfstUpdateLayersId.contains( layer->id() ) )
{
//wfs:Update element
QDomElement updateElement = doc.createElement( QStringLiteral( "Update" )/*wfs:Update*/ );
operationsElement.appendChild( updateElement );
}
if ( ( provider->capabilities() & QgsVectorDataProvider::DeleteFeatures ) && wfstDeleteLayersId.contains( layer->id() ) )
{
//wfs:Delete element
QDomElement deleteElement = doc.createElement( QStringLiteral( "Delete" )/*wfs:Delete*/ );
operationsElement.appendChild( deleteElement );
}
}

layerElem.appendChild( operationsElement );

//create OutputFormats element
QDomElement outputFormatsElem = doc.createElement( QStringLiteral( "OutputFormats" ) );
QDomElement outputFormatElem = doc.createElement( QStringLiteral( "Format" ) );
Expand All @@ -550,6 +589,7 @@ namespace QgsWfs
wgs84BoundingRect = QgsRectangle();
}
}

//create WGS84BoundingBox element
QDomElement bBoxElement = doc.createElement( QStringLiteral( "ows:WGS84BoundingBox" ) );
bBoxElement.setAttribute( QStringLiteral( "dimensions" ), QStringLiteral( "2" ) );
Expand Down Expand Up @@ -577,45 +617,6 @@ namespace QgsWfs
layerElem.appendChild( metaUrlElem );
}

//wfs:Operations element
QDomElement operationsElement = doc.createElement( QStringLiteral( "Operations" )/*wfs:Operations*/ );
//wfs:Query element
// QDomElement queryElement = doc.createElement( QStringLiteral( "Query" )/*wfs:Query*/ );
// operationsElement.appendChild( queryElement );
QDomElement operationElement = doc.createElement( QStringLiteral( "Operation" ) );
QDomText queryText = doc.createTextNode( "Query" );
operationElement.appendChild( queryText );
operationsElement.appendChild( operationElement );
if ( wfstUpdateLayersId.contains( layer->id() ) ||
wfstInsertLayersId.contains( layer->id() ) ||
wfstDeleteLayersId.contains( layer->id() ) )
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
QgsVectorDataProvider *provider = vlayer->dataProvider();
if ( ( provider->capabilities() & QgsVectorDataProvider::AddFeatures ) && wfstInsertLayersId.contains( layer->id() ) )
{
//wfs:Insert element
QDomElement insertElement = doc.createElement( QStringLiteral( "Insert" )/*wfs:Insert*/ );
operationsElement.appendChild( insertElement );
}
if ( ( provider->capabilities() & QgsVectorDataProvider::ChangeAttributeValues ) &&
( provider->capabilities() & QgsVectorDataProvider::ChangeGeometries ) &&
wfstUpdateLayersId.contains( layer->id() ) )
{
//wfs:Update element
QDomElement updateElement = doc.createElement( QStringLiteral( "Update" )/*wfs:Update*/ );
operationsElement.appendChild( updateElement );
}
if ( ( provider->capabilities() & QgsVectorDataProvider::DeleteFeatures ) && wfstDeleteLayersId.contains( layer->id() ) )
{
//wfs:Delete element
QDomElement deleteElement = doc.createElement( QStringLiteral( "Delete" )/*wfs:Delete*/ );
operationsElement.appendChild( deleteElement );
}
}

layerElem.appendChild( operationsElement );

featureTypeListElement.appendChild( layerElem );
}

Expand Down

0 comments on commit e295eb6

Please sign in to comment.