Интеграция WFS как gml в OL5

Я пытаюсь визуализировать WFS (от MapServer) в OL5.

WFS работает хорошо (я могу без проблем реализовать это в QGIS). Также запрос типа:

http://blablabla/mapserv?service=WFS&version=1.1.0&request=GetFeature&typename=Flurstueckepunkt&srsname=EPSG:25832&bbox=411554,5791886,411677,5792008 дает мне хороший вывод gml в формате epsg: 25832.

Я пытаюсь реализовать это в OpenLayers, например:

var vectorSource = new VectorSource({
        format: new WFS(), 
        loader: function(extent, resolution, projection) {
        var url = 'http://blablabla/mapserv?service=WFS&version=1.1.0&request=GetFeature&typename=ms:Flurstueckepunkt&srsname=EPSG:25832&bbox=412200,5791337,413600,5791800,EPSG:25832'
          fetch(url).then(function(response) {
            return response.text();
          }).then(function(text) {
            var features = vectorSource.getFormat().readFeatures(text);

            // Add parsed features to vectorSource
            vectorSource.addFeatures(features);
          }).catch(function(error) {
            alert(error.message);
          })
        }
      });

    var WFSLayer =new VectorLayer(
    {   
        source: vectorSource,
               projection: 'EPSG:25832',
        style: new Style({     fill: new Fill({ color: 'yellow'  })
    })
      });


      var view = new View({
           center: [rechtswert,hochwert],
        zoom: mzoom,
        projection: 'EPSG:25832'
      });
      var map = new Map({

        layers: [osm,wmsLayer2,WFSLayer],
        target: 'map',
        view: view
      });

... но слой WFS вообще не отображается.

Через Mozialle-Debugger я вижу, что wfs-запрос работает, но ничего не визуализируется? Кто-нибудь знает, что здесь не так?


person Kai Behncke    schedule 03.01.2020    source источник


Ответы (1)


Хорошо, я понял. Поскольку WFS ist доставляет очки, важен стиль визуализации.

Теперь он работает с:

var vectorSource = new Vector({
  format: new GML3(),
  loader: function(extent) {
  var url = 'http://blablalbvlAn/cgi-bin/mapserv?service=WFS&version=1.1.0&request=GetFeature&typename=ms:Flurstueckepunkt&srsname=EPSG:25832&' +
  'bbox='+ extent.join(',') +',EPSG:25832';

     var xhr = new XMLHttpRequest();
     xhr.open('GET', url);
     var onError = function() {
       vectorSource.removeLoadedExtent(extent);
     }
     xhr.onerror = onError;
     xhr.onload = function() {
       if (xhr.status == 200) {
         vectorSource.addFeatures(
             vectorSource.getFormat().readFeatures(xhr.responseText));
                var features3 = vectorSource.getFeatures();
       } else {
         onError();
       }
     }
     xhr.send();
   },
   strategy: bbox
 });




    var WFSLayer =new VectorLayer(
    {   
        source: vectorSource,
        style:  new Style({
    image: new CircleStyle({
      radius: 5,
      fill: new Fill({
        color: 'orange'
      })
    })
      })
      });

person Kai Behncke    schedule 03.01.2020