cables_from_joins_to_PE.xsl 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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:output indent="yes"/>
  8. <xsl:strip-space elements="*"/>
  9. <xsl:include href="asText.xsl"/>
  10. <xsl:variable name="PE_candidates_dump" select="doc('edge_paths_with_PE.xml')"/>
  11. <xsl:variable name="joins_asText" select="doc('joins_asText.xml')"/>
  12. <xsl:variable name="edge_joins_filled_paths" select="doc('edge_joins_filled_paths.xml') "/>
  13. <!-- <joins_asText>
  14. <item id="0">POINT (18.7909 51.701067999083)</item>-->
  15. <xsl:template match="joins2ways_z_ID_Way">
  16. <cables_from_joins_to_PE>
  17. <xsl:variable name="joins_asText_Path_Point">
  18. <xsl:apply-templates select="$joins_asText" mode="joins_asText"/>
  19. </xsl:variable>
  20. <joins_asText_Path_Point>
  21. <xsl:copy-of select="$joins_asText_Path_Point"/>
  22. </joins_asText_Path_Point>
  23. <xsl:variable name="edge_joins_filled_paths">
  24. <xsl:apply-templates select="$edge_joins_filled_paths" mode="edge_joins_filled_paths"/>
  25. </xsl:variable>
  26. <xsl:copy-of select="$edge_joins_filled_paths"/>
  27. <!-- jedziemy po joins2ways_z_ID_Way, sprawdzamy czy jest dla niego PE_candidates_dump , jak tak, to szukamy jego PE i liczymy sciezke
  28. lub probujemy rysowac zawsze od konca drogi-->
  29. <xsl:for-each select="item">
  30. <xsl:choose>
  31. <xsl:when test="$PE_candidates_dump/PE_candidates_dump/LINESTRING[@ID_Way=current()/@ID_Way]">
  32. <cable_to_PE_to_be_calculated>
  33. <xsl:attribute name="Joins" select="@id"/>
  34. <xsl:attribute name="ID_Way" select="@ID_Way"/>
  35. <xsl:variable name="ID_Way" select="@ID_Way"/>
  36. <xsl:variable name="Joins" select="@ID_Way"/>
  37. <!-- idziemy po drodze, -->
  38. <xsl:variable name="Join_X" select="$joins_asText_Path_Point/joins_asText/item[@id=$Joins]/As_POINT_to_xml/@X"/>
  39. <xsl:variable name="Join_Y" select="$joins_asText_Path_Point/joins_asText/item[@id=$Joins]/As_POINT_to_xml/@Y"/>
  40. <xsl:attribute name="Join_X" select="$Join_X"/><xsl:attribute name="Join_Y" select="$Join_Y"/>
  41. <xsl:for-each select="$edge_joins_filled_paths/edge_joins_filled_paths[@id=$ID_Way]/item/bp:Path_Point">
  42. <xsl:choose>
  43. <xsl:when test="@X=$Join_Y and @Y=$Join_Y">
  44. <found_in_path_in_edge_joins_filled_path>
  45. <xsl:copy-of select="."/>
  46. </found_in_path_in_edge_joins_filled_path>
  47. </xsl:when>
  48. </xsl:choose>
  49. </xsl:for-each>
  50. </cable_to_PE_to_be_calculated>
  51. </xsl:when>
  52. </xsl:choose>
  53. </xsl:for-each>
  54. </cables_from_joins_to_PE>
  55. </xsl:template>
  56. <xsl:template match="edge_joins_filled_paths" mode="edge_joins_filled_paths">
  57. <edge_joins_filled_paths>
  58. <xsl:apply-templates mode="edge_joins_filled_paths"/>
  59. </edge_joins_filled_paths>
  60. </xsl:template>
  61. <xsl:template match="item" mode="edge_joins_filled_paths">
  62. <item>
  63. <xsl:copy-of select="@*"/>
  64. <xsl:copy-of select="tried"/>
  65. <xsl:apply-templates/>
  66. </item>
  67. </xsl:template>
  68. <xsl:template match="joins_asText" mode="joins_asText">
  69. <joins_asText>
  70. <xsl:apply-templates mode="joins_asText"/>
  71. </joins_asText>
  72. </xsl:template>
  73. <xsl:template match="item" mode="joins_asText">
  74. <item>
  75. <xsl:copy-of select="@*"/>
  76. <xsl:call-template name="As_POINT_to_xml">
  77. <xsl:with-param name="As_POINT" select="text()"/>
  78. </xsl:call-template>
  79. </item>
  80. </xsl:template>
  81. <!-- todo do wypchniecia do funkcji ogolnych -->
  82. <xsl:template name="As_POINT_to_xml">
  83. <xsl:param name="As_POINT"/>
  84. <xsl:variable name="As_POINT_tok" select=" substring-before( substring-after(normalize-space(.),'POINT (') , ')') "/>
  85. <!--<test1><xsl:copy-of select="$LINESTRING"/></test1>-->
  86. <xsl:variable name="As_POINT_pos">
  87. <xsl:for-each select="tokenize($As_POINT_tok,' ')">
  88. <pos>
  89. <xsl:attribute name="pos" select="position()"/>
  90. <xsl:value-of select="."/>
  91. </pos>
  92. </xsl:for-each>
  93. </xsl:variable>
  94. <As_POINT_to_xml>
  95. <xsl:attribute name="X" select="$As_POINT_pos/pos[@pos=1]"/>
  96. <xsl:attribute name="Y" select="$As_POINT_pos/pos[@pos=2]"/>
  97. </As_POINT_to_xml>
  98. </xsl:template>
  99. </xsl:stylesheet>