javascriptgisgeoserverwms

wms url request does not work with coordinates with decimals


I have this to get the point when the user clicks on a map using betterWms plugin

getFeatureInfoUrl: function (latlng) 
  {
    // Construct a GetFeatureInfo request URL given a point
    var point = this._map.latLngToContainerPoint(latlng, this._map.getZoom()), size = this._map.getSize(),
    params = {
          request: 'GetFeatureInfo',
          service: 'WMS',
          srs: 'EPSG:4326',
          styles: this.wmsParams.styles,
          transparent: this.wmsParams.transparent,
          version: this.wmsParams.version,      
          format: this.wmsParams.format,
          bbox: this._map.getBounds().toBBoxString(),
          height: size.y,
          width: size.x,
          layers: this.wmsParams.layers,
          query_layers: this.wmsParams.layers,
          info_format: 'application/json'
    };
    
    params[params.version === '1.3.0' ? 'i' : 'x'] = point.x;
    params[params.version === '1.3.0' ? 'j' : 'y'] = point.y;
    
    console.log(point);
    var url = this._url + L.Util.getParamString(params, this._url, true);

The url is valid when the clicked point has no decimals, so by just removing them works, but I need to use decimals.

I try changing the url decimal to %2E, %2C, and also for comma and point but neither of this solutions works, the only way of having a valid url is by removing the decimals.

This request is being send to geoserver, the data is a shapefile and it displays in the correct places, the src is the same in geoserver and in the code (EPSG:4326).

I also try to change in the layer the decimals in the WFS section to 50 decimals but the request is wms so I don't know if this will do something or not.

Could you tell what could I do please?


Solution

  • In a getFeatureInfo request the X and Y values are in pixels and thus must be integers. The server then generates the picture of the map you have and looks at that to see what is below that pixel in the image.