1
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
2
|
|
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
|
WMTVER=<xsl:value-of select="$version"/>&REQUEST=map
|
114
|
|
115
|
</xsl:when>
|
116
|
|
117
|
<xsl:otherwise>
|
118
|
|
119
|
VERSION=<xsl:value-of select="$version"/>&REQUEST=GetMap
|
120
|
|
121
|
</xsl:otherwise>
|
122
|
|
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
|
&SRS=<xsl:value-of select="$srs"/>
|
138
|
|
139
|
&BBOX=<xsl:value-of select="$bbox"/>
|
140
|
|
141
|
&WIDTH=<xsl:value-of select="$width"/>
|
142
|
|
143
|
&HEIGHT=<xsl:value-of select="$height"/>
|
144
|
|
145
|
&LAYERS=<xsl:value-of select="Name"/>
|
146
|
|
147
|
&FORMAT=<xsl:value-of select="$format"/>
|
148
|
|
149
|
&<xsl:value-of select="$styleParam"/>
|
150
|
|
151
|
&TRANSPARENT=true
|
152
|
|
153
|
<xsl:if test="$timestamp">
|
154
|
|
155
|
&TIME=<xsl:value-of select="$timestamp"/>
|
156
|
|
157
|
</xsl:if>
|
158
|
|
159
|
<!--
|
160
|
|
161
|
//TBD: these still to be properly handled
|
162
|
|
163
|
//also sld support
|
164
|
|
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
|
WMTVER=<xsl:value-of select="$version"/>&REQUEST=map
|
316
|
|
317
|
</xsl:when>
|
318
|
|
319
|
<xsl:otherwise>
|
320
|
|
321
|
VERSION=<xsl:value-of select="$version"/>&REQUEST=GetMap
|
322
|
|
323
|
</xsl:otherwise>
|
324
|
|
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
|
&SRS=<xsl:value-of select="$srs"/>
|
340
|
|
341
|
&BBOX=<xsl:value-of select="$bbox"/>
|
342
|
|
343
|
&WIDTH=<xsl:value-of select="$width"/>
|
344
|
|
345
|
&HEIGHT=<xsl:value-of select="$height"/>
|
346
|
|
347
|
&LAYERS=<xsl:value-of select="wmc:Name"/>
|
348
|
|
349
|
&FORMAT=<xsl:value-of select="$format"/>
|
350
|
|
351
|
&<xsl:value-of select="$styleParam"/>
|
352
|
|
353
|
&TRANSPARENT=true
|
354
|
|
355
|
<xsl:if test="$timestamp">
|
356
|
|
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
|
|