1

I'm using OpenLayers 4 to build a GetFeatureInfo URL with a buffer parameter to a WMS layer in MapServer in order to find the closest feature of the layer given some specific coordinates.

The problem is that the request never returns any result at all. So I don't know if there is something wrong in my code or I'm missing something.

Here is my code explained:

var layer = new ol.layer.Image({
    source: new ol.source.ImageWMS({
        url: 'http://www.juntadeandalucia.es/medioambiente/mapwms/REDIAM_PPHH_2012?',
        params: {'LAYERS': 'MSPF_POLY'},
        serverType: 'mapserver',
        crossOrigin: 'anonymous'
    })
});

// I create the layer only for requesting purpose so I don't add it to the map.

var coordinates = [311618.514508171, 4040090.26715453];

var srs = this.map_.getProjection().code; //"EPSG:25830"

const getFeatureInfoParams = {
        'INFO_FORMAT': 'text/plain', //or application/vnd.ogc.gml
        'FEATURE_COUNT': 1,
        'SRS': srs,
        'Buffer': 10;
};

var viewResolution = this.map_.getMapImpl().getView().getResolution(); 
// 353.3212194629518

var urlToRequest = layer.getSource().getGetFeatureInfoUrl(coordinates, viewResolution, srs, 
getFeatureInfoParams);

return urlToRequest;
// urlToRequest is ==> http://www.juntadeandalucia.es/medioambiente/mapwms/REDIAM_PPHH_2012?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetFeatureInfo&FORMAT=image%2Fpng&TRANSPARENT=true&QUERY_LAYERS=MSPF_POLY&LAYERS=MSPF_POLY&INFO_FORMAT=text%2Fplain&FEATURE_COUNT=1&SRS=EPSG%3A25830&Buffer=10&I=50&J=50&CRS=EPSG%3A25830&STYLES=&WIDTH=101&HEIGHT=101&BBOX=293775.7929252919%2C4022247.5455716513%2C329461.2360910501%2C4057932.988737409

I have seen that it always return I=50/J=50 and perhaps this could be the problem I don't know. It is that correct?

The pixel coordinates shouldn't be different in different bounding boxes values per request?

  • Any errors in the debugger console? Errors in debugger network? – TomazicM Apr 17 at 15:13
  • 1
    I don't believe that MapServer supports "buffer" mapserver.org/ogc/wms_server.html. Buffer does not belong to WMS standard. GeoServer supports buffer as a vendor option. In MapServer LAYER-TOLERANCE mapserver.org/mapfile/layer.html has the same effect but it may not be possible to give tolerance as a variable. – user30184 Apr 17 at 17:29
  • @TomazicM unfortunately not. – Fran1911989 Apr 17 at 19:27
  • @user30184 are you sure about that? I thought that option too but I have another layer in my map apparently in the same Mapserver namespace and if you substitute in the URL of the request the layer MSPF_POLY for unidades_hidrogeologicas it returns the closest feature in the layer as expected. I have never work to deep with MapServer I have always used Geoserver, could it be possible that you have to configure in every layer that you publish the BUFFER option? – Fran1911989 Apr 17 at 19:27
  • I have seen that it always return I=50/J=50 and perhaps this could be the problem I don't know. It is that correct? Seems odd for the point you click on your image to always be at a location 50 pixels down and 50 across – nmtoken Apr 18 at 19:22

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.