| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000 |
- <?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="plamy_prefix" select="'test2'"/>
- <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="concat('edge_paths_with_PE_controll_temp',$plamy_prefix)"/> <!-- cache do przekazywani danych z petli-->
- <xsl:param name="edge_paths_with_PE_controll_temp.alias" select="concat('edge_paths_with_PE_controll_temp.alias',$plamy_prefix)" />
- <xsl:param name="edge_paths_with_PE_controll_paths_temp" select="concat('edge_paths_with_PE_controll_paths_temp',$plamy_prefix)"/> <!-- do przechowywania calych sciezek do PathCrossed-->
- <xsl:param name="edge_joins_filled_paths" select="concat('edge_joins_filled_paths',$plamy_prefix)"/>
- <!-- 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>
- <!-- narzucenie max ilosci grup oraz wyliczenie ile jest -->
- <!--<xsl:variable name="$max_combinate_groups_elements"/>-->
-
- <xsl:variable name="max_combinate_groups_elements_for_group">
- <xsl:variable name="elements_cnt" select="count($EconomicDistanceCut2/EconomicDistanceCut2/distance2[number(@point_count) > number(0) ])"/>
- <xsl:variable name="cost_dist_Cnt" select="count($EconomicDistanceCut2/EconomicDistanceCut2/distance2[ ( number(@cost_dist) > number($PE_Price) ) or number(@len) > ( number($PE_Price) div number($Cable_Price) ) ])"/>
- <xsl:variable name="bit_max" select="round($len div ( $PE_Price div $Cable_Price ) + $cost_dist_Cnt ) + 1"/>
- <xsl:choose>
- <xsl:when test="number($bit_max) < number(3) "> <!-- do przyjecia przez procesor kombinacji-->
- <xsl:message>#296 max_combinate_groups_elements_for_group number($bit_max=<xsl:value-of select="$bit_max"/>) < number(15)</xsl:message>
- <xsl:choose>
- <xsl:when test="number($elements_cnt) > 20">
- <xsl:message>#297 narzucam fixed liczbe 20 z uwagi na $bit_max=<xsl:value-of select="$bit_max"/> < 15 ilosc max = $elements_cnt=<xsl:value-of select="$elements_cnt"/>; </xsl:message>
- <xsl:value-of select="20"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:message>#302 max_combinate_groups_elements_for_group setting to current count - number($elements_cnt=<xsl:value-of select="$elements_cnt"/>); </xsl:message>
- <xsl:value-of select="number($elements_cnt)"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:message>#309 max_combinate_groups_elements_for_group otherwise setting to default $max_combinate_groups_elements=<xsl:value-of select="$max_combinate_groups_elements"/>; </xsl:message>
- <xsl:value-of select="$max_combinate_groups_elements"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <!-- tune max bit-->
- <xsl:variable name="bit_max">
- <xsl:variable name="elements_cnt" select="count($EconomicDistanceCut2/EconomicDistanceCut2/distance2[number(@point_count) > number(0) ])"/>
- <xsl:variable name="cost_dist_Cnt" select="count($EconomicDistanceCut2/EconomicDistanceCut2/distance2[ ( number(@cost_dist) > number($PE_Price) ) or number(@len) > ( number($PE_Price) div number($Cable_Price) ) ])"/>
- <xsl:variable name="bit_max" select="round($len div ( $PE_Price div $Cable_Price ) + $cost_dist_Cnt ) + 1"/>
- <xsl:choose>
- <xsl:when test=" number($bit_max) = number(1)">
- <xsl:value-of select="2"/>
- </xsl:when>
- <xsl:when test=" number($bit_max) = number(0)">
- <xsl:value-of select="2"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$bit_max"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <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_for_group = 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[number(@point_count) > number(0) ])"/><!-- liczba wezlow potencjalnych licbza PE-->
- <xsl:variable name="cost_dist_Cnt" select="count($EconomicDistanceCut2/EconomicDistanceCut2/distance2[ ( number(@cost_dist) > number($PE_Price) ) or number(@len) > ( number($PE_Price) div number($Cable_Price) ) ])"/>
- <xsl:variable name="bit_max" select="round($len div ( $PE_Price div $Cable_Price ) + $cost_dist_Cnt )"/>
- <!-- max licbza PE-->
- <xsl:message>#341Calc $cost_dist_Cnt=<xsl:value-of select="$cost_dist_Cnt"/>; $elements_cnt=<xsl:value-of select="$elements_cnt"/>; $bit_max=<xsl:value-of select="$bit_max"/> ; </xsl:message>
-
-
- <!-- 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()/number(@disttopkt) ) div ( number($PE_Price) div number($Cable_Price) ) )"/>
- <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-->
-
- <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:when test="$poprzednie_odpalam_liczenie_or_nie/poprzednie_odpalam_liczenie_or_nie"><!-- jak jest kolejny nr grupy to tez moze nie byc potrzebny wezel! -->
- <xsl:message>#505 Zakladamy, ze moze nie byc potrzebny wezel w tej grupie, bo jest poprzednia grupa w danych w tej petli!</xsl:message>
- <xsl:value-of select="0"/>
- </xsl:when>
- <xsl:otherwise><xsl:value-of select="1"/></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="max_possible_bit"><!-- produkuje 11111111 -->
- <xsl:for-each select="1 to count($candidates/bp:Path_Point)"><xsl:value-of select="1"/></xsl:for-each>
- </xsl:variable>
- <!-- tune -->
- <xsl:variable name="bit_max_Pos">
- <xsl:choose>
- <xsl:when test="number(@len_sum) > ( number($PE_Price) div number($Cable_Price) ) and number($bit_max_Pos) < 2">
- <xsl:value-of select=" round( (number(@len_sum)) div ( number($PE_Price) div number($Cable_Price) ) + 2 )"/> <!-- jak droga dluzsza od jedn kosztu, to przynajmniej tyle bin_max ile takich odcinkow-->
- </xsl:when>
- <xsl:when test="number($bit_max_Pos) < 2">
- <xsl:value-of select="2"/>
- </xsl:when>
- <xsl:otherwise><xsl:value-of select="round(number($bit_max_Pos))"/></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="$bit_max_Pos"/>
- <xsl:with-param name="max_possible_bit" select="$max_possible_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="max_possible_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 -->
-
- <!-- znajduje kolejny korzystny wariant bit , trzeba to wyzwolic jak jest wiecej jedynek-->
- <xsl:variable name="variant">
- <xsl:variable name="bit" select=" string-join(bp:decimalToBitFill($variant,$elements_cnt),'')"/>
- <xsl:variable name="digits">
- <xsl:for-each select="1 to string-length($bit)">
- <xsl:if test="substring($bit,.,1) = '1'">
- <xsl:value-of select="number(1)"/>
- </xsl:if>
- </xsl:for-each>
- </xsl:variable>
- <xsl:choose>
- <xsl:when test=" string-length($digits) > number($max_bit)">
- <xsl:choose>
- <xsl:when test="$variant = 0">
- <xsl:value-of select="$variant"/><!-- dla sprawdzenia wzajemnych relacji CrossWays -->
- </xsl:when>
- <xsl:when test="$bit = $max_possible_bit">
- <xsl:value-of select="$variant"/><!-- osiagnieto max -->
- <xsl:message>#627 Osiagnieto MAX $bit<xsl:value-of select="$bit"/>; = $max_possible_bit=<xsl:value-of select="$max_possible_bit"/>;</xsl:message>
- </xsl:when>
- <xsl:when test="number($max_bit) >= number($elements_cnt)">
- <xsl:message>#576 olac $max_bit <xsl:value-of select="$max_possible_bit"/> >$elements_cnt=<xsl:value-of select="$elements_cnt"/>; in $variant=<xsl:value-of select="$variant"/>;</xsl:message>
- <xsl:value-of select="number($variant)"/>
- </xsl:when>
- <xsl:when test="number($max_bit) > 0">
- <xsl:if test="$variant mod 2048 = 0 ">
- <xsl:message>#80 try to find next $bit=<xsl:value-of select="$bit"/>; $max_possible_bit=<xsl:value-of select="$max_possible_bit"/>; $max_bit <xsl:value-of select="$max_bit"/> >$elements_cnt=<xsl:value-of select="$elements_cnt"/>; in $variant=<xsl:value-of select="$variant"/>;</xsl:message>
- </xsl:if>
- <!--<xsl:variable name="variant_found" select="bp:next_bit_max(number($variant),$max_bit,$max_possible_bit,0)"/>-->
- <xsl:variable name="variant_found">
- <xsl:call-template name="bp:next_bit_max">
- <xsl:with-param name="variant" select="$variant"/>
- <xsl:with-param name="bit_limit" select="$max_bit"/> <!-- like 6 -->
- <xsl:with-param name="max_possible_bit" select="$max_possible_bit"/><!-- like 1111111 -->
- <xsl:with-param name="loop" select="0"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:value-of select="$variant_found"/>
- <xsl:message>#648 we found next propos new $variant_found=<xsl:value-of select="$variant_found"/> $bit of that: <xsl:value-of select="bp:decimalToBitFill($variant_found,$elements_cnt)"/>; from $max_bit=<xsl:value-of select="$max_bit"/>;</xsl:message>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="number($variant)"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise><xsl:value-of select="$variant"/></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="bit">
- <xsl:choose><!-- funkcja nearest possible bit moze zwrocic zero! -->
- <xsl:when test=" string-length($variant) > 0"><xsl:value-of select="string-join(bp:decimalToBitFill($variant,$elements_cnt),'')"/></xsl:when>
- <xsl:otherwise><xsl:value-of select="$max_possible_bit"/></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:if test=" string-length($bit) = 0"><xsl:message>#650 zerowy $bit ! nie moze byc tak!</xsl:message></xsl:if>
- <xsl:if test="$variant mod 2048 = 0 ">
- <xsl:message>...#625 $variant curr found <xsl:value-of select="$variant"/>; $max_bit=<xsl:value-of select="$max_bit"/>; $bit=<xsl:value-of select="$bit"/>, $elements_cnt=<xsl:value-of select="$elements_cnt"/>;</xsl:message>
- </xsl:if>
- <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_possible_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:if test=" not(contains($best_variant,'1'))"><xsl:message> #739 :-) Prawdopodobnie wykorzystano wezly z poprzedniej grupy lub drogi! </xsl:message></xsl:if>
- <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="max_possible_bit" select="$max_possible_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="no">#720 dowiazanie Crossed w srodku grupy @NeighJoin_way_up_ID_Join=<xsl:value-of select="@NeighJoin_way_up_ID_Join"/>!</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>
|