biale_plamy_joins2ways_do_paths.xsl 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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. exclude-result-prefixes="xs"
  5. xmlns:bp="https://procesy5.pl/biale_plamy-schema.xsd"
  6. version="2.0">
  7. <!--<xsl:param name=""></xsl:param>-->
  8. <xsl:variable name="ways2joins" select="doc('ways2joins.xml')"/>
  9. <xsl:output indent="yes"/>
  10. <xsl:strip-space elements="*"/>
  11. <!--example input
  12. <joins2ways>
  13. <item id="0">
  14. <item id="0">0</item>
  15. <item id="1">12135</item>
  16. <item id="2">29426</item>
  17. </item>
  18. <item id="1">
  19. <item id="0">0</item>
  20. <item id="1">1</item>
  21. <item id="2">24887</item>
  22. </item>
  23. </joins2ways>
  24. -->
  25. <xsl:template match="joins2ways_z_ID_Way">
  26. <!--<xsl:variable name="EdgeWayJoinsPair_cand">
  27. <xsl:apply-templates mode="joins"/>
  28. </xsl:variable>-->
  29. <!--<xsl:variable name="joins2ways_z_ID_Way" select="."/>-->
  30. <!--<xsl:copy-of select="$EdgeWayJoinsPair_cand"></xsl:copy-of>-->
  31. <!--<xsl:choose>
  32. <xsl:when test="$EdgeWayJoinsPair_cand/EdgeWayJoinsPair_cand[@ID_Way=current()/@ID_Way]">
  33. <JESTOK></JESTOK>
  34. </xsl:when>
  35. <xsl:otherwise>
  36. </xsl:otherwise>
  37. </xsl:choose>-->
  38. <!--<xsl:copy-of select="$EdgeWayJoinsPair_cand/no_EdgeWayJoinsPair"></xsl:copy-of>-->
  39. <xsl:variable name="guess_edges">
  40. <xsl:for-each select="item">
  41. <guess_join>
  42. <xsl:attribute name="ID_Way" select="@ID_Way"/>
  43. <xsl:variable name="ID_Way">
  44. <xsl:choose>
  45. <xsl:when test="@ID_Way"><xsl:value-of select="@ID_Way"/></xsl:when>
  46. <xsl:otherwise><xsl:value-of select="0"/></xsl:otherwise>
  47. </xsl:choose>
  48. </xsl:variable>
  49. <xsl:apply-templates select="." mode="joins_not_way">
  50. <xsl:with-param name="ID_Way" select="$ID_Way"/>
  51. </xsl:apply-templates>
  52. </guess_join>
  53. </xsl:for-each>
  54. </xsl:variable>
  55. <EdgeWayJoins>
  56. <!--<xsl:for-each-group select="$EdgeWayJoinsPair_cand/no_EdgeWayJoinsPair" group-by="@ID_Way">
  57. <EdgeWayJoinsPair>
  58. <xsl:attribute name="ID_Way" select="@ID_Way"/>
  59. <xsl:variable name="ID_Way" select="@ID_Way"/>
  60. <xsl:variable name="Joins_miss">
  61. <xsl:for-each select="$joins2ways_z_ID_Way/item[@ID_Way=$ID_Way and count( child::node())&gt;1 ]">
  62. <!-\- szukamy joinsa ktory ma joina do innego waysa-\->
  63. <xsl:variable name="Join_ID" select="@id"/>
  64. <xsl:for-each select="item">
  65. <ways>
  66. <xsl:attribute name="id_join" select="$Join_ID"/>
  67. <xsl:attribute name="id_way" select="text()"/>
  68. </ways>
  69. </xsl:for-each>
  70. </xsl:for-each>
  71. </xsl:variable>
  72. <xsl:copy-of select="$Joins_miss"/>
  73. <xsl:variable name="Ways_miss">
  74. <xsl:for-each select="$Joins_miss/ways">
  75. <xsl:variable name="id_join" select="@id_join"/>
  76. <xsl:variable name="id_way_test" select="@id_way"/>
  77. <xsl:for-each select="$ways2joins/ways2joins/item[@id=$id_way_test]/item">
  78. <found_joins_in_ways>
  79. <xsl:attribute name="id_join" select="$id_join"/>
  80. <xsl:attribute name="id_join_found" select="text()"/>
  81. </found_joins_in_ways>
  82. </xsl:for-each>
  83. </xsl:for-each>
  84. </xsl:variable>
  85. <xsl:copy-of select="$Ways_miss"/>
  86. <xsl:for-each select="$Ways_miss/found_joins_in_ways"> <!-\- [not(@id_join_found=$EdgeJoinFound)]-\->
  87. <xsl:choose>
  88. <xsl:when test="not($Joins_miss/ways[@id_join=current()/@id_join_found])">
  89. <!-\-<missed>-\->
  90. <!-\-<xsl:attribute name="Joins" select="@id_join"/>-\->
  91. <bp:Joins>
  92. <xsl:attribute name="Joins" select="current()/@id_join_found"/>
  93. </bp:Joins>
  94. <!-\-</missed>-\->
  95. </xsl:when>
  96. </xsl:choose>
  97. </xsl:for-each>
  98. </EdgeWayJoinsPair>
  99. </xsl:for-each-group>-->
  100. <xsl:for-each-group select="item" group-by="@ID_Way">
  101. <xsl:variable name="ID_Way" select="@ID_Way"/>
  102. <EdgeWayJoinsPair>
  103. <xsl:attribute name="ID_Way" select="@ID_Way"/>
  104. <!-- debug -->
  105. <!--<xsl:copy-of select="$guess_edges/guess_join[@ID_Way=$ID_Way]"></xsl:copy-of>-->
  106. <xsl:for-each select="$guess_edges/guess_join[@ID_Way=$ID_Way]/EdgeWayJoinsPair_cand">
  107. <bp:Joins>
  108. <xsl:attribute name="Joins" select="@joins"/>
  109. </bp:Joins>
  110. </xsl:for-each>
  111. <!--<xsl:for-each select="current-group()">
  112. <!-\-<GROUP><xsl:copy-of select="item("></xsl:copy-of></GROUP>-\->
  113. <xsl:choose>
  114. <xsl:when test=" position()=1 or position()=last()">
  115. <bp:Joins>
  116. <xsl:attribute name="Joins" select="@id"/>
  117. </bp:Joins>
  118. </xsl:when>
  119. </xsl:choose>
  120. </xsl:for-each>-->
  121. </EdgeWayJoinsPair>
  122. </xsl:for-each-group>
  123. <!--<xsl:for-each-group select="$EdgeWayJoinsPair_cand/EdgeWayJoinsPair_cand" group-by="@ID_Way">
  124. <EdgeWayJoinsPair>
  125. <xsl:attribute name="ID_Way" select="@ID_Way"/>
  126. <xsl:variable name="ID_Way" select="@ID_Way"/>
  127. <xsl:for-each select="current-group()">
  128. <xsl:variable name="EdgeJoinFound" select="@joins"/>
  129. <bp:Joins>
  130. <xsl:attribute name="Joins" select="@joins"/>
  131. </bp:Joins>
  132. <xsl:choose>
  133. <xsl:when test=" count( current-group())&lt;2">
  134. <bp:Joins>
  135. <xsl:variable name="Joins_miss">
  136. <xsl:for-each select="$joins2ways_z_ID_Way/item[@ID_Way=$ID_Way and count( child::node())=2 ]">
  137. <!-\- szukamy joinsa ktory ma joina do innego waysa-\->
  138. <xsl:variable name="Join_ID" select="@id"/>
  139. <xsl:for-each select="item">
  140. <ways>
  141. <xsl:attribute name="id_join" select="$Join_ID"/>
  142. <xsl:attribute name="id_way" select="text()"/>
  143. </ways>
  144. </xsl:for-each>
  145. </xsl:for-each>
  146. </xsl:variable>
  147. <!-\-<xsl:copy-of select="$Joins_miss"></xsl:copy-of>-\->
  148. <xsl:variable name="Ways_miss">
  149. <xsl:for-each select="$Joins_miss/ways">
  150. <xsl:variable name="id_join" select="@id_join"/>
  151. <xsl:variable name="id_way_test" select="@id_way"/>
  152. <xsl:for-each select="$ways2joins/ways2joins/item[@id=$id_way_test]/item">
  153. <found_joins_in_ways>
  154. <xsl:attribute name="id_join" select="$id_join"/>
  155. <xsl:attribute name="id_join_found" select="text()"/>
  156. </found_joins_in_ways>
  157. </xsl:for-each>
  158. </xsl:for-each>
  159. </xsl:variable>
  160. <!-\-<xsl:copy-of select="$Ways_miss"/>-\->
  161. <xsl:for-each select="$Ways_miss/found_joins_in_ways[not(@id_join_found=$EdgeJoinFound)]">
  162. <xsl:choose>
  163. <xsl:when test="not($Joins_miss/ways[@id_join=current()/@id_join_found])">
  164. <!-\-<missed>-\->
  165. <!-\-<xsl:attribute name="Joins" select="@id_join"/>-\->
  166. <xsl:attribute name="Joins" select="current()/@id_join_found"/>
  167. <!-\-</missed>-\->
  168. </xsl:when>
  169. </xsl:choose>
  170. </xsl:for-each>
  171. </bp:Joins>
  172. </xsl:when>
  173. </xsl:choose>
  174. </xsl:for-each>
  175. </EdgeWayJoinsPair>
  176. </xsl:for-each-group>-->
  177. </EdgeWayJoins>
  178. </xsl:template>
  179. <xsl:template match="item" mode="miss_join">
  180. </xsl:template>
  181. <xsl:template match="item" mode="joins_not_way">
  182. <xsl:param name="ID_Way" required="yes"/>
  183. <xsl:variable name="count_our_way">
  184. <xsl:for-each select="item">
  185. <xsl:element name="count_our_way">
  186. <xsl:choose>
  187. <xsl:when test="@ID_WAY=$ID_Way">1</xsl:when>
  188. <xsl:otherwise>0</xsl:otherwise>
  189. </xsl:choose>
  190. </xsl:element>
  191. </xsl:for-each>
  192. </xsl:variable>
  193. <see>
  194. <xsl:copy-of select="."/>
  195. <inside>
  196. <xsl:attribute name="count_our" select="count(item[@ID_WAY=$ID_Way])"/>
  197. <count_our_way_val>
  198. <xsl:copy-of select="$count_our_way"/>
  199. </count_our_way_val>
  200. <xsl:for-each select="item[@ID_WAY!=$ID_Way]">
  201. <xsl:element name="EdgeWayJoinsPair_cand">
  202. <xsl:attribute name="joins" select="../@id"/>
  203. <xsl:attribute name="ID_Way" select="../@ID_Way"/>
  204. </xsl:element>
  205. </xsl:for-each>
  206. </inside>
  207. </see>
  208. <xsl:variable name="if_item_not_in_way">
  209. <xsl:for-each select="item">
  210. <xsl:choose>
  211. <xsl:when test="not(@ID_WAY=$ID_Way)">
  212. <xsl:element name="EdgeWayJoinsPair_cand">
  213. <xsl:attribute name="joins" select="../@id"/>
  214. <xsl:attribute name="ID_Way" select="../@ID_Way"/>
  215. </xsl:element></xsl:when>
  216. </xsl:choose>
  217. </xsl:for-each>
  218. </xsl:variable>
  219. <xsl:choose>
  220. <xsl:when test="count(item)=1">
  221. <xsl:element name="EdgeWayJoinsPair_cand">
  222. <xsl:attribute name="pos" select="position()"/>
  223. <xsl:attribute name="joins" select="@id"/>
  224. <xsl:attribute name="ID_Way" select="@ID_Way"/>
  225. <xsl:attribute name="ways" select="item/text()"/>
  226. </xsl:element>
  227. </xsl:when>
  228. <xsl:when test="$if_item_not_in_way/EdgeWayJoinsPair_cand and count(item[@ID_WAY=$ID_Way])&lt;2">
  229. <xsl:element name="EdgeWayJoinsPair_cand">
  230. <xsl:attribute name="debug" select="'has other way'"/>
  231. <xsl:attribute name="joins" select="@id"/>
  232. <xsl:attribute name="ID_Way" select="@ID_Way"/>
  233. <xsl:attribute name="ways">
  234. <xsl:for-each select="item/text()">
  235. <xsl:value-of select=" concat(.,' ')"/>
  236. </xsl:for-each>
  237. </xsl:attribute>
  238. <!--<xsl:attribute name="ways" select="item/text()" separator="', '" />-->
  239. </xsl:element>
  240. </xsl:when>
  241. </xsl:choose>
  242. </xsl:template>
  243. <xsl:template match="item" mode="joins">
  244. <!--<xsl:param name="second_turn" />-->
  245. <xsl:choose>
  246. <!--<xsl:when test="count(item[@ID_WAY=current()/@ID_Way])&gt;1">
  247. <xsl:element name="EdgeWayJoinsPair_cand">
  248. <xsl:attribute name="joins" select="@id"/>
  249. <xsl:attribute name="ID_Way" select="@ID_Way"/>
  250. <xsl:attribute name="ways" select="item/text()"/>
  251. </xsl:element>
  252. </xsl:when>-->
  253. <xsl:when test="count(item)=1">
  254. <xsl:element name="EdgeWayJoinsPair_cand">
  255. <xsl:attribute name="pos" select="position()"/>
  256. <xsl:attribute name="joins" select="@id"/>
  257. <xsl:attribute name="ID_Way" select="@ID_Way"/>
  258. <xsl:attribute name="ways" select="item/text()"/>
  259. </xsl:element>
  260. </xsl:when>
  261. <!--<xsl:when test="count(../item[@ID_Way=current()/@ID_Way]) and count( child::node()=1)">
  262. <xsl:element name="no_EdgeWayJoinsPair">
  263. <xsl:attribute name="ID_Way" select="@ID_Way"/>
  264. </xsl:element>
  265. </xsl:when>-->
  266. <!--<xsl:when test="count(item)=2">
  267. <xsl:element name="EdgeWayJoinsPair_cand">
  268. <xsl:attribute name="joins" select="@id"/>
  269. <xsl:attribute name="ID_Way" select="@ID_Way"/>
  270. <xsl:attribute name="ways" select="item/text()"/>
  271. </xsl:element>
  272. </xsl:when>-->
  273. </xsl:choose>
  274. </xsl:template>
  275. </xsl:stylesheet>