| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- <?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:import href="PE_wariant_bit_table.xsl"/>-->
-
- <xsl:output indent="yes"/>
- <xsl:strip-space elements="*"/>
-
- <xsl:param name="PE_Price" select="1500"/>
- <xsl:param name="Cable_Price" select="10"/>
-
- <xsl:param name="edge_paths_with_PE.xml"/>
-
- <!-- bedziemy od najdluzszej drogi starac sie rozmiescic PE w oparciu o rozmieszczenie klientow oraz odleglosci -->
-
-
-
- <xsl:template match="edge_joins_filled_paths">
-
- <xsl:variable name="edge_joins_filled_paths_len">
- <xsl:for-each select="item">
- <xsl:sort select="number(asText/@len)" order="descending"/>
- <Path>
- <xsl:attribute name="id" select="@id"/>
- <xsl:attribute name="len" select="asText/@len"/>
- <xsl:attribute name="Points_cnt" select="asText/@Points_cnt"/>
- </Path>
- </xsl:for-each>
- </xsl:variable>
- <xsl:variable name="edge_paths_with_PE_controll">
- <edge_paths_with_PE_controll>
- <xsl:apply-templates select="$edge_joins_filled_paths_len" mode="PointMatrixGroup"/>
- </edge_paths_with_PE_controll>
- </xsl:variable>
- <xsl:copy-of select="$edge_paths_with_PE_controll"/>
- <xsl:result-document href="edge_paths_with_PE.xml">
- <xsl:apply-templates select="$edge_paths_with_PE_controll" mode="edge_paths_with_PE.xml"/>
- </xsl:result-document>
- </xsl:template>
-
-
- <xsl:template match="edge_paths_with_PE_controll" mode="edge_paths_with_PE.xml">
- <PE_candidates_dump>
- <xsl:apply-templates mode="edge_paths_with_PE.xml"/>
- </PE_candidates_dump>
- </xsl:template>
-
-
- <xsl:template match="Path" mode="edge_paths_with_PE.xml">
- <LINESTRING>
- <xsl:attribute name="ID_Way" select="@id"/>
- <xsl:attribute name="Count" select="''"/>
- <xsl:attribute name="ID_Point_count" select="@Points_cnt"/>
- <xsl:attribute name="distance"/>
- <xsl:attribute name="dumb_frequency" select="''"/>
- <xsl:apply-templates mode="edge_paths_with_PE.xml"/>
- </LINESTRING>
- </xsl:template>
-
-
-
- <xsl:template match="bp:Path_Point" mode="edge_paths_with_PE.xml">
- <xsl:copy-of select="."/>
- </xsl:template>
-
- <xsl:template match="Path" mode="PointMatrixGroup">
- <Path>
- <xsl:variable name="edge_joins_filled_path" select=" doc(concat('edge_joins_filled_paths/edge_joins_filled_paths.',@id,'.xml'))"/>
- <xsl:attribute name="id" select="@id"/>
- <xsl:attribute name="Points_cnt" select="@Points_cnt"/>
- <xsl:variable name="Points_cnt" select="@Points_cnt"/>
- <xsl:attribute name="len" select="@len"/>
- <xsl:attribute name="Count" select="count($edge_joins_filled_path/edge_joins_filled_paths_xml/asText_XMl/LineString)"/>
- <xsl:variable name="len" select="@len"/>
- <!--<xsl:variable name="edge_joins_filled_paths" select="collection( 'edge_joins_filled_paths?select=*.xml;recurse=yes')"/>-->
-
- <!--<EdgeWayJoinsPair>
- <xsl:copy-of select="$edge_joins_filled_path"></xsl:copy-of>
- </EdgeWayJoinsPair>-->
-
- <!-- liczmy najwieksza roznice odleglosci miedzy punktami -->
-
-
- <!-- rozmieszczamy prawidlowo PE na danej trasie -->
- <xsl:variable name="EconomicDistanceCut">
- <EconomicDistanceCut>
- <xsl:for-each select="$edge_joins_filled_path/edge_joins_filled_paths_xml/asText_XMl/LineString">
- <distance>
- <xsl:attribute name="pos" select="position()"/>
- <xsl:attribute name="not_id" select="@not_id"/>
- <xsl:attribute name="len" select="@len"/>
- <xsl:attribute name="id_path" select="@id_path"/>
- <xsl:variable name="Points" select="count(Points)"/>
- <xsl:variable name="Ways" select="count(Ways)"/>
- <xsl:choose>
- <xsl:when test="Points or Ways">
- <xsl:attribute name="point_count" select="$Points + $Ways"/>
- </xsl:when>
- </xsl:choose>
- </distance>
- </xsl:for-each>
- </EconomicDistanceCut>
- </xsl:variable>
- <!--<xsl:copy-of select="$EconomicDistanceCut"/>-->
- <xsl:variable name="EconomicDistanceCut2">
- <EconomicDistanceCut2>
- <xsl:for-each select="$EconomicDistanceCut/EconomicDistanceCut/distance">
- <distance2>
- <xsl:attribute name="distance" select="sum( $EconomicDistanceCut/EconomicDistanceCut/distance[number(@pos )< number(current()/@pos )]/@len)"/>
- <!-- suma do poprzedniego pkt tylko dla tych co maja pkt-->
- <xsl:choose>
- <xsl:when test="@point_count>0">
- <xsl:variable name="max_pos_z_pkt" select="max($EconomicDistanceCut/EconomicDistanceCut/distance[
- number(@pos )< number(current()/@pos ) and number(@point_count)>0
- ]/@pos)"/>
- <xsl:attribute name="max_pos_z_pkt" select="$max_pos_z_pkt"/>
- <xsl:variable name="disttopkt" select="sum( $EconomicDistanceCut/EconomicDistanceCut/distance[
- number(@pos )< number(current()/@pos )
- and number(@pos) >= number($max_pos_z_pkt)
- ]/@len)"/>
- <xsl:attribute name="disttopkt" select="$disttopkt" />
- <xsl:variable name="cost_dist" select="$Cable_Price * $disttopkt * @point_count"/>
- <xsl:attribute name="cost_dist" select="$cost_dist"/>
-
- <xsl:if test="$cost_dist > $PE_Price">
- <xsl:attribute name="cut_by_pe" select="1"/>
- </xsl:if>
- <xsl:attribute name="not_id" select="@not_id"/>
- </xsl:when>
- </xsl:choose>
- <xsl:attribute name="id_path" select="@id_path"/>
- <xsl:copy-of select="@point_count"/>
- <xsl:copy-of select="@pos"/>
- <xsl:copy-of select="@len"/>
- </distance2>
- </xsl:for-each>
- </EconomicDistanceCut2>
- </xsl:variable>
-
- <!--<xsl:copy-of select="$EconomicDistanceCut2"/>-->
-
- <xsl:variable name="elements_cnt" select="count($EconomicDistanceCut2/EconomicDistanceCut2/distance2[@point_count > 0])"/><!-- liczba wezlow potencjalnych licbza PE-->
- <xsl:variable name="bit_max" select="round($len div ( $PE_Price div $Cable_Price ) + count($EconomicDistanceCut2/EconomicDistanceCut2/distance2[@cost_dist > $PE_Price]) )"/><!-- max licbza PE-->
-
- <!-- pogrupujemy elementy co 50 metrow -->
- <xsl:variable name="PointMatrixGroup">
- <PointMatrixGroup>
- <xsl:for-each-group select="$EconomicDistanceCut2/EconomicDistanceCut2/distance2" group-by="round( @distance div ( $PE_Price div $Cable_Price + 50 ))">
- <PointMatrixGroupPos>
- <xsl:variable name="elements_cnt_Pos" select="count(current-group()[@point_count > 0])"/>
- <xsl:variable name="bit_max_Pos" select="round(sum( current-group()/@disttopkt ) div ( $PE_Price div 20 ) )"/>
- <xsl:attribute name="distanceGr" select=" current-grouping-key()"/>
- <xsl:attribute name="elements_cnt_Pos" select="$elements_cnt_Pos"/>
- <xsl:attribute name="bit_max_Pos" select="$bit_max_Pos"/>
- <xsl:attribute name="id_path" select="@id_path"/>
- <xsl:attribute name="point_count_Pos" select="sum(current-group()/@point_count)"/>
- <xsl:for-each select="current-group()">
- <xsl:copy-of select="."/>
- </xsl:for-each>
- </PointMatrixGroupPos>
- </xsl:for-each-group>
- </PointMatrixGroup>
- </xsl:variable>
- <!-- wsadzamy PE w grupach i moze w kilku wariantach - najlepiej tam gdzie jest najwiecej klientow najpierw
- gdzie najwiecej klientow walimy wezly - grupujemy ilosciami klientow dzielac sume drogi na ilosc przewidzianych wezlow
- -->
- <!-- debug -->
- <xsl:copy-of select="$PointMatrixGroup"/>
- <PointMatrixGroupPE>
- <xsl:for-each select="$PointMatrixGroup/PointMatrixGroup/PointMatrixGroupPos">
- <xsl:variable name="bit_max_Pos" select="@bit_max_Pos"/>
- <xsl:variable name="point_count_Pos" select="@point_count_Pos"/>
- <!-- ida kandydaci -->
- <xsl:for-each select="distance2[ position() <= $bit_max_Pos or ( position()=1 and $point_count_Pos > 0 ) ]"> <!-- jak jest maly wspolczynnik to chociaz jeden punkt jak sa punkty jakies w tej grupie -->
- <xsl:sort select="@cost_dist" order="descending"/>
- <bp:Path_Point>
- <xsl:attribute name="pos" select="@pos"/>
- <xsl:attribute name="len" select="@len"/>
- <xsl:attribute name="distance" select="@distance"/>
- <xsl:attribute name="id_path" select="@id_path"/>
- <xsl:attribute name="X" select="$edge_joins_filled_path/edge_joins_filled_paths_xml/asText_XMl/LineString[@id_path = current()/@id_path]/@X"/>
- <xsl:attribute name="Y" select="$edge_joins_filled_path/edge_joins_filled_paths_xml/asText_XMl/LineString[@id_path = current()/@id_path]/@Y"/>
- </bp:Path_Point>
- </xsl:for-each>
- </xsl:for-each>
- </PointMatrixGroupPE>
- <!--<PointMatrix>
- <xsl:attribute name="bit_max" select="$bit_max"/>
- <xsl:attribute name="elements_cnt" select="$elements_cnt"/>
-
- <xsl:attribute name="num_extr" select="count($EconomicDistanceCut2/EconomicDistanceCut2/distance2[@cost_dist > $PE_Price])"/>
- <!-\-<xsl:call-template name="PE_wariant">
- <xsl:with-param name="elements_cnt" select="$elements_cnt"/>
- <xsl:with-param name="bit_max" select="$bit_max"/>
- </xsl:call-template>-\->
-
- </PointMatrix>-->
- </Path>
- </xsl:template>
-
-
- </xsl:stylesheet>
|