Opened 14 years ago

Last modified 13 years ago

#3504 new enhancement

Add automated legend generation

Reported by: mraross Owned by: assefa
Priority: normal Milestone: FUTURE
Component: Output-KML Version: unspecified
Severity: normal Keywords: kml legend
Cc:

Description

In getMap with format='kml', include a legend.

Put the legend in the description element of a kml folder and generate as follows:

for each map layer

include a getLegendGraphic request include a hyperlink to the contents of wms_metadataurl_href

end for

Here is an example description element for a single map layer:

<description>

<![CDATA[<img src="http://openmaps.gov.bc.ca/mapserver/parks-and-recreation? service=wms&version=1.1.1&service=WMS&request=GetLegendGraphic&layer=TA_PARK_ECORES_PA_PROTECTED_C&format=image/png"><br>

For more information <A HREF="https://apps.gov.bc.ca/pub/geometadata/metadataDetail.do?recordUID=54259&recordSet=ISO19115">click here</A></P>]]> </description>

Attachments (1)

legend_example.jpg (18.6 KB ) - added by mraross 14 years ago.
An example legend

Download all attachments as: .zip

Change History (7)

by mraross, 14 years ago

Attachment: legend_example.jpg added

An example legend

comment:1 by assefa, 13 years ago

This is for a getmap exporting kml files right? (http://mapserver.org/development/rfc/ms-rfc-58.html)

It is possible to define a description of the layer level using a metadata kml_description (or ows_description to be added). That will be used in the <description> tag of the layer. You can put any thing in that. Would it be enough to use it to define manually the legend in there?

comment:2 by mraross, 13 years ago

Yes, it is for a getmap exporting kml files.

Yes, we could live with manual legend definition and we would use the metadata kml_description as you describe. Geoserver supports automatic legend generation but in an inferior way to that described here. We just thought you would like MapServer to jump ahead of GeoServer in this regard.

comment:3 by assefa, 13 years ago

In terms of code architecture in MapServer, when the kml is generated, we do not know if the call comes from wms request (getmap) or mapserv cgi or mapsscript. I am always in favor of doing things that are useful for the user but not any thing too specific to a driver.

Maybe something like this could be useful: kml_description=wms_get_legend_graphic setting could produce a predefined response:

    <![CDATA[<img src=" http://openmaps.gov.bc.ca/mapserver/parks-and-recreation? service=wms&version=1.1.1&service=WMS&request=GetLegendGraphic?&layer=TA_PARK_ECORES_PA_PROTECTED_C&format=image/png"><br>]]> 

or things like kml_description=auto would do something similar.

Open to discussion.

comment:4 by mraross, 13 years ago

A setting for kml_description sounds good. How about a syntax that will allow multiple settings. Today we have a need for a legend, tomorrow, suppression of directions links (e.g., Directions: To here - From here). Here is an example of such a syntax:

kml_description=auto:legend,metadataLink,noDirections

I separated out metadataLink in case someone just wanted the legend. Note also that if auto legend is requested, a getLegendGraphic request is made for each layer in the getMap request.

comment:5 by assefa, 13 years ago

can we define the different items:

  • legend: is it generating only the a getlegengraphic link as described above or is it expected to generate other type of legends for non wms layers?

metadataLink: I think this opens the possibility for others to ask for another metadata to be supported (why only support metadataLink). I think the fact that you can put any thing in a description tag allows you maximum control.

comment:6 by assefa, 13 years ago

Milestone: 6.0 releaseFUTURE
Note: See TracTickets for help on using tickets.