Dear GeoTools users, 

I am experiencing a strange behaviour of the WFS-T Update issued from a Java 
client using geotools library. 

I have a java client that should be enabled to insert / modify / delete 
features using WFS 1.1.0 transactions. The insert and delete seem to work fine, 
but the update won't work as expected. When trying to update the geometry, the 
transaction request to the geoserver finishes successfully, but the geometry in 
the database will be wiped out after the operation. 

I have debugged a little - both geotools and geoserver and I get the feeling 
that something is not right with geotools encoding the update GML. Here is an 
example of such a transaction request that is sent by geotools trying to update 
a feature's geometry: 

<?xml version="1.0" encoding="UTF-8"?>
<wfs:Transaction xmlns:dwd="http://dwd.de"; 
xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
xmlns:wfs="http://www.opengis.net/wfs"; xmlns:gml="http://www.opengis.net/gml"; 
xmlns:ogc="http://www.opengis.net/ogc"; xmlns:ows="http://www.opengis.net/ows"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; handle="GeoTools 
21.0(90b0c1c482733f6914bbf10aad19e78824634a69) WFS 1.1.0 DataStore @-----#3" 
releaseAction="ALL" service="WFS" version="1.1.0">
 <wfs:Update inputFormat="x-application/gml:3" 
srsName="urn:x-ogc:def:crs:EPSG:4326" typeName="dwd:simple.feature.test">
  <wfs:Property>
   <wfs:Name>dwd:THE_GEOM</wfs:Name>
   <wfs:Value>
    <gml:MultiPolygon>
     <gml:polygonMember>
      <gml:Polygon>
       <gml:outerBoundaryIs>
        <gml:LinearRing>
         <gml:coordinates>10.0,53.0 10.0,60.0 15.0,60.0 15.0,53.0 
10.0,53.0</gml:coordinates>
        </gml:LinearRing>
       </gml:outerBoundaryIs>
      </gml:Polygon>
     </gml:polygonMember>
    </gml:MultiPolygon>
   </wfs:Value>
  </wfs:Property>
  <ogc:Filter>
   <ogc:PropertyIsEqualTo matchCase="true">
    <ogc:PropertyName>METOBJECT_ID</ogc:PropertyName>
    <ogc:Literal>metobject-1</ogc:Literal>
   </ogc:PropertyIsEqualTo>
  </ogc:Filter>
 </wfs:Update>
</wfs:Transaction>

This request, when sent to GeoServer will wipe out the feature's geometry. 
Debugging GeoServer suggests that it cannot parse the GML representation of the 
geometry. The update to the database will be a "MULTIPOLYGON EMPTY".

Now I have compared that with a corresponding insert transaction issued from 
GeoTools which looks like this: 

<?xml version="1.0" encoding="UTF-8"?><wfs:Transaction 
xmlns:dwd="http://dwd.de"; xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
xmlns:wfs="http://www.opengis.net/wfs"; xmlns:gml="http://www.opengis.net/gml"; 
xmlns:ogc="http://www.opengis.net/ogc"; xmlns:ows="http://www.opengis.net/ows"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; handle="GeoTools 
21.0(90b0c1c482733f6914bbf10aad19e78824634a69) WFS 1.1.0 DataStore @------#2" 
releaseAction="ALL" service="WFS" version="1.1.0">
 <wfs:Insert idgen="GenerateNew" inputFormat="text/xml; subtype=gml/3.1.1" 
srsName="urn:x-ogc:def:crs:EPSG:4326">
  <dwd:simple.feature.test gml:id="new0">
   <gml:boundedBy>
    <gml:Envelope srsDimension="2" 
srsName="http://www.opengis.net/gml/srs/epsg.xml#4326";>
     <gml:lowerCorner>9 53</gml:lowerCorner>
     <gml:upperCorner>15 60</gml:upperCorner>
    </gml:Envelope>
   </gml:boundedBy>
   <dwd:THE_GEOM>
    <gml:MultiPolygon srsDimension="2" 
srsName="http://www.opengis.net/gml/srs/epsg.xml#4326";>
     <gml:polygonMember>
      <gml:Polygon srsDimension="2">
       <gml:exterior>
        <gml:LinearRing srsDimension="2">
         <gml:posList>9 53 9 60 15 60 15 53 9 53</gml:posList>
        </gml:LinearRing>
       </gml:exterior>
      </gml:Polygon>
     </gml:polygonMember>
    </gml:MultiPolygon>
   </dwd:THE_GEOM>
   <dwd:METOBJECT_ID>metobject-1</dwd:METOBJECT_ID>
   <dwd:VALID_TIME>2020-11-11T12:25:15.365Z</dwd:VALID_TIME>
  </dwd:simple.feature.test>
 </wfs:Insert>
</wfs:Transaction>

As you can easily see, the two geometry representations in insert and update 
are different. 

Could it be that the update is generating GML2 instead of GML3 that is declared 
in the input format tag? What seems to back my feeling is the code in class 

        org.geotools.wfs.bindings.PropertyTypeBinding#getProperty()

There it has a condition that is evaluated if the value is of type Geometry. 
Then this is performed: 

           if (value instanceof Geometry) {
                    Encoder encoder = new Encoder(new GMLConfiguration());
                    encoder.setInline(true);
                    encoder.encode(value, GML._Geometry, output);
                }

The GMLConfiguration and GML instances though are taken from package 
org.geotools.gml2.

So I guess my question would be: Shouldn't WFS 1.1.0 rather encode the 
geometries using GML3? And even if not, should it then rather declare to be 
issuing GML2 instead of GML3? Or is there any way to convince GeoServer to read 
the update request the way it is issued by GeoTools?

I have been desperate in finding a solution for this problem and should be very 
thankful for suggestions. 

Thanks you!
Sören




_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to