I am new to GeoServer and spatial data. I have a shapefile "shape-file-2" in geo server which is a collection of Points. I am trying to fetch all the points which are inside a provided polygon.
I am using this API
http://localhost:8888/geoserver/wfs
with body
<wfs:GetFeature service="WFS" version="1.0.0"
outputFormat="JSON"
xmlns:topp="http://www.openplans.org/topp"
xmlns:wfs="http://www.opengis.net/wfs"
xmlns:fes='http://www.opengis.org/fes/2.0'
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:gml="http://www.opengis.net/gml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wfs
http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd">
<wfs:Query typeName="aw:shape-file-2">
<fes:Filter>
<fes:Within>
<ValueReference>the_geom</ValueReference>
<!-- gml:id is mandatory on GML 3.2 geometry elements -->
<gml:Polygon srsName='http://www.opengis.net/def/crs/EPSG/0/4326'>
<gml:exterior>
<gml:LinearRing>
<gml:posList srsDimension="2">-71.89601791 42.07223825 -71.06278329 42.07223825 -71.06278329 42.52509234 -71.89601791 42.52509234 -71.89601791 42.07223825
</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</fes:Within>
<fes:Filter>
</wfs:Query>
</wfs:GetFeature>
I am getting this exception in response
<?xml version="1.0" ?>
<ServiceExceptionReport
version="1.2.0"
xmlns="http://www.opengis.net/ogc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/ogc http://schemas.opengis.net/wfs/1.0.0/OGC-exception.xsd">
<ServiceException>
java.lang.RuntimeException: Parsing failed for LinearRing: java.lang.RuntimeException: Could not find coordinates to build linestring
Parsing failed for LinearRing: java.lang.RuntimeException: Could not find coordinates to build linestring
Could not find coordinates to build linestring
</ServiceException>
</ServiceExceptionReport>
I am able to get the required output using GET call
http://localhost:8888/geoserver/wfs?service=wfs&version=2.0.0&request=GetFeature&outputFormat=json&typeNames=aw:shape-file-2&&cql_filter=WITHIN (the_geom,SRID=4326;POLYGON((-71.89601791 42.07223825,-71.06278329 42.07223825,-71.06278329 42.52509234,-71.89601791 42.52509234 ,-71.89601791 42.07223825)))
But I need to fire the POST call because polygon co-ordinates can be huge and I will not able to pass in the query string
How can I fix this?
Best Answer
You are using GML 3 and Filter 2.0 in a WFS 1.0.0 request and I suspect that is confusing GeoServer. Try changing your
wfs
definitions to:and see if it works better.
Failing that you'll need to turn logging up and look in the log file to see what is going wrong.