mapcomponents / react-map-components-maplibre

A react component framework for declarative GIS application development.
MIT License
119 stars 18 forks source link

Bug: WMS FeatureInfo does not work on tilted map #102

Closed JakobMiksch closed 1 year ago

JakobMiksch commented 1 year ago

@mapcomponents/react-maplibre version: The deployed version on 2023-04-26

Steps To Reproduce

  1. Open https://catalogue.mapcomponents.org/en/demo/AppWebGis/dashboard
  2. Activate the layer "Metadaten"
  3. Perform a WMS GetFeatureInfo Request when it is tilted.

The current behavior

The Request either fails or returns information of a wrong feature. In the screenshot below, I clicked on the tile "32296_5592" (lowest rectangle) but the response is "32312_5600" and apparently wrong

image

The expected behavior

The request also takes into account the tilted map.

Maybe this thread helps: https://gis.stackexchange.com/questions/307407/how-to-query-features-of-raster-layers-hosted-on-geoserver-that-are-added-to-map

cioddi commented 1 year ago

Thank you for raising the issue and the screenshot. The current implementation only works with the unpitched map.

https://github.com/mapcomponents/react-map-components-maplibre/blob/main/src/components/MlWmsLoader/MlWmsLoader.tsx#L166

We will have to get tile dimensions as bbox and then determine the pixel position of the click event relative to that bbox to make a valid getfeatureinfo request in this map state.

I am documenting my ideas on solving this here, one of my colleagues will take a look at fixing it.

  1. Use unproject to turn click events x and y into coordinates. https://maplibre.org/maplibre-gl-js-docs/api/map/#map#unproject
  2. Use the coordinates from step 1 to as the bbox north-west coordinates and construct the south-east coordinates from that.
  3. Use fixed width and height that matches the aspect ratio of the bbox from step 2. I/Y or X/Y coordinates can be 0,0.