Leaflet.NonTiledLayer icon indicating copy to clipboard operation
Leaflet.NonTiledLayer copied to clipboard

WMS getImageUrl Question

Open k-taylor opened this issue 7 years ago • 2 comments

In the getImageUrl the bounding bbox is using the pixel location (as appose to lat/lng) for the corner points in the URL. It's my understand that the WMS bounding box is suppose to be lat/lngs, am I miss understanding something?

When we made the following changes it worked with our wms server: `
wmsParams.width = width wmsParams.height = height

    const degNW = bounds.getNorthWest()
    const degSE = bounds.getSouthEast()

    const url = this._wmsUrl

    const bbox = (this._wmsVersion >= 1.3 && this._crs === L.CRS.EPSG4326 ?
        [degSE.lat, degNW.lng, degNW.lat, degSE.lng] :
        [degNW.lng, degSE.lat, degSE.lng, degNW.lat]).join(',')`

k-taylor avatar Nov 09 '18 17:11 k-taylor

Hi,

i've verified the behaviour, and the implementation is correct. It's the same implemetation as in L.TileLayer.WMS. However the result is not what you may expect:

  1. The default map projection/crs for Leaflet is "Google Mercator" (EPSG:3857, image 1). All WMS layers are queried with this crs then, the code reprojects the map-bounds to this crs, and the WMS must support EPSG:3857.
  2. You can set the map crs to EPSG.4326 with (image 2) var map = L.map('map', { crs:L.CRS.EPSG4326 // test for Plate Carree projection }); This means the map uses the 'EPSG:4326-projection' then, wich means all layers also must support EPSG:4326.
  3. You can set only the crs of the WMS-layer to EPSG:4326 and leave the map in Google Mecator (image 3). Then the bounds are not reprojected, it's effectively the same as in your code. But the result isn't really accurate. If the projection of the WMS image is different than the projection of the map, all individual pixels should be transformed, like here https://www.jasondavies.com/maps/raster/ . Leaflet just overlays the resulting image.

So the WMS layer works as expected, i've tested it with the meteosat WMS in the sample. But you should check if you can make your WMS "Google-Mercator" aware, because Leaflet cannot mash-up images from different projections accurately.

Google Mercator image Equirectangular image Google Mercator with Equirectangular Overlay image

oliverheilig avatar Nov 09 '18 19:11 oliverheilig

Thank you so much for your quick reply!

k-taylor avatar Nov 09 '18 21:11 k-taylor