1

I'm following the example from the official OL site for WFS, but I cannot get it to work with a different Feature Server when I add srsname= to the query string as specified in the example:

GET http://fbinter.stadt-berlin.de/fb/wfs/geometry/senstadt/re_spielplatzbestand/?service=WFS&version=2.0.0&request=GetFeature&typenames=fis:re_spielplatzbestand&outputFormat=application/json&srsname=EPSG:3857&bbox=1451195.2005082138,6878797.486467866,1529696.0285570899,6909372.297781937,EPSG:3857

Status Code: 400 Bad Request
Response Body:
<?xml version="1.0" encoding="UTF-8"?>
<ows:ExceptionReport xmlns:ows="http://www.opengis.net/ows/1.1" version="2.0.0">
  <ows:Exception exceptionCode="InvalidParameterValue" locator="service">
    <ows:ExceptionText>parameter SRSNAME invalid</ows:ExceptionText>
  </ows:Exception>
</ows:ExceptionReport>

Leaving srsname out produces a response with 0 features:

GET http://fbinter.stadt-berlin.de/fb/wfs/geometry/senstadt/re_spielplatzbestand/?service=WFS&version=2.0.0&request=GetFeature&typenames=fis:re_spielplatzbestand&outputFormat=application/json&bbox=1451195.2005082138,6878797.486467866,1529696.0285570899,6909372.297781937
{
  "type":"FeatureCollection",
  "totalFeatures":0,
  "features":[],
  "crs":{"type":"name","properties":{"name":"EPSG:25833"}}
}

I also tried with srsname=EPSG:25833 and appending .EPSG:25833 for the respective bits in url: function(extent) since it is the default projection that appears in GetCapabilities, but got the same result.

https://jsfiddle.net/bapms31j

Without the bbox filter, the URL for GetFeatures returns 1809 features, so it's definitely not a problem from the Feature Service. The same WFS vector layer works flawlessly in QGIS:

QGSI screenshot

Also tried changing version to 1.0.0 and 1.1.0 without success.

1 Answer 1

1

It seems to be a problem of projections:

The WFS allows only requests usings SRID 25833. A working example, including the bounding box parameter, is http://fbinter.stadt-berlin.de/fb/wfs/geometry/senstadt/re_spielplatzbestand/?service=WFS&version=2.0.0&request=GetFeature&typenames=fis:re_spielplatzbestand&outputFormat=application/json&srsname=EPSG:25833&bbox=392215,5818350,393129,5817949,EPSG:25833

Your OpenLayers map uses SRID 3857 as default. So, when including the current map extent using extent.join(',');, OpenLayers sends the bounding box in SRID:3857 coordinates whereas the WFS expects coordinates in SRID 25833.

Solution:

  1. Transform your bounding box parameters from SRID 3857 to SRID 25833.

  2. Transform the received features from SRID 25833 to SRID 3857 before viewing on the map.

5
  • I also tried with srsname=EPSG:25833 and appending .EPSG:25833 for the respective bits in url: function(extent) since it is the default projection that appears in GetCapabilities, but got the same result.
    – user100015
    Commented Mar 26, 2018 at 20:46
  • Any pointers as to how to perform the transformation you suggest specifically? I.e. with respect to the extent parameter to the url function.
    – user100015
    Commented Mar 26, 2018 at 20:47
  • Based on this question, tried ol.proj.transformExtent(extent, ol.proj.get('EPSG:3857'), ol.proj.get('EPSG:25833'));, but get TypeError: b is null ol.js:36:29 in the browser
    – user100015
    Commented Mar 26, 2018 at 20:56
  • 2
    EPSG:25833 is not supported in OpenLayers by default (only 4326 and 3857, see openlayers.org/en/latest/apidoc/ol.proj.Projection.html ). Here you can find an example for adding a new projection.
    – Mesa
    Commented Mar 26, 2018 at 21:03
  • That was bit more work than I anticipated for something at first glance so simple :\ Thanks for the pointers, I finally got it working with the linked question 👍
    – user100015
    Commented Mar 26, 2018 at 21:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.