source: subversion/applications/rendering/tilesAtHome/frollo1.xsl @ 6008

Last change on this file since 6008 was 2510, checked in by deelkar, 13 years ago

cp tilesgen to new place

File size: 3.0 KB
RevLine 
[2293]1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3==============================================================================
4
5Frollo - Osmarender pre-processor
6         Part 1, count the number of segments that connect to each end of
7         each segment in a way.  Output two attributes, osma:fromCount
8         and osma:toCount for each <seg> in a <way>.
9
10==============================================================================
11
12Copyright (C) 2007 Etienne Cherdlu
13
14This program is free software; you can redistribute it and/or modify
15it under the terms of the GNU General Public License as published by
16the Free Software Foundation; either version 2 of the License, or
17(at your option) any later version.
18
19This program is distributed in the hope that it will be useful,
20but WITHOUT ANY WARRANTY; without even the implied warranty of
21MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22GNU General Public License for more details.
23
24You should have received a copy of the GNU General Public License
25along with this program; if not, write to the Free Software
26Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
27
28==============================================================================
29-->
30<xsl:stylesheet version="1.0"
31  xmlns:osma="http://wiki.openstreetmap.org/index.php/Osmarender/Frollo/1.0"
32  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
33 
34    <xsl:output method="xml" omit-xml-declaration="no" indent="yes" encoding="UTF-8"/>
35
36
37    <xsl:key name="segmentById" match="/osm/segment" use="@id"/>
38   
39    <xsl:template match='/osm'>
40                <osm>
41                        <xsl:apply-templates select='@*|node()'/>
42                </osm>
43    </xsl:template>
44
45        <xsl:template match='seg'>
46                <seg>
47                        <xsl:apply-templates select='@*'/>
48
49                        <!-- Count the number of segments *in this way* that connect to the from node of this segment -->
50                        <xsl:variable name='currentSegmentFromNodeId' select='key("segmentById",@id)/@from' />
51                        <xsl:if test='$currentSegmentFromNodeId'>
52                                <xsl:variable name='fromCount' 
53                                        select='count(../seg[key("segmentById",@id)/@to=$currentSegmentFromNodeId])
54                                                + count(../seg[key("segmentById",@id)/@from=$currentSegmentFromNodeId])
55                                                - 1' />
56                                <xsl:attribute name='osma:fromCount'><xsl:value-of select='$fromCount'/></xsl:attribute>                                       
57                        </xsl:if>
58
59                        <!-- Count the number of segments *in this way* that connect to the to node of this segment -->
60                        <xsl:variable name='currentSegmentToNodeId' select='key("segmentById",@id)/@to' />
61                        <xsl:if test='$currentSegmentToNodeId'>
62                                <xsl:variable name='toCount' 
63                                        select='count(../seg[key("segmentById",@id)/@to=$currentSegmentToNodeId])
64                                                + count(../seg[key("segmentById",@id)/@from=$currentSegmentToNodeId])
65                                                - 1' />
66                                <xsl:attribute name='osma:toCount'><xsl:value-of select='$toCount'/></xsl:attribute>                                   
67                        </xsl:if>
68
69                </seg>
70        </xsl:template>
71
72
73
74        <!-- Identity Transform -->
75        <xsl:template match="@*|node()">
76          <xsl:copy>
77            <xsl:apply-templates select="@*|node()"/>
78          </xsl:copy>
79        </xsl:template>
80
81</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.