Reading-eScience-Centre / edal-java

Environmental Data Abstraction Layer libraries
Other
39 stars 30 forks source link

"Export to PNG" ignores base layer definition #99

Closed marceloandrioni closed 6 years ago

marceloandrioni commented 6 years ago

Hello, I think I found a small problem with the "Export to PNG" option on Godiva3. Despite baseLayers being a parameter in calling the Screenshot function with the "Export to PNG" link in Godiva3, the resulting image seems to default always to the same base layer:

link1 with baseLayers=bluemarble: http://godiva.rdg.ac.uk//ncWMS2/screenshots/createScreenshot?server=http://godiva.rdg.ac.uk/ncWMS2/wms&numColorBands=250&logScale=false&bbox=-180,-144,180,144&abovemaxcolor=0x000000&belowmincolor=0x000000&nodatacolor=transparent&layer=cci/analysed_sst&time=2010-12-31T12:00:00.000Z&palette=psu-inferno&style=default-scalar&scaleRange=269,306&displayScaleRange=269,306&opacity=1&bbox=-180,-144,180,144&layerTitle=Sea-surface%20temperature,SST,CCI%20SST%20(Regular%20Grid)&crs=CRS:84&mapHeight=600&mapWidth=750&style=default-scalar&zUnits=null&units=kelvin&baseUrl=http://godiva.reading.ac.uk/geoserver/ReSC/wms?&&baseLayers=bluemarble link2 with baseLayers=naturalEarth: http://godiva.rdg.ac.uk//ncWMS2/screenshots/createScreenshot?server=http://godiva.rdg.ac.uk/ncWMS2/wms&numColorBands=250&logScale=false&bbox=-180,-144,180,144&abovemaxcolor=0x000000&belowmincolor=0x000000&nodatacolor=transparent&layer=cci/analysed_sst&time=2010-12-31T12:00:00.000Z&palette=psu-inferno&style=default-scalar&scaleRange=269,306&displayScaleRange=269,306&opacity=1&bbox=-180,-144,180,144&layerTitle=Sea-surface%20temperature,SST,CCI%20SST%20(Regular%20Grid)&crs=CRS:84&mapHeight=600&mapWidth=750&style=default-scalar&zUnits=null&units=kelvin&baseUrl=http://godiva.reading.ac.uk/geoserver/ReSC/wms?&baseLayers=naturalEarth

Checking the code, the line https://github.com/Reading-eScience-Centre/edal-java/blob/master/wms/src/main/java/uk/ac/rdg/resc/edal/wms/ScreenshotServlet.java#L190 seems to ignore the base layer defined in the url in favor of the bluemarble one.

This can be a problem because starting with EDAL v1.2.11 the user can set his own layers as base/overlay layers. In my case I am behind a proxy and use a baselayer hosted on a geoserver inside the network to avoid problems. This options works fine for navigating the map, but the screenshot fails because it tries to recover a layer outside the network.

Also, considering that with EDAL v1.2.11 the user can set his own base and overlay layers, it would be really useful if the screenshot function would check witch overlay layers are active and insert then in the png image. Another small problem is that with the new parameter layerOnByDefault=true on godiva3.properties the user can make his own layer the default one, but when Godiva3.html loads for the first time, the layer defined in the link "Export to PNG" is always the first on the list (naturalEarth) and not the user defined default layer. The user has then to select another base layer and reselect his own layer to correct the link.

Thank you.

guygriffiths commented 6 years ago

There was definitely a reason why it was done like this - the sensible default would have been to use whichever base layer was active, rather than just the blue marble one - but I can't recall what it was, and it may not be valid any more. I'll have a go at implementing it properly and see if anything comes up.

guygriffiths commented 6 years ago

That's all fixed now, and I've done a 2.1.12 release of ncWMS

marceloandrioni commented 6 years ago

Hi, thanks for the updated version. Now the user baselayer is automatically selected in the "Export to PNG". The only minor problem is that the overlay layers are not show. Do I need to use a special layer name in godiva3.properties or something like that? Below a screenshot for Godiva3.html with the base and overlay layers and an image from "Export to PNG" showing only the baselayer. screenshot_overlayon screenshot_overlayoff

guygriffiths commented 6 years ago

So, in addition to a typo in the tag name (it should have been 2.2.12, not 2.1.12), the front-end had failed to compile properly, hence the continuing issues. I have updated the release to have the correct version and have rebuilt it, so this should all work now.

marceloandrioni commented 6 years ago

Ok, thanks. I will try the new ncWMS 2.2.12 war when available.

marceloandrioni commented 6 years ago

Everything is working now, base layer and overlay are show in the screenshot. Thanks. screenshot_withoverlays