edge_joins_filled_paths_make.xsl 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:xs="http://www.w3.org/2001/XMLSchema"
  4. xmlns:bp="https://procesy5.pl/biale_plamy-schema.xsd"
  5. exclude-result-prefixes="xs"
  6. version="2.0">
  7. <xsl:param name="ways_as_Text_z_ID_xml.xml" select="'ways_as_Text_z_ID_xml.xml'"/>
  8. <xsl:variable name="ways_asText_z_ID_xml" select="doc($ways_as_Text_z_ID_xml.xml)"/>
  9. <xsl:param name="joins_asText_xml.xml" select="'joins_asText_xml.xml'"/>
  10. <xsl:variable name="joins_asText_xml" select="doc($joins_asText_xml.xml)"/>
  11. <xsl:param name="ways2joins.xml" select="'ways2joins.xml'"/>
  12. <xsl:variable name="ways2joins" select="doc($ways2joins.xml)"/>
  13. <xsl:param name="joins2ways_z_ID_Way.xml" select="'joins2ways_z_ID_Way.xml'"/>
  14. <xsl:variable name="joins2ways_z_ID_Way" select="doc($joins2ways_z_ID_Way.xml)"/>
  15. <xsl:param name="edge_joins_filled_paths" select="'edge_joins_filled_paths'"/> <!-- katalog do zapisywania sciezek -->
  16. <xsl:param name="debug" select="0" /> <!-- set 1 to debug -->
  17. <xsl:param name="bypass_errors" select=" true()"/> <!-- set to 0 if you want to secure terminate on error -->
  18. <xsl:output indent="yes"/>
  19. <xsl:strip-space elements="*"/>
  20. <xsl:template match="EdgeWayJoins">
  21. <edge_joins_filled_paths>
  22. <xsl:attribute name="stylesheet" select="'edge_joins_filled_paths_make.xsl'"/>
  23. <xsl:apply-templates/>
  24. </edge_joins_filled_paths>
  25. </xsl:template>
  26. <xsl:template match="EdgeWayJoinsPair">
  27. <item>
  28. <xsl:attribute name="id" select="@ID_Way"/>
  29. <xsl:variable name="ID_Way" select="@ID_Way"/>
  30. <!--<xsl:attribute name="Count" select="$asText/asText/@Count"/>-->
  31. <asText>
  32. <xsl:variable name="bp:Joins">
  33. <xsl:for-each select="bp:Joins">
  34. <bp:Joins>
  35. <xsl:copy-of select="@*"/>
  36. <xsl:copy-of select="$joins_asText_xml/joins_asText_xml/item[@id= current()/@Joins]/bp:Path_Point/@X"/>
  37. <xsl:copy-of select="$joins_asText_xml/joins_asText_xml/item[@id= current()/@Joins]/bp:Path_Point/@Y"/>
  38. <xsl:attribute name="position" select="position()"/>
  39. <!--<xsl:copy-of select="$joins_asText_xml/joins_asText_xml/item[@id= current()/@id]/"/>-->
  40. </bp:Joins>
  41. </xsl:for-each>
  42. </xsl:variable>
  43. <!--<Joins>
  44. <xsl:copy-of select="$bp:Joins"/>
  45. </Joins>-->
  46. <xsl:variable name="Join_X1" select="$bp:Joins/bp:Joins[@position=1]/@X"/>
  47. <xsl:variable name="Join_Y1" select="$bp:Joins/bp:Joins[@position=1]/@Y"/>
  48. <xsl:variable name="Join_X2" select="$bp:Joins/bp:Joins[@position=2]/@X"/>
  49. <xsl:variable name="Join_Y2" select="$bp:Joins/bp:Joins[@position=2]/@Y"/>
  50. <!-- na podstawie joina ustalamy jego wspolrzedne -->
  51. <xsl:variable name="Ways">
  52. <Ways>
  53. <xsl:attribute name="Join_X1" select="$Join_X1"/>
  54. <xsl:attribute name="Join_Y1" select="$Join_Y1"/>
  55. <xsl:attribute name="Join_X2" select="$Join_X2"/>
  56. <xsl:attribute name="Join_Y2" select="$Join_Y2"/>
  57. <xsl:variable name="Ways">
  58. <xsl:for-each select="$ways_asText_z_ID_xml/ways_asText_z_ID_xml/item[@ID_Way=$ID_Way ]"> <!-- olanie zerowych and not(bp:Path_Point[1]/@X= bp:Path_Point[2]/@X) and not(bp:Path_Point[1]/@Y= bp:Path_Point[2]/@Y) TODO -->
  59. <Way>
  60. <xsl:attribute name="id" select="@id"/>
  61. <xsl:attribute name="len" select="@len"/>
  62. <xsl:variable name="bp:Path_Point">
  63. <xsl:for-each select="bp:Path_Point">
  64. <bp:Path_Point>
  65. <xsl:copy-of select="@*"/>
  66. <xsl:attribute name="position" select="position()"/>
  67. </bp:Path_Point>
  68. </xsl:for-each>
  69. </xsl:variable>
  70. <!-- <xsl:variable name="Way_X1" select="$bp:Path_Point/bp:Path_Point[@position=1]/@X"/>
  71. <xsl:variable name="Way_Y1" select="$bp:Path_Point/bp:Path_Point[@position=1]/@Y"/>
  72. <xsl:variable name="Way_X2" select="$bp:Path_Point/bp:Path_Point[@position=2]/@X"/>
  73. <xsl:variable name="Way_Y2" select="$bp:Path_Point/bp:Path_Point[@position=2]/@Y"/>-->
  74. <xsl:attribute name="Way_X1" select="$bp:Path_Point/bp:Path_Point[@position=1]/@X"/>
  75. <xsl:attribute name="Way_Y1" select="$bp:Path_Point/bp:Path_Point[@position=1]/@Y"/>
  76. <xsl:attribute name="Way_X2" select="$bp:Path_Point/bp:Path_Point[@position=2]/@X"/>
  77. <xsl:attribute name="Way_Y2" select="$bp:Path_Point/bp:Path_Point[@position=2]/@Y"/>
  78. </Way>
  79. </xsl:for-each>
  80. </xsl:variable>
  81. <xsl:copy-of select="$Ways"/>
  82. <!-- teraz trzeba wiedziec ktory punkt wziac z drogi - czy pierwszy czy drugi jaki pasuje do pary -->
  83. <xsl:variable name="Ways_J1_W1">
  84. <xsl:for-each select="$Ways/Way[@Way_X1=$Join_X1 and @Way_Y1=$Join_Y1]">
  85. <Way_next_cand>
  86. <xsl:copy-of select="@id"/>
  87. <xsl:copy-of select="@Way_X2"/>
  88. <xsl:copy-of select="@Way_Y2"/>
  89. </Way_next_cand>
  90. </xsl:for-each>
  91. </xsl:variable>
  92. <xsl:copy-of select="$Ways_J1_W1"/>
  93. <xsl:variable name="Ways_J2_W1">
  94. <xsl:for-each select="$Ways/Way[@Way_X1=$Join_X2 and @Way_Y1=$Join_Y2]">
  95. <Way_next_cand>
  96. <xsl:copy-of select="@id"/>
  97. <xsl:copy-of select="@Way_X2"/>
  98. <xsl:copy-of select="@Way_Y2"/>
  99. </Way_next_cand>
  100. </xsl:for-each>
  101. </xsl:variable>
  102. <xsl:copy-of select="$Ways_J2_W1"/>
  103. <xsl:variable name="Ways_J1_W2">
  104. <xsl:for-each select="$Ways/Way[@Way_X2=$Join_X1 and @Way_Y2=$Join_Y1]">
  105. <Way_next_cand>
  106. <xsl:copy-of select="@id"/>
  107. <xsl:copy-of select="@Way_X1"/>
  108. <xsl:copy-of select="@Way_Y1"/>
  109. </Way_next_cand>
  110. </xsl:for-each>
  111. </xsl:variable>
  112. <xsl:copy-of select="$Ways_J1_W2"/>
  113. <xsl:variable name="Ways_J2_W2">
  114. <xsl:for-each select="$Ways/Way[@Way_X2=$Join_X2 and @Way_Y2=$Join_Y2]">
  115. <Way_next_cand>
  116. <xsl:copy-of select="@id"/>
  117. <xsl:copy-of select="@Way_X1"/>
  118. <xsl:copy-of select="@Way_Y1"/>
  119. </Way_next_cand>
  120. </xsl:for-each>
  121. </xsl:variable>
  122. <!-- todo nei wiem czy potrzebne to echo -->
  123. <xsl:copy-of select="$Ways_J2_W2"/>
  124. <!-- poszukamy czy Way_X2 wystepuje -->
  125. </Ways>
  126. </xsl:variable>
  127. <!--<xsl:variable name="Way_1_or_2">
  128. <xsl:choose>
  129. <xsl:when test="$Ways/Ways/Way_next_cand[1]/@Way_X2">
  130. <xsl:value-of select="1"/>
  131. </xsl:when>
  132. <xsl:otherwise><xsl:value-of select="2"/></xsl:otherwise>
  133. </xsl:choose>
  134. </xsl:variable>-->
  135. <!--<Way_1_or_2><xsl:value-of select="$Way_1_or_2"/></Way_1_or_2>-->
  136. <xsl:variable name="LineString">
  137. <xsl:message>#152 run templ PlaceWay for ID_Way=<xsl:value-of select="$ID_Way"/>; </xsl:message>
  138. <xsl:call-template name="PlaceWay">
  139. <xsl:with-param name="Ways" select="$Ways"/>
  140. <xsl:with-param name="Cur_X1" select="$Ways/Ways/@Join_X1"/>
  141. <xsl:with-param name="Cur_Y1" select="$Ways/Ways/@Join_Y1"/>
  142. <xsl:with-param name="Last_X2" select="$Ways/Ways/@Join_X2"/>
  143. <xsl:with-param name="Last_Y2" select="$Ways/Ways/@Join_Y2"/>
  144. <xsl:with-param name="ID_Way" select="$ID_Way"/>
  145. <!--<xsl:with-param name="Way_1_or_2" select="$Way_1_or_2"/>-->
  146. <!--<xsl:with-param name="not_id" select="$Ways/Ways/Way_next_cand/@id"/>-->
  147. </xsl:call-template>
  148. </xsl:variable>
  149. <xsl:variable name="LineString"> <!-- dodanie tylko unikalnego @id_path bo sie chrzani bez tego -->
  150. <xsl:for-each select="$LineString/LineString">
  151. <LineString>
  152. <xsl:copy-of select="@*"/>
  153. <xsl:attribute name="id_path" select="position()"/>
  154. <xsl:copy-of select="child::node()"/>
  155. </LineString>
  156. </xsl:for-each>
  157. </xsl:variable>
  158. <xsl:variable name="len" select="sum($LineString/LineString/@len)"/>
  159. <xsl:attribute name="len" select="$len"/>
  160. <xsl:attribute name="Points_cnt" select="count($LineString/LineString/Points)"/>
  161. <xsl:attribute name="Count" select=" count($LineString/LineString)"/>
  162. <xsl:if test="$debug">
  163. <debug_Ways>
  164. <xsl:copy-of select="$Ways"/>
  165. </debug_Ways>
  166. </xsl:if>
  167. <!-- dodatkowo w xmlu aby bylo prosciej do przetwarzania -->
  168. <!--<asText_XMl>
  169. <xsl:copy-of select="$LineString"/>
  170. </asText_XMl>-->
  171. <xsl:result-document href="{$edge_joins_filled_paths}/edge_joins_filled_paths.{$ID_Way}.xml">
  172. <edge_joins_filled_paths_xml>
  173. <xsl:attribute name="id" select="$ID_Way"/>
  174. <xsl:attribute name="Points_cnt" select="count($LineString/LineString/Points)"/>
  175. <asText_XMl>
  176. <xsl:attribute name="len" select="$len"/>
  177. <xsl:attribute name="id" select="$ID_Way"/>
  178. <xsl:attribute name="Points_cnt" select="count($LineString/LineString/Points)"/>
  179. <xsl:copy-of select="$LineString"/>
  180. </asText_XMl>
  181. </edge_joins_filled_paths_xml>
  182. </xsl:result-document>
  183. <xsl:call-template name="AsText">
  184. <xsl:with-param name="LineString" select="$LineString"/>
  185. </xsl:call-template>
  186. </asText>
  187. </item>
  188. </xsl:template>
  189. <xsl:template name="PlaceWay">
  190. <xsl:param name="Ways" required="yes"/>
  191. <xsl:param name="Cur_X1" required="yes"/>
  192. <xsl:param name="Cur_Y1" required="yes"/>
  193. <!--<xsl:param name="Way_1_or_2" required="yes"/>-->
  194. <xsl:param name="Last_X2" required="yes"/>
  195. <xsl:param name="Last_Y2" required="yes"/>
  196. <xsl:param name="loop" select="1"/>
  197. <xsl:param name="not_id" required="no"/>
  198. <xsl:param name="not_id_prev" required="no" select="-1"/>
  199. <xsl:param name="ID_Way" required="yes"/>
  200. <!--<xsl:if test="$debug">-->
  201. <xsl:message>###PlaceWay(Cur_X1=<xsl:value-of select="$Cur_X1"/>,Cur_Y1=<xsl:value-of select="$Cur_Y1"/>### and not_id=<xsl:value-of select="$not_id"/>;not_id_prev=<xsl:value-of select="$not_id_prev"/>;</xsl:message>
  202. <!--</xsl:if>-->
  203. <!--<LineString>
  204. <xsl:attribute name="X1" select="$Cur_X1"/>
  205. <xsl:attribute name="Y1" select="$Cur_Y1"/>
  206. </LineString>-->
  207. <!--<xsl:choose>
  208. <xsl:when test="$Way_1_or_2"></xsl:when>
  209. </xsl:choose>-->
  210. <!--<debug>
  211. <xsl:attribute name="Cur_X1" select="$Cur_X1"/>
  212. <xsl:attribute name="Cur_Y1" select="$Cur_Y1"/>
  213. <xsl:attribute name="not_id" select="$not_id"/>
  214. </debug>-->
  215. <xsl:variable name="Linestring">
  216. <!-- jezeli sa zerowe drogi -->
  217. <xsl:choose>
  218. <xsl:when test="$Ways/Ways/Way[ ( @Way_X1=$Cur_X1 and @Way_Y1=$Cur_Y1 or @Way_X2=$Cur_X1 and @Way_Y2=$Cur_Y1 ) and ( not($not_id) or not(@id=$not_id)) and @Way_X1=@Way_X2 and @Way_Y1=@Way_Y2 and not(@id=$not_id_prev) ][1]">
  219. <xsl:for-each select="$Ways/Ways/Way[ ( @Way_X1=$Cur_X1 and @Way_Y1=$Cur_Y1 or @Way_X2=$Cur_X1 and @Way_Y2=$Cur_Y1 ) and ( not($not_id) or not(@id=$not_id)) and @Way_X1=@Way_X2 and @Way_Y1=@Way_Y2 and not(@id=$not_id_prev) ][1]">
  220. <LineString>
  221. <xsl:attribute name="error" select="'zerowa droga!'"/>
  222. <xsl:attribute name="X" select="@Way_X2"/>
  223. <xsl:attribute name="Y" select="@Way_Y2"/>
  224. <xsl:attribute name="not_id" select="@id"/>
  225. <xsl:attribute name="len" select="@len"/>
  226. <!--<xsl:if test="$debug">-->
  227. <xsl:message>Try to say @Way_X1:<xsl:value-of select="@Way_X1"/>; @Way_X2:<xsl:value-of select="@Way_X2"/>; $Cur_X1:<xsl:value-of select="$Cur_X1"/>; </xsl:message>
  228. <xsl:message>PlaceWay: 1=1;2=2 count()=<xsl:value-of select="count(.)"/>; lenX:<xsl:value-of select=" round(abs(number(@Way_X1) - number($Cur_X1)) * 1000)"/>; zerowa droga dla $Cur_X1=<xsl:value-of select="$Cur_X1"/>; $Cur_Y1=<xsl:value-of select="$Cur_Y1"/> @id=<xsl:value-of select="@id"/>; $not_id=<xsl:value-of select="$not_id"/>;$not_id_prev=<xsl:value-of select="$not_id_prev"/>;</xsl:message>
  229. <!--</xsl:if>-->
  230. <xsl:attribute name="not_id_prev" select="$not_id"/>
  231. <xsl:variable name="X" select="@Way_X2"/>
  232. <xsl:variable name="Y" select="@Way_Y2"/>
  233. <xsl:for-each select="$ways2joins/ways2joins/item[@id= current()/@id]/item"> <!-- musi byc wczesniej bo atrybut sie nie doda drugi raz-->
  234. <xsl:for-each select="$joins_asText_xml/joins_asText_xml/item[@id= current()/text()]/bp:Path_Point">
  235. <xsl:if test="@X=$X and @Y=$Y">
  236. <xsl:variable name="ID_Join" select="parent::node()/@id"/>
  237. <xsl:attribute name="ID_Join" select="$ID_Join"/>
  238. </xsl:if>
  239. </xsl:for-each>
  240. </xsl:for-each>
  241. <xsl:for-each select="$ways2joins/ways2joins/item[@id= current()/@id]/item">
  242. <xsl:for-each select="$joins_asText_xml/joins_asText_xml/item[@id= current()/text()]/bp:Path_Point">
  243. <xsl:if test="@X=$X and @Y=$Y">
  244. <xsl:variable name="ID_Join" select="parent::node()/@id"/>
  245. <!--<xsl:attribute name="ID_Join" select="$ID_Join"/>-->
  246. <!-- punkty podpiete -->
  247. <xsl:copy-of select="$joins2ways_z_ID_Way/joins2ways_z_ID_Way/item[@id=$ID_Join]/Points"/>
  248. <!-- wyszukanie drog wychodzacych innych niz nasza z punktu -->
  249. <xsl:for-each select="$joins2ways_z_ID_Way/joins2ways_z_ID_Way/item[@id=$ID_Join]/item[not(@ID_WAY=$ID_Way)]">
  250. <Ways>
  251. <xsl:attribute name="ID_WAY" select="@ID_WAY"/>
  252. <xsl:attribute name="ways_id" select="text()"/>
  253. </Ways>
  254. </xsl:for-each>
  255. </xsl:if>
  256. </xsl:for-each>
  257. </xsl:for-each>
  258. </LineString>
  259. </xsl:for-each>
  260. </xsl:when>
  261. <xsl:otherwise>
  262. <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)) and not(@Way_X1=@Way_X2 and @Way_Y1=@Way_Y2) and not(@id=$not_id_prev) ]">
  263. <LineString>
  264. <xsl:attribute name="X" select="@Way_X2"/>
  265. <xsl:attribute name="Y" select="@Way_Y2"/>
  266. <xsl:attribute name="not_id" select="@id"/>
  267. <xsl:attribute name="len" select="@len"/>
  268. <xsl:attribute name="not_id_prev" select="$not_id"/>
  269. <xsl:variable name="X" select="@Way_X2"/>
  270. <xsl:variable name="Y" select="@Way_Y2"/>
  271. <xsl:choose>
  272. <xsl:when test="number(count(@Way_X2)) &gt; number(1)"><xsl:message>#282 error count&gt; of @Way_X2<xsl:value-of select="@Way_X2"/> </xsl:message></xsl:when>
  273. <xsl:otherwise>
  274. <!--<xsl:if test=" abs(number(@Way_X2) - number($Cur_X1)) &gt; 0.001 ">
  275. <xsl:message>#326 too long way <xsl:value-of select="abs(number(@Way_X2) - number($Cur_X1))"/></xsl:message>
  276. </xsl:if>-->
  277. <xsl:if test="$debug">
  278. <xsl:message>Try to say @Way_X1:<xsl:value-of select="@Way_X1"/>; @Way_X2:<xsl:value-of select="@Way_X2"/>; $Cur_X1:<xsl:value-of select="$Cur_X1"/>; </xsl:message>
  279. <xsl:message>PlaceWay: 1=1 count()=<xsl:value-of select="count(.)"/>; number(@Way_X2)<xsl:value-of select="@Way_X2"/> lenX:<xsl:value-of select=" round(number(@Way_X2) - number($Cur_X1) * 100) "/>; dla $Cur_X1=<xsl:value-of select="$Cur_X1"/>; $Cur_Y1=<xsl:value-of select="$Cur_Y1"/> @id=<xsl:value-of select="@id"/>; $not_id=<xsl:value-of select="$not_id"/>;$not_id_prev=<xsl:value-of select="$not_id_prev"/>;</xsl:message>
  280. </xsl:if>
  281. </xsl:otherwise>
  282. </xsl:choose>
  283. <xsl:for-each select="$ways2joins/ways2joins/item[@id= current()/@id]/item"> <!-- musi byc wczesniej bo atrybut sie nie doda drugi raz-->
  284. <xsl:for-each select="$joins_asText_xml/joins_asText_xml/item[@id= current()/text()]/bp:Path_Point">
  285. <xsl:if test="@X=$X and @Y=$Y">
  286. <xsl:variable name="ID_Join" select="parent::node()/@id"/>
  287. <xsl:attribute name="ID_Join" select="$ID_Join"/>
  288. </xsl:if>
  289. </xsl:for-each>
  290. </xsl:for-each>
  291. <xsl:for-each select="$ways2joins/ways2joins/item[@id= current()/@id]/item">
  292. <xsl:for-each select="$joins_asText_xml/joins_asText_xml/item[@id= current()/text()]/bp:Path_Point">
  293. <xsl:if test="@X=$X and @Y=$Y">
  294. <xsl:variable name="ID_Join" select="parent::node()/@id"/>
  295. <!--<xsl:attribute name="ID_Join" select="$ID_Join"/>-->
  296. <!-- punkty podpiete -->
  297. <xsl:copy-of select="$joins2ways_z_ID_Way/joins2ways_z_ID_Way/item[@id=$ID_Join]/Points"/>
  298. <!-- wyszukanie drog wychodzacych innych niz nasza z punktu -->
  299. <xsl:for-each select="$joins2ways_z_ID_Way/joins2ways_z_ID_Way/item[@id=$ID_Join]/item[not(@ID_WAY=$ID_Way)]">
  300. <Ways>
  301. <xsl:attribute name="ID_WAY" select="@ID_WAY"/>
  302. <xsl:attribute name="ways_id" select="text()"/>
  303. </Ways>
  304. </xsl:for-each>
  305. </xsl:if>
  306. </xsl:for-each>
  307. </xsl:for-each>
  308. </LineString>
  309. </xsl:for-each>
  310. <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)) and ( not(@Way_X1=@Way_X2 and @Way_Y1=@Way_Y2) ) and not(@id=$not_id_prev) ]">
  311. <LineString>
  312. <xsl:attribute name="X" select="@Way_X1"/>
  313. <xsl:attribute name="Y" select="@Way_Y1"/>
  314. <xsl:attribute name="not_id" select="@id"/>
  315. <xsl:attribute name="len" select="@len"/>
  316. <xsl:attribute name="not_id_prev" select="$not_id"/>
  317. <xsl:variable name="X" select="@Way_X1"/>
  318. <xsl:variable name="Y" select="@Way_Y1"/>
  319. <xsl:if test="$debug">
  320. <xsl:message>PlaceWay: 1=2 count()=<xsl:value-of select="count(.)"/>; lenX:<xsl:value-of select=" round(number(@Way_X1) - number($Cur_X1) * 100)"/>; dla $Cur_X1=<xsl:value-of select="$Cur_X1"/>; $Cur_Y1=<xsl:value-of select="$Cur_Y1"/> @id=<xsl:value-of select="@id"/>; $not_id=<xsl:value-of select="$not_id"/>;</xsl:message>
  321. </xsl:if>
  322. <xsl:if test=" abs(number(@Way_X1) - number($Cur_X1)) &gt; 0.001 ">
  323. <xsl:message>#326 too long way <xsl:value-of select="abs(number(@Way_X1) - number($Cur_X1))"/></xsl:message>
  324. </xsl:if>
  325. <xsl:for-each select="$ways2joins/ways2joins/item[@id= current()/@id]/item"> <!-- musi byc wczesniej bo atrybut sie nie doda drugi raz-->
  326. <xsl:for-each select="$joins_asText_xml/joins_asText_xml/item[@id= current()/text()]/bp:Path_Point">
  327. <xsl:if test="@X=$X and @Y=$Y">
  328. <xsl:variable name="ID_Join" select="parent::node()/@id"/>
  329. <xsl:attribute name="ID_Join" select="$ID_Join"/>
  330. </xsl:if>
  331. </xsl:for-each>
  332. </xsl:for-each>
  333. <xsl:for-each select="$ways2joins/ways2joins/item[@id= current()/@id]/item">
  334. <xsl:for-each select="$joins_asText_xml/joins_asText_xml/item[@id= current()/text()]/bp:Path_Point">
  335. <xsl:if test="@X=$X and @Y=$Y">
  336. <xsl:variable name="ID_Join" select="parent::node()/@id"/>
  337. <!-- punkty podpiete -->
  338. <xsl:copy-of select="$joins2ways_z_ID_Way/joins2ways_z_ID_Way/item[@id=$ID_Join]/Points"/>
  339. <!-- wyszukanie drog wychodzacych innych niz nasza z punktu -->
  340. <xsl:for-each select="$joins2ways_z_ID_Way/joins2ways_z_ID_Way/item[@id=$ID_Join]/item[not(@ID_WAY=$ID_Way)]">
  341. <Ways>
  342. <xsl:attribute name="ID_WAY" select="@ID_WAY"/>
  343. <xsl:attribute name="ways_id" select="text()"/>
  344. </Ways>
  345. </xsl:for-each>
  346. </xsl:if>
  347. </xsl:for-each>
  348. </xsl:for-each>
  349. </LineString>
  350. </xsl:for-each>
  351. </xsl:otherwise>
  352. </xsl:choose>
  353. </xsl:variable>
  354. <xsl:copy-of select="$Linestring"/>
  355. <xsl:choose>
  356. <xsl:when test="$loop &gt; 1000">
  357. <loop_limit>
  358. <xsl:choose>
  359. <xsl:when test="$bypass_errors">
  360. <xsl:message terminate="no">
  361. !!!!!!!!!!!!!!!! Loop limit dla PlaceWay: 1=2 dla $Cur_X1=<xsl:value-of select="$Cur_X1"/>; $Cur_Y1=<xsl:value-of select="$Cur_Y1"/> @id=<xsl:value-of select="@id"/>; $not_id=<xsl:value-of select="$not_id"/>
  362. </xsl:message>
  363. </xsl:when>
  364. <xsl:otherwise>
  365. <xsl:message terminate="yes">
  366. !!!!!!!!!!!!!!!! Loop limit dla PlaceWay: 1=2 dla $Cur_X1=<xsl:value-of select="$Cur_X1"/>; $Cur_Y1=<xsl:value-of select="$Cur_Y1"/> @id=<xsl:value-of select="@id"/>; $not_id=<xsl:value-of select="$not_id"/>
  367. </xsl:message>
  368. </xsl:otherwise>
  369. </xsl:choose>
  370. </loop_limit>
  371. </xsl:when>
  372. <xsl:when test="$Linestring/LineString/@X = $Last_X2 and $Linestring/LineString/@Y = $Last_Y2 ">
  373. <ostatni/>
  374. </xsl:when>
  375. <xsl:otherwise>
  376. <xsl:if test="$debug">
  377. <xsl:message>call-templ with Cur_X1=<xsl:value-of select="$Linestring/LineString/@X"/>; not_id=<xsl:value-of select="$Linestring/LineString/@not_id"/>; not_id_prev=<xsl:value-of select="$Linestring/LineString/@not_id_prev"/></xsl:message>
  378. </xsl:if>
  379. <xsl:call-template name="PlaceWay">
  380. <xsl:with-param name="Ways" select="$Ways"/>
  381. <xsl:with-param name="Cur_X1" select="$Linestring/LineString/@X"/>
  382. <xsl:with-param name="Cur_Y1" select="$Linestring/LineString/@Y"/>
  383. <xsl:with-param name="Last_X2" select="$Last_X2"/>
  384. <xsl:with-param name="Last_Y2" select="$Last_Y2"/>
  385. <xsl:with-param name="not_id" select="$Linestring/LineString/@not_id"/>
  386. <xsl:with-param name="not_id_prev" select="$Linestring/LineString/@not_id_prev"></xsl:with-param>
  387. <xsl:with-param name="loop" select="$loop+1"/>
  388. <xsl:with-param name="ID_Way" select="$ID_Way"/>
  389. </xsl:call-template>
  390. </xsl:otherwise>
  391. </xsl:choose>
  392. </xsl:template>
  393. <!--<xsl:template name="AsText_XML">
  394. <xsl:param name="LineString" required="yes"/>
  395. <xsl:for-each select="$LineString/LineString">
  396. <PathPoint>
  397. <xsl:copy-of select="@*"/>
  398. </PathPoint>
  399. </xsl:for-each>
  400. </xsl:template>-->
  401. <xsl:template name="AsText">
  402. <xsl:param name="LineString" required="yes"/>
  403. <xsl:value-of select="'LINESTRING ('"/>
  404. <xsl:for-each select="$LineString/LineString">
  405. <xsl:value-of select="concat(@X,' ',@Y)"/>
  406. <xsl:if test="not(position()= last())">
  407. <xsl:value-of select="', '"/>
  408. </xsl:if>
  409. </xsl:for-each>
  410. <xsl:value-of select="')'"/>
  411. </xsl:template>
  412. </xsl:stylesheet>