Spojovat nody me nenapadlo, ale opravdu by nemel byt problem to
dodelat. Zitra to zkusim upravit.
Transformace je v priloze. Kdybych to napsal v Jave tak by to bylo
urcite jednodusi vymyslet, a mozna i kratsi, ale jsem chut si trochu
pohrat.
> Skoda jen, ze ta silnicni sit nesdili nody. Kdyz se nekde napojuje silnice X
> na silnici Y, tak na Y sice ve spojeni lezi node, ale silnice X konci svym
> vlastnim nodem o stejnych souradnicich.
> Teda nevim, jestli bych to v xslt umel zunifikovat, ale dalo by se to kdyztak
> prohnat i proceduralnim filtrem - ta transformace neni slozita ne?
>
> Ono by se totiz i podle tech primych spojnic krizovatka-krizovatka,
> kdyz budou spravne propojene, dalo navigovat :-)
>
> --
> Petr "Nenik" Nejedly, NetBeans/Sun Microsystems, http://www.netbeans.org
> 355/113 -- Not the famous irrational number PI, but an incredible simulation!
>
> _______________________________________________
> Talk-cz mailing list
> Talk-cz@openstreetmap.org
> http://lists.openstreetmap.org/cgi-bin/mailman/listinfo/talk-cz
>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:generate-id="java:GenerateId"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="generate-id"
>
<xsl:output method="xml" indent="yes"/>
<xsl:template name="spoj-useky">
<xsl:param name="zacatek" as="element(usek)"/>
<xsl:param name="zbytek" as="element(usek)*"/>
<xsl:variable name="ke-spojeni" select=
"$zbytek[((@startLon=$zacatek/@stopLon) and (@startLat=$zacatek/@stopLat))][position()=1]"/>
<xsl:choose>
<xsl:when test="count($ke-spojeni)=0">
<xsl:copy-of select="$zacatek"/>
<xsl:copy-of select="$zbytek"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="spoj-useky">
<xsl:with-param name="zacatek" as="element(usek)">
<usek startLon="{$zacatek/@startLon}" startLat="{$zacatek/@stopLon}"
stopLon="{$ke-spojeni/@stopLon}" stopLat="{$ke-spojeni/@stopLat}">
<xsl:copy-of select="$zacatek/bod"/>
<xsl:copy-of select="$ke-spojeni/bod[position()=count($ke-spojeni/bod)]"/>
</usek>
</xsl:with-param>
<xsl:with-param name="zbytek" as="element(usek)*">
<xsl:copy-of select="$zbytek[not(count(.|$ke-spojeni)=1)]"/>
</xsl:with-param>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="iterate">
<xsl:param name="zacatek" as="element(usek)*"/>
<xsl:param name="konec" as="element(usek)*"/>
<xsl:choose>
<xsl:when test="count($konec)=0">
<xsl:copy-of select="$zacatek"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="novy-konec" as="element(usek)*">
<xsl:call-template name="spoj-useky">
<xsl:with-param name="zacatek" select="$konec[position()=1]"/>
<xsl:with-param name="zbytek" select="$konec[position()!=1]"/>
</xsl:call-template>
</xsl:variable>
<xsl:call-template name="iterate">
<xsl:with-param name="zacatek" as="element(usek)*">
<xsl:call-template name="spoj-useky">
<xsl:with-param name="zacatek" select="$novy-konec[position()=1]"/>
<xsl:with-param name="zbytek" select="$zacatek"/>
</xsl:call-template>
</xsl:with-param>
<xsl:with-param name="konec" select="$novy-konec[position()!=1]" as="element(usek)*"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="generate-map">
<xsl:param name="silnice" as="element(silnice)*"/>
<xsl:variable name="generateId" select="generate-id:new()"/>
<osm version="0.5" generator="rsdToOsm.xsl">
<xsl:for-each select="$silnice">
<xsl:variable name="aktualniSilnice" select="."/>
<xsl:variable name="useky">
<xsl:for-each select="usek">
<usek startLon="[EMAIL PROTECTED]" startLat="[EMAIL PROTECTED]" stopLon="[EMAIL PROTECTED]" stopLat="[EMAIL PROTECTED]">
<bod lon="[EMAIL PROTECTED]" lat="[EMAIL PROTECTED]"/>
<bod lon="[EMAIL PROTECTED]" lat="[EMAIL PROTECTED]"/>
</usek>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="optUseky">
<xsl:call-template name="iterate">
<xsl:with-param name="zacatek" select="$useky/usek[false]" as="element(usek)*"/>
<xsl:with-param name="konec" select="$useky/usek" as="element(usek)*"/>
</xsl:call-template>
</xsl:variable>
<xsl:for-each select="$optUseky/usek">
<xsl:variable name="nodes">
<xsl:for-each select="bod">
<node lat="[EMAIL PROTECTED]" lon="[EMAIL PROTECTED]" id="{generate-id:next-id($generateId)}">
<tag k="josm/ignore" v="yes"/>
</node>
</xsl:for-each>
</xsl:variable>
<xsl:copy-of select="$nodes"/>
<way id="{generate-id:next-id($generateId)}">
<xsl:for-each select="$nodes/node">
<nd ref="[EMAIL PROTECTED]"/>
</xsl:for-each>
<tag k="highway" v="{$aktualniSilnice/@trida}"/>
<tag k="ref" v="{$aktualniSilnice/ref}"/>
<tag k="created_by" v="rsdToOsm.xsl"/>
<tag k="josm/ignore" v="yes"/>
</way>
</xsl:for-each>
</xsl:for-each>
</osm>
</xsl:template>
<xsl:template name="generate-maps">
<xsl:param name="silnice" as="element(silnice)*"/>
<xsl:param name="name"/>
<xsl:result-document href="{concat('results/osm/', $name, '/czechia.osm')}">
<xsl:call-template name="generate-map">
<xsl:with-param name="silnice" select="$silnice"/>
</xsl:call-template>
</xsl:result-document>
<xsl:for-each-group select="$silnice" group-by="oblast">
<xsl:result-document href="{concat('results/osm/',$name, '/', current-grouping-key(), '.osm')}">
<xsl:call-template name="generate-map">
<xsl:with-param name="silnice" select="current-group()"/>
</xsl:call-template>
</xsl:result-document>
</xsl:for-each-group>
</xsl:template>
<xsl:template match="/roads">
<xsl:call-template name="generate-maps">
<xsl:with-param name="silnice" select="silnice"/>
<xsl:with-param name="name" select="'all'"/>
</xsl:call-template>
<xsl:call-template name="generate-maps">
<xsl:with-param name="silnice" select="[EMAIL PROTECTED]'false']"/>
<xsl:with-param name="name" select="'not-in-osm'"/>
</xsl:call-template>
<!--<xsl:call-template name="generate-maps">
<xsl:with-param name="silnice" select="[EMAIL PROTECTED]'true']"/>
<xsl:with-param name="name" select="'in-osm'"/>
</xsl:call-template>-->
<!--<xsl:call-template name="generate-map">
<xsl:with-param name="silnice" select="silnice[ref='3503']"/>
</xsl:call-template>-->
</xsl:template>
</xsl:stylesheet>
_______________________________________________
Talk-cz mailing list
Talk-cz@openstreetmap.org
http://lists.openstreetmap.org/cgi-bin/mailman/listinfo/talk-cz