MapServer icon indicating copy to clipboard operation
MapServer copied to clipboard

Set layer extent to requested wms bbox

Open PatrikSylve opened this issue 1 year ago • 4 comments

When constructing the WMS URL for a layer with a WMS connection, the layerObj.projection is assigned the requested SRS if allowed. However, in some cases, reprojecting the layer's extent into the requested SRS can result in invalid values (e.g., when the layer covers the entire world in EPSG:4326, and the requested SRS is a UTM zone), causing the layer to fail the msLayerIsVisible check and not render. To avoid this issue, the WMS bounding box extent is assigned directly rather than attempting to reproject the layer extent.

PatrikSylve avatar Sep 12 '24 08:09 PatrikSylve

Does it mean that after this change the LAYER-EXTENT and wms_extent won't have any meaning, but the BBOX is always accepted and Mapserver tries to render the WMS layer, even when the BBOX really is outside the extent?

jratike80 avatar Sep 12 '24 08:09 jratike80

Does it mean that after this change the LAYER-EXTENT and wms_extent won't have any meaning, but the BBOX is always accepted and Mapserver tries to render the WMS layer, even when the BBOX really is outside the extent?

At this point in the code it has already been asserted that the layer is visible (https://github.com/MapServer/MapServer/blob/main/src/mapdraw.c#L402), so it should not render it if the original layer extent is outside. When mapserver mapserver performs the WMS request the layer is treated as a Raster, so in that context the layer-extent has meaning.

PatrikSylve avatar Sep 12 '24 09:09 PatrikSylve

@PatrikSylve can you include an msautotest test for the scenario that you mention here, as part of this pull request? thanks.

jmckenna avatar Sep 30 '24 14:09 jmckenna

@jmckenna I updated wms_client test and added that the wms client layer supports ESPG:32663. Since the remote https://demo.mapserver.org does not support this CRS the test results in an 'Invalid CRS'-exception (which is expected). Without this fix the response is just an empty image since the layer was evaluated to be outside map extent.

For a cleaner test, would it be possible to add EPSG:32663 as an accepted SRS for a service on demo.mapserver?

PatrikSylve avatar Oct 04 '24 06:10 PatrikSylve

@PatrikSylve I've added EPSG:32633 to that service (see GetCapabilities). Can you quickly try this again? (I'd like to include your change in today's MapServer 8.4.0 beta release) Please let me know.

jmckenna avatar Dec 09 '24 20:12 jmckenna

Thanks!

My previous example request pointed to no data so I updated the BBOX in test to get a better output. I tested this request with a build of the previous version of the code as well, and that one resulted in an empty image. So looks like it works as expected :+1:

PatrikSylve avatar Dec 09 '24 21:12 PatrikSylve

Cool, thanks for the fast changes @PatrikSylve . Merging! (willdo the beta release tomorrow morning)

jmckenna avatar Dec 10 '24 00:12 jmckenna