Skip to content
Permalink
Browse files

WFS-T 1.1.0 thanks to ESRI use coordinates

Apparently ESRI mapserver does not like pos and posList
for coordinates in GML3 but only accepts "coordinates".
  • Loading branch information
elpaso committed Oct 14, 2020
1 parent 1b80ca3 commit 6ec7919b4357a47b5924cbcde0e03d5024fc25d1
Showing with 10 additions and 13 deletions.
  1. +6 −5 src/providers/wfs/qgswfsprovider.cpp
  2. +4 −8 tests/src/python/test_provider_wfs.py
@@ -878,12 +878,13 @@ bool QgsWFSProvider::addFeatures( QgsFeatureList &flist, Flags flags )
the_geom.convertToMultiType();
}
QDomElement gmlElem;
// WFS 1.1.0 uses GML 3
// WFS 1.1.0 uses preferably GML 3, but ESRI mapserver in 2020 doesn't like it so we stick to GML2
/*
if ( mShared->mWFSVersion == QStringLiteral( "1.1.0" ) )
{
gmlElem = QgsOgcUtils::geometryToGML( the_geom, transactionDoc, QLatin1String( "GML3" ) );
}
else
else */
{
gmlElem = QgsOgcUtils::geometryToGML( the_geom, transactionDoc, QLatin1String( "GML2" ) );
}
@@ -1055,12 +1056,12 @@ bool QgsWFSProvider::changeGeometryValues( const QgsGeometryMap &geometry_map )
propertyElem.appendChild( nameElem );
QDomElement valueElem = transactionDoc.createElementNS( QgsWFSConstants::WFS_NAMESPACE, QStringLiteral( "Value" ) );
QDomElement gmlElem;
// WFS 1.1.0 uses GML 3
if ( mShared->mWFSVersion == QStringLiteral( "1.1.0" ) )
// WFS 1.1.0 uses preferably GML 3, but ESRI mapserver in 2020 doesn't like it so we stick to GML2
/* if ( mShared->mWFSVersion == QStringLiteral( "1.1.0" ) )
{
gmlElem = QgsOgcUtils::geometryToGML( geomIt.value(), transactionDoc, QLatin1String( "GML3" ) );
}
else
else */
{
gmlElem = QgsOgcUtils::geometryToGML( geomIt.value(), transactionDoc, QLatin1String( "GML2" ) );
}
@@ -4728,24 +4728,19 @@ def testWFST11(self):
| QgsVectorDataProvider.SelectAtId)

# Transaction response failure (no modifications)
shutil.copy(os.path.join(TEST_DATA_DIR, 'provider', 'wfst-1-1', 'transaction_response_empty.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://localhost:8600/geoserver/ws1/wfs?SERVICE=WFS&amp;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"/></Insert></Transaction>'))
shutil.copy(os.path.join(TEST_DATA_DIR, 'provider', 'wfst-1-1', 'transaction_response_empty.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"_><_Insert><_Transaction>'))

(ret, _) = vl.dataProvider().addFeatures([QgsFeature()])
self.assertFalse(ret)

self.assertEqual(vl.featureCount(), 0)

self.assertFalse(vl.dataProvider().deleteFeatures([0]))

self.assertEqual(vl.featureCount(), 0)

self.assertFalse(vl.dataProvider().changeGeometryValues({0: QgsGeometry.fromWkt('Polygon ((9 45, 10 45, 10 46, 9 46, 9 45))')}))

self.assertFalse(vl.dataProvider().changeAttributeValues({0: {0: 0}}))

# 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: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>'))
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>'))

feat = QgsFeature(vl.fields())
feat.setAttribute('name', 'one')
@@ -4764,9 +4759,10 @@ 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: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>'))
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>'))

new_geom = QgsGeometry.fromWkt('Polygon ((10 46, 11 46, 11 47, 10 47, 10 46))')

self.assertTrue(vl.dataProvider().changeGeometryValues({1: new_geom}))
self.assertEqual(next(vl.dataProvider().getFeatures()).geometry().asWkt(), new_geom.asWkt())

0 comments on commit 6ec7919

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