eblondel / ows4R

R Interface for OGC Web-Services (OWS)
https://eblondel.github.io/ows4R/
Other
36 stars 8 forks source link

[WFS/WCS] Add support POST requests #100

Open salvafern opened 1 year ago

salvafern commented 1 year ago

Hello there! πŸ‘‹

An issue I have faced using ows4R is that CQL/OGC (or viewParams via vendor params) filters fail if you try to perform a spatial query with a very detailed feature. See https://github.com/lifewatch/eurobis/issues/16

This is because URLs have a limit in the number of characters they can have in GET requests. Hence a possible solution is to allow POST and pass polygons there.

Example with curl:

Get all features that intersect with a certain polygon. I will use the EEZ layer of MarineRegions.

Create a post request as XML and name as xmlquery.xml. Contains the name of the layer (MarineRegions:eez), the name of the geometry column (the_geom), the instructions to intersect and the polygon to intersect with as gml

<wfs:GetFeature xmlns:wfs='http://www.opengis.net/wfs' xmlns:ogc='http://www.opengis.net/ogc' xmlns:gml='http://www.opengis.net/gml' service='WFS' version='1.0.0'>
  <Query typeName='MarineRegions:eez'>
  <ogc:Filter xmlns:gml="http://www.opengis.net/gml">
      <Overlaps>
        <PropertyName>the_geom</PropertyName>
        <gml:Polygon srsName="http://www.opengis.net/gml/srs/epsg.xml#63266405">
          <gml:outerBoundaryIs>
            <gml:LinearRing>
               <gml:coordinates>-0.258498799963897,58.4594990974729 2.76925390761733,58.4594990974729 2.76925390761733,53.7259702166065 -0.258498799963897,58.4594990974729</gml:coordinates>
            </gml:LinearRing>
          </gml:outerBoundaryIs>
        </gml:Polygon>
       </Overlaps>
  </ogc:Filter>
  </Query>
</wfs:GetFeature>

Perform POST request with curl:

curl -XPOST -d @wfsquery.xml -H "Content-type: application/xml" "http://geo.vliz.be/geoserver/MarineRegions/ows?" --output test.geojson

From https://github.com/EMODnet/EMODnetWFS/issues/115#issuecomment-1384197510

Is this something feasible? Is there another approach we are overlooking?

Thanks!

eblondel commented 1 year ago

@salvafern yes POST would be the right approach but POST is not supported yet for WxS in ows4R. It is for CSW.

salvafern commented 1 year ago

I understand this is not trivial and would require some work. For now I just wanted to raise the issue to document. Thanks @eblondel !

eblondel commented 1 year ago

yes indeed it requires some work. ows4R POST request encoding is done generically. There is need to test / apply this other services than CSW. If I find some time, I'll give it a try for some basic WFS requests.