0

I am teaching myself the use of Services (WFS) in and OpenLayers itself. As far as I know I managed to get a proper gml-file (GML2, I hope [EDIT: It is GML 3.1, I figured]) from a governmental server by calling the following url:

https://www.wfs.nrw.de/geobasis/wfs_nw_atkis-basis-dlm_aaa-modell-basiert?service=WFS&version=1.1.0&srsName=EPSG:25832&request=GetFeature&typeName=adv:AX_Strassenachse&bbox=391918,5709660,393499,5710570,urn:ogc:def:crs:EPSG::25832&fin=fin

(I can get a GML3.2-File by using this url instead, but I think OL can't handle that)

var utm32nName = 'EPSG:25832';
proj4.defs(utm32nName, "+proj=utm +zone=32 +ellps=GRS80 +units=m +no_defs");
utm32n = ol.proj.get(utm32nName)
var wfsSource = new ol.source.Vector({
    format: new ol.format.WFS({gmlFormat: ol.format.GML3 }),
    loader: function(extent, resolution, projection) {
        var url = 'https://www.wfs.nrw.de/geobasis/wfs_nw_atkis-basis-dlm_aaa-modell-basiert?service=WFS&' +
              'version=1.1.0&srsName=EPSG:25832&request=GetFeature&' +
              'typeName=adv:AX_Strassenachse&' +
              'bbox=' + [391918,5709660,393499,5710570].join(',') +
              ',urn:ogc:def:crs:EPSG::25832&fin=fin';
        console.log(url);
        $.ajax({
              url
        }).done(
                loadFeatures
        ).fail(
                function(err, txtstatus) {
                   console.log('something went wrong')
                   console.log(err)
                   console.log(txtstatus)
                }
        );
    },
    strategy: ol.loadingstrategy.bbox
});
var loadFeatures = function(response) {
    //console.log(response)
    wfsSource.addFeatures(new ol.format.WFS().readFeatures(response));
    console.log(wfsSource.getFeatures());
};

var wfsvector = new ol.layer.Vector({
    source: wfsSource,
    style: new ol.style.Style({
      stroke: new ol.style.Stroke({
        color: 'rgba(0, 0, 0, 1.0)',
        width: 2
      })
    }),
    name: 'basisdlm'
});
fliederstrasse = [7.453175, 51.531939];
fliederstrasseWebMercator = ol.proj.transform(
    ol.proj.fromLonLat(fliederstrasse), 'EPSG:3857', 'EPSG:25832'
);
map = new ol.Map({
    layers: [
        wfsvector, 
        raster
    ],
    target: document.getElementById('map'),
    controls: ol.control.defaults({
      attributionOptions: {
        collapsible: false
      }
    }),
    view: new ol.View({
        projection: 'EPSG:25832',
      center: fliederstrasseWebMercator,
      maxZoom: 19,
      zoom: 17
    })
});

At

new ol.format.WFS().readFeatures(response)

I get the Error from the Headline and deep inside in ol.js in Ob(d).b it handles the srs-string, as far as I can tell. At some point in me working (don't know what I did, then), I managed to get no error, but nevertheless no feature has been loaded (0 features in source). Initially I tried to load the WFS with the url-attribute of ol.source.Vector() but that didn't work, either.

Even if I changed it to:

new ol.format.GML2().readFeatures(response)

or

new ol.format.GML3().readFeatures(response) //with different url

I got stuck at the same line in ol.js

Does anyone have a clue whats wrong?

I am not a native speaker of English.


EDIT: As requested in the comments, here is a small portion of the GML provided by the link above (and it seems to be GML3.1, not GML2):

<gmlx:FeatureCollection
    xmlns="http://www.adv-online.de/namespaces/adv/gid/6.0"
    xmlns:gmlx="http://www.opengis.net/gml"
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.adv-online.de/namespaces/adv/gid/6.0 http://www.wfs.nrw.de/aaa-suite/schema/old-gml-versions/3.1.1/NAS/6.0/schema/AAA-Fachschema.xsd http://www.opengis.net/gml http://www.wfs.nrw.de/aaa-suite/schema/old-gml-versions/3.1.1/NAS/6.0/schema/gml/3.1.1/base/gml.xsd http://www.isotc211.org/2005/gco http://www.wfs.nrw.de/aaa-suite/schema/old-gml-versions/3.1.1/NAS/6.0/schema/iso/19139/20070417/gco/gco.xsd http://www.isotc211.org/2005/gmd http://www.wfs.nrw.de/aaa-suite/schema/old-gml-versions/3.1.1/NAS/6.0/schema/iso/19139/20070417/gmd/gmd.xsd">
    <gmlx:boundedBy>
        <gmlx:Envelope srsName="urn:ogc:def:crs:EPSG::25832" srsDimension="2">
            <gmlx:lowerCorner>391831.345 5709517.376</gmlx:lowerCorner>
            <gmlx:upperCorner>393630.29 5710694.863</gmlx:upperCorner>
        </gmlx:Envelope>
    </gmlx:boundedBy>
    <gmlx:featureMember>
        <AX_Strassenachse gmlx:id="DENWAT01D0001uqC">
            <lebenszeitintervall>
                <AA_Lebenszeitintervall>
                    <beginnt>2015-12-06T19:58:47Z</beginnt>
                </AA_Lebenszeitintervall>
            </lebenszeitintervall>
            <modellart>
                <AA_Modellart>
                    <advStandardModell>Basis-DLM</advStandardModell>
                </AA_Modellart>
            </modellart>
            <istTeilVon xlink:href="urn:adv:oid:DENWAT01D000070p"/>
            <position>
                <gmlx:LineString srsName="urn:ogc:def:crs:EPSG::25832" srsDimension="2">
                    <gmlx:posList>
    392921.714 5709720.797 392991.374 5709731.245 392999.596 5709734.109 393006.221 5709739.54
    </gmlx:posList>
                </gmlx:LineString>
            </position>
            <anzahlDerFahrstreifen>2</anzahlDerFahrstreifen>
        </AX_Strassenachse>
    </gmlx:featureMember>
    ...
1
  • please add a small example of the GML returned
    – Ian Turton
    Commented May 20, 2018 at 9:31

1 Answer 1

1

I found out, what the problem was, after switching from ol.js to ol-debug.js (should have done this earlier!).

This issue isn't in the WFS/GML3 or Openlayers. The issue was in the identifier for the utm32n-SRS. urn:ogc:def:crs:EPSG::25832 and EPSG:25832 aren't the same (the identifier, the SRS is)!

After replacing the short code with the long one (as the WFS-Server requires...) all the data has been loaded into Openlayers. Though I had to use ol.format.WFS().

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.