MapRestServiceExamples » History » Version 74
Andreas Müller, 02/23/2022 09:52 PM
1 | 1 | Andreas Kohlbecker | # Examples for URI requests to the Map REST Service |
---|---|---|---|
2 | 40 | Niels Hoffmann | |
3 | {{>toc}} |
||
4 | |||
5 | 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. |
6 | 1 | Andreas Kohlbecker | |
7 | 23 | Pere Roca Ristol | This page give some usage examples of the [[MapRestServiceApi|Map REST Service API]]. |
8 | |||
9 | 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. |
10 | 1 | Andreas Kohlbecker | |
11 | 43 | Niels Hoffmann | ---- |
12 | 1 | Andreas Kohlbecker | |
13 | |||
14 | 50 | Franck Theeten | ## WMS and Layers |
15 | |||
16 | The WMS bound to the service is http://edit.africamuseum.be/geoserver/ (don't forget the trailing slash). |
||
17 | |||
18 | 57 | Franck Theeten | Since December 2012, this service use the version 2.2.2 of GeoServer. |
19 | 50 | Franck Theeten | |
20 | 53 | Franck Theeten | The services displays TDWG and vmap0 layers (http://gis-lab.info/qa/vmap0-eng.html) imported in the "topp" namespace. |
21 | |||
22 | The list of layers can be accessed by executing a WMS GetCapabilties request on the "topp" dataset: |
||
23 | |||
24 | http://edit.africamuseum.be/geoserver/topp/wms?service=WMS&request=GetCapabilities. |
||
25 | |||
26 | Alternatively, you can also use the "preview layer" part of the graphical interface of GeoServer |
||
27 | |||
28 | http://edit.africamuseum.be/geoserver/web/;?wicket:bookmarkablePage=:org.geoserver.web.demo.MapPreviewPage |
||
29 | |||
30 | 57 | Franck Theeten | If you have requests or questions related to the available layers contact franck.theeten @ africamuseum.be |
31 | 53 | Franck Theeten | |
32 | ## Description of layers |
||
33 | |||
34 | 51 | Franck Theeten | Since 2011, any layer registered in the WMS can be used in distribution maps and have its style dynamically defined in the HTTP GET parameters (this functionnality was originally limited to TDWG layers). |
35 | |||
36 | When building a query, the programmer needs to know the structure of a layer (i.e. the name and the type of fields) since some functionnalities do not work withnumeric attributes. For instance, you can define a filter to apply a style on specific values (like names of countries), but only if the correponding attribute in the database has a text format (you cannot apply filter on integer column). |
||
37 | 1 | Andreas Kohlbecker | |
38 | It is possible to get an XML describing the types and fieldnames of a layer by running a WFS "DescribeFeature" query on GeoServer like in the example below ("typename" being the name of the layer) |
||
39 | 51 | Franck Theeten | |
40 | e.g: |
||
41 | |||
42 | http://edit.africamuseum.be/geoserver/topp/wfs?service=WFS&version=1.1.0&request=DescribefeatureType&typename=topp:vmap0_afsa_hydro_inland_water_prm_only_a |
||
43 | |||
44 | 53 | Franck Theeten | => in the answer: "xsd:string" corresponds to attribute having a test format that can be used in filter. |
45 | 51 | Franck Theeten | |
46 | 1 | Andreas Kohlbecker | |
47 | ## Map REST Service - Version 1 |
||
48 | 51 | Franck Theeten | |
49 | 65 | Andreas Kohlbecker | *Does not conform to the latest syntax definition!* |
50 | 53 | Franck Theeten | |
51 | 51 | Franck Theeten | ### Distribution Maps |
52 | 50 | Franck Theeten | |
53 | Service URL: http://edit.africamuseum.be/edit_wp5/v1.2/areas.php |
||
54 | 1 | Andreas Kohlbecker | |
55 | |||
56 | 50 | Franck Theeten | #### Basic Issues |
57 | 1 | Andreas Kohlbecker | |
58 | 9 | Andreas Kohlbecker | 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. |
59 | 1 | Andreas Kohlbecker | |
60 | 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). |
||
61 | |||
62 | 9 | Andreas Kohlbecker | We provide world country borders and all TDWG levels as background. This parameter must be specified in "l" parameter (l=earth in that example). |
63 | |||
64 | 62 | Andreas Kohlbecker | Current codes for background layers are: |
65 | 3 | Andreas Kohlbecker | |
66 | 65 | Andreas Kohlbecker | * Country borders: earth |
67 | * TDWG level 1: tdwg1 |
||
68 | * TDWG level 2: tdwg2 |
||
69 | * TDWG level 3: tdwg3 |
||
70 | * TDWG level 4: tdwg4 |
||
71 | 1 | Andreas Kohlbecker | |
72 | 65 | Andreas Kohlbecker | ![](http://edit.africamuseum.be/edit_wp5/v1.2/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) |
73 | 26 | Pere Roca Ristol | |
74 | ~~~ |
||
75 | 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 |
||
76 | &as=a:8dd3c7,,1&ms=500&bbox=-180,-90,180,90 |
||
77 | ~~~ |
||
78 | 1 | Andreas Kohlbecker | |
79 | 26 | Pere Roca Ristol | #### Recalculate Parameter |
80 | |||
81 | We see here the "recalculate" parameter in action. |
||
82 | |||
83 | 34 | Pere Roca Ristol | 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. |
84 | 6 | Andreas Kohlbecker | |
85 | 1 | Andreas Kohlbecker | 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 | 6 | Andreas Kohlbecker | |
87 | 70 | Andreas Kohlbecker | ![](http://edit.africamuseum.be/edit_wp5/v1.2/areas.php?l=earth&ad=tdwg3:a:PHI,VAN,BOR%7Cb:BIS,SUM&as=a:8dd3c7,,2%7Cb:e91f16,5be166,,2_4&ms=500&label=1) |
88 | 1 | Andreas Kohlbecker | |
89 | 70 | Andreas Kohlbecker | ![](http://edit.africamuseum.be/edit_wp5/v1.2/areas.php?l=earth&ad=tdwg3:a:PHI,VAN,BOR%7Cb:BIS,SUM&as=a:8dd3c7,,2%7Cb:e91f16,5be166,,2_4&ms=500&label=1&recalculate=false) |
90 | 25 | Pere Roca Ristol | |
91 | ~~~ |
||
92 | l=earth&ad=tdwg3:a:PHI,VAN,BOR|b:BIS,SUM&as=a:8dd3c7,,2|b:e91f16,5be166,,2_4&ms=500&label=1 |
||
93 | 1 | Andreas Kohlbecker | ~~~ |
94 | 6 | Andreas Kohlbecker | ~~~ |
95 | 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 | 62 | Andreas Kohlbecker | ~~~ |
97 | 25 | Pere Roca Ristol | |
98 | #### Different TDWG Layers |
||
99 | 1 | Andreas Kohlbecker | |
100 | You can mix different TDWG layers. In that case, TDWG level 3 and TDWG level 1. |
||
101 | 65 | Andreas Kohlbecker | |
102 | 1 | Andreas Kohlbecker | No background layer is defined, so you simply get the specified areas. |
103 | |||
104 | 70 | Andreas Kohlbecker | ![](http://edit.africamuseum.be/edit_wp5/v1.2/areas.php?ad=tdwg3:b:ZIM%7Ca:SPA,ITA%7C%7Ctdwg1:b:2&as=a:d7add2%7Cb:ab8dc9F&ms=300,200&label=1) |
105 | 26 | Pere Roca Ristol | |
106 | ~~~ |
||
107 | ad=tdwg3:b:ZIM|a:SPA,ITA||tdwg1:b:2&as=a:d7add2|b:ab8dc9F&ms=600,300&label=1 |
||
108 | 7 | Andreas Kohlbecker | ~~~ |
109 | 1 | Andreas Kohlbecker | |
110 | #### Symbolize Parameters |
||
111 | 62 | Andreas Kohlbecker | |
112 | 7 | Andreas Kohlbecker | A more complex styling. The parameters for styling an area are: |
113 | |||
114 | 65 | Andreas Kohlbecker | * Area fill color |
115 | * Area stroke color |
||
116 | * Area stroke width |
||
117 | * 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). |
||
118 | 1 | Andreas Kohlbecker | |
119 | 41 | Niels Hoffmann | We always provide default values. So, you could even specify styles "a" and "b" as a:|b: and the image will be generated. |
120 | 28 | Pere Roca Ristol | |
121 | 27 | 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. |
122 | |||
123 | 70 | Andreas Kohlbecker | ![](http://edit.africamuseum.be/edit_wp5/v1.2/areas.php?l=tdwg_level_1&ad=tdwg4:c:MXEDU%7Cb:MXETA%7C%7Ctdwg3:a:MXC,CUB%7Cb:MXE,MXG%7Cc:MXS,MXT&as=a:329d2a,483eef,2,2_2%7Cb:ab8dc9F,da1029,2,5_7%7Cc:d2e347%7Cd:f7555d&ms=500&bbox=-115,6.78,-75.19,29.8&recalculate=false) |
124 | 61 | Andreas Kohlbecker | |
125 | 28 | Pere Roca Ristol | ~~~ |
126 | 16 | Andreas Kohlbecker | l=tdwg_level_1&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 |
127 | 1 | Andreas Kohlbecker | ~~~ |
128 | 28 | Pere Roca Ristol | |
129 | 1 | Andreas Kohlbecker | #### Map Legends |
130 | 28 | Pere Roca Ristol | |
131 | 1 | Andreas Kohlbecker | A legend can be appended to your map in different positions. |
132 | 28 | Pere Roca Ristol | |
133 | Specify "title" parameter, associating to each style the desired legend. Also legend=1 and "mlp" (map legend position) |
||
134 | |||
135 | It is important to assign, for each style, a title, otherwise cause error. |
||
136 | |||
137 | The map legend position can be: |
||
138 | |||
139 | 65 | Andreas Kohlbecker | * 1: outside of the map, up left |
140 | * 2: outside of the map, up |
||
141 | * 3: outside of the map, up right |
||
142 | * 4: outside of the map, below left |
||
143 | * 5: inside of the map, below right |
||
144 | * 6: inside of the map, below left |
||
145 | * 7: inside of the map, up right |
||
146 | 28 | Pere Roca Ristol | |
147 | 72 | Andreas Kohlbecker | ![](http://edit.africamuseum.be/edit_wp5/v1.2/areas.php?l=tdwg_level_1&legend=1&mlp=3&title=a:foreign%7Cb:native%7Cc:rare%7Cd:unknown&ad=tdwg4:code:c:MXEDU%7C%7Ctdwg4:code:b:MXETA%7C%7Ctdwg3:code:a:MXC,CUB%7C%7Ctdwg3:code:b:MXE,MXG%7C%7Ctdwg3:code:c:MXS,MXT&as=b:ab8dc9F,da1029,2,5_7%7Cc:d2e347%7Ca:329d2a,483eef,2,2_2%7Cd:f7555d&ms=500&bbox=-115,6.78,-75.19,29.8&recalculate=false) |
148 | 60 | Andreas Kohlbecker | |
149 | 28 | Pere Roca Ristol | ~~~ |
150 | 1 | Andreas Kohlbecker | areas.php?l=tdwg_level_1&legend=1&mlp=3&title=a:foreign|b:native|c:rare|d:unknown&ad=tdwg4:code:c:MXEDU||tdwg4:code:b:MXETA||tdwg3:code:a:MXC,CUB||tdwg3:code:b:MXE,MXG||tdwg3:code:c:MXS,MXT&as=b:ab8dc9F,da1029,2,5_7|c:d2e347|a:329d2a,483eef,2,2_2|d:f7555d&ms=500&bbox=-115,6.78,-75.19,29.8&recalculate=false |
151 | ~~~ |
||
152 | 34 | Pere Roca Ristol | A separate service generating legend is working, so you can put the legend wherever you want on your html. |
153 | |||
154 | 72 | Andreas Kohlbecker | ![](http://edit.africamuseum.be/edit_wp5/v1.2/legends.php?title=a:foreign%7Cb:native%7Cc:rare%7Cd:unknown&as=a:329d2a,483eef,2,2_2%7Cb:ab8dc9F,da1029,2,5_7%7Cc:d2e347%7Cd:f7555d&ms=60,50) |
155 | 1 | Andreas Kohlbecker | |
156 | 62 | Andreas Kohlbecker | ~~~ |
157 | 1 | Andreas Kohlbecker | http://edit.africamuseum.be/edit_wp5/v1.2/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 |
158 | 29 | Pere Roca Ristol | ~~~ |
159 | |||
160 | #### Hatching Patterns |
||
161 | |||
162 | 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. |
||
163 | 1 | Andreas Kohlbecker | |
164 | 17 | Andreas Müller | The second parameter of "symbols" specifies the size of the image used for hatching. |
165 | 33 | Pere Roca Ristol | |
166 | 71 | Andreas Kohlbecker | ![](http://edit.africamuseum.be/edit_wp5/v1.2/areas.php?l=tdwg4&ad=tdwg4:c:MXEDU%7Cb:MXETA%7Cd:NICOO%7C%7Ctdwg3:a:MXC,CUB%7Cb:MXE,MXG%7Cc:MXS,MXT&as=b:d7add2,,3,%7Ca:d7add2,ab899F,1,1_2%7Cc:,,,10_5%7Cd:&ms=500&images_url=a,c:edit.csic.es/v1.2/hatch_images%7Cb:maps.massgis.state.ma.us/images&symbols=a,c:cow,10,gif%7Cb:med_green_cross_hatch,30,gif&&bbox=-115,6.78,-75.19,29.8&recalculate=false) |
167 | 16 | Andreas Kohlbecker | |
168 | ~~~ |
||
169 | 1 | Andreas Kohlbecker | 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 |
170 | 32 | Pere Roca Ristol | ~~~ |
171 | 43 | Niels Hoffmann | |
172 | 30 | Pere Roca Ristol | #### Using MapRest on a webmapping application |
173 | 1 | Andreas Kohlbecker | |
174 | 31 | Pere Roca Ristol | All these mapping services can be used on a dynamic webmapping application like [OpenLayers](http://openlayers.org/.) |
175 | |||
176 | 1 | Andreas Kohlbecker | 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. |
177 | 30 | Pere Roca Ristol | |
178 | 64 | Andreas Kohlbecker | With some little javascript coding you can get dynamic maps (zoom in/out, panning...). |
179 | |||
180 | 30 | Pere Roca Ristol | Some EDIT dataportals using this technology are PalmWeb (http://dev.e-taxonomy.eu/dataportal/palmae/) and Cichorieae (http://dev.e-taxonomy.eu/dataportal/cichorieae/) |
181 | |||
182 | 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... |
||
183 | |||
184 | 66 | Andreas Kohlbecker | ~~~json |
185 | 30 | Pere Roca Ristol | [{"bbox":"-28.267,27.664,72.65,81.851", |
186 | 1 | Andreas Kohlbecker | "legend":" http://edit.africamuseum.be/edit_wp5/v1.2/sld/4e9b417a9789481932b57e53c47291c6.sld", |
187 | 62 | Andreas Kohlbecker | "layers":[{"tdwg": "tdwg3","session": "","sld": "tdwg3_4e9b417a9789481932b57e53c47291c6.sld"}, |
188 | 4 | Andreas Kohlbecker | {"tdwg": "tdwg1","session": "","sld": "tdwg1_4e9b417a9789481932b57e53c47291c6.sld"}]}] |
189 | 65 | Andreas Kohlbecker | ~~~ |
190 | 33 | Pere Roca Ristol | |
191 | 32 | Pere Roca Ristol | 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. |
192 | 33 | Pere Roca Ristol | |
193 | 32 | Pere Roca Ristol | 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. |
194 | 20 | Pere Roca Ristol | |
195 | 65 | Andreas Kohlbecker | By this way you can avoid distorted images that too often happen with "image" MapRest services. |
196 | 32 | Pere Roca Ristol | |
197 | 13 | Andreas Kohlbecker | ### Occurrence Maps |
198 | 1 | Andreas Kohlbecker | |
199 | 10 | Andreas Kohlbecker | Service URL: http://edit.africamuseum.be/edit_wp5/v1.2/points.php |
200 | 1 | Andreas Kohlbecker | |
201 | MapRest services also can plot occurrences. Just specify each point data coordinates (in latitude/longitude) |
||
202 | 33 | Pere Roca Ristol | |
203 | 1 | Andreas Kohlbecker | This service is subject to changes soon. |
204 | |||
205 | Current symbolization parameters are: |
||
206 | 8 | Andreas Kohlbecker | |
207 | 65 | Andreas Kohlbecker | * symbol: you can choose "c" (a circle), "s" (a star), and "sq" (square) |
208 | * symbol size |
||
209 | * a name to be used on the legend |
||
210 | 47 | Franck Theeten | |
211 | 49 | Franck Theeten | Also a "q_layer" has to be specified. It must be the same than the background layer and is used to calculate the bbox. |
212 | 47 | Franck Theeten | |
213 | ATBI sites like Gemer (http://www.atbi.eu/gemer/) and Mercantour/Alpi-Marittime (http://www.atbi.eu/mercantour-marittime/) are already using this service. |
||
214 | |||
215 | Also point occurrences can be mapped on a dynamic webmapping application but it is still not implemented. |
||
216 | |||
217 | 73 | Andreas Kohlbecker | ![](http://edit.africamuseum.be/edit_wp5/v1.2/points.php?l=v:e_w_0&od=1:38.326,-0.822%7C38.328,-0.542%7C38.062,-0.893%7C%7C2:38.062,-0.893%7C38.012,-1.883%7C%7C3:40.78,-4.009%7C43.461,-5.412%7C38.062,-0.893&os=1:c/f78755/10/Onthophagus%20semipunctatus%7C2:s/64cb48/10/Euoniticellus%20pallipes%7C3:sq/cbde4f/10/Onthophagus%20joannae&ms=700,350&bbox=-10,36,8,45&recalculate=true&legend=1) |
218 | 59 | Andreas Kohlbecker | |
219 | 47 | Franck Theeten | ~~~ |
220 | 59 | Andreas Kohlbecker | 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 |
221 | 47 | Franck Theeten | ~~~ |
222 | 59 | Andreas Kohlbecker | |
223 | 47 | Franck Theeten | ## Map REST Service - Version 2 |
224 | |||
225 | 56 | Franck Theeten | The major improvement of version 2 is that transparency can be applied both on point data and overlay layers. |
226 | 47 | Franck Theeten | |
227 | 1 | Andreas Kohlbecker | ### Distribution Maps |
228 | 57 | Franck Theeten | |
229 | Service URL: |
||
230 | |||
231 | 65 | Andreas Kohlbecker | * http://edit.africamuseum.be/edit_wp5/v1.2/rest_gen.php |
232 | * http://edit.africamuseum.be/edit_wp5/v1.2/points.php |
||
233 | * http://edit.africamuseum.be/edit_wp5/v1.2/areas.php |
||
234 | 57 | Franck Theeten | |
235 | 65 | Andreas Kohlbecker | * http://edit.africamuseum.be/edit_wp5/v1.4_dev/rest_gen.php |
236 | * http://edit.africamuseum.be/edit_wp5/v1.4_dev/points.php |
||
237 | * http://edit.africamuseum.be/edit_wp5/v1.4_dev/areas.php |
||
238 | 57 | Franck Theeten | |
239 | 65 | Andreas Kohlbecker | "rest_gen.php" merges the functionalities of points.php and areas.php. |
240 | 58 | Franck Theeten | |
241 | 1 | Andreas Kohlbecker | "points.php" and "areas.php" are still available as aliases to rest_gen for backward compatibility reasons. |
242 | 57 | Franck Theeten | |
243 | #### Compatibility with OGC syntax |
||
244 | 58 | Franck Theeten | |
245 | 57 | Franck Theeten | Since version 1.2, the service compliant with the syntax version 2.2.2 of GeoServer. |
246 | |||
247 | Geoserver follows now more strictly the OGC syntax than before, especially for legends, a point which created an importantbackward compatibility issue when upgrading Geoservber. |
||
248 | 58 | Franck Theeten | |
249 | 57 | Franck Theeten | Since GeoServer 2.2.1, the syntax of the “GetLegendGraphic” request used in the original version of the PHP script was not valid anymore. |
250 | |||
251 | The previous version had this element in the URL: “...geoserver/GetLegendGraphic?service=WMS&…” |
||
252 | |||
253 | ...while GeoServer awaits now: “...geoserver/wms?REQUEST=GetGraphicLegend&…” |
||
254 | |||
255 | This has been fixed in version 1.2 and also commited back to version 1.1 |
||
256 | |||
257 | #### Merging point and area data |
||
258 | |||
259 | #### Transparency on overlay layers |