| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879 |
- <?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="2500"/>
- <xsl:param name="Cable_Price" select="3"/>
- <xsl:param name="max_combinate_groups_elements" select="8"/> <!-- po ile wezlow mamy grupowac do wyliczania kombinacji kosztow -->
- <xsl:param name="logic" select="'grouped'"/> <!-- tutaj robi grupy po $max_combinate_groups_elements -->
- <!--<xsl:param name="logic" select="'sorted'"/>--> <!-- tutaj robi grupy ale analizyje w grupie tylko wazniejsze/bardziej oblozone wezly -->
-
- <xsl:param name="debug" select="1"/>
-
-
- <!--<xsl:param name="edge_paths_with_PE.xml"/>-->
- <xsl:param name="edge_paths_with_PE_controll_temp" select="'edge_paths_with_PE_controll_temp'"/> <!-- cache do przekazywani danych z petli-->
- <xsl:param name="edge_paths_with_PE_controll_temp.alias" select="'edge_paths_with_PE_controll_temp.alias'" />
- <xsl:param name="edge_paths_with_PE_controll_paths_temp" select="'edge_paths_with_PE_controll_paths_temp'"/> <!-- do przechowywania calych sciezek do PathCrossed-->
- <xsl:param name="edge_joins_filled_paths" select="'edge_joins_filled_paths'"/>
- <!-- bedziemy od najdluzszej drogi starac sie rozmiescic PE w oparciu o rozmieszczenie klientow oraz odleglosci -->
-
-
-
- <xsl:template match="edge_joins_filled_paths_xml"><!-- w przypadku wyzwolenia dla pojedynczego pliku -->
- <xsl:message>Running script for params:
- PE_Price=<xsl:value-of select="$PE_Price"/>
- Cable_Price=<xsl:value-of select="$Cable_Price"/>
- max_combinate_groups_elements=<xsl:value-of select="$max_combinate_groups_elements"/>
- logic=<xsl:value-of select="$logic"/> .EOF
- </xsl:message>
- <edge_paths_with_PE_controll>
- <xsl:attribute name="logic" select="$logic"/>
- <!-- <xsl:attribute name="id" select="@id"/>
- <xsl:attribute name="len" select="@len"/>
- <xsl:attribute name="Points_cnt" select="@Points_cnt"/>-->
- <xsl:apply-templates mode="PointMatrixGroup">
- <xsl:with-param name="edge_joins_filled_path" select="parent::node()"/><!-- jak lecimy natywnie dla pliku edge_joins_filled_paths_xml to dane sa w node()-->
- </xsl:apply-templates>
- </edge_paths_with_PE_controll>
- </xsl:template>
-
- <xsl:template match="edge_joins_filled_paths">
- <xsl:message>Running script for params:
- PE_Price=<xsl:value-of select="$PE_Price"/>
- Cable_Price=<xsl:value-of select="$Cable_Price"/>
- max_combinate_groups_elements=<xsl:value-of select="$max_combinate_groups_elements"/>
- logic=<xsl:value-of select="$logic"/> .EOF
- </xsl:message>
- <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>
-
- <edge_paths_with_PE_controll>
- <xsl:attribute name="logic" select="$logic"/>
- <xsl:apply-templates select="$edge_joins_filled_paths_len" mode="PointMatrixGroup"/>
- </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="Path|asText_XMl" mode="PointMatrixGroup">
- <xsl:param name="edge_joins_filled_path" select=" doc(concat($edge_joins_filled_paths,'/edge_joins_filled_paths.',@id,'.xml'))"/>
- <Path>
- <xsl:attribute name="id" select="@id"/>
- <xsl:variable name="ID_Way" 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:message> Path dla ID_Way=<xsl:value-of select="$ID_Way"/>; len=<xsl:value-of select="@len"/>; Count=<xsl:value-of select="count($edge_joins_filled_path/edge_joins_filled_paths_xml/asText_XMl/LineString)"/>
- Points_cnt=<xsl:value-of select="@Points_cnt"/>
- </xsl:message>
- <!--<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 -->
-
-
- <!-- sciagamy dane drog, z ktorymi sie przecinamy -->
- <xsl:variable name="PathsCrossed">
- <PathsCrossed>
- <xsl:for-each-group select="$edge_joins_filled_path/edge_joins_filled_paths_xml/asText_XMl/LineString/Ways" group-by="@ID_WAY">
- <Ways>
- <xsl:variable name="ID_WAY_joining" select="@ID_WAY"/>
- <xsl:attribute name="ID_WAY" select="$ID_WAY_joining"/>
- <xsl:variable name="ways_id_joining" select="@ways_id"/>
- <xsl:attribute name="ways_id_joining" select="$ways_id_joining"/>
- <xsl:variable name="ID_Join_joining" select="parent::node()/@ID_Join"/>
- <xsl:attribute name="ID_Join_joining" select="$ID_Join_joining"/>
- <xsl:choose>
- <xsl:when test="doc-available(concat($edge_paths_with_PE_controll_paths_temp,'/','edge_paths_with_PE_controll.xsl.',@ID_WAY,'.xml'))">
- <xsl:variable name="Neigh_controll">
- <xsl:copy-of select="doc(concat($edge_paths_with_PE_controll_paths_temp,'/','edge_paths_with_PE_controll.xsl.',@ID_WAY,'.xml'))"/>
- </xsl:variable>
- <!-- wykryc gdzie sie lacza i jakie sa odleglosci prawdziwe -->
- <!-- jak nasza droga sie laczy do przeciwnej? ktory nasz Way w nim siedzi -->
- <!-- zignorowac wezel zwiazany z podlaczonym tam joinem -->
- <!-- <IgnoreLocaldistance>
- <xsl:attribute name="ID_Join" select="$ID_Join_joining"/>
- </IgnoreLocaldistance>
- <IgnoreLocaldistance>
- <xsl:attribute name="ID_Join" select="$ID_Join_joining"/>
- </IgnoreLocaldistance>-->
- <!--<xsl:for-each select="$Neigh_controll/edge_paths_with_PE_controll/Path/PointMatrixGroupPE/PointMatrixGroup/odpalam_liczenie/(bp:Path_Point|bp:Path_Point_Cable)">
- <xsl:copy-of select="."/>
- </xsl:for-each>-->
- <xsl:apply-templates mode="PathsCrossed" select="$Neigh_controll"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:message> WARNING path should be analyzed and aviable in:<xsl:value-of select="concat($edge_paths_with_PE_controll_paths_temp,'/','edge_paths_with_PE_controll.xsl.',@ID_WAY,'.xml')"/> , because logest first than shortest: for : <xsl:value-of select="concat($edge_paths_with_PE_controll_temp,'/','edge_paths_with_PE_controll.xsl.',@ID_WAY,'.xml')"/></xsl:message>
- <Warning> WARNING path should be analyzed and aviable in: <xsl:value-of select="concat($edge_paths_with_PE_controll_paths_temp,'/','edge_paths_with_PE_controll.xsl.',@ID_WAY,'.xml')"/> , because logest first than shortest: for : <xsl:value-of select="concat($edge_paths_with_PE_controll_temp,'/','edge_paths_with_PE_controll.xsl.',@ID_WAY,'.xml')"/></Warning>
- </xsl:otherwise>
- </xsl:choose>
- </Ways>
- </xsl:for-each-group>
- </PathsCrossed>
- </xsl:variable>
- <xsl:copy-of select="$PathsCrossed"/>
-
-
- <!-- 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[not(@error)]">
- <distance>
- <xsl:attribute name="pos" select="position()"/>
- <xsl:attribute name="not_id" select="@not_id"/>
- <xsl:attribute name="ID_Join" select="@ID_Join"/>
- <xsl:attribute name="len" select="@len"/>
- <xsl:attribute name="id_path" select="@id_path"/>
- <xsl:variable name="Points" select="count(Points)"/>
- <xsl:attribute name="Points" select="$Points"/>
- <xsl:variable name="Ways" select="count(Ways)"/>
- <xsl:attribute name="Ways_count" select="$Ways"/>
- <xsl:choose>
- <xsl:when test="$Ways or $Points">
- <xsl:attribute name="point_count" select="$Points + $Ways"/>
- <!--<xsl:attribute name="NotPoints" select="0"/>--><!-- do Grupowanai potrzebne aby nie liczyc tych w count -->
- <xsl:if test="Ways">
- <!-- sprawdzamy jak sie dowiazuje i ile ma do najblizszego wezla -->
- <xsl:for-each-group select="Ways" group-by="@ID_WAY">
- <PathsCrossed>
- <xsl:attribute name="ID_WAY" select="@ID_WAY"/><xsl:attribute name="debug" select="'created at #163 by parsing Ways'"/>
- <xsl:variable name="Joining_ID_Join_from" select="parent::node()/@ID_Join"/>
- <xsl:choose>
- <xsl:when test="$PathsCrossed/PathsCrossed/Ways[@ID_WAY= current()/@ID_WAY]/(bp:Path_Point)[@ID_Join= $Joining_ID_Join_from]/@pos">
- <xsl:variable name="NeighJoin_pos" select="$PathsCrossed/PathsCrossed/Ways[@ID_WAY= current()/@ID_WAY]/(bp:Path_Point)[@ID_Join= $Joining_ID_Join_from]/@pos"/>
- <xsl:variable name="NeighJoin_pos_distance" select="number($PathsCrossed/PathsCrossed/Ways[@ID_WAY= current()/@ID_WAY]/(bp:Path_Point)[@pos= $NeighJoin_pos]/@distance)"/>
- <xsl:attribute name="NeighJoin_pos" select="$NeighJoin_pos"/>
- <!--<xsl:attribute name="NeighJoin_pos_distance" select="$NeighJoin_pos_distance"/>-->
- <xsl:attribute name="Deb_Cur_ID_WAY" select="@ID_WAY"/>
- <xsl:attribute name="Joining_ID_Join_from" select="$Joining_ID_Join_from"/>
-
- <!-- chk w gore -->
- <xsl:variable name="NeighJoin_way_up_pos" select="max($PathsCrossed/PathsCrossed/Ways[@ID_WAY= current()/@ID_WAY]/(bp:Path_Point)[ number(@pos) < number($NeighJoin_pos) ] /@pos)"/>
- <xsl:choose>
- <xsl:when test="$NeighJoin_way_up_pos">
- <xsl:attribute name="NeighJoin_way_up_pos" select="$NeighJoin_way_up_pos"/>
- <xsl:variable name="NeighJoin_way_up_ID_Join" select="$PathsCrossed/PathsCrossed/Ways[@ID_WAY= current()/@ID_WAY]/(bp:Path_Point)[ @pos=$NeighJoin_way_up_pos] /@ID_Join" />
- <xsl:variable name="NeighJoin_way_up_len" select="number($NeighJoin_pos_distance) - number($PathsCrossed/PathsCrossed/Ways[@ID_WAY= current()/@ID_WAY]/(bp:Path_Point)[ @pos=$NeighJoin_way_up_pos] /@distance) "/>
- <xsl:attribute name="NeighJoin_way_up_len" select="$NeighJoin_way_up_len"/>
- <xsl:attribute name="NeighJoin_way_up_pos" select="$NeighJoin_way_up_pos"/>
- <xsl:attribute name="NeighJoin_way_up_ID_Join" select="$NeighJoin_way_up_ID_Join"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="NeighJoin_way_up_len" select="-1"/>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:variable name="NeighJoin_way_dn_pos" select="min($PathsCrossed/PathsCrossed/Ways[@ID_WAY= current()/@ID_WAY]/(bp:Path_Point)[ number(@pos) > number($NeighJoin_pos) ] /@pos)"/>
- <xsl:choose>
- <xsl:when test="$NeighJoin_way_dn_pos">
- <xsl:variable name="NeighJoin_way_dn_ID_Join" select="$PathsCrossed/PathsCrossed/Ways[@ID_WAY= current()/@ID_WAY]/(bp:Path_Point)[ @pos=$NeighJoin_way_dn_pos] /@ID_Join"/>
- <xsl:variable name="NeighJoin_way_dn_len" select="number($PathsCrossed/PathsCrossed/Ways[@ID_WAY= current()/@ID_WAY]/(bp:Path_Point)[ @pos=$NeighJoin_way_dn_pos] /@distance) - number($NeighJoin_pos_distance) "/>
- <xsl:attribute name="NeighJoin_way_dn_pos" select="$NeighJoin_way_dn_pos"/>
- <xsl:attribute name="NeighJoin_way_dn_ID_Join" select="$NeighJoin_way_dn_ID_Join"/>
- <xsl:attribute name="NeighJoin_way_dn_len" select="$NeighJoin_way_dn_len"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="NeighJoin_way_dn_len" select="-1"/>
- </xsl:otherwise>
- </xsl:choose>
- <!-- chk w dol -->
- <xsl:if test=" number($debug) > 3">
- <debug186>
- <xsl:copy-of select="$PathsCrossed/PathsCrossed/Ways[@ID_WAY= current()/@ID_WAY]"/>
- </debug186>
- </xsl:if>
- </xsl:when>
- <xsl:otherwise>
- <xsl:comment>No connection to other roads found</xsl:comment>
- </xsl:otherwise>
- </xsl:choose>
- </PathsCrossed>
- </xsl:for-each-group>
- </xsl:if>
- </xsl:when>
- <xsl:otherwise><xsl:attribute name="NotPoints" select="1"/>
- <xsl:attribute name="point_count" select="0"/>
- </xsl:otherwise><!-- do Grupowanai potrzebne aby nie liczyc tych w count -->
- </xsl:choose>
-
- </distance>
- </xsl:for-each>
- </EconomicDistanceCut>
- </xsl:variable>
- <xsl:if test="$debug">
- <debug_174>
- <xsl:copy-of select="$EconomicDistanceCut"/>
- </debug_174>
- </xsl:if>
- <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)"/>
- <xsl:copy-of select="@ID_Join"/>
- <!-- suma do poprzedniego pkt tylko dla tych co maja pkt-->
- <xsl:choose>
- <xsl:when test="number(@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 * number(@point_count)"/>
- <xsl:attribute name="cost_dist" select="$cost_dist"/>
- <xsl:attribute name="point_count" select="@point_count"/>
- <xsl:attribute name="Ways_count" select="@Ways_count"/>
- <xsl:choose> <!-- to powinno przeciac grupe ale moze nie? -->
- <xsl:when test="$cost_dist > $PE_Price">
- <xsl:attribute name="cut_by_pe" select="1"/>
- </xsl:when>
- <xsl:otherwise><xsl:attribute name="cut_by_pe" select="0"/></xsl:otherwise>
- </xsl:choose>
- <xsl:attribute name="not_id" select="@not_id"/> <!-- to jest z ID way - way ma 2 pointsy! -->
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when test="number(@Ways_count)>0">
- <xsl:attribute name="point_count" select="@Ways_count"/>
- </xsl:when>
- <xsl:otherwise><xsl:attribute name="point_count" select="0"/></xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:attribute name="id_path" select="@id_path"/>
- <xsl:copy-of select="@point_count"/>
- <xsl:copy-of select="@pos"/><!-- position() -->
- <xsl:copy-of select="@len"/>
- <xsl:copy-of select="@ForceCutByPrice"/>
- <xsl:copy-of select="PathsCrossed"/>
- <!--<xsl:copy-of select="@NotPoints"/>--><!--debug -->
- </distance2>
- </xsl:for-each>
- </EconomicDistanceCut2>
- </xsl:variable>
- <debug_Cut2_183>
- <xsl:copy-of select="$EconomicDistanceCut2"/>
- </debug_Cut2_183>
-
- <xsl:variable name="EconomicDistanceCut2">
- <EconomicDistanceCut2><xsl:attribute name="debug" select="'bez pustych punktow tylko grupowanie'"/>
- <xsl:for-each select="$EconomicDistanceCut2/EconomicDistanceCut2/distance2[number(@point_count) > 0 ]">
- <distance2>
- <xsl:copy-of select="@*"/>
- <xsl:choose>
- <xsl:when test=" position() mod $max_combinate_groups_elements = 0"> <!--- minus puste sum($EconomicDistanceCut/EconomicDistanceCut/distance[ number(@pos) < number(current()/@pos) ]/number(@NotPoints)) ) --><!-- nabija grupe do przeliczenia-->
- <xsl:attribute name="PosCut3Flag" select="1"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="PosCut3Flag" select="0"/>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:copy-of select="PathsCrossed"/>
- </distance2>
- </xsl:for-each>
- </EconomicDistanceCut2>
- </xsl:variable>
-
-
- <xsl:variable name="EconomicDistanceCut2"> <!-- dla potrzeb przegrupowania po iles do wyliczen grup i posortowania -->
- <EconomicDistanceCut2><xsl:attribute name="debug" select="'add mod gr'"/>
- <xsl:for-each select="$EconomicDistanceCut2/EconomicDistanceCut2/distance2"> <!-- [@point_count > 0] -->
- <distance2>
- <xsl:attribute name="PosCut3GrId" select="sum($EconomicDistanceCut2/EconomicDistanceCut2/distance2[ number(@pos) < number(current()/@pos) ]/number(@PosCut3Flag))"/>
- <xsl:copy-of select="@*"/>
- <xsl:copy-of select="PathsCrossed"/>
- </distance2>
- </xsl:for-each>
- </EconomicDistanceCut2>
- </xsl:variable>
-
- <!-- debug -->
- <!--<EconomicDistanceCut2><xsl:attribute name="debug" select="'#183 just show PosCut3GrId data'"/>
- <xsl:for-each select="$EconomicDistanceCut2/EconomicDistanceCut2/distance2">
- <distance2>
- <xsl:attribute name="fl" select="@PosCut3Flag"/>
- <xsl:copy-of select="@PosCut3GrId"/>
- <xsl:copy-of select="@CurSumNotPoints"/>
- <xsl:copy-of select="@NotPoints"/>
- <!-\-<xsl:copy-of select="@pos"/>-\->
- </distance2>
- </xsl:for-each>
- </EconomicDistanceCut2>-->
- <!-- debug -->
- <!--<debug>
- <xsl:copy-of select="$EconomicDistanceCut2"/>
- </debug>-->
-
- <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 lub grupy ilosciowe -->
- <xsl:variable name="PointMatrixGroup">
- <PointMatrixGroup>
- <xsl:for-each-group select="$EconomicDistanceCut2/EconomicDistanceCut2/distance2" group-by="@PosCut3GrId "> <!-- stare : 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="countGr" select="count(current-group())"/>
- <xsl:variable name="bit_max_Pos" select="round(sum( current-group()/@disttopkt ) div ( $PE_Price div 20 ) )"/>
- <xsl:message>Nowa grupa Ways:<xsl:value-of select="@PosCut3GrId"/>; distanceGr=<xsl:value-of select="@PosCut3GrId"/>;elements_cnt_Pos=<xsl:value-of select="$elements_cnt_Pos"/>; @bit_max_Pos=<xsl:value-of select="$bit_max_Pos"/>; @id_path=<xsl:value-of select="@id_path"/>; countGr=<xsl:value-of select="$countGr"/>; point_count_Pos=<xsl:value-of select="sum(current-group()/@point_count)"/>; len_sum=<xsl:value-of select="sum(current-group()/@len)"/> ; distanceBeg/distanceEnd= <xsl:value-of select="min(current-group()/number(@distance))"/>/<xsl:value-of select="max(current-group()/number(@distance))"/>
- </xsl:message>
- <xsl:attribute name="distanceGr" select="@PosCut3GrId "/> <!-- bylo 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)"/><!-- po przesortowaniu z usunieciem wezlow bez skojarzen przylaczy - jest to nieprawdziwe - rzebaa dodac te dane z poprzednich sciezek itp -->
- <xsl:attribute name="LineStringCount" select="count( current-group())"/>
- <xsl:attribute name="len_sum" select="sum(current-group()/@len)"/>
- <xsl:attribute name="distanceBeg" select="min(current-group()/number(@distance))"/>
- <xsl:attribute name="distanceEnd" select="max(current-group()/number(@distance))"/>
- <xsl:attribute name="countGr" select="$countGr"/>
- <!--<xsl:attribute name="GroupPos" select="position()"/>-->
- <xsl:for-each select="current-group()">
- <distance2>
- <xsl:attribute name="PosMatrGroup" select="position()"/>
- <xsl:copy-of select="@*"></xsl:copy-of>
- <xsl:copy-of select="PathsCrossed"/>
- </distance2>
- </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:if test="number($debug) > 3">
- <debug_356>
- <xsl:copy-of select="$PointMatrixGroup"/>
- </debug_356>
- </xsl:if>
- <PointMatrixGroupPE>
- <xsl:for-each select="$PointMatrixGroup/PointMatrixGroup">
- <xsl:for-each select="PointMatrixGroupPos">
- <xsl:variable name="bit_max_Pos" select="@bit_max_Pos"/>
- <xsl:variable name="point_count_Pos" select="@point_count_Pos"/>
- <xsl:variable name="distanceGr" select="@distanceGr"/>
- <PointMatrixGroup>
- <xsl:attribute name="bit_max_Pos" select="$bit_max_Pos"/>
- <xsl:attribute name="point_count_Pos" select="$point_count_Pos"/>
- <xsl:attribute name="distanceGr" select="$distanceGr"/>
- <xsl:attribute name="LineStringCount" select="@LineStringCount"/>
- <xsl:attribute name="len_sum" select="@len_sum"/>
- <xsl:attribute name="point_count_Pos" select="@point_count_Pos"/>
- <xsl:attribute name="distanceBeg" select="@distanceBeg"/>
- <xsl:attribute name="distanceEnd" select="@distanceEnd"/>
- <xsl:message>#239: calc @distanceGr=<xsl:value-of select="$distanceGr"/>; @point_count_Pos=<xsl:value-of select="@point_count_Pos"/>;@LineStringCount ; @len_sum=<xsl:value-of select="@len_sum"/>; @distanceBeg=<xsl:value-of select="@distanceBeg"/>; @distanceEnd=<xsl:value-of select="@distanceEnd"/>;
- </xsl:message>
- <!-- ida kandydaci -->
- <xsl:variable name="candidates">
- <xsl:for-each select="distance2[ @point_count >0 ]"> <!--@point_count >0--> <!-- ( $logic='sorted' and ( ( position() <= $bit_max_Pos and @point_count >0 ) or ( position()=1 and $point_count_Pos > 0 ) ) or position()= last() ) or ( @point_count >0 and $logic='grouped' ) --> <!--( position() <= $bit_max_Pos and @point_count >0 ) or ( position()=1 and $point_count_Pos > 0 ) or position()= last() --> <!-- 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:copy-of select="@ID_Join"/>
- <xsl:attribute name="DebugPosPoint" select="position()"/>
- <xsl:attribute name="PosMatrGroup" select="@PosMatrGroup"/>
- <xsl:attribute name="distanceGr" select="$distanceGr"/>
- <xsl:attribute name="pos" select="@pos"/>
- <xsl:attribute name="len" select="@len"/>
- <xsl:attribute name="distance" select="@distance"/>
- <xsl:attribute name="cost_dist" select="@cost_dist"/>
- <xsl:attribute name="id_path" select="@id_path"/>
- <xsl:attribute name="point_count" select="@point_count"/>
- <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"/>
- <xsl:copy-of select="PathsCrossed"/>
- </bp:Path_Point>
- </xsl:for-each>
- </xsl:variable>
-
-
- <!-- potrzebuje wywolac petle raz, aby sie do niej odniesc drugi raz z poprzednim wynikiem
- $last = A
- - najprosciej przez pliki oszukujac silnik xsl
- - tozsamowsci $ID_Way $distanceGr
- - do edge_paths_with_PE_controll_temp, read z edge_paths_with_PE_controll_temp.alias
- -->
- <xsl:variable name="cache_file_name" select="concat($edge_paths_with_PE_controll_temp,'/odpalam_liczenie_or_nie_',$ID_Way,'_',$distanceGr,'.xml')"/>
- <xsl:variable name="PrevdistanceGr" select="number($distanceGr) - 1"/>
- <xsl:variable name="cache_file_name_previous" select="concat( $edge_paths_with_PE_controll_temp.alias,'/odpalam_liczenie_or_nie_',$ID_Way,'_',$PrevdistanceGr,'.xml')"/>
- <xsl:variable name="poprzednie_odpalam_liczenie_or_nie">
- <xsl:if test="$PrevdistanceGr > 0 ">
- <xsl:copy-of select="doc($cache_file_name_previous)"/>
- </xsl:if>
- </xsl:variable>
- <!--<poprzednie_odpalam_liczenie_or_nie>
- <xsl:attribute name="cache_file_name_previous" select="$cache_file_name_previous"/>
- <xsl:copy-of select="$poprzednie_odpalam_liczenie_or_nie/poprzednie_odpalam_liczenie_or_nie"/>
- </poprzednie_odpalam_liczenie_or_nie>-->
- <xsl:variable name="odpalam_liczenie_or_nie">
- <xsl:choose>
- <xsl:when test="1=1"> <!-- bylo count($candidates/bp:Path_Point) <= $max_combinate_groups_elements and count($candidates/bp:Path_Point)>1-->
- <xsl:variable name="max_bit">
- <xsl:for-each select="1 to count($candidates/bp:Path_Point)"><xsl:value-of select="1"/></xsl:for-each>
- </xsl:variable>
- <odpalam_liczenie>
- <!-- todo dolozyc poprzedni wezel dodany aby mogl od niego zawsze liczyc -->
- <!--<disabled>temporary blad after #410 OK - przeliczony wariant bit=000000010000 ( nr 4095;)
- [xslt] #239: calc @distanceGr=23; @point_count_Pos=19;@LineStringCount ; @len_sum=177; @distanceBeg=5055; @distanceEnd=5475;
- [xslt]
- [xslt] /Users/a.binder/Documents/biuro.biall-net.pl-gitlab-se-2015-02-16.git/SE/dev/php-cli/edge_paths_with_PE_controll.xsl:571: Fatal Error! Cannot convert string to double: ""
- [xslt] Failed to process /Users/a.binder/Documents/biuro.biall-net.pl-gitlab-se-2015-02-16.git/SE/dev/php-cli/edge_joins_filled_paths.xml</disabled>-->
-
- <xsl:variable name="IfPathsCrossed" >
- <xsl:choose>
- <xsl:when test="$candidates/bp:Path_Point/PathsCrossed[@NeighJoin_way_up_ID_Join or @NeighJoin_way_dn_ID_Join]">
- <xsl:message>#534 there are PathsCrossed - allow to decrease -1</xsl:message>
- <xsl:value-of select="0"/>
- </xsl:when>
- <xsl:otherwise><xsl:value-of select="1"/></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:call-template name="calculate_optimum">
- <xsl:with-param name="candidates" select="$candidates"/>
- <xsl:with-param name="elements_cnt" select="count($candidates/bp:Path_Point)"/>
- <xsl:with-param name="max_bit" select="$max_bit"/>
- <xsl:with-param name="poprzednie_odpalam_liczenie_or_nie" select="$poprzednie_odpalam_liczenie_or_nie/poprzednie_odpalam_liczenie_or_nie"/>
- <xsl:with-param name="variant" select="$IfPathsCrossed"/>
- </xsl:call-template>
- </odpalam_liczenie>
- </xsl:when>
- <xsl:otherwise>
- <xsl:message terminate="yes">#440 niewlasciwe wyzwlowneie - powinno byc domyslnie when </xsl:message>
- <xsl:for-each select="$candidates/bp:Path_Point">
- <bp:Path_Point>
- <xsl:copy-of select="@*"/>
- <xsl:attribute name="bin_pos" select="1"/>
- </bp:Path_Point>
- </xsl:for-each>
- <!--<xsl:copy-of select="$candidates"></xsl:copy-of>-->
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:if test="number($debug) > 0">
- <debug423>
- <xsl:attribute name="liczenie_dla"/>
- <candidates>
- <xsl:copy-of select="$candidates"/>
- </candidates>
- <poprzednie_odpalam_liczenie_or_nie>
- <xsl:copy-of select="$poprzednie_odpalam_liczenie_or_nie"/>
- </poprzednie_odpalam_liczenie_or_nie>
- </debug423>
- </xsl:if>
- <xsl:copy-of select="$odpalam_liczenie_or_nie"/>
- <xsl:result-document href="{$cache_file_name}"> <!-- zapisanie do cache, aby odczytac w kolejnej petli-->
- <poprzednie_odpalam_liczenie_or_nie>
- <xsl:for-each select="$odpalam_liczenie_or_nie/odpalam_liczenie/koniec_wariantow/bp:Path_Point">
- <xsl:if test="position() = last()">
- <xsl:copy-of select="."/>
- </xsl:if>
- </xsl:for-each>
- <nizej_zwykly></nizej_zwykly>
- <xsl:for-each select="$odpalam_liczenie_or_nie/bp:Path_Point">
- <xsl:if test="position() = last()">
- <xsl:copy-of select="."/>
- </xsl:if>
- </xsl:for-each>
- <!--<xsl:copy-of select="$odpalam_liczenie_or_nie/odpalam_liczenie/koniec_wariantow/bp:Path_Point"/>
- <xsl:copy-of select="$odpalam_liczenie_or_nie/bp:Path_Point"/>-->
- </poprzednie_odpalam_liczenie_or_nie>
- </xsl:result-document>
- </PointMatrixGroup>
- </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:template match="edge_paths_with_PE_controll|Path|PointMatrixGroupPE|PointMatrixGroup|odpalam_liczenie|koniec_wariantow" mode="PathsCrossed">
- <xsl:apply-templates mode="PathsCrossed"/>
- </xsl:template>
- <xsl:template match="bp:Path_Point" mode="PathsCrossed"> <!-- nie potrzebujemy kabli ! bp:Path_Point_Cable-->
- <xsl:copy-of select="."/>
- </xsl:template>
- <xsl:template match="*|text()" mode="PathsCrossed"/>
-
-
-
-
- <xsl:template name="calculate_optimum">
- <xsl:param name="candidates" required="yes"/>
- <xsl:param name="elements_cnt" required="yes"/>
- <xsl:param name="variant" select="1"/>
- <xsl:param name="max_bit" required="yes"/>
- <xsl:param name="best_cost"/><xsl:param name="best_variant"/>
- <xsl:param name="poprzednie_odpalam_liczenie_or_nie"/>
- <!-- do jednorazowego wyzwolenia przez fukcje, aby tylko raz odjelo wariant zerowy -->
-
-
- <xsl:variable name="bit" select=" string-join(bp:decimalToBitFill($variant,$elements_cnt),'')"/>
-
- <xsl:variable name="cand_to_calc">
- <xsl:for-each select="$candidates/bp:Path_Point">
- <!--<xsl:sort select="number(@distance)"/>-->
- <bp:Path_Point>
- <!--<xsl:attribute name="bit" select="$bit"/>-->
- <xsl:attribute name="bin_pos" select="substring($bit, position(),1)"/>
- <xsl:copy-of select="@*"/>
- <!--<xsl:copy-of select="bp:Path_Point"/>-->
- <xsl:copy-of select="PathsCrossed"/>
- </bp:Path_Point>
- </xsl:for-each>
- </xsl:variable>
- <!-- debug -->
- <xsl:if test=" number($debug) > 2">
- <variant><xsl:attribute name="variant" select="$variant"/>
- <xsl:attribute name="cur_bit" select="$bit"/>
- <xsl:attribute name="best_cost" select="$best_cost"/>
- <xsl:attribute name="best_variant" select="$best_variant"/>
- <xsl:copy-of select="$cand_to_calc"/>
- </variant>
- </xsl:if>
- <xsl:variable name="calc_cost_way">
- <xsl:call-template name="calc_cost_way">
- <xsl:with-param name="cand_to_calc" select="$cand_to_calc"/>
- <xsl:with-param name="poprzednie_odpalam_liczenie_or_nie" select="$poprzednie_odpalam_liczenie_or_nie"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:variable name="cost_sum">
- <costs>
- <xsl:attribute name="Cable_Price" select="sum($calc_cost_way/cost/@Cable_Price)" />
- <xsl:attribute name="PE_Price" select="sum($calc_cost_way/cost/@PE_Price)"/>
- <xsl:attribute name="Price" select="sum($calc_cost_way/cost/@Price)"/>
- <xsl:copy-of select="$calc_cost_way"/>
- </costs>
- </xsl:variable>
- <xsl:if test="number($debug) >2 "><xsl:copy-of select="$cost_sum"/></xsl:if>
- <xsl:variable name="best">
- <xsl:variable name="cur_Price" select="$cost_sum/costs/@Price"/>
- <xsl:choose>
- <xsl:when test="number($cur_Price) < number($best_cost) or not($best_cost) ">
- <best>
- <xsl:attribute name="best_cost" select="$cur_Price"/>
- <xsl:attribute name="best_variant" select="$bit"/>
- </best>
- </xsl:when>
- <xsl:otherwise>
- <best>
- <xsl:attribute name="best_cost" select="$best_cost"/>
- <xsl:attribute name="best_variant" select="$best_variant"/>
- </best>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:if test=" number($debug) > 3 ">
- <xsl:copy-of select="$best"/>
- <xsl:message>#688 (C$<xsl:value-of select="$cost_sum/costs/@Cable_Price"/>+P$<xsl:value-of select="$cost_sum/costs/@PE_Price"/> =<xsl:value-of select="$cost_sum/costs/@Price"/>) v:<xsl:value-of select="$variant"/>; b:<xsl:value-of select="$bit"/>; bestV=<xsl:value-of select="$best_variant"/>; bestC=<xsl:value-of select="$best_cost"/> </xsl:message>
- </xsl:if>
- <xsl:choose>
- <xsl:when test="$bit = $max_bit">
- <koniec_wariantow>
- <xsl:message>#410 OK - cost:<xsl:value-of select="$best_cost"/>; bit=<xsl:value-of select="$best_variant"/> ( nr <xsl:value-of select="$variant"/>;) </xsl:message>
- <xsl:attribute name="best_variant" select="$best_variant"/>
- <!-- trzeba przygotowac stary set dla best do pokazania kabli -->
- <xsl:variable name="cand_to_calc_best">
- <xsl:for-each select="$candidates/bp:Path_Point">
- <!--<xsl:sort select="@distance"/>-->
- <bp:Path_Point>
- <!--<xsl:attribute name="bit" select="$bit"/>-->
- <xsl:attribute name="bin_pos" select="substring($best_variant, position(),1)"/>
- <xsl:copy-of select="@*"/>
- <xsl:copy-of select="bp:Path_Point"/>
- </bp:Path_Point>
- </xsl:for-each>
- </xsl:variable>
- <xsl:variable name="show_cables">
- <xsl:call-template name="calc_cost_way">
- <xsl:with-param name="cand_to_calc" select="$cand_to_calc_best"/>
- <xsl:with-param name="poprzednie_odpalam_liczenie_or_nie" select="$poprzednie_odpalam_liczenie_or_nie"/>
- <xsl:with-param name="show_cables" select="1"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:for-each select="$candidates/bp:Path_Point">
- <!--<xsl:sort select="number(@distance)"/>-->
- <xsl:if test="substring($best_variant, position(),1)='1'"><!-- jak wystawiony w wariancie-->
- <bp:Path_Point>
- <xsl:attribute name="bit" select="$best_variant"/>
- <xsl:attribute name="bin_pos" select="substring($best_variant, position(),1)"/>
- <xsl:copy-of select="@*"/>
- <xsl:attribute name="Price" select="$best_cost"/>
- <xsl:copy-of select="bp:Path_Point"/>
- </bp:Path_Point>
- </xsl:if>
- <xsl:if test="substring($best_variant, position(),1)='0'"><!-- wyznaczenie od razu kabla -->
- <bp:Path_Point_Cable>
- <xsl:attribute name="bit" select="$best_variant"/>
- <xsl:attribute name="bin_pos" select="substring($best_variant, position(),1)"/>
- <xsl:copy-of select="@*"/>
- <xsl:attribute name="Price" select="$best_cost"/>
- <xsl:attribute name="Target_ID_Join" select="$show_cables/cost[@ID_Join = current()/@ID_Join]/@Target_ID_Join"/>
- <!-- todo do jakiego Join zostal przybity -->
- <xsl:copy-of select="bp:Path_Point"/>
- <!-- <xsl:if test="$debug">-->
- <debug_show_cables>
- <xsl:copy-of select="$show_cables/cost[@ID_Join= current()/@ID_Join]"/>
- </debug_show_cables>
- <!--</xsl:if>-->
- </bp:Path_Point_Cable>
- </xsl:if>
- </xsl:for-each>
- </koniec_wariantow>
- </xsl:when>
- <xsl:otherwise>
- <!--<xsl:if test="$variant < 10 ">--><!-- debug limit -->
- <xsl:call-template name="calculate_optimum">
- <xsl:with-param name="candidates" select="$candidates"/>
- <xsl:with-param name="max_bit" select="$max_bit"/>
- <xsl:with-param name="variant" select="$variant + 1"/>
- <xsl:with-param name="elements_cnt" select="$elements_cnt"/>
- <xsl:with-param name="best_cost" select="$best/best/@best_cost"/>
- <xsl:with-param name="best_variant" select="$best/best/@best_variant"/>
- <xsl:with-param name="poprzednie_odpalam_liczenie_or_nie" select="$poprzednie_odpalam_liczenie_or_nie"/>
- </xsl:call-template>
- <!--</xsl:if>-->
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template name="calc_cost_way"><!-- do wyliczenia ile wyjda kable w takiej konfiguracji -->
- <xsl:param name="cand_to_calc" required="yes"/>
- <xsl:param name="poprzednie_odpalam_liczenie_or_nie"/>
- <xsl:param name="show_cables"/><!-- do ostatneigo wyzwolenia w koniec_wariantow aby pokazac skad dokad sa kable-->
- <xsl:variable name="candidates_merged_with_poprzednie">
- <xsl:for-each select="$poprzednie_odpalam_liczenie_or_nie/bp:Path_Point">
- <bp:Path_Point>
- <xsl:attribute name="poprzednia_grupa" select="true()"/>
- <xsl:copy-of select="@*"/>
- <xsl:attribute name="distance_Neigh" select="0"/>
- </bp:Path_Point>
- </xsl:for-each>
- <xsl:for-each select="$cand_to_calc/bp:Path_Point">
- <bp:Path_Point>
- <xsl:copy-of select="@*"/>
- <xsl:attribute name="distance_Neigh" select="0"/>
- </bp:Path_Point>
- </xsl:for-each>
- <!-- dorzucenie Crossed -->
- <xsl:for-each select="$cand_to_calc/bp:Path_Point">
- <xsl:variable name="PathCrossLast" select="position() = last()"/>
- <xsl:variable name="PathCrossFirst" select="position() = 1"/>
- <xsl:for-each select="PathsCrossed[@NeighJoin_way_up_ID_Join]">
- <!--<xsl:message>#681: PathsCrossed up $PathCrossLast=<xsl:value-of select="$PathCrossLast"/>; to up:<xsl:value-of select="@NeighJoin_way_up_ID_Join"/>; @NeighJoin_way_up_len=<xsl:value-of select="@NeighJoin_way_up_len"/></xsl:message>-->
- <bp:Path_Point>
- <xsl:attribute name="poprzednia_grupa" select="true()"/>
- <xsl:attribute name="bin_pos" select="1"/>
- <xsl:attribute name="ID_Join" select="@NeighJoin_way_up_ID_Join"/>
- <xsl:choose>
- <xsl:when test="$PathCrossLast">
- <!--<xsl:message>adding distance to local from:<xsl:value-of select="number(parent::node()/@distance)"/>; to:<xsl:value-of select="number(parent::node()/@distance) + number(@NeighJoin_way_up_len)"/>; </xsl:message>-->
- <xsl:attribute name="distance" select="number(parent::node()/@distance) + number(@NeighJoin_way_up_len)"/>
- </xsl:when>
- <xsl:when test="$PathCrossFirst">
- <!--<xsl:message>reducing distance to local:from:<xsl:value-of select="number(parent::node()/@distance)"/>; to: <xsl:value-of select="number(parent::node()/@distance) - number(@NeighJoin_way_up_len)"/>; </xsl:message>-->
- <xsl:attribute name="distance" select="number(parent::node()/@distance) - number(@NeighJoin_way_up_len)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:message terminate="yes">#720 dowiazanie Crossed w srodku grupy</xsl:message>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:attribute name="pos" select="-1"/>
- </bp:Path_Point>
- </xsl:for-each>
- </xsl:for-each>
- <xsl:for-each select="$cand_to_calc/bp:Path_Point">
- <xsl:variable name="PathCrossLast" select="position() = last()"/>
- <xsl:for-each select="PathsCrossed[@NeighJoin_way_dn_ID_Join]">
- <!--<xsl:message>#681: PathsCrossed dwn $PathCrossLast=<xsl:value-of select="$PathCrossLast"/>; to up:<xsl:value-of select="@NeighJoin_way_dn_len"/>; @distance=<xsl:value-of select="@NeighJoin_way_dn_len"/>; </xsl:message>-->
- <bp:Path_Point>
- <xsl:attribute name="poprzednia_grupa" select="true()"/>
- <xsl:attribute name="bin_pos" select="1"/>
- <xsl:attribute name="ID_Join" select="@NeighJoin_way_dn_ID_Join"/>
- <xsl:choose>
- <xsl:when test="$PathCrossLast">
- <xsl:message>adding distance to local:<xsl:value-of select="number(parent::node()/@distance)"/>== <xsl:value-of select="number(parent::node()/@distance) + number(@NeighJoin_way_dn_len)"/>; </xsl:message>
- <xsl:attribute name="distance" select="number(parent::node()/@distance) + number(@NeighJoin_way_dn_len)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:message>reducing distance to local:<xsl:value-of select="number(parent::node()/@distance)"/>== <xsl:value-of select="number(parent::node()/@distance) - number(@NeighJoin_way_dn_len)"/>; </xsl:message>
- <xsl:attribute name="distance" select="number(parent::node()/@distance) - number(@NeighJoin_way_dn_len)"/>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:attribute name="pos" select="-1"/>
- </bp:Path_Point>
- </xsl:for-each>
- </xsl:for-each>
- <!--<xsl:copy-of select="$cand_to_calc/bp:Path_Point"/>-->
- </xsl:variable>
- <xsl:if test="number($debug) >1">
- <candidates_merged_with_poprzednie>
- <cand_to_calc><xsl:copy-of select="$cand_to_calc"/></cand_to_calc>
- <poprzedniee><xsl:copy-of select="$poprzednie_odpalam_liczenie_or_nie/poprzednie_odpalam_liczenie_or_nie"/></poprzedniee>
- <merged><xsl:copy-of select="$candidates_merged_with_poprzednie"/></merged>
- </candidates_merged_with_poprzednie>
- <xsl:message>calc_cost_way: calc <xsl:copy-of select="$candidates_merged_with_poprzednie//node()/@ID_Join"/></xsl:message>
- </xsl:if>
- <xsl:for-each select="$candidates_merged_with_poprzednie/bp:Path_Point"> <!-- bylo cand_to_calc -->
- <xsl:sort select="number(@distance)"/>
- <!--<xsl:message>#764 test @distance=<xsl:value-of select="@distance"/>; z @bin_pos=<xsl:value-of select="@bin_pos"/>; @distance=<xsl:value-of select="@distance"/>;@id_path=<xsl:value-of select="@id_path"/> </xsl:message>-->
- <xsl:variable name="CurDist" select="@distance"/> <!-- do wykorzystania w zalaeznosciach z jednej drogi do przylaczonej -->
- <xsl:choose>
- <xsl:when test="@poprzednia_grupa">
- <cost>
- <xsl:attribute name="Cable_Price" select="0"/>
- <xsl:attribute name="PE_Price" select="0"/>
- <xsl:attribute name="Price" select="0"/>
- <xsl:attribute name="debug" select="'ignore by last DistGroup @poprzednia_grupa'"/>
- </cost>
- </xsl:when>
- <!--<xsl:when test="number(string-length(@bin_pos))=0">
- <xsl:message>#768 debug @bin_pos=<xsl:value-of select="@bin_pos"/>; </xsl:message>
- </xsl:when>-->
- <xsl:when test="@bin_pos=0"><!-- szukamy gdzie ma najblizej i za ile -->
- <xsl:variable name="way_up_id" select="max($candidates_merged_with_poprzednie/bp:Path_Point[@bin_pos=1 and number(@distance) < current()/number(@distance )]/number(@ID_Join))"/>
- <!--<xsl:variable name="ID_Join_up" select="$candidates_merged_with_poprzednie/bp:Path_Point[@id_path =$way_up_id ]/@ID_Join"/>-->
- <xsl:variable name="way_up_len" >
- <xsl:choose>
- <xsl:when test="$way_up_id">
- <xsl:value-of select="number( current()/@distance) - number($candidates_merged_with_poprzednie/bp:Path_Point[@ID_Join=$way_up_id]/@distance)"/>
- </xsl:when>
- <xsl:otherwise><xsl:value-of select="-1"/></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="way_dn_id" select="max($candidates_merged_with_poprzednie/bp:Path_Point[@bin_pos=1 and number(@distance) > current()/number(@distance) ]/number(@ID_Join)) " />
- <!--<xsl:variable name="ID_Join_dn" select="$candidates_merged_with_poprzednie/bp:Path_Point[@ID_Join =$way_dn_id ]/@ID_Join"/>-->
- <xsl:variable name="way_dn_len">
- <xsl:choose>
- <xsl:when test="$way_dn_id">
- <xsl:value-of select=" number( $candidates_merged_with_poprzednie/bp:Path_Point[@ID_Join=$way_dn_id]/@distance ) - current()/number(@distance)"/>
- </xsl:when>
- <xsl:otherwise><xsl:value-of select="-1"/></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:choose><!-- czy w gore czy w dol -->
- <xsl:when test=" number($way_up_len) >= number($way_dn_len) and number($way_dn_len) > 0 or $way_up_len=-1"> <!--and not($way_dn_len='NaN') -->
- <cost>
- <xsl:variable name="Cable_Price_sum">
- <xsl:choose>
- <xsl:when test="number(@point_count) > 0 ">
- <xsl:value-of select="$Cable_Price * $way_dn_len * number(@point_count) "/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$Cable_Price * $way_dn_len "/> <!-- todo @point_count -->
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <!-- todo @point_count -->
- <xsl:if test="$show_cables">
- <xsl:attribute name="choosed" select="'down'"/>
- <xsl:attribute name="way_up_id" select="$way_up_id"/>
- <xsl:attribute name="way_up_len" select="$way_up_len"/>
- <xsl:attribute name="way_dn_id" select="$way_dn_id"/>
- <xsl:attribute name="way_dn_len" select="$way_dn_len"/>
- <xsl:attribute name="PE_Price" select="0"/>
- <xsl:attribute name="Target_ID_Join" select="$way_dn_id"/>
- <xsl:attribute name="ID_Join" select="@ID_Join"/>
- <xsl:attribute name="Cable_Price" select="$Cable_Price_sum"/>
- </xsl:if>
- <xsl:attribute name="Price" select="$Cable_Price_sum"/>
- </cost>
- </xsl:when>
- <xsl:otherwise>
- <cost>
- <xsl:variable name="Cable_Price_sum">
- <xsl:choose>
- <xsl:when test="number(@point_count) > 0 ">
- <xsl:value-of select="$Cable_Price * $way_up_len * number(@point_count) "/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$Cable_Price * $way_up_len "/> <!-- todo @point_count -->
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:if test="$show_cables or $debug">
- <xsl:attribute name="Cable_Price" select="$Cable_Price_sum"/> <!-- todo @point_count -->
- <xsl:attribute name="PE_Price" select="0"/>
- <xsl:attribute name="choosed" select="'up'"/>
- <xsl:attribute name="way_up_id" select="$way_up_id"/>
- <xsl:attribute name="way_up_len" select="$way_up_len"/>
- <xsl:attribute name="way_dn_len" select="$way_dn_len"/>
- <xsl:attribute name="Target_ID_Join" select="$way_up_id"/>
- <xsl:attribute name="ID_Join" select="@ID_Join"/>
- </xsl:if>
- <xsl:attribute name="Price" select="$Cable_Price_sum"/>
- </cost>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <cost>
- <xsl:attribute name="Cable_Price" select="0"/>
- <xsl:attribute name="PE_Price" select="$PE_Price"/>
- <xsl:attribute name="Price" select="$PE_Price"/>
- <xsl:attribute name="mial_bin_pos" select="@bin_pos"/>
- </cost>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
- </xsl:template>
-
-
-
-
-
-
-
-
-
-
-
-
- </xsl:stylesheet>
|