Project

General

Profile

Actions

MapRestServiceExamples » History » Revision 40

« Previous | Revision 40/75 (diff) | Next »
Niels Hoffmann, 01/26/2011 01:39 PM


Examples for URI requests to the Map REST Service

Integrate clear colourful maps into your own website or application. Choose data sources and adapt colour, symbology, extent, background textures and line types to fully customise your map.

This page give some usage examples of the Map REST Service API.

Be aware that these examples *don't conform to RFC 398*6, as the current implementation still doesn't follow the proposed syntaxis. It means that the syntaxis of these examples (and MapRest Services) may change in the coming weeks.

Map REST Service - Version 1

_ Does not conform to the latest syntax definition! _

1. Distribution Maps

Service URL: http://edit.br.fgov.be/edit_wp5/v1/areas.php


1.1: basic issues

Map Image size is specified as 400 pixels width. It means the height will be 200 pixels (just the half). Attention: you cannot specify an odd number as width/height.

A bounding box (bbox) is specified. We strongly recommend to use bbox if know it (for example if all your data is on the same zone).

We provide world country borders and all TDWG levels as background. This parameter must be specified in "l" parameter (l=earth in that example).

Current codes for background layers are:

-Country borders: earth

-TDWG level 1: tdwg1

-TDWG level 2: tdwg2

-TDWG level 3: tdwg3

-TDWG level 4: tdwg4

<code class="html">
<img src="http://edit.br.fgov.be/edit_wp5/v1/areas.php?l=earth&ad=tdwg3:a:PHI,VAN,BAN,SRL,VIE,MOL,CHC,CRL,JAW,FIJ,SUM,MYA,MLY,NWG,MRN,AND,CHH,BOR,IND,CHS,THA,TAI,LAO,SUL,BIS,CBD,SOL,ASS&as=a:8dd3c7,,1&ms=500&bbox=-180,-90,180,90" />
l=earth&ad=tdwg3:a:PHI,VAN,BAN,SRL,VIE,MOL,CHC,CRL,JAW,FIJ,SUM,MYA,MLY,NWG,MRN,AND,CHH,BOR,IND,CHS,THA,TAI,LAO,SUL,BIS,CBD,SOL,ASS
&as=a:8dd3c7,,1&ms=500&bbox=-180,-90,180,90


1.2: recalculate parameter

We see here the "recalculate" parameter in action.

When the bbox is not specified, the service will calculate it and try to fit the image to the specified dimensions (width/height). It can cause distorted images.

Recalculate=true (this is the default if nothing is specified) tries to avoid these distortions. It means also that in some cases the final image size will change as you can see in the first image.

<code class="html">
<img src="http://edit.br.fgov.be/edit_wp5/v1/areas.php?l=earth&ad=tdwg3:a:PHI,VAN,BOR|b:BIS,SUM&as=a:8dd3c7,,2|b:e91f16,5be166,,2_4&ms=500&label=1" />
<code class="html">
<img src="http://edit.br.fgov.be/edit_wp5/v1/areas.php?l=earth&ad=tdwg3:a:PHI,VAN,BOR|b:BIS,SUM&as=a:8dd3c7,,2|b:e91f16,5be166,,2_4&ms=500&label=1&recalculate=false" />
l=earth&ad=tdwg3:a:PHI,VAN,BOR|b:BIS,SUM&as=a:8dd3c7,,2|b:e91f16,5be166,,2_4&ms=500&label=1
l=earth&ad=tdwg3:a:PHI,VAN,BOR|b:BIS,SUM&as=a:8dd3c7,,2|b:e91f16,5be166,,2_4&ms=500&label=1&recalculate=false


1.3: different TDWG layers

You can mix different TDWG layers. In that case, TDWG level 3 and TDWG level 1.

No background layer is defined, so you simply get the specified areas.

<code class="html">
<img src="http://edit.br.fgov.be/edit_wp5/v1/areas.php?ad=tdwg3:b:ZIM|a:SPA,ITA||tdwg1:b:2&as=a:d7add2|b:ab8dc9F&ms=300,200&label=1" />
ad=tdwg3:b:ZIM|a:SPA,ITA||tdwg1:b:2&as=a:d7add2|b:ab8dc9F&ms=600,300&label=1

1.4: symbolize parameters

A more complex styling. The parameters for styling an area are:

-Area fill color

-Area stroke color

-Area stroke width

-Area stroke dash style: we currently provide 1_2,1_4,2_2,2_4,5_7 and 10_5 but it can change. First parameter determine the length in pixels to draw the line, and the second, the length in pixels to blank out the line. As example, 5_7 means a very dashed line (separated 7 pixels one line from another).

We allways provide default values. So, you could even specify styles "a" and "b" as a:|b: and the image will be generated.

A style like b:0000ff~2 would mean 0000ff fill color and 2 pixels stroke width. The other parameters would be set as default.

<code class="html">
<img src="http://edit.br.fgov.be/edit_wp5/v1/areas.php?l=tdwg1&ad=tdwg4:c:MXEDU|b:MXETA||tdwg3:a:MXC,CUB|b:MXE,MXG|c:MXS,MXT&as=a:329d2a,483eef,2,2_2|b:ab8dc9F,da1029,2,5_7|c:d2e347|d:f7555d&ms=500&bbox=-115,6.78,-75.19,29.8&recalculate=false" />
l=tdwg1&ad=tdwg4:c:MXEDU|b:MXETA||tdwg3:a:MXC,CUB|b:MXE,MXG|c:MXS,MXT&as=a:329d2a,483eef,2,2_2|b:ab8dc9F,da1029,2,5_7|c:d2e347|d:f7555d&ms=700&bbox=-115,6.78,-75.19,29.8&recalculate=false

1.5: map legends

A legend can be appended to your map in different positions.

Specify "title" parameter, associating to each style the desired legend. Also legend=1 and "mlp" (map legend position)

It is important to assign, for each style, a title, otherwise cause error.

The map legend position can be:

-1: outside of the map, up left

-2: outside of the map, up

-3:outside of the map, up right

-4: outside of the map, below left

-5: inside of the map, below right

-6: inside of the map, below left

-7: inside of the map, up right

<code class="html">
<img src="http://edit.br.fgov.be/edit_wp5/v1/areas.php?l=tdwg1&legend=1&mlp=3&title=a:foreign|b:native|c:rare|d:unknown&ad=tdwg4:c:MXEDU|b:MXETA||tdwg3:a:MXC,CUB|b:MXE,MXG|c:MXS,MXT&as=a:329d2a,483eef,2,2_2|b:ab8dc9F,da1029,2,5_7|c:d2e347|d:f7555d&ms=500&bbox=-115,6.78,-75.19,29.8&recalculate=false" />
l=tdwg1&legend=1&mlp=3&title=a:foreign|b:native|c:rare|d:unknown&ad=tdwg4:c:MXEDU|b:MXETA||tdwg3:a:MXC,CUB|b:MXE,MXG|c:MXS,MXT&as=a:329d2a,483eef,2,2_2|b:ab8dc9F,da1029,2,5_7|c:d2e347|d:f7555d&ms=500&bbox=-115,6.78,-75.19,29.8&recalculate=false

A separate service generating legend is working, so you can put the legend wherever you want on your html.

<code class="html">
<img src="http://edit.br.fgov.be/edit_wp5/v1/legends.php?title=a:foreign|b:native|c:rare|d:unknown&as=a:329d2a,483eef,2,2_2|b:ab8dc9F,da1029,2,5_7|c:d2e347|d:f7555d&ms=60,50"/>
http://edit.br.fgov.be/edit_wp5/v1/legends.php?title=a:foreign|b:native|c:rare|d:unknown&as=a:329d2a,483eef,2,2_2|b:ab8dc9F,da1029,2,5_7|c:d2e347|d:f7555d&ms=60,50

1.6: hatching patterns

You can also specify a hatch pattern. You need to fill "images_url" and "symbols" for each pattern as shown below. The URL to the image can be remote or local.

The second parameter of "symbols" specifies the size of the image used for hatching.

<code class="html">
<img src="http://edit.br.fgov.be/edit_wp5/v1/areas.php?l=tdwg4&ad=tdwg4:c:MXEDU|b:MXETA|d:NICOO||tdwg3:a:MXC,CUB|b:MXE,MXG|c:MXS,MXT&as=b:d7add2,,3,|a:d7add2,ab899F,1,1_2|c:,,,10_5|d:&ms=500&images_url=a,c:edit.csic.es/v1/hatch_images|b:maps.massgis.state.ma.us/images&symbols=a,c:cow,10,gif|b:med_green_cross_hatch,30,gif&&bbox=-115,6.78,-75.19,29.8&recalculate=false"/>
l=tdwg4&ad=tdwg4:c:MXEDU|b:MXETA|d:NICOO||tdwg3:a:MXC,CUB|b:MXE,MXG|c:MXS,MXT&as=b:d7add2,,3,|a:d7add2,ab899F,1,1_2|c:,,,10_5|d:&ms=500&images_url=a,c:edit.csic.es/v1/hatch_images|b:maps.massgis.state.ma.us/images&symbols=a,c:cow,10,gif|b:med_green_cross_hatch,30,gif&&bbox=-115,6.78,-75.19,29.8&recalculate=false

Using MapRest on a webmapping application

All these mapping services can be used on a dynamic webmapping application like OpenLayers.

The question is that, if desired, we return back not an image but a file that specifies the path to the XML that is used for layer symbolization.

With some little javascript coding you can get dynamic maps (zoom in/out, panning...).

Some EDIT dataportals using this technology are PalmWeb (http://dev.e-taxonomy.eu/dataportal/palmae/) and Cichorieae (http://dev.e-taxonomy.eu/dataportal/cichorieae/)

How to get this file to be integrated on webmapping application? just specify "img=false" and will get a JSON file that could be something similar to...

[{bbox

[legend]("http://edit.br.fgov.be/edit_wp5/v1/sld/4e9b417a9789481932b57e53c47291c6.sld",)

[layers":[{"tdwg" "tdwg3""session" """sld" "tdwg3_4e9b417a9789481932b57e53c47291c6sld"}|{"tdwg": "tdwg1","session": "","sld "tdwg1_4e9b417a9789481932b57e53c47291c6.sld"}]]}]

As you can see, there is the name of XML (SLD) files that provide symbolization for each of specified TDWG layer. Also the legend is specified there.

With some javascript coding you can get dynamic maps. A big advantage of using these widgets is that they automatically calculate the scale at which the image has to be visualized.

By this way you can avoid distorted images that too often happen with "image" MapRest services.

Occurrence Maps

Service URL: http://edit.br.fgov.be/edit_wp5/v1/points.php

MapRest services also can plot occurrences. Just specify each point data coordinates (in latitude/longitude)

This service is subject to changes soon.

Current symbolization parameters are:

-symbol: you can choose "c" (a circle), "s" (a star), and "sq" (square)

-symbol size

-a name to be used on the legend

Also a "q_layer" has to be specified. It must be the same than the background layer and is used to calculate the bbox.

ATBI sites like Gemer (http://www.atbi.eu/gemer/) and Mercantour/Alpi-Marittime (http://www.atbi.eu/mercantour-marittime/) are already using this service.

Also point occurrences can be mapped on a dynamic webmapping application but it is still not implemented.


<code class="html">
<img src="http://edit.br.fgov.be/edit_wp5/v1/points.php?l=v:e_w_0&od=1:38.326,-0.822|38.328,-0.542|38.062,-0.893||2:38.062,-0.893|38.012,-1.883||3:40.78,-4.009|43.461,-5.412|38.062,-0.893&os=1:c/f78755/10/Onthophagus%20semipunctatus|2:s/64cb48/10/Euoniticellus%20pallipes|3:sq/cbde4f/10/Onthophagus%20joannae&ms=700,350&bbox=-10,36,8,45&recalculate=true&legend=1" />
l=v:e_w_0&od=1:38.326,-0.822|38.328,-0.542|38.062,-0.893||2:38.062,-0.893|38.012,-1.883||3:40.78,-4.009|43.461,-5.412|38.062,-0.893&os=1:c/f78755/10/Onthophagus%20semipunctatus|2:s/64cb48/10/Euoniticellus%20pallipes|3:sq/cbde4f/10/Onthophagus%20joannae&ms=700,350&bbox=-10,36,8,45&recalculate=true&legend=1

Map REST Service - next Version

Updated by Niels Hoffmann about 13 years ago · 40 revisions