Revision 4307
Added by ben leinfelder over 15 years ago
GetFeatureInfo.xsl | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
|
|
3 |
<!-- |
|
4 |
Description: parses an OGC context document to generate a GetFeatureInfo url |
|
5 |
Author: Nedjo |
|
6 |
Licence: LGPL as specified in http://www.gnu.org/copyleft/lesser.html . |
|
7 |
|
|
8 |
$Id$ |
|
9 |
$Name$ |
|
10 |
--> |
|
11 |
<xsl:stylesheet version="1.0" xmlns:wmc="http://www.opengis.net/context" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xlink="http://www.w3.org/1999/xlink"> |
|
12 |
<xsl:output method="xml"/> |
|
13 |
<xsl:strip-space elements="*"/> |
|
14 |
|
|
15 |
<!-- parameters to be passed into the XSL --> |
|
16 |
<!-- The name of the WMS GetFeatureInfo layer --> |
|
17 |
<xsl:param name="queryLayer">highways</xsl:param> |
|
18 |
<xsl:param name="xCoord">1</xsl:param> |
|
19 |
<xsl:param name="yCoord">1</xsl:param> |
|
20 |
<xsl:param name="infoFormat">text/html</xsl:param> |
|
21 |
<xsl:param name="featureCount">1</xsl:param> |
|
22 |
|
|
23 |
<!-- Global variables --> |
|
24 |
<xsl:variable name="bbox"> |
|
25 |
<xsl:value-of select="/wmc:ViewContext/wmc:General/wmc:BoundingBox/@minx"/>,<xsl:value-of select="/wmc:ViewContext/wmc:General/wmc:BoundingBox/@miny"/>,<xsl:value-of select="/wmc:ViewContext/wmc:General/wmc:BoundingBox/@maxx"/>,<xsl:value-of select="/wmc:ViewContext/wmc:General/wmc:BoundingBox/@maxy"/> |
|
26 |
</xsl:variable> |
|
27 |
<xsl:variable name="width"> |
|
28 |
<xsl:value-of select="/wmc:ViewContext/wmc:General/wmc:Window/@width"/> |
|
29 |
</xsl:variable> |
|
30 |
<xsl:variable name="height"> |
|
31 |
<xsl:value-of select="/wmc:ViewContext/wmc:General/wmc:Window/@height"/> |
|
32 |
</xsl:variable> |
|
33 |
<xsl:variable name="srs" select="/wmc:ViewContext/wmc:General/wmc:BoundingBox/@SRS"/> |
|
34 |
|
|
35 |
<!-- Root template --> |
|
36 |
<xsl:template match="/"> |
|
37 |
<url> |
|
38 |
<xsl:apply-templates select="wmc:ViewContext/wmc:LayerList"/> |
|
39 |
<error>URL not calculated for layer=<xsl:value-of select="$queryLayer"/></error> |
|
40 |
</url> |
|
41 |
</xsl:template> |
|
42 |
|
|
43 |
<!-- Layer template --> |
|
44 |
<xsl:template match="wmc:Layer"> |
|
45 |
<xsl:if test="contains($queryLayer,wmc:Name)"> |
|
46 |
<!-- Layer variables --> |
|
47 |
<xsl:variable name="version"> |
|
48 |
<xsl:value-of select="wmc:Server/@version"/> |
|
49 |
</xsl:variable> |
|
50 |
<xsl:variable name="baseUrl"> |
|
51 |
<xsl:value-of select="wmc:Server/wmc:OnlineResource/@xlink:href"/> |
|
52 |
</xsl:variable> |
|
53 |
<xsl:variable name="firstJoin"> |
|
54 |
<xsl:choose> |
|
55 |
<xsl:when test="substring($baseUrl,string-length($baseUrl))='?'"></xsl:when> |
|
56 |
<xsl:when test="contains($baseUrl, '?')">&</xsl:when> |
|
57 |
<xsl:otherwise>?</xsl:otherwise> |
|
58 |
</xsl:choose> |
|
59 |
</xsl:variable> |
|
60 |
|
|
61 |
<!-- Print the URL --> |
|
62 |
<xsl:value-of select="$baseUrl"/><xsl:value-of select="$firstJoin"/>VERSION=<xsl:value-of select="$version"/>&REQUEST=GetFeatureInfo&LAYERS=<xsl:value-of select="$queryLayer"/>&SRS=<xsl:value-of select="$srs"/>&BBOX=<xsl:value-of select="$bbox"/>&WIDTH=<xsl:value-of select="$width"/>&HEIGHT=<xsl:value-of select="$height"/>&INFO_FORMAT=<xsl:value-of select="$infoFormat"/>&FEATURE_COUNT=<xsl:value-of select="$featureCount"/>&QUERY_LAYERS=<xsl:value-of select="$queryLayer"/>&X=<xsl:value-of select="$xCoord"/>&Y=<xsl:value-of select="$yCoord"/>&FORMAT |
|
63 |
</xsl:if> |
|
64 |
</xsl:template> |
|
65 |
</xsl:stylesheet> |
|
1 |
<?xml version="1.0"?> |
|
2 |
<xsl:stylesheet xmlns:wmc="http://www.opengis.net/context" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ows="http://www.opengis.net/ows" version="1.0"><xsl:output method="xml" omit-xml-declaration="yes"/><xsl:strip-space elements="*"/><xsl:param name="queryLayer">route</xsl:param><xsl:param name="layer">route</xsl:param><xsl:param name="xCoord">1</xsl:param><xsl:param name="yCoord">1</xsl:param><xsl:param name="infoFormat">text/html</xsl:param><xsl:param name="featureCount">1</xsl:param><xsl:variable name="bbox"><xsl:choose><xsl:when test="/wmc:ViewContext"><xsl:value-of select="/wmc:ViewContext/wmc:General/wmc:BoundingBox/@minx"/>,<xsl:value-of select="/wmc:ViewContext/wmc:General/wmc:BoundingBox/@miny"/>,<xsl:value-of select="/wmc:ViewContext/wmc:General/wmc:BoundingBox/@maxx"/>,<xsl:value-of select="/wmc:ViewContext/wmc:General/wmc:BoundingBox/@maxy"/></xsl:when><xsl:otherwise><xsl:value-of select="translate(/wmc:OWSContext/wmc:General/ows:BoundingBox/ows:LowerCorner, ' ', ',')"/>,<xsl:value-of select="translate(/wmc:OWSContext/wmc:General/ows:BoundingBox/ows:UpperCorner, ' ', ',')"/></xsl:otherwise></xsl:choose></xsl:variable><xsl:variable name="width"><xsl:value-of select="/*/wmc:General/wmc:Window/@width"/></xsl:variable><xsl:variable name="height"><xsl:value-of select="/*/wmc:General/wmc:Window/@height"/></xsl:variable><xsl:variable name="srs" select="/wmc:ViewContext/wmc:General/wmc:BoundingBox/@SRS|/wmc:OWSContext/wmc:General/ows:BoundingBox/@crs"/><xsl:template match="/"><url><xsl:apply-templates select="wmc:ViewContext/wmc:LayerList"/><xsl:apply-templates select="wmc:OWSContext/wmc:ResourceList"/><error>URL not calculated for layer=<xsl:value-of select="$queryLayer"/></error></url></xsl:template><xsl:template match="wmc:Layer"><xsl:if test="wmc:Name=$queryLayer"><xsl:variable name="version"><xsl:value-of select="wmc:Server/@version"/></xsl:variable><xsl:variable name="baseUrl"><xsl:value-of select="wmc:Server/wmc:OnlineResource/@xlink:href"/></xsl:variable><xsl:variable name="firstJoin"><xsl:choose><xsl:when test="substring($baseUrl,string-length($baseUrl))='?'"/><xsl:when test="contains($baseUrl, '?')">&</xsl:when><xsl:otherwise>?</xsl:otherwise></xsl:choose></xsl:variable><xsl:value-of select="$baseUrl"/><xsl:value-of select="$firstJoin"/>VERSION=<xsl:value-of select="$version"/>&REQUEST=GetFeatureInfo&LAYERS=<xsl:value-of select="$layer"/>&SRS=<xsl:value-of select="$srs"/>&BBOX=<xsl:value-of select="$bbox"/>&WIDTH=<xsl:value-of select="$width"/>&HEIGHT=<xsl:value-of select="$height"/>&INFO_FORMAT=<xsl:value-of select="$infoFormat"/>&FEATURE_COUNT=<xsl:value-of select="$featureCount"/>&QUERY_LAYERS=<xsl:value-of select="$queryLayer"/>&X=<xsl:value-of select="$xCoord"/>&Y=<xsl:value-of select="$yCoord"/></xsl:if></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)