Skip to content
Permalink
Browse files

Merge pull request #7947 from pblottiere/server_wfs_operation

[server] Fixes Operations in WFS GetCapabilities document
  • Loading branch information
pblottiere committed Sep 19, 2018
2 parents b4ab101 + 07d400c commit 420bcc9fc45db219970b7b48f7817614be7b9157
@@ -431,8 +431,10 @@ namespace QgsWfs
QDomElement operationsElement = doc.createElement( QStringLiteral( "Operations" )/*wfs:Operations*/ );
featureTypeListElement.appendChild( operationsElement );
//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 );

const QStringList wfsLayerIds = QgsServerProjectUtils::wfsLayerIds( *project );
const QStringList wfstUpdateLayersId = QgsServerProjectUtils::wfstUpdateLayerIds( *project );
@@ -520,6 +522,52 @@ namespace QgsWfs
layerElem.appendChild( otherSrsElem );
}

//wfs:Operations element
QDomElement operationsElement = doc.createElement( QStringLiteral( "Operations" )/*wfs:Operations*/ );
//wfs:Query element
QDomElement operationElement = doc.createElement( QStringLiteral( "Operation" ) );
QDomText queryText = doc.createTextNode( QStringLiteral( "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 operationElement = doc.createElement( QStringLiteral( "Operation" ) );
QDomText insertText = doc.createTextNode( QStringLiteral( "Insert" )/*wfs:Insert*/ );
operationElement.appendChild( insertText );
operationsElement.appendChild( operationElement );
}

if ( ( provider->capabilities() & QgsVectorDataProvider::ChangeAttributeValues ) &&
( provider->capabilities() & QgsVectorDataProvider::ChangeGeometries ) &&
wfstUpdateLayersId.contains( layer->id() ) )
{
//wfs:Update element
QDomElement operationElement = doc.createElement( QStringLiteral( "Operation" ) );
QDomText updateText = doc.createTextNode( QStringLiteral( "Update" )/*wfs:Update*/ );
operationElement.appendChild( updateText );
operationsElement.appendChild( operationElement );
}

if ( ( provider->capabilities() & QgsVectorDataProvider::DeleteFeatures ) && wfstDeleteLayersId.contains( layer->id() ) )
{
//wfs:Delete element
QDomElement operationElement = doc.createElement( QStringLiteral( "Operation" ) );
QDomText deleteText = doc.createTextNode( QStringLiteral( "Delete" )/*wfs:Delete*/ );
operationElement.appendChild( deleteText );
operationsElement.appendChild( operationElement );
}
}

layerElem.appendChild( operationsElement );

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

//create WGS84BoundingBox element
QDomElement bBoxElement = doc.createElement( QStringLiteral( "ows:WGS84BoundingBox" ) );
bBoxElement.setAttribute( QStringLiteral( "dimensions" ), QStringLiteral( "2" ) );
@@ -572,41 +621,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 );
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 );
}

@@ -82,27 +82,27 @@ Content-Type: text/xml; charset=utf-8
</ows:OperationsMetadata>
<FeatureTypeList>
<Operations>
<Query/>
<Operation>Query</Operation>
</Operations>
<FeatureType>
<Name>testlayer</Name>
<Title>A test vector layer</Title>
<Abstract>A test vector layer with unicode òà</Abstract>
<DefaultSRS>EPSG:4326</DefaultSRS>
<OtherSRS>EPSG:3857</OtherSRS>
<Operations>
<Operation>Query</Operation>
<Operation>Insert</Operation>
<Operation>Update</Operation>
<Operation>Delete</Operation>
</Operations>
<OutputFormats>
<Format>text/xml; subtype=gml/3.1.1</Format>
</OutputFormats>
<ows:WGS84BoundingBox dimensions="2">
<ows:LowerCorner>8.20346 44.9014</ows:LowerCorner>
<ows:UpperCorner>8.20355 44.9015</ows:UpperCorner>
</ows:WGS84BoundingBox>
<Operations>
<Query/>
<Insert/>
<Update/>
<Delete/>
</Operations>
</FeatureType>
</FeatureTypeList>
<ogc:Filter_Capabilities>

0 comments on commit 420bcc9

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