0

I want to request a WFS feature but my mapfile returns WMS, I have tried to change the mapfile but it still returns the WMS. I am using MapServer 7.3 and OpenLayers 4. Below is my mapfile

...                     
WEB
    TEMPLATE "/data/mapFile/template.html"
    IMAGEPATH "/data/mapFile/output/"
    IMAGEURL "/data/mapFile/output/"

    METADATA
        'wfs_title'             'Provincial Boundaries'
        'wfs_onlineresource'    'http://*****/cgi-bin/mapserv?map=/data/mapFile/South.map'
        'wfs_srs'               'EPSG:4326'
        "wfs_abstract"          "Provincial boundaries" 
        'wfs_enable_request'    '*' 
    END
END

PROJECTION
    'init=epsg:4326'
END

LAYER
    NAME    'south'
    METADATA
        "wfs_title"             "Provincial Boundaries"
        "wfs_srs"               "EPSG:4326"
        "gml_include_items"     "all"
        "wfs_request_method"    "GET"
        "gml_featureid"         "ID"
        "wfs_enable_request"    "*"
    END
    CONNECTIONTYPE WFS
    TYPE    POLYGON
    STATUS  ON
    DATA    '/Data/Webmapping/National/Provinces.shp'
    TRANSPARENCY 100
    PROJECTION
        'init=epsg:4326'
    END
    CLASS
        NAME    'Privincial Boundaries' 
        STYLE
            WIDTH 0.55 
            OUTLINECOLOR 0 0 0
        END
    END
END
....

And below is my layer

africa = new ol.layer.Tile({ 
  visible : true,
  source: new ol.source.TileWMS({
      url: 'http://*****/cgi-bin/mapserv?map=/data/mapFile/South.map',     
      params: {
          'LAYERS': 'south', 
          'TRANSPARENT': true
      }
  })
});
  • 2
    You ask for TileWMS from the client side. Ask for WFS. – user30184 Nov 20 '18 at 8:28
  • You can check that a WFS is enabled by making a GetCapabilities request – nmtoken Nov 20 '18 at 9:11
  • e.g using http://*****/cgi-bin/mapserv?map=/data/mapFile/South.map&service=WFS&request=GetCapabilities& – nmtoken Nov 21 '18 at 12:05
1

As mentioned in comments the reason why you are getting a WMS response from MapServer in OpenLayers is because you are asking for a WMS response!

e.g.

...source: new ol.source.TileWMS({...

1

The map file is correct. In OpenLayers, you have created a tile layer and its source is tileWMS, that's why you are getting WMS. to get WFS,

africa_wfs_source = new ol.source.vector({
    format : new ol.format.GeoJson(),
    url: function(extent) {
        return 'http://*****/cgi-bin/mapserv? 
        map=/data/mapFile/South.map&service=WFS&' +
        'version=1.1.0&request=GetFeature&typename=south&' +
        'outputFormat=application/json&srsname=EPSG:3857&' +
        'bbox=' + extent.join(',') + ',EPSG:3857';
    },
    strategy: bboxStrategy
});


var vector = new ol.layer.Vector({
    source: africa_wfs_source,
    style: new ol.Style({
        stroke: new ol.style.Stroke({
            color: 'rgba(0, 0, 255, 1.0)',
            width: 2
        })
    })
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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