edge_paths_with_PE.xsl 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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:param name="joins2ways_z_ID_Way.xml" select="'joins2ways_z_ID_Way.xml'"/>
  10. <xsl:variable name="joins2ways_z_ID_Way" select="$joins2ways_z_ID_Way.xml"/>
  11. <!--//match edge_joins_filled_paths-->
  12. <xsl:template match="edge_joins_filled_paths">
  13. <xsl:variable name="PE_track">
  14. <xsl:apply-templates/>
  15. </xsl:variable>
  16. <!--<PE_track>
  17. <xsl:copy-of select="$PE_track"/>
  18. </PE_track>-->
  19. <xsl:variable name="PE_track">
  20. <xsl:for-each select="$PE_track/LINESTRING">
  21. <LINESTRING>
  22. <xsl:attribute name="Count" select="count(*)"/>
  23. <xsl:copy-of select="@*"/>
  24. <!--<xsl:copy-of select="test1"/>-->
  25. <xsl:for-each select="bp:Path_Point">
  26. <bp:Path_Point>
  27. <xsl:copy-of select="@*"/>
  28. <xsl:attribute name="Pos" select="position()"/>
  29. <xsl:choose>
  30. <xsl:when test=" string-length(pos[@pos=1]/text())&gt;1">
  31. <xsl:attribute name="X" select="pos[@pos=1]"/>
  32. <xsl:attribute name="Y" select="pos[@pos=2]"/>
  33. </xsl:when>
  34. <xsl:otherwise>
  35. <xsl:attribute name="X" select="pos[@pos=2]"/>
  36. <xsl:attribute name="Y" select="pos[@pos=3]"/>
  37. </xsl:otherwise>
  38. </xsl:choose>
  39. </bp:Path_Point>
  40. </xsl:for-each>
  41. </LINESTRING>
  42. </xsl:for-each>
  43. </xsl:variable>
  44. <!--<edge_paths_with_PE>-->
  45. <!--<SRC>
  46. <xsl:copy-of select="$PE_track"/>
  47. </SRC>-->
  48. <PE_candidates_dump>
  49. <xsl:call-template name="PE_candidates_dump">
  50. <xsl:with-param name="edge_paths_with_PE" select="$PE_track"/>
  51. </xsl:call-template>
  52. </PE_candidates_dump>
  53. <!--</edge_paths_with_PE>-->
  54. </xsl:template>
  55. <xsl:template name="dumb_frequency">
  56. <xsl:param name="Count"/>
  57. <xsl:param name="distance"/>
  58. <xsl:param name="ID_Point_count"/>
  59. <xsl:choose>
  60. <xsl:when test="$ID_Point_count=0">
  61. <xsl:value-of select="0"/>
  62. </xsl:when>
  63. <!--<xsl:when test="$Count&lt;2">
  64. <xsl:value-of select="2"/>
  65. </xsl:when>
  66. <xsl:when test="$Count&lt;3">
  67. <xsl:value-of select="2"/>
  68. </xsl:when>
  69. <xsl:when test="$Count&lt;10">
  70. <xsl:value-of select="3"/>
  71. </xsl:when>
  72. <xsl:when test="$Count&lt;15">
  73. <xsl:value-of select="5"/>
  74. </xsl:when>-->
  75. <xsl:when test="$Count&lt;20">
  76. <xsl:value-of select="$Count - 1"/>
  77. </xsl:when>
  78. <xsl:when test="$Count&lt;30">
  79. <xsl:value-of select="15"/>
  80. </xsl:when>
  81. <xsl:otherwise>
  82. <xsl:value-of select="20"/>
  83. </xsl:otherwise>
  84. </xsl:choose>
  85. </xsl:template>
  86. <xsl:template name="PE_candidates_dump">
  87. <xsl:param name="edge_paths_with_PE" required="yes"/>
  88. <xsl:param name="dumb_frequency" select="20"/>
  89. <xsl:param name="clients_xpoint_count"/> <!--Ile jest na trasie punktow klienckich -->
  90. <!--<PE_candidates_dump>-->
  91. <xsl:attribute name="desc" select="'brakuje ominiecia punktow ways tylko do przylaczy i analizy dlugosci'"/>
  92. <xsl:for-each select="$edge_paths_with_PE/LINESTRING">
  93. <LINESTRING>
  94. <xsl:variable name="Count" select="@Count"/>
  95. <xsl:variable name="ID_Point_count" select="@ID_Point_count"/>
  96. <xsl:variable name="ID_Way" select="@ID_Way"/>
  97. <xsl:variable name="distance" select="@distance"/>
  98. <xsl:variable name="dumb_frequency">
  99. <xsl:call-template name="dumb_frequency">
  100. <xsl:with-param name="Count" select="$Count"/>
  101. <xsl:with-param name="ID_Point_count" select="$ID_Point_count"/>
  102. <xsl:with-param name="distance" select="$distance"/>
  103. </xsl:call-template>
  104. </xsl:variable>
  105. <xsl:attribute name="ID_Way" select="$ID_Way"/>
  106. <xsl:copy-of select="@*"/>
  107. <xsl:attribute name="dumb_frequency" select="$dumb_frequency"/>
  108. <xsl:for-each select="bp:Path_Point">
  109. <xsl:choose>
  110. <xsl:when test="(@Pos mod $dumb_frequency = 0 ) and $dumb_frequency &gt;0">
  111. <xsl:copy-of select="."/>
  112. </xsl:when>
  113. </xsl:choose>
  114. </xsl:for-each>
  115. </LINESTRING>
  116. </xsl:for-each>
  117. <!--</PE_candidates_dump>-->
  118. </xsl:template>
  119. <xsl:template match="item">
  120. <xsl:choose>
  121. <xsl:when test="asText">
  122. <LINESTRING>
  123. <xsl:attribute name="ID_Way" select="@id"/>
  124. <xsl:attribute name="ID_Point_count" select="count($joins2ways_z_ID_Way/joins2ways_z_ID_Way/item[@ID_Way=current()/@id and @ID_Point])"/>
  125. <xsl:attribute name="distance" select="distance/text()"/>
  126. <xsl:apply-templates/>
  127. </LINESTRING>
  128. </xsl:when>
  129. <xsl:otherwise>
  130. <bp:Path_Not_Found>
  131. <xsl:attribute name="ID_Way" select="@id"/>
  132. </bp:Path_Not_Found>
  133. </xsl:otherwise>
  134. </xsl:choose>
  135. </xsl:template>
  136. <!--<asText>LINESTRING (18.636657356658 51.253416226324, 18.6366871 51.253538999079, 18.6367062
  137. 51.253605499079, 18.6368933 51.25441199908, 18.6369493 51.254670399079, 18.6370223
  138. 51.254905799079, 18.6370965 51.255053899079, 18.6371814 51.255153699079, 18.637252
  139. 51.255236599079, 18.63765 51.255476599079, 18.6386978 51.255913099079, 18.6414059
  140. 51.257032799079, 18.6449346 51.25849289908, 18.6467805 51.25926169908, 18.64743915153
  141. 51.259545049387)</asText>-->
  142. <xsl:template match="asText">
  143. <xsl:variable name="LINESTRING" select=" substring-before( substring-after(normalize-space(.),'LINESTRING (') , ')') "/>
  144. <!--<test1><xsl:copy-of select="$LINESTRING"/></test1>-->
  145. <xsl:for-each select="tokenize($LINESTRING,',')">
  146. <bp:Path_Point>
  147. <!--<test2><xsl:copy-of select="."/></test2>-->
  148. <xsl:for-each select="tokenize(.,' ')">
  149. <pos>
  150. <xsl:attribute name="pos" select="position()"/>
  151. <xsl:value-of select="."/>
  152. </pos>
  153. </xsl:for-each>
  154. </bp:Path_Point>
  155. </xsl:for-each>
  156. </xsl:template>
  157. </xsl:stylesheet>