分享

GeoServer - Requesting a Legend from the WMS

 LibraryPKU 2014-07-30

The WMS standard provides a way of getting a legend for a layer, called GetLegendGraphic.

For simple legends - those with one point symbol, one line symbol, or one polygon symbol, it works well.

For example: Airports - the layer name massgis:GISDATA.AIRPORTS_PT and the style GISDATA.AIRPORTS_PT::Default

http://giswebservices.massgis.state./geoserver/wms?VERSION=1.1.0&REQUEST=GetLegendGraphic&LAYER=massgis:GISDATA.AIRPORTS_PT&STYLE=GISDATA.AIRPORTS_PT::Default&WIDTH=16&HEIGHT=16&FORMAT=image/png&SERVICE=WMS

or (ACECS, different styles):

(brown hatch)

http://giswebservices.massgis.state./geoserver/wms?VERSION=1.1.0&REQUEST=GetLegendGraphic&LAYER=massgis:GISDATA.ACECS_POLY&STYLE=GISDATA.ACECS_POLY::Default&WIDTH=16&HEIGHT=16&FORMAT=image/png&SERVICE=WMS

(solid green fill)

http://giswebservices.massgis.state./geoserver/wms?VERSION=1.1.0&REQUEST=GetLegendGraphic&LAYER=massgis:GISDATA.ACECS_POLY&STYLE=GISDATA.ACECS_POLY::Green_Fill&WIDTH=16&HEIGHT=16&FORMAT=image/png&SERVICE=WMS

The SLD can come from a remote file: (SLD file is not there, syntax example)

http://giswebservices.massgis.state./geoserver/wms?VERSION=1.1.0&REQUEST=GetLegendGraphic&LAYER=massgis:GISDATA.AIRPORTS_PT&SLD=http://maps.massgis.state./misc/black_points.sld.xml&WIDTH=16&HEIGHT=16&FORMAT=image/png&SERVICE=WMS

For a more complicated layer, GeoServer's GetLegendGraphic is not there yet:
Take the massgis:COUNTIES_POLY layer for example.

An attempt to get the legend though, provides color swatches only, no text with which to distinguish the color meanings. (NOTE: I set HEIGHT to 200 pixels here, in order to get all the colors.)

http://giswebservices.massgis.state./geoserver/wms?VERSION=1.1.0&REQUEST=GetLegendGraphic&LAYER=massgis:GISDATA.COUNTIES_POLY&STYLE=GISDATA.COUNTIES_POLY::Default&WIDTH=16&HEIGHT=200&FORMAT=image/png&SERVICE=WMS

To get a legend swatch for one rule, the rule can be specified in the URL:

http://giswebservices.massgis.state./geoserver/wms?VERSION=1.1.0&REQUEST=GetLegendGraphic&LAYER=massgis:GISDATA.COUNTIES_POLY&STYLE=GISDATA.COUNTIES_POLY::Default&RULE=Barnstable&WIDTH=16&HEIGHT=16&FORMAT=image/png&SERVICE=WMS

Currently there is no XML format request to get a legend.

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多