Revision 4307
Added by ben leinfelder over 15 years ago
wms_GetMap.xsl | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
1 |
<?xml version="1.0"?> |
|
2 |
<xsl:stylesheet xmlns:wmc="http://www.opengis.net/context" xmlns:mb="http://mapbuilder.sourceforge.net/mapbuilder" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.0"><xsl:output method="xml" omit-xml-declaration="yes"/><xsl:strip-space elements="*"/><xsl:param name="bbox"/><xsl:param name="width"/><xsl:param name="height"/><xsl:param name="srs"/><xsl:param name="version"/><xsl:param name="timeList"/><xsl:param name="timeListName"/><xsl:template match="Layer | wmc:Layer"><xsl:choose><xsl:when test="$timeList and wmc:DimensionList/wmc:Dimension[@name='time']"><xsl:call-template name="tokenize"><xsl:with-param name="str" select="$timeList"/><xsl:with-param name="sep" select="','"/></xsl:call-template></xsl:when><xsl:otherwise><xsl:call-template name="layerOutput"/></xsl:otherwise></xsl:choose></xsl:template><xsl:template name="layerOutput"><xsl:variable name="format">image/png</xsl:variable><xsl:variable name="styleParam"/><xsl:variable name="visibility"/><xsl:variable name="mapRequest"><xsl:choose><xsl:when test="starts-with($version, '1.0')"> |
|
2 | 3 |
|
3 |
<!-- |
|
4 |
|
|
5 |
Description: transforms a WMS Layer node into an XML structure that contains |
|
6 |
|
|
7 |
the URL for the GetMap request for both context docs and WMS caps. |
|
8 |
|
|
9 |
This one is not used yet, because WMS caps don't use a namespace, |
|
10 |
|
|
11 |
use GteMap.xsl instead. |
|
12 |
|
|
13 |
Author: adair |
|
14 |
|
|
15 |
Licence: LGPL as specified in http://www.gnu.org/copyleft/lesser.html . |
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
$Id$ |
|
20 |
|
|
21 |
$Name$ |
|
22 |
|
|
23 |
--> |
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
<xsl:stylesheet version="1.0" |
|
28 |
|
|
29 |
xmlns:wmc="http://www.opengis.net/context" |
|
30 |
|
|
31 |
xmlns:mb="http://mapbuilder.sourceforge.net/mapbuilder" |
|
32 |
|
|
33 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
|
34 |
|
|
35 |
xmlns:xlink="http://www.w3.org/1999/xlink"> |
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
<xsl:output method="xml"/> |
|
40 |
|
|
41 |
<xsl:strip-space elements="*"/> |
|
42 |
|
|
43 |
<!-- |
|
44 |
|
|
45 |
<xsl:include href="ogcMapImgObjects.xsl" /> |
|
46 |
|
|
47 |
--> |
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
<xsl:param name="bbox"/> |
|
52 |
|
|
53 |
<xsl:param name="width"/> |
|
54 |
|
|
55 |
<xsl:param name="height"/> |
|
56 |
|
|
57 |
<xsl:param name="srs"/> |
|
58 |
|
|
59 |
<xsl:param name="version"/> |
|
60 |
|
|
61 |
<xsl:param name="timeList"/> |
|
62 |
|
|
63 |
<xsl:param name="timeListName"/> |
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
<xsl:template match="Layer | wmc:Layer"> |
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
<xsl:choose> |
|
72 |
|
|
73 |
<xsl:when test="$timeList and wmc:DimensionList/wmc:Dimension[@name='time']"> |
|
74 |
|
|
75 |
<xsl:call-template name="tokenize"> |
|
76 |
|
|
77 |
<xsl:with-param name="str" select="$timeList"/> |
|
78 |
|
|
79 |
<xsl:with-param name="sep" select="','"/> |
|
80 |
|
|
81 |
</xsl:call-template> |
|
82 |
|
|
83 |
</xsl:when> |
|
84 |
|
|
85 |
<xsl:otherwise> |
|
86 |
|
|
87 |
<xsl:call-template name="layerOutput"/> |
|
88 |
|
|
89 |
</xsl:otherwise> |
|
90 |
|
|
91 |
</xsl:choose> |
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
</xsl:template> |
|
96 |
|
|
97 |
|
|
98 |
|
|
99 |
<xsl:template name="layerOutput"> |
|
100 |
|
|
101 |
<xsl:variable name="format">image/png</xsl:variable> |
|
102 |
|
|
103 |
<xsl:variable name="styleParam"/> |
|
104 |
|
|
105 |
<xsl:variable name="visibility"/> |
|
106 |
|
|
107 |
<xsl:variable name="mapRequest"> |
|
108 |
|
|
109 |
<xsl:choose> |
|
110 |
|
|
111 |
<xsl:when test="starts-with($version, '1.0')"> |
|
112 |
|
|
113 | 4 |
WMTVER=<xsl:value-of select="$version"/>&REQUEST=map |
114 | 5 |
|
115 |
</xsl:when>
|
|
6 |
</xsl:when><xsl:otherwise>
|
|
116 | 7 |
|
117 |
<xsl:otherwise> |
|
118 |
|
|
119 | 8 |
VERSION=<xsl:value-of select="$version"/>&REQUEST=GetMap |
120 | 9 |
|
121 |
</xsl:otherwise> |
|
10 |
</xsl:otherwise></xsl:choose></xsl:variable><GetMap><mb:QueryString><xsl:variable name="src"><xsl:value-of select="$mapRequest"/>
|
|
122 | 11 |
|
123 |
</xsl:choose> |
|
124 |
|
|
125 |
</xsl:variable> |
|
126 |
|
|
127 |
|
|
128 |
|
|
129 |
<GetMap> |
|
130 |
|
|
131 |
<mb:QueryString> |
|
132 |
|
|
133 |
<xsl:variable name="src"> |
|
134 |
|
|
135 |
<xsl:value-of select="$mapRequest"/> |
|
136 |
|
|
137 | 12 |
&SRS=<xsl:value-of select="$srs"/> |
138 | 13 |
|
139 | 14 |
&BBOX=<xsl:value-of select="$bbox"/> |
... | ... | |
152 | 27 |
|
153 | 28 |
<xsl:if test="$timestamp"> |
154 | 29 |
|
155 |
&TIME=<xsl:value-of select="$timestamp"/> |
|
30 |
&TIME=<xsl:value-of select="$timestamp"/></xsl:if></xsl:variable><xsl:value-of select="translate(normalize-space($src),' ', '' )" disable-output-escaping="no"/></mb:QueryString></GetMap></xsl:template><xsl:template name="tokenize"><xsl:param name="str"/><xsl:param name="sep"/><xsl:choose><xsl:when test="contains($str,$sep)"><xsl:call-template name="process-token"><xsl:with-param name="token" select="substring-before($str,$sep)"/></xsl:call-template><xsl:call-template name="tokenize"><xsl:with-param name="str" select="substring-after($str,$sep)"/><xsl:with-param name="sep" select="$sep"/></xsl:call-template></xsl:when><xsl:otherwise><xsl:call-template name="process-token"><xsl:with-param name="token" select="$str"/></xsl:call-template></xsl:otherwise></xsl:choose></xsl:template><xsl:template name="process-token"><xsl:param name="token"/><xsl:call-template name="layerOutput"><xsl:with-param name="timestamp" select="$token"/><xsl:with-param name="visibility">hidden</xsl:with-param></xsl:call-template></xsl:template><xsl:template match="wmc:Layer"><xsl:param name="version"><xsl:value-of select="wmc:Server/@version"/></xsl:param><xsl:variable name="format"><xsl:choose><xsl:when test="wmc:FormatList"><xsl:value-of select="wmc:FormatList/wmc:Format[@current='1']"/></xsl:when><xsl:otherwise>image/gif</xsl:otherwise></xsl:choose></xsl:variable><xsl:variable name="styleParam"><xsl:choose><xsl:when test="wmc:StyleList/wmc:Style[@current='1']/wmc:SLD">
|
|
156 | 31 |
|
157 |
</xsl:if>
|
|
32 |
SLD=<xsl:value-of select="wmc:StyleList/wmc:Style[@current='1']/wmc:SLD/wmc:OnlineResource/@xlink:href"/></xsl:when><xsl:when test="wmc:StyleList/wmc:Style[@current='1']/wmc:SLD/wmc:StyledLayerDescriptor">
|
|
158 | 33 |
|
159 |
<!--
|
|
34 |
SLD=<xsl:value-of select="wmc:StyleList/wmc:Style[@current='1']/wmc:SLD/wmc:StyledLayerDescriptor"/></xsl:when><xsl:when test="wmc:StyleList/wmc:Style[@current='1']/wmc:SLD/wmc:FeatureTypeStyle">
|
|
160 | 35 |
|
161 |
//TBD: these still to be properly handled
|
|
36 |
SLD=<xsl:value-of select="wmc:StyleList/wmc:Style[@current='1']/wmc:SLD/wmc:FeatureTypeStyle"/></xsl:when><xsl:otherwise>
|
|
162 | 37 |
|
163 |
//also sld support
|
|
38 |
STYLES=<xsl:value-of select="wmc:StyleList/wmc:Style[@current='1']/wmc:Name"/></xsl:otherwise></xsl:choose></xsl:variable><xsl:variable name="visibility"><xsl:choose><xsl:when test="@hidden='1'">hidden</xsl:when><xsl:otherwise>visible</xsl:otherwise></xsl:choose></xsl:variable><xsl:variable name="mapRequest"><xsl:choose><xsl:when test="starts-with($version, '1.0')">
|
|
164 | 39 |
|
165 |
if (this.transparent) src += '&' + 'TRANSPARENT=' + this.transparent; |
|
166 |
|
|
167 |
if (this.bgcolor) src += '&' + 'BGCOLOR=' + this.bgcolor; |
|
168 |
|
|
169 |
//if (this.exceptions) src += '&' + 'EXCEPTIONS=' + this.exceptions; |
|
170 |
|
|
171 |
if (this.vendorstr) src += '&' + this.vendorstr; |
|
172 |
|
|
173 |
// --> |
|
174 |
|
|
175 |
</xsl:variable> |
|
176 |
|
|
177 |
<xsl:value-of select="translate(normalize-space($src),' ', '' )" disable-output-escaping="no"/> |
|
178 |
|
|
179 |
</mb:QueryString> |
|
180 |
|
|
181 |
</GetMap> |
|
182 |
|
|
183 |
</xsl:template> |
|
184 |
|
|
185 |
|
|
186 |
|
|
187 |
<xsl:template name="tokenize"> <!-- tokenize a string --> |
|
188 |
|
|
189 |
<xsl:param name="str"/> <!-- String to process --> |
|
190 |
|
|
191 |
<xsl:param name="sep"/> <!-- Legal separator character --> |
|
192 |
|
|
193 |
<xsl:choose> |
|
194 |
|
|
195 |
<xsl:when test="contains($str,$sep)"> <!-- Only tokenize if there is a separator present in the string --> |
|
196 |
|
|
197 |
<xsl:call-template name="process-token"> <!-- Process the token before the separator --> |
|
198 |
|
|
199 |
<xsl:with-param name="token" select="substring-before($str,$sep)"/> |
|
200 |
|
|
201 |
</xsl:call-template> |
|
202 |
|
|
203 |
<xsl:call-template name="tokenize"> <!-- Re-tokenize the new string which is contained after the separator --> |
|
204 |
|
|
205 |
<xsl:with-param name="str" select="substring-after($str,$sep)"/> |
|
206 |
|
|
207 |
<xsl:with-param name="sep" select="$sep"/> <!-- carriage return --> |
|
208 |
|
|
209 |
</xsl:call-template> |
|
210 |
|
|
211 |
</xsl:when> |
|
212 |
|
|
213 |
<xsl:otherwise> <!-- If there is nothing else to tokenize, just treat the last part of the str as a regular token --> |
|
214 |
|
|
215 |
<xsl:call-template name="process-token"> |
|
216 |
|
|
217 |
<xsl:with-param name="token" select="$str"/> |
|
218 |
|
|
219 |
</xsl:call-template> |
|
220 |
|
|
221 |
</xsl:otherwise> |
|
222 |
|
|
223 |
</xsl:choose> |
|
224 |
|
|
225 |
</xsl:template> |
|
226 |
|
|
227 |
|
|
228 |
|
|
229 |
<xsl:template name="process-token"> <!-- process - separate with <br> --> |
|
230 |
|
|
231 |
<xsl:param name="token"/> <!-- token to process --> |
|
232 |
|
|
233 |
<xsl:call-template name="layerOutput"> |
|
234 |
|
|
235 |
<xsl:with-param name="timestamp" select="$token"/> |
|
236 |
|
|
237 |
<xsl:with-param name="visibility">hidden</xsl:with-param> |
|
238 |
|
|
239 |
</xsl:call-template> |
|
240 |
|
|
241 |
</xsl:template> |
|
242 |
|
|
243 |
|
|
244 |
|
|
245 |
<xsl:template match="wmc:Layer"> |
|
246 |
|
|
247 |
<xsl:param name="version"> |
|
248 |
|
|
249 |
<xsl:value-of select="wmc:Server/@version"/> |
|
250 |
|
|
251 |
</xsl:param> |
|
252 |
|
|
253 |
<xsl:variable name="format"> |
|
254 |
|
|
255 |
<xsl:choose> |
|
256 |
|
|
257 |
<xsl:when test="wmc:FormatList"><xsl:value-of select="wmc:FormatList/wmc:Format[@current='1']"/></xsl:when> |
|
258 |
|
|
259 |
<xsl:otherwise>image/gif</xsl:otherwise> |
|
260 |
|
|
261 |
</xsl:choose> |
|
262 |
|
|
263 |
</xsl:variable> |
|
264 |
|
|
265 |
<xsl:variable name="styleParam"> |
|
266 |
|
|
267 |
<xsl:choose> |
|
268 |
|
|
269 |
<xsl:when test="wmc:StyleList/wmc:Style[@current='1']/wmc:SLD"> |
|
270 |
|
|
271 |
SLD=<xsl:value-of select="wmc:StyleList/wmc:Style[@current='1']/wmc:SLD/wmc:OnlineResource/@xlink:href"/> |
|
272 |
|
|
273 |
</xsl:when> |
|
274 |
|
|
275 |
<xsl:when test="wmc:StyleList/wmc:Style[@current='1']/wmc:SLD/wmc:StyeLayerDescriptor"> |
|
276 |
|
|
277 |
SLD=<xsl:value-of select="wmc:StyleList/wmc:Style[@current='1']/wmc:SLD/wmc:StyeLayerDescriptor"/> |
|
278 |
|
|
279 |
</xsl:when> |
|
280 |
|
|
281 |
<xsl:when test="wmc:StyleList/wmc:Style[@current='1']/wmc:SLD/wmc:FeatureTypeStyle"> |
|
282 |
|
|
283 |
SLD=<xsl:value-of select="wmc:StyleList/wmc:Style[@current='1']/wmc:SLD/wmc:FeatureTypeStyle"/> |
|
284 |
|
|
285 |
</xsl:when> |
|
286 |
|
|
287 |
<xsl:otherwise> |
|
288 |
|
|
289 |
STYLES=<xsl:value-of select="wmc:StyleList/wmc:Style[@current='1']/wmc:Name"/> |
|
290 |
|
|
291 |
</xsl:otherwise> |
|
292 |
|
|
293 |
</xsl:choose> |
|
294 |
|
|
295 |
</xsl:variable> |
|
296 |
|
|
297 |
<xsl:variable name="visibility"> |
|
298 |
|
|
299 |
<xsl:choose> |
|
300 |
|
|
301 |
<xsl:when test="@hidden='1'">hidden</xsl:when> |
|
302 |
|
|
303 |
<xsl:otherwise>visible</xsl:otherwise> |
|
304 |
|
|
305 |
</xsl:choose> |
|
306 |
|
|
307 |
</xsl:variable> |
|
308 |
|
|
309 |
<xsl:variable name="mapRequest"> |
|
310 |
|
|
311 |
<xsl:choose> |
|
312 |
|
|
313 |
<xsl:when test="starts-with($version, '1.0')"> |
|
314 |
|
|
315 | 40 |
WMTVER=<xsl:value-of select="$version"/>&REQUEST=map |
316 | 41 |
|
317 |
</xsl:when>
|
|
42 |
</xsl:when><xsl:otherwise>
|
|
318 | 43 |
|
319 |
<xsl:otherwise> |
|
320 |
|
|
321 | 44 |
VERSION=<xsl:value-of select="$version"/>&REQUEST=GetMap |
322 | 45 |
|
323 |
</xsl:otherwise> |
|
46 |
</xsl:otherwise></xsl:choose></xsl:variable><GetMap><mb:QueryString><xsl:variable name="src"><xsl:value-of select="$mapRequest"/>
|
|
324 | 47 |
|
325 |
</xsl:choose> |
|
326 |
|
|
327 |
</xsl:variable> |
|
328 |
|
|
329 |
|
|
330 |
|
|
331 |
<GetMap> |
|
332 |
|
|
333 |
<mb:QueryString> |
|
334 |
|
|
335 |
<xsl:variable name="src"> |
|
336 |
|
|
337 |
<xsl:value-of select="$mapRequest"/> |
|
338 |
|
|
339 | 48 |
&SRS=<xsl:value-of select="$srs"/> |
340 | 49 |
|
341 | 50 |
&BBOX=<xsl:value-of select="$bbox"/> |
... | ... | |
354 | 63 |
|
355 | 64 |
<xsl:if test="$timestamp"> |
356 | 65 |
|
357 |
&TIME=<xsl:value-of select="$timestamp"/> |
|
358 |
|
|
359 |
</xsl:if> |
|
360 |
|
|
361 |
<!-- |
|
362 |
|
|
363 |
//TBD: these still to be properly handled |
|
364 |
|
|
365 |
//also sld support |
|
366 |
|
|
367 |
if (this.transparent) src += '&' + 'TRANSPARENT=' + this.transparent; |
|
368 |
|
|
369 |
if (this.bgcolor) src += '&' + 'BGCOLOR=' + this.bgcolor; |
|
370 |
|
|
371 |
//if (this.exceptions) src += '&' + 'EXCEPTIONS=' + this.exceptions; |
|
372 |
|
|
373 |
if (this.vendorstr) src += '&' + this.vendorstr; |
|
374 |
|
|
375 |
// --> |
|
376 |
|
|
377 |
</xsl:variable> |
|
378 |
|
|
379 |
<xsl:value-of select="translate(normalize-space($src),' ', '' )" disable-output-escaping="no"/> |
|
380 |
|
|
381 |
</mb:QueryString> |
|
382 |
|
|
383 |
</GetMap> |
|
384 |
|
|
385 |
</xsl:template> |
|
386 |
|
|
387 |
|
|
388 |
|
|
389 |
</xsl:stylesheet> |
|
390 |
|
|
66 |
&TIME=<xsl:value-of select="$timestamp"/></xsl:if></xsl:variable><xsl:value-of select="translate(normalize-space($src),' ', '' )" disable-output-escaping="no"/></mb:QueryString></GetMap></xsl:template></xsl:stylesheet> |
Also available in: Unified diff
upgrade to MapBuilder 1.5rc2 - includes support for Firefox 3 compatibility (yes, it is also EOLed)