Skip to content
Permalink
Browse files

WFS-T 1.1.0 uses GML3

  • Loading branch information
elpaso committed Oct 13, 2020
1 parent b1da081 commit 1b80ca33351af9d3a769abc2383d9e6711a2a98e
Showing with 22 additions and 4 deletions.
  1. +20 −2 src/providers/wfs/qgswfsprovider.cpp
  2. +2 −2 tests/src/python/test_provider_wfs.py
@@ -877,7 +877,16 @@ bool QgsWFSProvider::addFeatures( QgsFeatureList &flist, Flags flags )
{
the_geom.convertToMultiType();
}
QDomElement gmlElem = QgsOgcUtils::geometryToGML( the_geom, transactionDoc );
QDomElement gmlElem;
// WFS 1.1.0 uses GML 3
if ( mShared->mWFSVersion == QStringLiteral( "1.1.0" ) )
{
gmlElem = QgsOgcUtils::geometryToGML( the_geom, transactionDoc, QLatin1String( "GML3" ) );
}
else
{
gmlElem = QgsOgcUtils::geometryToGML( the_geom, transactionDoc, QLatin1String( "GML2" ) );
}
if ( !gmlElem.isNull() )
{
gmlElem.setAttribute( QStringLiteral( "srsName" ), crs().authid() );
@@ -1045,7 +1054,16 @@ bool QgsWFSProvider::changeGeometryValues( const QgsGeometryMap &geometry_map )
nameElem.appendChild( nameText );
propertyElem.appendChild( nameElem );
QDomElement valueElem = transactionDoc.createElementNS( QgsWFSConstants::WFS_NAMESPACE, QStringLiteral( "Value" ) );
QDomElement gmlElem = QgsOgcUtils::geometryToGML( geomIt.value(), transactionDoc );
QDomElement gmlElem;
// WFS 1.1.0 uses GML 3
if ( mShared->mWFSVersion == QStringLiteral( "1.1.0" ) )
{
gmlElem = QgsOgcUtils::geometryToGML( geomIt.value(), transactionDoc, QLatin1String( "GML3" ) );
}
else
{
gmlElem = QgsOgcUtils::geometryToGML( geomIt.value(), transactionDoc, QLatin1String( "GML2" ) );
}
gmlElem.setAttribute( QStringLiteral( "srsName" ), crs().authid() );
valueElem.appendChild( gmlElem );
propertyElem.appendChild( valueElem );
@@ -4745,7 +4745,7 @@ def testWFST11(self):

# Test add features for real
# Transaction response with 1 feature added
shutil.copy(os.path.join(TEST_DATA_DIR, 'provider', 'wfst-1-1', 'transaction_response_feature_added.xml'), sanitize(endpoint, '?SERVICE=WFS&POSTDATA=<Transaction xmlns="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" xmlns:ws1="ws1" xsi:schemaLocation="ws1 http://fake_qgis_http_endpoint?REQUEST=DescribeFeatureType&amp;VERSION=1.0.0&amp;TYPENAME=ws1:polygons" version="1.1.0" service="WFS"><Insert xmlns="http://www.opengis.net/wfs"><polygons xmlns="ws1"><name xmlns="ws1">one</name><value xmlns="ws1">1</value><geometry xmlns="ws1"><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates cs="," ts=" ">9,45 10,45 10,46 9,46 9,45</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></geometry></polygons></Insert></Transaction>'))
shutil.copy(os.path.join(TEST_DATA_DIR, 'provider', 'wfst-1-1', 'transaction_response_feature_added.xml'), sanitize(endpoint, '?SERVICE=WFS&POSTDATA=<Transaction xmlns="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" xmlns:ws1="ws1" xsi:schemaLocation="ws1 http://fake_qgis_http_endpoint?REQUEST=DescribeFeatureType&amp;VERSION=1.0.0&amp;TYPENAME=ws1:polygons" version="1.1.0" service="WFS"><Insert xmlns="http://www.opengis.net/wfs"><polygons xmlns="ws1"><name xmlns="ws1">one</name><value xmlns="ws1">1</value><geometry xmlns="ws1"><gml:Polygon srsName="EPSG:4326"><gml:exterior><gml:LinearRing><gml:posList srsDimension="2">9 45 10 45 10 46 9 46 9 45</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></geometry></polygons></Insert></Transaction>'))

feat = QgsFeature(vl.fields())
feat.setAttribute('name', 'one')
@@ -4764,7 +4764,7 @@ def testWFST11(self):

# Test change geometry
# Transaction response with 1 feature changed
shutil.copy(os.path.join(TEST_DATA_DIR, 'provider', 'wfst-1-1', 'transaction_response_feature_changed.xml'), sanitize(endpoint, '?SERVICE=WFS&POSTDATA=<Transaction xmlns="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" xmlns:ws1="ws1" xsi:schemaLocation="ws1 http://fake_qgis_http_endpoint?REQUEST=DescribeFeatureType&amp;VERSION=1.0.0&amp;TYPENAME=ws1:polygons" version="1.1.0" service="WFS"><Update xmlns="http://www.opengis.net/wfs" typeName="ws1:polygons"><Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">ws1:geometry</Name><Value xmlns="http://www.opengis.net/wfs"><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates cs="," ts=" ">10,46 11,46 11,47 10,47 10,46</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></Value></Property><Filter xmlns="http://www.opengis.net/ogc"><FeatureId xmlns="http://www.opengis.net/ogc" fid="123"/></Filter></Update></Transaction>'))
shutil.copy(os.path.join(TEST_DATA_DIR, 'provider', 'wfst-1-1', 'transaction_response_feature_changed.xml'), sanitize(endpoint, '?SERVICE=WFS&POSTDATA=<Transaction xmlns="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" xmlns:ws1="ws1" xsi:schemaLocation="ws1 http://fake_qgis_http_endpoint?REQUEST=DescribeFeatureType&amp;VERSION=1.0.0&amp;TYPENAME=ws1:polygons" version="1.1.0" service="WFS"><Update xmlns="http://www.opengis.net/wfs" typeName="ws1:polygons"><Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">ws1:geometry</Name><Value xmlns="http://www.opengis.net/wfs"><gml:Polygon srsName="EPSG:4326"><gml:exterior><gml:LinearRing><gml:posList srsDimension="2">10 46 11 46 11 47 10 47 10 46</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></Value></Property><Filter xmlns="http://www.opengis.net/ogc"><FeatureId xmlns="http://www.opengis.net/ogc" fid="123"/></Filter></Update></Transaction>'))

new_geom = QgsGeometry.fromWkt('Polygon ((10 46, 11 46, 11 47, 10 47, 10 46))')
self.assertTrue(vl.dataProvider().changeGeometryValues({1: new_geom}))

0 comments on commit 1b80ca3

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