[Geoserver-users] Problem with WFS-T 1.1.0 Insert Multipolygon

Hello

i would like to do an insert WFS-T into a PostGis Datastore with this command

<wfs:Transaction service="WFS" version="1.1.0"
xmlns:wfs="http://www.opengis.net/wfs&quot;
xmlns:topp="http://www.openplans.org/topp&quot;
xmlns:gml="http://www.opengis.net/gml&quot;
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/WFS-transaction.xsd http://www.openplans.org/topp http://localhost:8180/geoserver170a/wfs/DescribeFeatureType?typename=topp:edit_mulitpolygon <http://localhost:8180/geoserver170a/wfs/DescribeFeatureType?typename=topp:wfs_test_mulitpolygon&gt;&quot;&gt;
<wfs:Insert>
<topp:edit_multipolygon>
   <topp:the_geom>
     <gml:MultiPolygon srsName="http://www.opengis.net/gml/srs/epsg.xml#4326 <http://www.opengis.net/gml/srs/epsg.xml#31467&gt;&quot;&gt;
      <gml:Polygon>
       <gml:outerBoundaryIs>
        <gml:LinearRing>
         <gml:coordinates decimal="." cs="," ts=" ">31,60 35,56 37,51 31,60
         </gml:coordinates>
        </gml:LinearRing>
       </gml:outerBoundaryIs>
      </gml:Polygon>
     </gml:MultiPolygon>
   </topp:the_geom>
  </topp:edit_multipolygon>
</wfs:Insert>
</wfs:Transaction>

After this there is a new entry in the Datastore table, but the_geom is empty. It looks like this SRID=4326;MULTIPOLYGON ((EMPTY)).

What is the problem! Can anybody help?

Thank you.

Alex

Hi Alexander,

The issue is here is that the multi polygon is being specified in GML2, but the request is a WFS 1.1 request so it expects GML3. If you change the Polygon element to:

<gml:Polygon>
    <gml:exterior>
       <gml:LinearRing>
           <gml:posList>31 60 35 56 37 51 31 60
        </gml:coordinates>
     </gml:LinearRing>
   </gml:exterior>
</gml:Polygon>

It should work.

-Justin

Alexander Strunck wrote:

Hello

i would like to do an insert WFS-T into a PostGis Datastore with this command

<wfs:Transaction service="WFS" version="1.1.0"
xmlns:wfs="http://www.opengis.net/wfs&quot;
xmlns:topp="http://www.openplans.org/topp&quot;
xmlns:gml="http://www.opengis.net/gml&quot;
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/WFS-transaction.xsd http://www.openplans.org/topp http://localhost:8180/geoserver170a/wfs/DescribeFeatureType?typename=topp:edit_mulitpolygon <http://localhost:8180/geoserver170a/wfs/DescribeFeatureType?typename=topp:wfs_test_mulitpolygon&gt;&quot;&gt;
<wfs:Insert>
<topp:edit_multipolygon>
   <topp:the_geom>
     <gml:MultiPolygon srsName="http://www.opengis.net/gml/srs/epsg.xml#4326 <http://www.opengis.net/gml/srs/epsg.xml#31467&gt;&quot;&gt;
      <gml:Polygon>
       <gml:outerBoundaryIs>
        <gml:LinearRing>
         <gml:coordinates decimal="." cs="," ts=" ">31,60 35,56 37,51 31,60
         </gml:coordinates>
        </gml:LinearRing>
       </gml:outerBoundaryIs>
      </gml:Polygon>
     </gml:MultiPolygon>
   </topp:the_geom>
  </topp:edit_multipolygon>
</wfs:Insert>
</wfs:Transaction>

After this there is a new entry in the Datastore table, but the_geom is empty. It looks like this SRID=4326;MULTIPOLYGON ((EMPTY)).

What is the problem! Can anybody help?

Thank you.

Alex

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

Justin Deoliveira ha scritto:

Hi Alexander,

The issue is here is that the multi polygon is being specified in GML2, but the request is a WFS 1.1 request so it expects GML3. If you change the Polygon element to:

<gml:Polygon>
    <gml:exterior>
       <gml:LinearRing>
           <gml:posList>31 60 35 56 37 51 31 60
        </gml:coordinates>
     </gml:LinearRing>
   </gml:exterior>
</gml:Polygon>

It should work.

Alexander, to avoid being tripped with these errors you can
also enable strict CITE compliance in the WFS configuration.
That should enable request validation so if a request it's not
schema valid (like the one you used) you'll get a meaningful
error.
Downside, the WFS will become very very strict, any mistake
and you'll get back a service exception.
Another option is to post your requests to:
http://<host>:<port>/geoserver/ows?strict=true

that will enable xml schema validation only
(see also http://geoserver.org/display/GEOSDOC/WFS+vendor+parameters)

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

Hi all,

i have the same problem here. Its the first time im working with wfs-t though.

I started with demo wfs-t included in geoserver (1.7.1), that writes
new features to shape files (tasmania cities and roads) Demo is
working fine. Then i shp2pgsql roads and tried to make wfs-t work with
postgis.i get the same result as alexander, new rows in table without
geom data.

im posting my geom in gml3, this is my request

<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs&quot;
version="1.1.0" service="WFS">
<wfs:Insert>
<feature:roads xmlns:feature="http://test">
<feature:the_geom>
<gml:MultiLineString
xmlns:gml="http://www.opengis.net/gml&quot;&gt;&lt;gml:lineStringMember&gt;&lt;gml:LineString&gt;&lt;gml:posList&gt;149\.29868203125
-40.8492431640625 146.991553125 -40.4757080078125 144.42075234375
-40.1461181640625 143.7835453125 -42.2994384765625 148.50766640625
-43.7276611328125 149.0130375
-42.5191650390625</gml:posList></gml:LineString></gml:lineStringMember></gml:MultiLineString>
</feature:the_geom></feature:roads></wfs:Insert></wfs:Transaction>

and the response

<wfs:TransactionResponse version="1.1.0"
xsi:schemaLocation="http://www.opengis.net/wfs
http://localhost:8888/geoserver171/schemas/wfs/1.1.0/wfs.xsd&quot;&gt;

<wfs:TransactionSummary>
<wfs:totalInserted>1</wfs:totalInserted>
<wfs:totalUpdated>0</wfs:totalUpdated>
<wfs:totalDeleted>0</wfs:totalDeleted>
</wfs:TransactionSummary>
<wfs:TransactionResults/>

<wfs:InsertResults>
<wfs:Feature>
<ogc:FeatureId fid="roads.78"/>
</wfs:Feature>
</wfs:InsertResults>
</wfs:TransactionResponse>

running it with http://localhost:8888/geoserver171/ows?strict=true i get
WARN [org.geotools.xml] - cvc-complex-type.2.4.a: Invalid content
starting with element 'feature:roads'. One of
'{"http://www.opengis.net/gml&quot;:\_Feature\}' is expected.

but i still get same response...alex have u maybe made it work?

Thank you, Ivan

On Fri, Nov 28, 2008 at 5:37 PM, Andrea Aime <aaime@anonymised.com> wrote:

Justin Deoliveira ha scritto:

Hi Alexander,

The issue is here is that the multi polygon is being specified in GML2,
but the request is a WFS 1.1 request so it expects GML3. If you change
the Polygon element to:

<gml:Polygon>
    <gml:exterior>
       <gml:LinearRing>
           <gml:posList>31 60 35 56 37 51 31 60
        </gml:coordinates>
     </gml:LinearRing>
   </gml:exterior>
</gml:Polygon>

It should work.

Alexander, to avoid being tripped with these errors you can
also enable strict CITE compliance in the WFS configuration.
That should enable request validation so if a request it's not
schema valid (like the one you used) you'll get a meaningful
error.
Downside, the WFS will become very very strict, any mistake
and you'll get back a service exception.
Another option is to post your requests to:
http://<host>:<port>/geoserver/ows?strict=true

that will enable xml schema validation only
(see also http://geoserver.org/display/GEOSDOC/WFS+vendor+parameters)

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Ivan Grcic ha scritto:

Hi all,

i have the same problem here. Its the first time im working with wfs-t though.

I started with demo wfs-t included in geoserver (1.7.1), that writes
new features to shape files (tasmania cities and roads) Demo is
working fine. Then i shp2pgsql roads and tried to make wfs-t work with
postgis.i get the same result as alexander, new rows in table without
geom data.

im posting my geom in gml3, this is my request

<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs&quot;
version="1.1.0" service="WFS">
<wfs:Insert>
<feature:roads xmlns:feature="http://test">

Ivan, is this xmlns made up or is it known to GeoServer?
A real schema driven parse is done, so if you make up
namespaces the parser won't work.
If you don't specify the namespace of your feature and
just use the prefix configured in GeoServer it should
work anyways (failing to find a proper xmlns it will
try to do a prefix match with the known prefixes in
the server, as most client cannot really make
up a proper wfs request with the right namespace
references and so on), but if you do, make sure
the xmlns you specify exactly matches the one you
specified in GeoServer for your data store.

Hope this helps

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

Thanks Andrea&Alexander I got it working, it wasnt issue with
namespaces (i always use ones that i specify in geoserver) but it was
some problem with ndims constraint in pgis table:

by default shp2pgsql creates 3dim coordinates
   SELECT AddGeometryColumn('','roads','geom','4326','MULTILINESTRING',3);
which creates constraint:
   ALTER TABLE roads ADD CONSTRAINT enforce_dims_geom2 CHECK (ndims(geom2) = 3);

that throws
Caused by: org.geotools.data.DataSourceException: SQL Exception
writing geometry columnERROR: new row for relation "roads" violates
check constraint "enforce_dims_geom"

droping constraint and changing it to
ALTER TABLE roads ADD CONSTRAINT enforce_dims_geom2 CHECK (ndims(geom2) = 2);

successfully inserts the data. For now im happy with that, but what if
I want to insert 3rd dimension? iIf I leave (ndims(geom2) = 3) and add
3d coordinate
<gml:posList>146 -44.3 0 146.2 -44.5 0 146.3 -44.7 0</gml:posList>

i get:

<ows:ExceptionText>
org.geotools.referencing.operation.projection.PointOutsideEnvelopeException:
      146.2 outside of (-90.0,90.0) Parsing failed for
      LineString: org.geoserver.wfs.WFSException:
      org.geotools.referencing.operation.projection.PointOutsideEnvelopeException:
      146.2 outside of (-90.0,90.0)
      org.geotools.referencing.operation.projection.PointOutsideEnvelopeException:
      146.2 outside of (-90.0,90.0) 146.2 outside of (-90.0,90.0)
</ows:ExceptionText>

Obviously thats not the way to insert third dimension, posList accepts
only 2dims, am i right? What would be the right way to insert 3rd
dimension in GML3?

Thank you

On Mon, Jan 12, 2009 at 3:02 PM, Andrea Aime <aaime@anonymised.com> wrote:

Ivan Grcic ha scritto:

Hi all,

i have the same problem here. Its the first time im working with wfs-t
though.

I started with demo wfs-t included in geoserver (1.7.1), that writes
new features to shape files (tasmania cities and roads) Demo is
working fine. Then i shp2pgsql roads and tried to make wfs-t work with
postgis.i get the same result as alexander, new rows in table without
geom data.

im posting my geom in gml3, this is my request

<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs&quot;
version="1.1.0" service="WFS">
<wfs:Insert>
<feature:roads xmlns:feature="http://test">

Ivan, is this xmlns made up or is it known to GeoServer?
A real schema driven parse is done, so if you make up
namespaces the parser won't work.
If you don't specify the namespace of your feature and
just use the prefix configured in GeoServer it should
work anyways (failing to find a proper xmlns it will
try to do a prefix match with the known prefixes in
the server, as most client cannot really make
up a proper wfs request with the right namespace
references and so on), but if you do, make sure
the xmlns you specify exactly matches the one you
specified in GeoServer for your data store.

Hope this helps

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

--
Ivan Grcic

Ivan Grcic ha scritto:

Thanks Andrea&Alexander I got it working, it wasnt issue with
namespaces (i always use ones that i specify in geoserver) but it was
some problem with ndims constraint in pgis table:

by default shp2pgsql creates 3dim coordinates
   SELECT AddGeometryColumn('','roads','geom','4326','MULTILINESTRING',3);
which creates constraint:
   ALTER TABLE roads ADD CONSTRAINT enforce_dims_geom2 CHECK (ndims(geom2) = 3);

that throws
Caused by: org.geotools.data.DataSourceException: SQL Exception
writing geometry columnERROR: new row for relation "roads" violates
check constraint "enforce_dims_geom"

droping constraint and changing it to
ALTER TABLE roads ADD CONSTRAINT enforce_dims_geom2 CHECK (ndims(geom2) = 2);

successfully inserts the data. For now im happy with that, but what if
I want to insert 3rd dimension? iIf I leave (ndims(geom2) = 3) and add
3d coordinate
<gml:posList>146 -44.3 0 146.2 -44.5 0 146.3 -44.7 0</gml:posList>

i get:

<ows:ExceptionText>
org.geotools.referencing.operation.projection.PointOutsideEnvelopeException:
      146.2 outside of (-90.0,90.0) Parsing failed for
      LineString: org.geoserver.wfs.WFSException:
      org.geotools.referencing.operation.projection.PointOutsideEnvelopeException:
      146.2 outside of (-90.0,90.0)
      org.geotools.referencing.operation.projection.PointOutsideEnvelopeException:
      146.2 outside of (-90.0,90.0) 146.2 outside of (-90.0,90.0)
</ows:ExceptionText>

Obviously thats not the way to insert third dimension, posList accepts
only 2dims, am i right? What would be the right way to insert 3rd
dimension in GML3?

GML3 supports 3 dimensions as a language, but GeoServer code does not.
Please open a improvement request at jira.codehaus.org,
not sure when we can work on it, but if many people vote on it we'll
look into it.

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.