Bug report #14139
Error inserting feature in WFS-T server
|Affected QGIS version:||2.12.2||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||22141|
Cannot insert a new feature composed by a single polygon/linestring into a geoserver multipolygon/multilinestring WFS-t layer.
It raises an error:
Could not commit changes to layer xxx:yyy
Errors: ERROR: 1 feature(s) not added. Provider errors: unsuccessful service response: Error performing insert: java.lang.String cannot be cast to com.vividsolutions.jts.geom.Geometry
But if create two polygon/linestring and merging them into a single feature, the insert works.
It seems QGis send a gml multypoligon feature if there is more than a polygon, a polygon feature otherwise, while geoserver needs a strictly corresponding feature type with that defined on the layer.
I think the correct behavior was to send a multi feature with a single polygon/linestring if the wfs layer is a multipolygon/multilinestring.
Fix for simple geometries insert error in WFS-T
Fixes #14139 Error inserting feature in WFS-T server
#1 Updated by Jukka Rahkonen about 4 years ago
Yes, there is only one way to do it right and it is to respect the schema of the feature type. For example the schema of "topp:states" feature type can be checked with
<xsd:element maxOccurs="1" minOccurs="0" name="the_geom" nillable="true" type="gml:MultiPolygonPropertyType"/>
which means that WFS client must use either an empty geometry or or a MultiPolygon geometry in WFS transactions.