Project

General

Profile

MapRestServiceExamples » History » Version 50

Franck Theeten, 05/17/2013 04:13 PM

1 1 Andreas Kohlbecker
2 7 Andreas Kohlbecker
3 1 Andreas Kohlbecker
4 40 Niels Hoffmann
5 1 Andreas Kohlbecker
# Examples for URI requests to the Map REST Service
6 40 Niels Hoffmann
7
8
{{>toc}}
9
10 1 Andreas Kohlbecker
11
12 23 Pere Roca Ristol
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. 
13 1 Andreas Kohlbecker
14 23 Pere Roca Ristol
This page give some usage examples of the [[MapRestServiceApi|Map REST Service API]].
15
16 42 Niels Hoffmann
Be aware that these examples do *not conform to RFC 3986*, 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.
17 1 Andreas Kohlbecker
18 42 Niels Hoffmann
19 1 Andreas Kohlbecker
20 43 Niels Hoffmann
----
21 1 Andreas Kohlbecker
22
23 43 Niels Hoffmann
24 50 Franck Theeten
## WMS and Layers
25
26
27
The WMS bound to the service is http://edit.africamuseum.be/geoserver/ (don't forget the trailing slash).
28
29
30
31
The services is connected to TDWG and vmap0 layers (http://gis-lab.info/qa/vmap0-eng.html) imported in the "topp" namespace.
32
33
34
35
The list of layers can be accessed by executing a WMS GetCapabilties request on the "topp" dataset: http://edit.africamuseum.be/geoserver/topp/wms?service=WMS&request=GetCapabilities.
36
37
38
39
Alternatively, you can also use the "preview layer" part of the graphical interface of GeoSerber
40
41
http://edit.africamuseum.be/geoserver/web/;?wicket:bookmarkablePage=:org.geoserver.web.demo.MapPreviewPage
42
43
44
45
46
If you have request or questions on the available layer contact franck.theeten @ africamuseum.be
47
48
49
50 9 Andreas Kohlbecker
## Map REST Service - Version 1
51 3 Andreas Kohlbecker
52 1 Andreas Kohlbecker
_ Does not conform to the latest syntax definition! _
53
54
55 9 Andreas Kohlbecker
56 41 Niels Hoffmann
### Distribution Maps
57 9 Andreas Kohlbecker
58 35 Andreas Kohlbecker
Service URL: http://edit.br.fgov.be/edit_wp5/v1/areas.php
59 3 Andreas Kohlbecker
60 5 Andreas Kohlbecker
61 1 Andreas Kohlbecker
62 17 Andreas Müller
63 41 Niels Hoffmann
#### Basic Issues
64 17 Andreas Müller
65 24 Pere Roca Ristol
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.
66
67
68 26 Pere Roca Ristol
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).
69 25 Pere Roca Ristol
70 1 Andreas Kohlbecker
71 26 Pere Roca Ristol
We provide world country borders and all TDWG levels as background. This parameter must be specified in "l" parameter (l=earth in that example).
72
73
74
Current codes for background layers are:
75
76
77
-Country borders: earth
78
79
80
-TDWG level 1: tdwg1
81
82
83
-TDWG level 2: tdwg2
84
85
86
-TDWG level 3: tdwg3
87
88
89
-TDWG level 4: tdwg4
90
91
92 1 Andreas Kohlbecker
~~~
93 22 Pere Roca Ristol
<code class="html">
94 35 Andreas Kohlbecker
<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" />
95 1 Andreas Kohlbecker
~~~
96
97
~~~
98 6 Andreas Kohlbecker
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
99 34 Pere Roca Ristol
&as=a:8dd3c7,,1&ms=500&bbox=-180,-90,180,90
100 6 Andreas Kohlbecker
~~~
101
102
103 1 Andreas Kohlbecker
104 17 Andreas Müller
105 41 Niels Hoffmann
####  Recalculate Parameter
106 1 Andreas Kohlbecker
107 25 Pere Roca Ristol
We see here the "recalculate" parameter in action. 
108
109
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. 
110
111
112
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.
113
114
115
116 6 Andreas Kohlbecker
~~~
117
<code class="html">
118 35 Andreas Kohlbecker
<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" />
119 25 Pere Roca Ristol
~~~
120
~~~
121
<code class="html">
122 35 Andreas Kohlbecker
<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" />
123 1 Andreas Kohlbecker
~~~
124
125 25 Pere Roca Ristol
~~~
126
l=earth&ad=tdwg3:a:PHI,VAN,BOR|b:BIS,SUM&as=a:8dd3c7,,2|b:e91f16,5be166,,2_4&ms=500&label=1
127
~~~
128 7 Andreas Kohlbecker
~~~
129
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
130
~~~
131
132
133 17 Andreas Müller
134 1 Andreas Kohlbecker
135 41 Niels Hoffmann
####  Different TDWG Layers
136 1 Andreas Kohlbecker
137 26 Pere Roca Ristol
You can mix different TDWG layers. In that case, TDWG level 3 and TDWG level 1.  
138
139
140
No background layer is defined, so you simply get the specified areas. 
141
142 7 Andreas Kohlbecker
~~~
143 1 Andreas Kohlbecker
<code class="html">
144 35 Andreas Kohlbecker
<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" />
145 7 Andreas Kohlbecker
~~~
146
147
~~~
148 26 Pere Roca Ristol
ad=tdwg3:b:ZIM|a:SPA,ITA||tdwg1:b:2&as=a:d7add2|b:ab8dc9F&ms=600,300&label=1
149 1 Andreas Kohlbecker
~~~
150
151 3 Andreas Kohlbecker
152 1 Andreas Kohlbecker
153 41 Niels Hoffmann
#### Symbolize Parameters
154 34 Pere Roca Ristol
155 18 Andreas Müller
A more complex styling. The parameters for styling an area are:
156 27 Pere Roca Ristol
157 28 Pere Roca Ristol
158 27 Pere Roca Ristol
-Area fill color
159
160 28 Pere Roca Ristol
161 27 Pere Roca Ristol
-Area stroke color
162
163 28 Pere Roca Ristol
164 27 Pere Roca Ristol
-Area stroke width
165
166 28 Pere Roca Ristol
167 27 Pere Roca Ristol
-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).
168 1 Andreas Kohlbecker
169 27 Pere Roca Ristol
170 33 Pere Roca Ristol
171 28 Pere Roca Ristol
We allways provide default values. So, you could even specify styles "a" and "b"  as a:|b: and the image will be generated. 
172 27 Pere Roca Ristol
173 28 Pere Roca Ristol
A style like b:0000ff~2  would mean 0000ff fill color and 2 pixels stroke width. The other parameters would be set as default.
174 27 Pere Roca Ristol
175 28 Pere Roca Ristol
176 19 Andreas Müller
~~~
177 1 Andreas Kohlbecker
<code class="html">
178 35 Andreas Kohlbecker
<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" />
179 18 Andreas Müller
~~~
180 1 Andreas Kohlbecker
181 18 Andreas Müller
~~~
182 27 Pere Roca Ristol
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
183 1 Andreas Kohlbecker
~~~
184
185 18 Andreas Müller
186 41 Niels Hoffmann
#### Map Legends
187 18 Andreas Müller
188 28 Pere Roca Ristol
A legend can be appended to your map in different positions. 
189 16 Andreas Kohlbecker
190 1 Andreas Kohlbecker
191 28 Pere Roca Ristol
Specify "title" parameter, associating to each style the desired legend. Also legend=1 and "mlp" (map legend position) 
192 1 Andreas Kohlbecker
193
194 28 Pere Roca Ristol
It is important to assign, for each style, a title, otherwise cause error.
195 1 Andreas Kohlbecker
196
197 34 Pere Roca Ristol
198 28 Pere Roca Ristol
The map legend position can be:
199 1 Andreas Kohlbecker
200 28 Pere Roca Ristol
201
-1: outside of the map, up left 
202
203
204
-2: outside of the map, up 
205
206
207
-3:outside of the map, up right 
208
209
210
-4: outside of the map, below left
211
212
213
-5: inside of the map, below right
214
215
216
-6:  inside of the map, below left
217
218
219
-7:  inside of the map, up right
220
221
222
223
~~~
224
<code class="html">
225 35 Andreas Kohlbecker
<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" />
226 28 Pere Roca Ristol
~~~
227
228 1 Andreas Kohlbecker
~~~
229 28 Pere Roca Ristol
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
230 1 Andreas Kohlbecker
~~~
231 34 Pere Roca Ristol
A separate service generating legend is working, so you can put the legend wherever you want on your html. 
232 28 Pere Roca Ristol
233 34 Pere Roca Ristol
234
235 28 Pere Roca Ristol
~~~
236 1 Andreas Kohlbecker
<code class="html">
237 36 Andreas Kohlbecker
<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"/>
238 28 Pere Roca Ristol
~~~
239 29 Pere Roca Ristol
~~~
240 36 Andreas Kohlbecker
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
241 1 Andreas Kohlbecker
~~~
242 29 Pere Roca Ristol
243
244
245 41 Niels Hoffmann
#### Hatching Patterns
246 29 Pere Roca Ristol
247 30 Pere Roca Ristol
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.
248 1 Andreas Kohlbecker
249 29 Pere Roca Ristol
250 1 Andreas Kohlbecker
The second parameter of "symbols"  specifies the size of the image used for hatching.
251 30 Pere Roca Ristol
252 17 Andreas Müller
253 33 Pere Roca Ristol
~~~
254 16 Andreas Kohlbecker
<code class="html">
255 1 Andreas Kohlbecker
<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"/>
256 35 Andreas Kohlbecker
~~~
257 1 Andreas Kohlbecker
~~~
258
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
259 30 Pere Roca Ristol
~~~
260 16 Andreas Kohlbecker
261
262 1 Andreas Kohlbecker
263 32 Pere Roca Ristol
#### Using MapRest on a webmapping application
264 30 Pere Roca Ristol
265 43 Niels Hoffmann
All these mapping services can be used on a dynamic webmapping application like [OpenLayers](http://openlayers.org/.) 
266 30 Pere Roca Ristol
267 1 Andreas Kohlbecker
268
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. 
269 31 Pere Roca Ristol
270 32 Pere Roca Ristol
271 31 Pere Roca Ristol
With some little javascript coding you can get dynamic maps (zoom in/out, panning...).
272 1 Andreas Kohlbecker
273 30 Pere Roca Ristol
274
Some EDIT dataportals using this technology are PalmWeb (http://dev.e-taxonomy.eu/dataportal/palmae/) and Cichorieae (http://dev.e-taxonomy.eu/dataportal/cichorieae/)
275
276 1 Andreas Kohlbecker
277
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...
278 30 Pere Roca Ristol
279
280
281 34 Pere Roca Ristol
[{[bbox]("-28.267,27.664,72.65,81.851",)
282 30 Pere Roca Ristol
283 36 Andreas Kohlbecker
[legend]("http://edit.br.fgov.be/edit_wp5/v1/sld/4e9b417a9789481932b57e53c47291c6.sld",) 
284 30 Pere Roca Ristol
285
286
[layers":[[{"tdwg" "tdwg3""session" """sld" "tdwg3_4e9b417a9789481932b57e53c47291c6sld"}|{"tdwg": "tdwg1","session": "","sld]() "tdwg1_4e9b417a9789481932b57e53c47291c6.sld"}]]}] 
287
288
289
290
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.
291
292
293
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. 
294
295
 By this way you can avoid distorted images that too often happen with "image" MapRest services.
296
297
298 16 Andreas Kohlbecker
299
300
301 41 Niels Hoffmann
### Occurrence Maps
302 1 Andreas Kohlbecker
303 36 Andreas Kohlbecker
Service URL: http://edit.br.fgov.be/edit_wp5/v1/points.php
304 4 Andreas Kohlbecker
305 1 Andreas Kohlbecker
306
MapRest services also can plot occurrences. Just specify each point data coordinates (in latitude/longitude) 
307
308
309 33 Pere Roca Ristol
This service is subject to changes soon.
310 32 Pere Roca Ristol
311 33 Pere Roca Ristol
312 32 Pere Roca Ristol
Current symbolization parameters are:
313 17 Andreas Müller
314 1 Andreas Kohlbecker
315 32 Pere Roca Ristol
-symbol: you can choose "c" (a circle),  "s" (a star), and "sq" (square)
316 20 Pere Roca Ristol
317 10 Andreas Kohlbecker
318 32 Pere Roca Ristol
-symbol size
319 10 Andreas Kohlbecker
320 13 Andreas Kohlbecker
321
-a name to be used on the legend
322 1 Andreas Kohlbecker
323
324 10 Andreas Kohlbecker
325 32 Pere Roca Ristol
326 33 Pere Roca Ristol
Also a "q_layer" has to be specified. It must be the same than the background layer and is used to calculate the bbox. 
327 1 Andreas Kohlbecker
328
329
330 34 Pere Roca Ristol
ATBI sites like Gemer (http://www.atbi.eu/gemer/) and Mercantour/Alpi-Marittime (http://www.atbi.eu/mercantour-marittime/) are already using this service.
331 33 Pere Roca Ristol
332
333 1 Andreas Kohlbecker
Also point occurrences can be mapped on a dynamic webmapping application but it is still not implemented.
334
335
336
337 14 Andreas Kohlbecker
~~~
338 8 Andreas Kohlbecker
<code class="html">
339 39 Niels Hoffmann
<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" />
340 8 Andreas Kohlbecker
~~~
341
342
~~~
343 47 Franck Theeten
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
344
~~~
345
346 49 Franck Theeten
347 47 Franck Theeten
348
349
## Map REST Service - Version 2
350
351
_ Does not conform to the latest syntax definition! _
352
353
354
355
### Distribution Maps
356
357
Service URL: 
358
359
http://edit.br.fgov.be/edit_wp5/v1.2/rest_gen.php
360
361
http://edit.br.fgov.be/edit_wp5/v1.2/points.php
362
363
http://edit.br.fgov.be/edit_wp5/v1.2/areas.php
364
365
366
rest_gen.php merges the functionnalities of points.php and areas.php. 
367
368 48 Franck Theeten
points.php and areas.php are still available as aliases to rest_gen for backward compatibility reasons.