3

When I make a GetFeatureInfo request to a WMS service, I get an invalid point response. I wonder what is missing from my request.

My Layer definition :

var Parcels = new TileLayer({
      name: 'Parcels',
      source: new TileWMS({
        projection: 'EPSG:4326',

        url: 'https://blabla.com',
        params: { 'LAYERS': ['myLayer'], 'TILED': true }

      })
    });

Map definition:

var mymap = new Map({
  layers: [Parcels],
  target: document.getElementById('map'),
  pixelRatio: 1,
  view: new View({

    center: fromLonLat([171.00, -45.00], 'EPSG:3857'),
    zoom: 9

  })
});

Map event:

map.on('singleclick', function (evt) {

          var layer = findByName('Parcels');
          console.log(layer);
          var url = layer
            .getSource()
            .getGetFeatureInfoUrl(
              evt.coordinate,
              map.getView().getResolution(),
              map.getView().getProjection(),
              {
                'INFO_FORMAT': 'text/xml',
                'propertyName': 'parcel'

              }
          );

When I click on a map it returns:

Invalid point (I parameter must be smaller than width parameter and J parameter must be smaller than height parameter.

It makes a request with coordinates higher than the Width and Height of the Tile map.

https://blabla.com?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetFeatureInfo&FORMAT=image%2Fpng&TRANSPARENT=true&QUERY_LAYERS=myLayer&INFO_FORMAT=text%2Fxml&propertyName=mylayerprop&I=706&J=282&WIDTH=516&HEIGHT=516&CRS=EPSG%3A4326&STYLES=&BBOX=-44.939169199785766%2C170.8956793139546%2C-44.93687999023354%2C170.8989132489774

I believe that this has to do with the openlayers getGetFeatureInfoUrl method options.

What am I missing here?

  • It might be a reprojection problem. Does the WMS support any other projections? – Mike Jan 31 at 23:52
  • 1
    If you replace GetFeatureInfo with GetMap in that request do get the map you were looking at when you clicked the point location – nmtoken Feb 1 at 3:41
  • @nmtoken, I don't want the map, I want the Feature Information – ePascoal Feb 1 at 3:55
  • 1
    Yes, of course, but the GetFeatureInfo request is a request for a pixel coordinate in a map image, the GFI request is the same as the GM, other than the request name, plus extra parameters related to pixel coord, and request response format. – nmtoken Feb 1 at 4:26
  • So the issue to debug is, are the pixel coords wrong (if you get the same map as you clicked on...), else is the map size wrong (you have a different map image) – nmtoken Feb 1 at 4:43
1

There does appear to be a problem with getGetFeatureInfoUrl when a TileWMS layer and view use projections with different units. Two meter based projections work correctly, e.g. I have a map with an EPSG:3857 TileWMS reprojected to the local UTM which works as expected. The WMS also supports EPSG:4326 but when the TileWMS is changed to degree based EPSG:4326 a getGetFeatureInfoUrl call results in a url with invalid I or J parameters. It's not even possible to simply transform the coordinates and use the layer projection ( this question also tried that OpenLayers getGetFeatureInfoUrl in other projections ) because the resolution is in different units.

0

Your layer is tiled but your I/J pixel coordinates are not so they (nearly always) fall outside the tile. You need to adjust the coordinates to reflect the tile origin for this to work.

  • getGetFeatureInfoUrl should be doing that, and the calculation would be complex because in this case the tiles are being reprojected from an EPSG:4326 grid to an EPSG:3857 view. The 516 tile size also looks wrong when OpenLayers defaults to 256. – Mike Feb 1 at 8:35
  • yeah, 516 is very odd 512 might make sense though – Ian Turton Feb 1 at 8:36
  • Yes, 516 is wrong I already fixed it. Is now 512, but even though it has the same issue.Sure @IanTurton, Yes in fact it is what the error describes but how do you adjust the coordinates to reflect the tile origin? – ePascoal Feb 3 at 21:52

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.