MapRestServiceExamples » History » Version 35
Andreas Kohlbecker, 05/05/2010 04:35 PM
1 | 7 | Andreas Kohlbecker | {{>toc}} |
---|---|---|---|
2 | 1 | Andreas Kohlbecker | |
3 | 7 | Andreas Kohlbecker | |
4 | |||
5 | 1 | Andreas Kohlbecker | # Examples for URI requests to the Map REST Service |
6 | |||
7 | |||
8 | 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. |
9 | 1 | Andreas Kohlbecker | |
10 | 23 | Pere Roca Ristol | This page give some usage examples of the [[MapRestServiceApi|Map REST Service API]]. |
11 | |||
12 | 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. |
||
13 | 1 | Andreas Kohlbecker | |
14 | |||
15 | |||
16 | |||
17 | 9 | Andreas Kohlbecker | ## Map REST Service - Version 1 |
18 | 3 | Andreas Kohlbecker | |
19 | 1 | Andreas Kohlbecker | _ Does not conform to the latest syntax definition! _ |
20 | |||
21 | |||
22 | 9 | Andreas Kohlbecker | |
23 | 17 | Andreas Müller | ### 1. Distribution Maps |
24 | 9 | Andreas Kohlbecker | |
25 | 35 | Andreas Kohlbecker | Service URL: http://edit.br.fgov.be/edit_wp5/v1/areas.php |
26 | 3 | Andreas Kohlbecker | |
27 | |||
28 | 5 | Andreas Kohlbecker | |
29 | ---- |
||
30 | 1 | Andreas Kohlbecker | |
31 | 17 | Andreas Müller | |
32 | 32 | Pere Roca Ristol | #### 1.1: basic issues |
33 | 17 | Andreas Müller | |
34 | 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. |
35 | |||
36 | |||
37 | 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). |
38 | 25 | Pere Roca Ristol | |
39 | 1 | Andreas Kohlbecker | |
40 | 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). |
41 | |||
42 | |||
43 | Current codes for background layers are: |
||
44 | |||
45 | |||
46 | -Country borders: earth |
||
47 | |||
48 | |||
49 | -TDWG level 1: tdwg1 |
||
50 | |||
51 | |||
52 | -TDWG level 2: tdwg2 |
||
53 | |||
54 | |||
55 | -TDWG level 3: tdwg3 |
||
56 | |||
57 | |||
58 | -TDWG level 4: tdwg4 |
||
59 | |||
60 | |||
61 | 1 | Andreas Kohlbecker | ~~~ |
62 | 22 | Pere Roca Ristol | <code class="html"> |
63 | 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" /> |
64 | 1 | Andreas Kohlbecker | ~~~ |
65 | |||
66 | ~~~ |
||
67 | 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 |
68 | 34 | Pere Roca Ristol | &as=a:8dd3c7,,1&ms=500&bbox=-180,-90,180,90 |
69 | 6 | Andreas Kohlbecker | ~~~ |
70 | |||
71 | ---- |
||
72 | |||
73 | |||
74 | |||
75 | ---- |
||
76 | 1 | Andreas Kohlbecker | |
77 | 17 | Andreas Müller | |
78 | 32 | Pere Roca Ristol | #### 1.2: recalculate parameter |
79 | 1 | Andreas Kohlbecker | |
80 | 25 | Pere Roca Ristol | We see here the "recalculate" parameter in action. |
81 | |||
82 | 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. |
||
83 | |||
84 | |||
85 | 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. |
||
86 | |||
87 | |||
88 | |||
89 | 6 | Andreas Kohlbecker | ~~~ |
90 | <code class="html"> |
||
91 | 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" /> |
92 | 25 | Pere Roca Ristol | ~~~ |
93 | ~~~ |
||
94 | <code class="html"> |
||
95 | 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" /> |
96 | 1 | Andreas Kohlbecker | ~~~ |
97 | |||
98 | 25 | Pere Roca Ristol | ~~~ |
99 | l=earth&ad=tdwg3:a:PHI,VAN,BOR|b:BIS,SUM&as=a:8dd3c7,,2|b:e91f16,5be166,,2_4&ms=500&label=1 |
||
100 | ~~~ |
||
101 | 7 | Andreas Kohlbecker | ~~~ |
102 | 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 |
||
103 | ~~~ |
||
104 | |||
105 | ---- |
||
106 | |||
107 | |||
108 | 1 | Andreas Kohlbecker | |
109 | 17 | Andreas Müller | ---- |
110 | |||
111 | 1 | Andreas Kohlbecker | |
112 | 32 | Pere Roca Ristol | #### 1.3: different TDWG layers |
113 | 1 | Andreas Kohlbecker | |
114 | 26 | Pere Roca Ristol | You can mix different TDWG layers. In that case, TDWG level 3 and TDWG level 1. |
115 | |||
116 | |||
117 | No background layer is defined, so you simply get the specified areas. |
||
118 | |||
119 | 7 | Andreas Kohlbecker | ~~~ |
120 | 1 | Andreas Kohlbecker | <code class="html"> |
121 | 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" /> |
122 | 7 | Andreas Kohlbecker | ~~~ |
123 | |||
124 | ~~~ |
||
125 | 26 | Pere Roca Ristol | ad=tdwg3:b:ZIM|a:SPA,ITA||tdwg1:b:2&as=a:d7add2|b:ab8dc9F&ms=600,300&label=1 |
126 | 5 | Andreas Kohlbecker | ~~~ |
127 | 1 | Andreas Kohlbecker | |
128 | ---- |
||
129 | |||
130 | 3 | Andreas Kohlbecker | |
131 | 1 | Andreas Kohlbecker | ====1.4: symbolize parameters ==== |
132 | 32 | Pere Roca Ristol | |
133 | 34 | Pere Roca Ristol | |
134 | 18 | Andreas Müller | A more complex styling. The parameters for styling an area are: |
135 | 27 | Pere Roca Ristol | |
136 | 28 | Pere Roca Ristol | |
137 | 27 | Pere Roca Ristol | -Area fill color |
138 | |||
139 | 28 | Pere Roca Ristol | |
140 | 27 | Pere Roca Ristol | -Area stroke color |
141 | |||
142 | 28 | Pere Roca Ristol | |
143 | 27 | Pere Roca Ristol | -Area stroke width |
144 | |||
145 | 28 | Pere Roca Ristol | |
146 | 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). |
147 | 1 | Andreas Kohlbecker | |
148 | 27 | Pere Roca Ristol | |
149 | 33 | Pere Roca Ristol | |
150 | 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. |
151 | 27 | Pere Roca Ristol | |
152 | 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. |
153 | 27 | Pere Roca Ristol | |
154 | 28 | Pere Roca Ristol | |
155 | 19 | Andreas Müller | ~~~ |
156 | 1 | Andreas Kohlbecker | <code class="html"> |
157 | 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" /> |
158 | 18 | Andreas Müller | ~~~ |
159 | 1 | Andreas Kohlbecker | |
160 | 18 | Andreas Müller | ~~~ |
161 | 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 |
162 | 1 | Andreas Kohlbecker | ~~~ |
163 | |||
164 | 18 | Andreas Müller | ---- |
165 | 1 | Andreas Kohlbecker | |
166 | 18 | Andreas Müller | |
167 | 32 | Pere Roca Ristol | #### 1.5: map legends |
168 | 18 | Andreas Müller | |
169 | 28 | Pere Roca Ristol | A legend can be appended to your map in different positions. |
170 | 16 | Andreas Kohlbecker | |
171 | 1 | Andreas Kohlbecker | |
172 | 28 | Pere Roca Ristol | Specify "title" parameter, associating to each style the desired legend. Also legend=1 and "mlp" (map legend position) |
173 | 1 | Andreas Kohlbecker | |
174 | |||
175 | 28 | Pere Roca Ristol | It is important to assign, for each style, a title, otherwise cause error. |
176 | 1 | Andreas Kohlbecker | |
177 | |||
178 | 34 | Pere Roca Ristol | |
179 | 28 | Pere Roca Ristol | The map legend position can be: |
180 | 1 | Andreas Kohlbecker | |
181 | 28 | Pere Roca Ristol | |
182 | -1: outside of the map, up left |
||
183 | |||
184 | |||
185 | -2: outside of the map, up |
||
186 | |||
187 | |||
188 | -3:outside of the map, up right |
||
189 | |||
190 | |||
191 | -4: outside of the map, below left |
||
192 | |||
193 | |||
194 | -5: inside of the map, below right |
||
195 | |||
196 | |||
197 | -6: inside of the map, below left |
||
198 | |||
199 | |||
200 | -7: inside of the map, up right |
||
201 | |||
202 | |||
203 | |||
204 | ~~~ |
||
205 | <code class="html"> |
||
206 | 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" /> |
207 | 28 | Pere Roca Ristol | ~~~ |
208 | |||
209 | 1 | Andreas Kohlbecker | ~~~ |
210 | 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 |
211 | 1 | Andreas Kohlbecker | ~~~ |
212 | 34 | Pere Roca Ristol | A separate service generating legend is working, so you can put the legend wherever you want on your html. |
213 | 28 | Pere Roca Ristol | |
214 | 34 | Pere Roca Ristol | |
215 | |||
216 | 28 | Pere Roca Ristol | ~~~ |
217 | 1 | Andreas Kohlbecker | <code class="html"> |
218 | 28 | Pere Roca Ristol | <img src="http://edit.csic.es/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"/> |
219 | ~~~ |
||
220 | 29 | Pere Roca Ristol | ~~~ |
221 | 34 | Pere Roca Ristol | http://edit.csic.es/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 |
222 | 1 | Andreas Kohlbecker | ~~~ |
223 | 29 | Pere Roca Ristol | |
224 | |||
225 | ---- |
||
226 | |||
227 | |||
228 | 32 | Pere Roca Ristol | #### 1.6: hatching patterns |
229 | 29 | Pere Roca Ristol | |
230 | 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. |
231 | 29 | Pere Roca Ristol | |
232 | 1 | Andreas Kohlbecker | |
233 | 30 | Pere Roca Ristol | The second parameter of "symbols" specifies the size of the image used for hatching. |
234 | 17 | Andreas Müller | |
235 | 33 | Pere Roca Ristol | |
236 | 16 | Andreas Kohlbecker | ~~~ |
237 | 1 | Andreas Kohlbecker | <code class="html"> |
238 | 35 | 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"/> |
239 | 1 | Andreas Kohlbecker | ~~~ |
240 | ~~~ |
||
241 | 30 | Pere Roca Ristol | 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 |
242 | 16 | Andreas Kohlbecker | ~~~ |
243 | |||
244 | 1 | Andreas Kohlbecker | |
245 | |||
246 | 32 | Pere Roca Ristol | #### Using MapRest on a webmapping application |
247 | 30 | Pere Roca Ristol | |
248 | 1 | Andreas Kohlbecker | All these mapping services can be used on a dynamic webmapping application like OpenLayers. |
249 | 30 | Pere Roca Ristol | |
250 | 1 | Andreas Kohlbecker | |
251 | 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. |
||
252 | 31 | Pere Roca Ristol | |
253 | 32 | Pere Roca Ristol | |
254 | 31 | Pere Roca Ristol | With some little javascript coding you can get dynamic maps (zoom in/out, panning...). |
255 | 1 | Andreas Kohlbecker | |
256 | 30 | Pere Roca Ristol | |
257 | Some EDIT dataportals using this technology are PalmWeb (http://dev.e-taxonomy.eu/dataportal/palmae/) and Cichorieae (http://dev.e-taxonomy.eu/dataportal/cichorieae/) |
||
258 | |||
259 | 1 | Andreas Kohlbecker | |
260 | 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... |
||
261 | 30 | Pere Roca Ristol | |
262 | |||
263 | |||
264 | 34 | Pere Roca Ristol | [{[bbox]("-28.267,27.664,72.65,81.851",) |
265 | 30 | Pere Roca Ristol | |
266 | 34 | Pere Roca Ristol | [legend]("http://edit.csic.es/v1/sld/4e9b417a9789481932b57e53c47291c6.sld",) |
267 | 30 | Pere Roca Ristol | |
268 | |||
269 | [layers":[[{"tdwg" "tdwg3""session" """sld" "tdwg3_4e9b417a9789481932b57e53c47291c6sld"}|{"tdwg": "tdwg1","session": "","sld]() "tdwg1_4e9b417a9789481932b57e53c47291c6.sld"}]]}] |
||
270 | |||
271 | |||
272 | |||
273 | 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. |
||
274 | |||
275 | |||
276 | 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. |
||
277 | |||
278 | By this way you can avoid distorted images that too often happen with "image" MapRest services. |
||
279 | |||
280 | |||
281 | 16 | Andreas Kohlbecker | |
282 | |||
283 | |||
284 | 1 | Andreas Kohlbecker | ## Occurrence Maps |
285 | |||
286 | Service URL: http://edit.csic.es/v1/points.php |
||
287 | 4 | Andreas Kohlbecker | |
288 | 1 | Andreas Kohlbecker | |
289 | MapRest services also can plot occurrences. Just specify each point data coordinates (in latitude/longitude) |
||
290 | |||
291 | |||
292 | 33 | Pere Roca Ristol | This service is subject to changes soon. |
293 | 32 | Pere Roca Ristol | |
294 | 33 | Pere Roca Ristol | |
295 | 32 | Pere Roca Ristol | Current symbolization parameters are: |
296 | 17 | Andreas Müller | |
297 | 1 | Andreas Kohlbecker | |
298 | 32 | Pere Roca Ristol | -symbol: you can choose "c" (a circle), "s" (a star), and "sq" (square) |
299 | 20 | Pere Roca Ristol | |
300 | 10 | Andreas Kohlbecker | |
301 | 32 | Pere Roca Ristol | -symbol size |
302 | 10 | Andreas Kohlbecker | |
303 | 13 | Andreas Kohlbecker | |
304 | -a name to be used on the legend |
||
305 | 1 | Andreas Kohlbecker | |
306 | |||
307 | 10 | Andreas Kohlbecker | |
308 | 32 | Pere Roca Ristol | |
309 | 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. |
310 | 1 | Andreas Kohlbecker | |
311 | |||
312 | |||
313 | 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. |
314 | 33 | Pere Roca Ristol | |
315 | |||
316 | 1 | Andreas Kohlbecker | Also point occurrences can be mapped on a dynamic webmapping application but it is still not implemented. |
317 | 33 | Pere Roca Ristol | |
318 | |||
319 | 1 | Andreas Kohlbecker | |
320 | ---- |
||
321 | |||
322 | 14 | Andreas Kohlbecker | ~~~ |
323 | 8 | Andreas Kohlbecker | <code class="html"> |
324 | 34 | Pere Roca Ristol | <img src="http://edit.csic.es/v1/points.php?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/35/Euoniticellus%20pallipes|3:sq/cbde4f/20/Onthophagus%20joannae&ms=700&l=v:tdwg3&q_layer=tdwg3&recalculate=true" /> |
325 | 1 | Andreas Kohlbecker | ~~~ |
326 | 13 | Andreas Kohlbecker | |
327 | ~~~ |
||
328 | 34 | Pere Roca Ristol | 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 semipunctatus|2:s/64cb48/35/Euoniticellus pallipes|3:sq/cbde4f/20/Onthophagus joannae&ms=700&l=v:tdwg3&q_layer=tdwg3&recalculate=true |
329 | 8 | Andreas Kohlbecker | ~~~ |
330 | |||
331 | ---- |
||
332 | |||
333 | |||
334 | |||
335 | 3 | Andreas Kohlbecker | ### Map REST Service - next Version |