简体   繁体   中英

Strange error returned while trying to access raster pixel value

I am trying to access the value of a pixel served through MapServer from webapp via OpenLayers getFeatureInfoUrl(). The server responds with msWMSFeatureInfo(): WMS server error. Invalid I/J values I have tried googling it but could not find any clues on what might be wring with my request only that I/J values refer to the coorndinates of the mouse click so the problem might originate in evt.coordinate from:

var vs = this.wmsLayer
mapol.on('singleclick', function(evt) {
  document.getElementById('info').innerHTML = '';
  var viewResolution = /** @type {number} */ (view.getResolution());
  var url = vs.getSource().getGetFeatureInfoUrl(
     evt.coordinate, viewResolution, 'EPSG:4326',
      {'INFO_FORMAT': 'text/html'});
  if (url) {
    document.getElementById('info').innerHTML =
        '<iframe seamless src="' + url + '"></iframe>';
  }
});

The wmsLayer uses the same 'EPSG:4326' coordinate system as request. Can anyone help me get the pixel value at the clicked location:)

The SRS of the coordinate you pass to the #getGetFeatureInfoUrl() method needs to match the projection you provide as argument. So you'd have to change your code to

var url = vs.getSource().getGetFeatureInfoUrl(
   ol.proj.toLonLat(evt.coordinate, view.getProjection()),
   viewResolution, 'EPSG:4326', {'INFO_FORMAT': 'text/html'});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM