Ticket #985 (closed defect: fixed)

Opened 9 years ago

Last modified 8 years ago

legend output and raster data

Reported by: tomkralidis Owned by: mapserverbugs
Priority: high Milestone:
Component: WMS Server Version: unspecified
Severity: normal Keywords:
Cc:

Description

Currently, issuing a GetLegendGraphic request for raster layers return blank for 
 me using latest CVS.  This is also the case for MapServer CGI mode=legend (and
probably MapScript).

Some sort of legend icon would be useful.  Suggested approaches (in logical order)

1./

Define KEYIMAGE in the CLASS object, pointing to a static image file.  Request
returns KEYIMAGE

2./

If the raster layer is classified in the mapfile, create legend graphic with
this classification

3./

If GetLegendGraphic is called with an SLD with a RasterSymbolizer defined for
the raster layer, create legend graphic with this definition

4./

Scan all cells for RGB values (or SLD ColorMap or mapfile
classification) and generate a graduated image.  This appears to be 
the CubeWerx way, i.e.:

http://demo.cubewerx.com/demo/cubeserv/cubeserv.cgi?CONFIG=main&SERVIC
E=WMS&VERSION=1.1.1&REQUEST=GetLegendGraphic&LAYER=GTOPO30%3AFoundation&FO
RMAT=image%2Fpng&width=300&height=322

Daniel says this may be expensive in real-time, and I would tend to agree.  This
would be a nice feature in legend.c, which could help people create these
offline, then referring to them via KEYIMAGE.

5./

If none of the above exist/occur, then return something arbitrary as the graphic
(anything is better than blank), such as an "R", or "RGB", etc.

Change History

Changed 9 years ago by sdlime

As a basisi for discussion I assume it's known that 1 (only at the layer level 
though, class level makes sense too and would be easy to add) and 2 are 
already supported.

Steve

Changed 9 years ago by tomkralidis

Correct.  Note for case 2, only if CLASS/NAME is defined for each CLASS.

Changed 9 years ago by tomkralidis

So, I guess the way forward for this would be (not for 4.4, unless someone's
bored), by suggested approaches:

1./ Covered
2./ Covered
3./ Have GetLegendGraphic convert RasterSymbolizer to CLASS objects and feed to
legend function
4./ Add a flag (and functionality) to generated a graduated output legend image
for a raster layer?  Which could be used by KEYIMAGE

Changed 9 years ago by fwarmerdam

With regard to option 4, I am not exactly clear on what is proposed. 
However, at some point do hope to support use of graduated color ramps
for rasters.  This would _likely_ be implemented by the user defining a
class for interim locations on the ramp (often just the start and end) with
the code smoothly interpolating between them when assinging output colors. 
We would also need an abililty to include a generated color ramp showing values
along the ramp (likely the class names) in the legend.  

Assuming I am talking about roughly the same issue as (4), I would suggest we
leave any action on that part till I get the underyling rendering changes
implemented. 

I think interpolated color ramps are definately a post-4.4 thing.

I would add it might make sense to allow interpolated color ramps for 
coloring vector features as well as rasters.  If that is seen as highly
desirable, someone should likely let me know in advance, so I can implement
accordingly.


Changed 9 years ago by tomkralidis

We might be.  I guess the question is: how can one best represent a raster image
as a layer icon in case 4.

Changed 9 years ago by fwarmerdam

It would appear Cubewerx is using a graduated ramp for their GTOPO data,
and they represent that in their returned legend.  However, we don't support
graduated ramps yet so for now we don't have a case(4).  

I have no opinion on what we should be doing by default, and generally try
to avoid responsibility for anything to do with legends. 


Changed 9 years ago by tomkralidis

Good question.  For me, anything's better than blank (maybe an "R" embedded in
an image?).

Perhaps some of the developers have some ideas?

Changed 8 years ago by franck@…

For default why not take a medium extract (4 or 8 times keyzise) from the raster
data, then resize it to fit the legend key.

This should not be too computer intensive and provide an image which has the
right colors/texture in a majority of cases...

Changed 8 years ago by tomkralidis

This might well be an option.  Comments from the developers on performance on
this type of fix?

Changed 8 years ago by fwarmerdam

First, I would like to note that now that we have "range" styling (a graduated
color ramp), it would make sense for the legends to show this properly, and
GetLegendGraphic to return it.

Second, if the suggestion is that we render a chip size view of the whole image,
that might be OK, but the performance would depend on how the data is structured.
For large layers folks normally define multiple .map layers with different
min/max scale values to prevent having to touch too much data.  If this was
done, and we picked the right real layer to render it might be quite fast.

However, it is easy to think of situations where it would be very painfully 
slow, so I am pretty nervous about the idea. 


Changed 8 years ago by fwarmerdam

  • status changed from new to closed
  • resolution set to fixed
I have modified mapdrawgdal.c so that rasters are only rendering using
classification rules if at least one of the classes have an expression set
(via classObj.expression.string). 

So, no we can have classes on a raster layer that will produce legend entries
while retaining normal (non-classified) rendering.  The KEYIMAGE class attribute
can be used to provide a small pregenerated graphic for the raster layer in the
legend.  


Note: See TracTickets for help on using tickets.