TerriaJS / terriajs

A library for building rich, web-based geospatial data platforms.
https://terria.io
Apache License 2.0
1.18k stars 362 forks source link

Support non-standard ncWMS2 implementation of GetLegendGraphic #2338

Open rsignell-usgs opened 7 years ago

rsignell-usgs commented 7 years ago

When I add a categorical data variable from ncWMS2, such as: http://gamone.whoi.edu/ncWMS/wms?SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.3.0 then: Inundation_hampton=>flood_index (or just go to: http://tinyurl.com/ztenh99) I don't get a legend:

2017-01-18_19-26-11

TerriaJS is requesting: http://gamone.whoi.edu/ncWMS/wms?service=WMS&version=1.1.0&request=GetLegendGraphic&format=image%2Fpng&transparent=True&layer=Inundation_hampton%2Fflood_index&colorscalerange=-50%2C50

But the successful request is: http://gamone.whoi.edu/ncWMS/wms?STYLES=default-categorical&LAYERS=Inundation_hampton/flood_index&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetLegendGraphic

wms 1

kring commented 6 years ago

This server's implementation of GetLegendGraphic is non-standard in two ways:

We could address the first by always including STYLE in the GetLegendGraphic request (currently we onyl include it if the user has specified one).

For the second, we either need to detect the type of server we're dealing with, or always pass both LAYER and LAYERS.

A possible workaround is to specify both STYLE and LAYERS in the parameters part of the catalog item definition.

rsignell-usgs commented 6 years ago

@guygriffiths, could ncWMS2 also accept LAYER?

guygriffiths commented 6 years ago

GetLegendGraphic is not in the WMS standard at all, but our implementation is slightly different from that of Geoserver. I can add LAYER as an alternative to LAYERS - it'll be in the next release.

rsignell-usgs commented 6 years ago

@guygriffiths excellent! When you do that PR, can you put in there "fixes https://github.com/TerriaJS/terriajs/issues/2338", (or maybe that doesn't work across repos...)

kring commented 6 years ago

GetLegendGraphic is not in the WMS standard at all, but our implementation is slightly different from that of Geoserver.

Right, that's true, GetLegendGraphic is named but not specified in WMS 1.1.1, and is not even named in WMS 1.3.0. It's part of SLD, though, which is referenced by both WMS specifications. And the SLD spec does say layer not layers: http://www.opengeospatial.org/standards/sld (see section 10.2.1 in the 1.1.0 version of the spec)