GetLegendGraphic and Scalebar

Maarten Plieger plieger at KNMI.NL
Thu Aug 30 05:17:17 EDT 2007


Kralidis,Tom [Burlington] wrote:
>>> Is it possible to request a scalebar graphic from a mapserver WMS 
>>> service?
>>> To request a legend you can call getlegendgraphic:
>>>
>>>       
>> http://my.host.com/cgi-bin/mapserver.cgi?map=test.map&SERVICE=WMS&VERS
>>     
>>> ION=1.0.0&REQUEST=getlegendgraphic&LAYER=world_line&FORMAT=PNG
>>>
>>> Is there something like getscalebargraphic?
>>> Thanks in advance
>>> Maarten
>>>
>>>       
>> Dear Maarten,
>>
>> no, the WMS specification only allows these requests:
>>
>> -GetCapabilities(must)
>> -Getmap (must)
>> -getFeatureinforequest (optional)
>> -getlegendgraphic (optional)
>> -getStyle (optional)
>> -describelayer (optional)**
>>
>> Have a look at:
>> http://mapserver.gis.umn.edu/docs/howto/wms_server
>>
>> For having a scalebar you need a function in your wms-client 
>> (optionally you may set the scalebar "INIMAGE" but the result 
>> does not look well.... )
>>
>>     
>
> CGI mode offers a mode=scalebar option:
>
> http://example.org/mapserv?map=/path/to/map.map&mode=scalebar&mapext=-18
> 0.000000%20-90.000000%20180.000000%2090.000000&map_units=dd
>
> Not WMS per se (is there any reason you'd want this back from a WMS?),
> but will return a scalebar graphic.
>
> ..Tom
>
>   
Thanks a lot to all, this is exactly what i wanted.
I have also included the mapsize parameter to be sure that the scalebar 
displays always the proper values. (Because the scale is of course 
dependent on the mapsize). The STATUS EMBED parameter is also tested, 
this gives me the same results.
This is the request:
http://myhostname/cgi-bin/mapserver.cgi?map=test.map&mode=scalebar&mapext=-180+-90+180+90&mapsize=1200+600&map_units=DD 


Maarten



More information about the mapserver-users mailing list