| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326 |
- <?xml version="1.0" encoding="UTF-8"?>
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:bp="https://procesy5.pl/biale_plamy-schema.xsd"
- exclude-result-prefixes="xs"
- version="2.0">
-
- <xsl:param name="ways_as_Text_z_ID_xml.xml" select="'ways_as_Text_z_ID_xml.xml'"/>
- <xsl:variable name="ways_asText_z_ID_xml" select="doc($ways_as_Text_z_ID_xml.xml)"/>
-
- <xsl:param name="joins_asText_xml.xml" select="'joins_asText_xml.xml'"/>
- <xsl:variable name="joins_asText_xml" select="doc($joins_asText_xml.xml)"/>
-
-
- <xsl:param name="ways2joins.xml" select="'ways2joins.xml'"/>
- <xsl:variable name="ways2joins" select="doc($ways2joins.xml)"/>
-
- <xsl:param name="joins2ways_z_ID_Way.xml" select="'joins2ways_z_ID_Way.xml'"/>
- <xsl:variable name="joins2ways_z_ID_Way" select="doc($joins2ways_z_ID_Way.xml)"/>
-
-
- <xsl:output indent="yes"/>
- <xsl:strip-space elements="*"/>
-
- <xsl:template match="EdgeWayJoins">
- <edge_joins_filled_paths>
- <xsl:attribute name="stylesheet" select="'edge_joins_filled_paths_make.xsl'"/>
- <xsl:apply-templates/>
- </edge_joins_filled_paths>
- </xsl:template>
-
-
- <xsl:template match="EdgeWayJoinsPair">
- <item>
- <xsl:attribute name="id" select="@ID_Way"/>
- <xsl:variable name="ID_Way" select="@ID_Way"/>
- <!--<xsl:attribute name="Count" select="$asText/asText/@Count"/>-->
- <asText>
- <xsl:variable name="bp:Joins">
- <xsl:for-each select="bp:Joins">
- <bp:Joins>
- <xsl:copy-of select="@*"/>
- <xsl:copy-of select="$joins_asText_xml/joins_asText_xml/item[@id= current()/@Joins]/bp:Path_Point/@X"/>
- <xsl:copy-of select="$joins_asText_xml/joins_asText_xml/item[@id= current()/@Joins]/bp:Path_Point/@Y"/>
- <xsl:attribute name="position" select="position()"/>
- <!--<xsl:copy-of select="$joins_asText_xml/joins_asText_xml/item[@id= current()/@id]/"/>-->
- </bp:Joins>
- </xsl:for-each>
- </xsl:variable>
- <!--<Joins>
- <xsl:copy-of select="$bp:Joins"/>
- </Joins>-->
- <xsl:variable name="Join_X1" select="$bp:Joins/bp:Joins[@position=1]/@X"/>
- <xsl:variable name="Join_Y1" select="$bp:Joins/bp:Joins[@position=1]/@Y"/>
- <xsl:variable name="Join_X2" select="$bp:Joins/bp:Joins[@position=2]/@X"/>
- <xsl:variable name="Join_Y2" select="$bp:Joins/bp:Joins[@position=2]/@Y"/>
- <!-- na podstawie joina ustalamy jego wspolrzedne -->
- <xsl:variable name="Ways">
- <Ways>
- <xsl:attribute name="Join_X1" select="$Join_X1"/>
- <xsl:attribute name="Join_Y1" select="$Join_Y1"/>
- <xsl:attribute name="Join_X2" select="$Join_X2"/>
- <xsl:attribute name="Join_Y2" select="$Join_Y2"/>
- <xsl:variable name="Ways">
- <xsl:for-each select="$ways_asText_z_ID_xml/ways_asText_z_ID_xml/item[@ID_Way=$ID_Way]">
- <Way>
- <xsl:attribute name="id" select="@id"/>
- <xsl:attribute name="len" select="@len"/>
- <xsl:variable name="bp:Path_Point">
- <xsl:for-each select="bp:Path_Point">
- <bp:Path_Point>
- <xsl:copy-of select="@*"/>
- <xsl:attribute name="position" select="position()"/>
- </bp:Path_Point>
- </xsl:for-each>
- </xsl:variable>
- <!-- <xsl:variable name="Way_X1" select="$bp:Path_Point/bp:Path_Point[@position=1]/@X"/>
- <xsl:variable name="Way_Y1" select="$bp:Path_Point/bp:Path_Point[@position=1]/@Y"/>
- <xsl:variable name="Way_X2" select="$bp:Path_Point/bp:Path_Point[@position=2]/@X"/>
- <xsl:variable name="Way_Y2" select="$bp:Path_Point/bp:Path_Point[@position=2]/@Y"/>-->
- <xsl:attribute name="Way_X1" select="$bp:Path_Point/bp:Path_Point[@position=1]/@X"/>
- <xsl:attribute name="Way_Y1" select="$bp:Path_Point/bp:Path_Point[@position=1]/@Y"/>
- <xsl:attribute name="Way_X2" select="$bp:Path_Point/bp:Path_Point[@position=2]/@X"/>
- <xsl:attribute name="Way_Y2" select="$bp:Path_Point/bp:Path_Point[@position=2]/@Y"/>
- </Way>
- </xsl:for-each>
- </xsl:variable>
- <xsl:copy-of select="$Ways"/>
- <!-- teraz trzeba wiedziec ktory punkt wziac z drogi - czy pierwszy czy drugi jaki pasuje do pary -->
- <xsl:variable name="Ways_J1_W1">
- <xsl:for-each select="$Ways/Way[@Way_X1=$Join_X1 and @Way_Y1=$Join_Y1]">
- <Way_next_cand>
- <xsl:copy-of select="@id"/>
- <xsl:copy-of select="@Way_X2"/>
- <xsl:copy-of select="@Way_Y2"/>
- </Way_next_cand>
- </xsl:for-each>
- </xsl:variable>
- <xsl:copy-of select="$Ways_J1_W1"/>
-
- <xsl:variable name="Ways_J2_W1">
- <xsl:for-each select="$Ways/Way[@Way_X1=$Join_X2 and @Way_Y1=$Join_Y2]">
- <Way_next_cand>
- <xsl:copy-of select="@id"/>
- <xsl:copy-of select="@Way_X2"/>
- <xsl:copy-of select="@Way_Y2"/>
- </Way_next_cand>
- </xsl:for-each>
- </xsl:variable>
- <xsl:copy-of select="$Ways_J2_W1"/>
-
- <xsl:variable name="Ways_J1_W2">
- <xsl:for-each select="$Ways/Way[@Way_X2=$Join_X1 and @Way_Y2=$Join_Y1]">
- <Way_next_cand>
- <xsl:copy-of select="@id"/>
- <xsl:copy-of select="@Way_X1"/>
- <xsl:copy-of select="@Way_Y1"/>
- </Way_next_cand>
- </xsl:for-each>
- </xsl:variable>
- <xsl:copy-of select="$Ways_J1_W2"/>
-
- <xsl:variable name="Ways_J2_W2">
- <xsl:for-each select="$Ways/Way[@Way_X2=$Join_X2 and @Way_Y2=$Join_Y2]">
- <Way_next_cand>
- <xsl:copy-of select="@id"/>
- <xsl:copy-of select="@Way_X1"/>
- <xsl:copy-of select="@Way_Y1"/>
- </Way_next_cand>
- </xsl:for-each>
- </xsl:variable>
- <xsl:copy-of select="$Ways_J2_W2"/>
- <!-- poszukamy czy Way_X2 wystepuje -->
- </Ways>
- </xsl:variable>
- <!--<xsl:copy-of select="$Ways"/>-->
- <!--<xsl:variable name="Way_1_or_2">
- <xsl:choose>
- <xsl:when test="$Ways/Ways/Way_next_cand[1]/@Way_X2">
- <xsl:value-of select="1"/>
- </xsl:when>
- <xsl:otherwise><xsl:value-of select="2"/></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>-->
- <!--<Way_1_or_2><xsl:value-of select="$Way_1_or_2"/></Way_1_or_2>-->
- <xsl:variable name="LineString">
- <xsl:call-template name="PlaceWay">
- <xsl:with-param name="Ways" select="$Ways"/>
- <xsl:with-param name="Cur_X1" select="$Ways/Ways/@Join_X1"/>
- <xsl:with-param name="Cur_Y1" select="$Ways/Ways/@Join_Y1"/>
- <xsl:with-param name="Last_X2" select="$Ways/Ways/@Join_X2"/>
- <xsl:with-param name="Last_Y2" select="$Ways/Ways/@Join_Y2"/>
- <xsl:with-param name="ID_Way" select="$ID_Way"/>
- <!--<xsl:with-param name="Way_1_or_2" select="$Way_1_or_2"/>-->
- <!--<xsl:with-param name="not_id" select="$Ways/Ways/Way_next_cand/@id"/>-->
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:variable name="LineString"> <!-- dodanie tylko unikalnego @id_path bo sie chrzani bez tego -->
- <xsl:for-each select="$LineString/LineString">
- <LineString>
- <xsl:copy-of select="@*"/>
- <xsl:attribute name="id_path" select="position()"/>
- <xsl:copy-of select="child::node()"/>
- </LineString>
- </xsl:for-each>
- </xsl:variable>
- <xsl:variable name="len" select="sum($LineString/LineString/@len)"/>
- <xsl:attribute name="len" select="$len"/>
- <xsl:attribute name="Points_cnt" select="count($LineString/LineString/Points)"/>
- <xsl:attribute name="Count" select=" count($LineString/LineString)"/>
- <!-- dodatkowo w xmlu aby bylo prosciej do przetwarzania -->
- <!--<asText_XMl>
- <xsl:copy-of select="$LineString"/>
- </asText_XMl>-->
- <xsl:result-document href="edge_joins_filled_paths/edge_joins_filled_paths.{$ID_Way}.xml">
- <edge_joins_filled_paths_xml>
- <xsl:attribute name="id" select="$ID_Way"/>
- <xsl:attribute name="Points_cnt" select="count($LineString/LineString/Points)"/>
- <asText_XMl>
- <xsl:attribute name="len" select="$len"/>
- <xsl:attribute name="id" select="$ID_Way"/>
- <xsl:attribute name="Points_cnt" select="count($LineString/LineString/Points)"/>
- <xsl:copy-of select="$LineString"/>
- </asText_XMl>
- </edge_joins_filled_paths_xml>
- </xsl:result-document>
- <xsl:call-template name="AsText">
- <xsl:with-param name="LineString" select="$LineString"/>
- </xsl:call-template>
- </asText>
-
-
-
- </item>
- </xsl:template>
-
-
- <xsl:template name="PlaceWay">
- <xsl:param name="Ways" required="yes"/>
- <xsl:param name="Cur_X1" required="yes"/>
- <xsl:param name="Cur_Y1" required="yes"/>
- <!--<xsl:param name="Way_1_or_2" required="yes"/>-->
- <xsl:param name="Last_X2" required="yes"/>
- <xsl:param name="Last_Y2" required="yes"/>
- <xsl:param name="loop" select="1"/>
- <xsl:param name="not_id" required="no"/>
- <xsl:param name="ID_Way" required="yes"/>
- <!--<LineString>
- <xsl:attribute name="X1" select="$Cur_X1"/>
- <xsl:attribute name="Y1" select="$Cur_Y1"/>
- </LineString>-->
- <!--<xsl:choose>
- <xsl:when test="$Way_1_or_2"></xsl:when>
- </xsl:choose>-->
- <!--<debug>
- <xsl:attribute name="Cur_X1" select="$Cur_X1"/>
- <xsl:attribute name="Cur_Y1" select="$Cur_Y1"/>
- <xsl:attribute name="not_id" select="$not_id"/>
- </debug>-->
- <xsl:variable name="Linestring">
- <xsl:for-each select="$Ways/Ways/Way[@Way_X1=$Cur_X1 and @Way_Y1=$Cur_Y1 and ( not($not_id) or not(@id=$not_id)) ]">
- <LineString>
- <xsl:attribute name="X" select="@Way_X2"/>
- <xsl:attribute name="Y" select="@Way_Y2"/>
- <xsl:attribute name="not_id" select="@id"/>
- <xsl:attribute name="len" select="@len"/>
- <xsl:variable name="X" select="@Way_X2"/>
- <xsl:variable name="Y" select="@Way_Y2"/>
- <xsl:for-each select="$ways2joins/ways2joins/item[@id= current()/@id]/item">
- <xsl:for-each select="$joins_asText_xml/joins_asText_xml/item[@id= current()/text()]/bp:Path_Point">
- <xsl:if test="@X=$X and @Y=$Y">
- <xsl:variable name="ID_Join" select="parent::node()/@id"/>
- <!-- punkty podpiete -->
- <xsl:copy-of select="$joins2ways_z_ID_Way/joins2ways_z_ID_Way/item[@id=$ID_Join]/Points"/>
- <!-- wyszukanie drog wychodzacych innych niz nasza z punktu -->
- <xsl:for-each select="$joins2ways_z_ID_Way/joins2ways_z_ID_Way/item[@id=$ID_Join]/item[not(@ID_WAY=$ID_Way)]">
- <Ways>
- <xsl:attribute name="ID_WAY" select="@ID_WAY"/>
- <xsl:attribute name="ways_id" select="text()"/>
- </Ways>
- </xsl:for-each>
- </xsl:if>
- </xsl:for-each>
- </xsl:for-each>
- </LineString>
- </xsl:for-each>
- <xsl:for-each select="$Ways/Ways/Way[@Way_X2=$Cur_X1 and @Way_Y2=$Cur_Y1 and ( not($not_id) or not(@id=$not_id)) ]">
- <LineString>
- <xsl:attribute name="X" select="@Way_X1"/>
- <xsl:attribute name="Y" select="@Way_Y1"/>
- <xsl:attribute name="not_id" select="@id"/>
- <xsl:attribute name="len" select="@len"/>
- <xsl:variable name="X" select="@Way_X1"/>
- <xsl:variable name="Y" select="@Way_Y1"/>
- <xsl:for-each select="$ways2joins/ways2joins/item[@id= current()/@id]/item">
- <xsl:for-each select="$joins_asText_xml/joins_asText_xml/item[@id= current()/text()]/bp:Path_Point">
- <xsl:if test="@X=$X and @Y=$Y">
- <xsl:variable name="ID_Join" select="parent::node()/@id"/>
- <!-- punkty podpiete -->
- <xsl:copy-of select="$joins2ways_z_ID_Way/joins2ways_z_ID_Way/item[@id=$ID_Join]/Points"/>
- <!-- wyszukanie drog wychodzacych innych niz nasza z punktu -->
- <xsl:for-each select="$joins2ways_z_ID_Way/joins2ways_z_ID_Way/item[@id=$ID_Join]/item[not(@ID_WAY=$ID_Way)]">
- <Ways>
- <xsl:attribute name="ID_WAY" select="@ID_WAY"/>
- <xsl:attribute name="ways_id" select="text()"/>
- </Ways>
- </xsl:for-each>
- </xsl:if>
- </xsl:for-each>
- </xsl:for-each>
- </LineString>
- </xsl:for-each>
- </xsl:variable>
- <xsl:copy-of select="$Linestring"/>
- <xsl:choose>
- <xsl:when test="$loop > 100000">
- <loop_limit/>
- </xsl:when>
- <xsl:when test="$Linestring/LineString/@X = $Last_X2 and $Linestring/LineString/@Y = $Last_Y2 ">
- <ostatni/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="PlaceWay">
- <xsl:with-param name="Ways" select="$Ways"/>
- <xsl:with-param name="Cur_X1" select="$Linestring/LineString/@X"/>
- <xsl:with-param name="Cur_Y1" select="$Linestring/LineString/@Y"/>
- <xsl:with-param name="Last_X2" select="$Last_X2"/>
- <xsl:with-param name="Last_Y2" select="$Last_Y2"/>
- <xsl:with-param name="not_id" select="$Linestring/LineString/@not_id"/>
- <xsl:with-param name="loop" select="$loop+1"/>
- <xsl:with-param name="ID_Way" select="$ID_Way"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
-
-
- </xsl:template>
-
-
- <!--<xsl:template name="AsText_XML">
- <xsl:param name="LineString" required="yes"/>
- <xsl:for-each select="$LineString/LineString">
- <PathPoint>
- <xsl:copy-of select="@*"/>
- </PathPoint>
- </xsl:for-each>
- </xsl:template>-->
-
- <xsl:template name="AsText">
- <xsl:param name="LineString" required="yes"/>
- <xsl:value-of select="'LINESTRING ('"/>
- <xsl:for-each select="$LineString/LineString">
- <xsl:value-of select="concat(@X,' ',@Y)"/>
- <xsl:if test="not(position()= last())">
- <xsl:value-of select="', '"/>
- </xsl:if>
- </xsl:for-each>
- <xsl:value-of select="')'"/>
- </xsl:template>
-
-
-
-
-
- </xsl:stylesheet>
|