瀏覽代碼

Merge branch 'master' of bn.git:plabudda/se

Piotr Labudda 9 年之前
父節點
當前提交
a2d3b74edc

+ 143 - 14
SE/dev/php-cli/PE_wariant_bit_table.xsl

@@ -65,30 +65,136 @@
         <xsl:value-of select=" substring($bit,number($pos),1)"/>
     </xsl:function>
     
+    
+    <xsl:template  name="bp:next_bit_max">
+        <xsl:param name="variant" required="yes"/>
+        <xsl:param name="bit_limit" required="yes"/> <!-- like 6 -->
+        <xsl:param name="max_possible_bit" required="yes"/><!-- like 1111111 -->
+        <xsl:param name="loop" required="no"/>
+        <!--<xsl:message>#80 f. v:<xsl:value-of select="$variant"/>;$bit_limit=<xsl:value-of select="$bit_limit"/>;$max_possible_bit=<xsl:value-of select="$max_possible_bit"/>; $loop=<xsl:value-of select="$loop"/>;</xsl:message>-->
+        <xsl:variable name="variant" select="number($variant) + 1"/><!-- dodajemy 1 aby sprawdzic jak wyglada -->
+        <xsl:variable name="curr_bit" select="bp:decimalToBit($variant)"/>
+        <xsl:variable name="digits">
+            <xsl:for-each select="1 to string-length($curr_bit)">
+                <xsl:if test="substring($curr_bit,.,1) = '1'">
+                    <xsl:value-of select="number(1)"/>
+                </xsl:if>
+            </xsl:for-each>
+        </xsl:variable>
+        <xsl:variable name="cur_bit_len" select=" string-length($digits)"/>
+        <!--<xsl:message>#85 debug: $variant=<xsl:value-of select="$variant"/>; $curr_bit=<xsl:value-of select="$curr_bit"/>; $cur_bit_len=<xsl:value-of select="$cur_bit_len"/>; $$bit_limit=<xsl:value-of select="$bit_limit"/>;</xsl:message>-->
+        <xsl:choose>
+            <xsl:when test=" string-length($max_possible_bit) &lt; string-length($curr_bit)"><!-- mamy wieksza liczbe niz limit -->
+                <xsl:value-of select=" $variant - 1 "/>
+            </xsl:when>
+            
+            <xsl:when test="number($loop) &gt; 50000012">
+                <!--<xsl:message>#91 loop:<xsl:value-of select="$loop"/>; hit returning $variant=<xsl:value-of select="$variant"/>; $curr_bit=<xsl:value-of select="$curr_bit"/>;</xsl:message>-->
+                <xsl:value-of select="$variant"/>
+            </xsl:when>
+            <xsl:when test="$curr_bit = $max_possible_bit">
+                <xsl:message>#90 brak kolejnych wariantow $variant=<xsl:value-of select="$variant"/>;$bit_limit=<xsl:value-of select="$bit_limit"/>; $curr_bit=<xsl:value-of select="$curr_bit"/></xsl:message>
+                <xsl:value-of select="$variant"/>
+            </xsl:when>
+            <xsl:when test="number($cur_bit_len) &lt;=  number($bit_limit)">
+                <!--<xsl:variable name="next_bit" select="bp:decimalToBit($variant+1)"/>-->
+                <!--<xsl:message>#104 next <xsl:value-of select="$variant"/></xsl:message>-->
+                <xsl:value-of select="$variant"/>
+            </xsl:when>
+            
+            <xsl:when test="number($cur_bit_len) &gt;  number($bit_limit)">
+                <!--<xsl:variable name="next_bit" select="bp:decimalToBit($variant+1)"/>-->
+                <!--<xsl:message>#104 next <xsl:value-of select="$variant"/></xsl:message>-->
+                <xsl:call-template name="bp:next_bit_max">
+                    <xsl:with-param name="variant" select="$variant"/>
+                    <xsl:with-param name="bit_limit" select="$bit_limit"/> <!-- like 6 -->
+                    <xsl:with-param name="max_possible_bit" select="$max_possible_bit"/><!-- like 1111111 -->
+                    <xsl:with-param name="loop" select="$loop"/>
+                </xsl:call-template>
+            </xsl:when>
+            <!--<xsl:otherwise>
+                <xsl:message terminate="yes">#107 f. else $variant=<xsl:value-of select="$variant"/>; $curr_bit=<xsl:value-of select="$curr_bit"/>; $digits=<xsl:value-of select="$digits"/>;</xsl:message>
+                <xsl:value-of select="$variant"/></xsl:otherwise>-->
+        </xsl:choose>
+    </xsl:template>
+    
+    
+    <xsl:function name="bp:next_bit_max">
+       <!-- for ($i = 1; $i < 1024; $i++) {
+                $bin = decbin($i);
+                $array = str_split($bin);
+                $sum = array_sum($array);
+                if ($sum <= 3) echo str_pad($bin, 10, "0", STR_PAD_LEFT) . " = " . $i . "\n";
+        }-->
+        <xsl:param name="variant" required="yes"/>
+        <xsl:param name="bit_limit" required="yes"/> <!-- like 6 -->
+        <xsl:param name="max_possible_bit" required="yes"/><!-- like 1111111 -->
+        <xsl:param name="loop" required="no"/>
+        <!--<xsl:message>#80 f. v:<xsl:value-of select="$variant"/>;$bit_limit=<xsl:value-of select="$bit_limit"/>;$max_possible_bit=<xsl:value-of select="$max_possible_bit"/>; $loop=<xsl:value-of select="$loop"/>;</xsl:message>-->
+        <xsl:variable name="variant" select="number($variant) + 1"/><!-- dodajemy 1 aby sprawdzic jak wyglada -->
+        <xsl:variable name="curr_bit" select="bp:decimalToBit($variant)"/>
+        <xsl:variable name="digits">
+            <xsl:for-each select="1 to string-length($curr_bit)">
+                <xsl:if test="substring($curr_bit,.,1) = '1'">
+                    <xsl:value-of select="number(1)"/>
+                </xsl:if>
+            </xsl:for-each>
+        </xsl:variable>
+        <xsl:variable name="cur_bit_len" select=" string-length($digits)"/>
+        <xsl:choose>
+            <xsl:when test=" string-length($max_possible_bit)&gt; string-length($curr_bit)">
+                <xsl:value-of select=" $variant - 1 "/>
+            </xsl:when>
+            
+            <xsl:when test="number($loop) &gt; 512">
+                <!--<xsl:message>#91 loop:<xsl:value-of select="$loop"/>; hit returning $variant=<xsl:value-of select="$variant"/>; $curr_bit=<xsl:value-of select="$curr_bit"/>;</xsl:message>-->
+                <xsl:value-of select="$variant"/>
+            </xsl:when>
+            <xsl:when test="$curr_bit = $max_possible_bit">
+                <!--<xsl:message>#90 brak kolejnych wariantow $variant=<xsl:value-of select="$variant"/>;$bit_limit=<xsl:value-of select="$bit_limit"/>; $curr_bit=<xsl:value-of select="$curr_bit"/></xsl:message>-->
+                <xsl:value-of select="$variant"/>
+            </xsl:when>
+            <xsl:when test="number($cur_bit_len) &lt;=  number($bit_limit)">
+                <!--<xsl:variable name="next_bit" select="bp:decimalToBit($variant+1)"/>-->
+                <!--<xsl:message>#104 next <xsl:value-of select="$variant"/></xsl:message>-->
+                <xsl:value-of select="$variant"/>
+            </xsl:when>
+            
+            <xsl:when test="number($cur_bit_len) &gt;  number($bit_limit)">
+                <!--<xsl:variable name="next_bit" select="bp:decimalToBit($variant+1)"/>-->
+                <!--<xsl:message>#104 next <xsl:value-of select="$variant"/></xsl:message>-->
+                <xsl:value-of select="bp:next_bit_max($variant ,$bit_limit,$max_possible_bit,$loop+1)"/>
+            </xsl:when>
+            <!--<xsl:otherwise>
+                <xsl:message terminate="yes">#107 f. else $variant=<xsl:value-of select="$variant"/>; $curr_bit=<xsl:value-of select="$curr_bit"/>; $digits=<xsl:value-of select="$digits"/>;</xsl:message>
+                <xsl:value-of select="$variant"/></xsl:otherwise>-->
+        </xsl:choose>
+    </xsl:function>
+    
     <xsl:template name="PE_wariant_bit_table">
         <xsl:param name="wariant_id" required="yes"/>
         <xsl:param name="elements_cnt" required="yes"/>
         <xsl:param name="bit" required="yes"/>
-        <xsl:param name="bit_limit" required="yes"/>
-        <xsl:variable name="table">
+        <xsl:param name="max_possible_bit" required="yes"/>
+        <!--<xsl:variable name="table">
             <variant>
                 <xsl:for-each select="1 to $elements_cnt">
                     <pos>
                         <xsl:attribute name="pos" select="."/>
-                        <!--<xsl:attribute name="bin_pos" select=" bp:if_bit_pos($bit,.)"/>-->
+                        <!-\-<xsl:attribute name="bin_pos" select=" bp:if_bit_pos($bit,.)"/>-\->
                         <xsl:if test=" string-length($bit) &gt; 0">
                             <xsl:attribute name="bin_pos"  select="substring($bit,.,1)"/>
                         </xsl:if>
-                        <!--<xsl:attribute name="bin_poss" select="$bit"/>-->
-                        <!--<xsl:value-of select="substring($bit,.,1)"/>-->
+                        <!-\-<xsl:attribute name="bin_poss" select="$bit"/>-\->
+                        <!-\-<xsl:value-of select="substring($bit,.,1)"/>-\->
                     </pos>
                 </xsl:for-each>
             </variant>
-        </xsl:variable>
+        </xsl:variable>-->
         
-        <xsl:variable name="sum_bit" select="sum($table/variant/pos/@bin_pos)"/>
+        <!--<xsl:variable name="sum_bit" select="sum($table/variant/pos/@bin_pos)"/>-->
         <!--<xsl:variable name="sum_bit" select="1"/>-->
-        <xsl:choose>
+        <!--<xsl:choose> errory
             <xsl:when test="$sum_bit = $elements_cnt and $sum_bit &lt;= $bit_limit">
                 <variant>
                     <xsl:attribute name="no_more_variants" select="$sum_bit"/>
@@ -114,23 +220,40 @@
                     <xsl:attribute name="bit_limit_hit" select="$sum_bit"/>
                 </variant>
             </xsl:otherwise>
-        </xsl:choose>
+        </xsl:choose>-->
         
     </xsl:template>
     
     <xsl:template name="main">
-        <xsl:call-template name="PE_wariant"/>
+        <!--<xsl:call-template name="PE_wariant"/>-->
+        
+        <xsl:call-template name="bp:next_bit_max">
+            <xsl:with-param name="variant" select="9999999"/>
+            <xsl:with-param name="bit_limit" select="2"/> <!-- like 6 -->
+            <xsl:with-param name="max_possible_bit" select="'111111111111111111'"/><!-- like 1111111 -->
+            <xsl:with-param name="loop" select="0"/>
+        </xsl:call-template>
+        next:
+        
+        <xsl:value-of select="number(999990000999)"/>
+        
+        else
+        
+        <xsl:value-of select="number(9.99990000999E11)+1"/>
+        else
+        <xsl:value-of select=" format-number(number(99999000099999999)+2 ,'#')"/>
     </xsl:template>
     
     
     
     <xsl:template name="PE_wariant">
-        <xsl:param name="elements_cnt" select="20"/>
-        <xsl:param name="bit_max" select="63"/>
+        <xsl:param name="elements_cnt" select="10"/>
+        <xsl:param name="max_possible_bit" select="1111111111"/>
         <xsl:param name="EconomicDistanceCut2"/><!-- tabela do podstawiania danych i wyliczen -->
+        
         <PE_wariant_bit_table>
             <!--<xsl:variable name="no_more_variants" select=" math:power(2,$elements_cnt)"/>-->
-            <xsl:variable name="no_more_variants" select="100"/>
+            <xsl:variable name="no_more_variants" select="6"/>
             <xsl:attribute name="no_more_variants" select="$no_more_variants"/>
             <xsl:for-each select="1 to ($no_more_variants+1)">
             <xsl:variable name="wariant_id" select="."/>
@@ -141,21 +264,27 @@
                             </test>-->
                 <xsl:variable name="bit" select=" string-join(bp:decimalToBitFill(.,$elements_cnt),'')"/>
                 <xsl:variable name="bit2" select=" string-join(bp:decimalToBit($wariant_id),'')"/>
+                <xsl:variable name="bp:next_bit_max" select="bp:next_bit_max($wariant_id,$max_possible_bit,$elements_cnt,0)"/>
                 
             <xsl:variable name="PE_wariant_bit_table">
                 <PE_wariant_bit_table>
                     <xsl:attribute name="wariant_id" select="."/>
                     <xsl:attribute name="bit" select="$bit" />
                     <xsl:attribute name="bit2" select="$bit2" />
+                    <bp:next_bit_max><xsl:attribute name="bit_od"  select=" string-join(bp:decimalToBitFill($bp:next_bit_max,$elements_cnt),'')"/>
+                        <xsl:copy-of select="$bp:next_bit_max"/></bp:next_bit_max>
                     <xsl:call-template name="PE_wariant_bit_table">
                         <xsl:with-param name="wariant_id" select="$wariant_id"/>
                         <xsl:with-param name="elements_cnt" select="$elements_cnt"/>
                         <xsl:with-param name="bit" select="bp:decimalToBitFill($wariant_id,$elements_cnt)"/>
-                        <xsl:with-param name="bit_limit" select="$bit_max"/>
+                        <xsl:with-param name="max_possible_bit" select="$max_possible_bit"/>
                     </xsl:call-template>
                 </PE_wariant_bit_table>
             </xsl:variable>
             <xsl:choose>
+                <xsl:when test="$bp:next_bit_max = $no_more_variants">
+                    No More variants by $bp:next_bit_max hits!
+                </xsl:when>
                 <xsl:when test="$PE_wariant_bit_table/PE_wariant_bit_table/variant[@bit_limit_hit]">
                     <PE_wariant_bit_table>
                         <xsl:attribute name="wariant_id" select="$wariant_id"/>

+ 12 - 1
SE/dev/php-cli/biale_plamy_class_regenerate.php

@@ -3,20 +3,31 @@
 require("biale_plamy_class.php");
 
 $test = new bialePlamy(array("pointsTable"=>"Rozdzielcza_test2_bzyk_punkty_adresowe", "origWaysTable"=>"Rozdzielcza_test2_bzyk_drogi"));
-$test->enableShowProgress();
+//$test->enableShowProgress();
 //$test->loadCache();
 
 
 $test->generateWays();
+echo "\n generateWays complete";
 $test->generateXpoints();
+echo "\n generateJoins complete";
 ////$test->generateJoins();
 $test->generatePrzylacza();
+echo "\n generatePrzylacza complete";
+
 $test->generateWaysLenghts();
+echo "\n generateWaysLenghts complete";
+
 //$test->generateLongWays();
 
 $test->saveCache();
+echo "\n saveCache complete";
+
 $test->saveXML();
+echo "\n saveXML complete";
+
 $test->saveArrays();
+echo "\n saveArrays complete";
 
 
 //echo $test->printArray('joins2ways');

+ 20 - 66
SE/dev/php-cli/biale_put_Cables_to_PE.php

@@ -11,65 +11,8 @@ else require("../../../../SE-production-git/SE/se-lib/bootstrap.php");
 Lib::loadClass("Vendor_Geophp");
 
 
-
-function init_sh_check() {
-    //check if run from bash
-    if(isset($_SERVER["argv"])) {
-        if(@$_SERVER["argv"][1]=='--help') {
-            echo "
-                Options are:
-                php ".$_SERVER["argv"][0]." --check   - control if we have needed tables/data
-                
-                .EOF
-            ";
-        } else if(@$_SERVER["argv"][1]=='--check') { 
-            check();
-        } else echo " bad option, try:
-            php ".$_SERVER["argv"][0]." --help
-            
-            .EOF
-            ";
-    } else {
-        echo "<br> this script could be run from bash e.g. php biale_plamy.php --help <br>" ;
-        check();
-    }
-}
-
-
-
-function check() {
-	echo "<br>\n i run check()";
-    //todo to set arguments to rebuild tables etc:
-    $check_tbls=array('Rozdzielcza_test_bzyk_drogi','Rozdzielcza_test_bzyk_joins','Rozdzielcza_test_bzyk_przylacza_HIST',
-                    'Rozdzielcza_test_bzyk_przylacza','Rozdzielcza_test_bzyk_punkty_adresowe','Rozdzielcza_test_bzyk_ways');
-
-    //$tables =  DB::getPDO()->list_tables();
-    foreach($check_tbls as $tbl) {
-        $query = "select ID from ".$tbl." limit 1 ";
-        echo "<br>\nresult chk for tbl:".$tbl." ;";
-        
-        try{
-            $result = DB::getPDO()->fetchall($query);
-        } catch(Exception $exception) {
-            // return $exception;
-            echo "<br>\n jest blad z tbl:".$tbl." i get sample table structure with data from ../sql/".$tbl.".sql  - it should be manually replaced by correct/newer!";
-            $sql = file_get_contents('../sql/'.$tbl.'.sql');
-            
-            try{
-                $result = DB::getPDO()->fetchall($sql);
-            } catch(Exception $exception2) {
-                echo "<br>\n jest blad dump dla tbl:".$tbl;
-            }
-        } 
-        //	print_r($exception);
-        print_r($result);
-    }
-}
-
-init_sh_check();   
-
-
-$cables_from_joins_to_PE=simplexml_load_file("cables_from_joins_to_PE.xml");
+ 
+$cables_from_joins_to_PE=simplexml_load_file('cables_from_joins_to_PE.xml');
 $cables_from_joins_to_PE->registerXPathNamespace('bp', 'https://procesy5.pl/biale_plamy-schema.xsd');
 /*
 	
@@ -112,11 +55,11 @@ $cables_from_joins_to_PE->registerXPathNamespace('bp', 'https://procesy5.pl/bial
             <bp:Path_Point Pos="20" X="18.955739759724" Y="51.611953909961"/>
             <LINESTRING>LINESTRING (18.960657743695 51.612137008899, 18.960110541501 51.612105643896, 18.959774447246 51.612086379359, 18.959754322927 51.612085225856, 18.959645426785 51.612078984054, 18.959455431877 51.612068093763, 18.959126615445 51.612049246382, 18.958655233785 51.612022227326, 18.958386790309 51.612006840454, 18.957723493448 51.611968821038, 18.957421446031 51.611951508026, 18.9573044 51.611944799082, 18.956794400864 51.611932376808, 18.9566352 51.611928499082, 18.955813488168 51.611951817689, 18.955739759724 51.611953909961)</LINESTRING>
          </detect_next_PE>
-         
                           
 	
 	 */
 //print_r($edge_joins);
+
 $cables_from_joins_to_PE_arr=array();
 $id_j=0;
 foreach($cables_from_joins_to_PE->xpath('cable_to_PE_to_be_calculated') as $child)  { //cable_to_PE_to_be_calculated
@@ -146,7 +89,21 @@ foreach($cables_from_joins_to_PE->xpath('cable_to_PE_to_be_calculated') as $chil
 		   $cables_from_joins_to_PE_arr[$id_j]['Joins']=$Joins;
 		   $cables_from_joins_to_PE_arr[$id_j]['ID_Way']=$ID_Way;
 		   $cables_from_joins_to_PE_arr[$id_j]['ID_Point']=$ID_Point;
-	   }
+		   
+		   
+		    foreach($Path_Point_xml->xpath('detect_next_PE') as $detect_next_PE ) {
+		   
+			   		foreach($detect_next_PE->attributes() as $a=>$b) {
+				   		if($a=='len') $len=$b[0];
+				   		if($a=='PE_ID_Join') $PE_ID_Join=$b[0];		   
+		   			}
+		   			settype($len, "integer");
+		   			settype($PE_ID_Join, "integer");
+		   			
+		   	   $cables_from_joins_to_PE_arr[$id_j]['len']=$len;
+			   $cables_from_joins_to_PE_arr[$id_j]['PE_ID_Join']=$PE_ID_Join;
+			   }
+			}
 }
 
 echo "\n<br>#150 cables_from_joins_to_PE_arr";
@@ -159,9 +116,9 @@ unset($ID_Way);
 
 foreach($cables_from_joins_to_PE_arr as $id_j=>$Path_Point_val) {
 		
-		$sql_Path_Point_val="insert into Rozdzielcza_test_bzyk_Cables_to_PE (the_geom,ID_Way,ID_Point)
+		$sql_Path_Point_val="insert into Rozdzielcza_test_bzyk_Cables_to_PE (the_geom,ID_Way,ID_Point,len,PE_ID_Join)
 		     values (ST_GeomFromText('".$Path_Point_val['LINESTRING']."'),'".$Path_Point_val['ID_Way']."',
-		     '".$Path_Point_val['ID_Point']."'   )   ";
+		     '".$Path_Point_val['ID_Point']."' ,'".$Path_Point_val['len']."','".$Path_Point_val['PE_ID_Join']."'  )   ";
 		    echo "#216Query path ins:: ".$sql_Path_Point_val."  ";
 		    //if(strlen($edge_joins_filled_paths[$ID_Way]['asText'])>2)
 		    if(strlen($Path_Point_val['LINESTRING'])>1) 
@@ -171,6 +128,3 @@ foreach($cables_from_joins_to_PE_arr as $id_j=>$Path_Point_val) {
 			
 	
 }
-
-
-

+ 279 - 56
SE/dev/php-cli/build__biale_plamy.xml → SE/dev/php-cli/build.xml

@@ -1,13 +1,48 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project
     xmlns:bp="https://procesy5.pl/biale_plamy-schema.xsd"
-    basedir="." name="biale_plamy-generate_data" default="biale_plamy-generate_data">
-    <!-- 
+    basedir="." name="biale_plamy-generate_data" default="default">
     
     
-    -->
+    <tstamp><format property="TODAY_UK" pattern="yyyy-mm-dd"/></tstamp>
+   
+   
+    
+    <property name="bypass_errors" value="1"/><!-- to continue transform even with errors -->
+    <property name="build.log" value="build.log"/><property name="build.log.old" value="${build.log}.old"/>
+    
+    <target name="build_log_exists">
+        
+        <condition taskname="build.log.old_file"  property="build_log_exists" value="tak">
+            <!--<echo>sprawdzam czy jest ${build.log} </echo>-->
+            <available file="${build.log}" filepath="." />
+        </condition>
+    </target>
+    
+    <target name="build.log.old_file" depends="build_log_exists">
+        <!--<move file="${build.log}" tofile="${build.log}.old"/>-->
+        <echo append="true" file="${build.log}"> Archiwizacja loga w dniu  ${TODAY_UK} 
+        </echo>
+        <concat destfile="${build.log.old}" append="true">
+            <filelist dir="." files="${build.log}"/>
+        </concat>
+        <delete file="${build.log}"/>
+    </target>
+    
+    <target name="default">
+        <antcall target="build.log.old_file"/>
+        <antcall target="biale_plamy-generate_data"/>
+    </target>
+    
+    <property name="PE_Price" value="2500"/>
+    <property name="Cable_Price" value="3"/>
+    <property name="max_combinate_groups_elements" value="12"/> <!-- po ile wezlow mamy grupowac do wyliczania kombinacji kosztow -->
+    <property name="logic" value="grouped"/>
+    <!--<xsl:param name="logic" select="'sorted'"/>--> <!-- tutaj robi grupy ale analizyje w grupie tylko wazniejsze/bardziej oblozone wezly -->
+    
+    <property name="mail_inform" value="a.binder@biall-net.pl"/> <!-- to inform about job complete -->
+    
     
-    <!--<property name="biale_plamy-prepare_sql_data.php" value="biale_plamy-prepare_sql_data.php"/>-->
     <property name="biale_plamy_class_regenerate.php" value="biale_plamy_class_regenerate.php"/>
     
     <property name="ways_as_Text_z_ID_xml.xsl" value="ways_as_Text_z_ID_xml.xsl"/>
@@ -19,31 +54,42 @@
         <property name="points2ID_Way.xml" value="points2ID_Way.xml"/>
         <property name="ways2drogi.xml" value="ways2drogi.xml"/><!--<property name="ways_2ID_Way.xml" value="ways_2ID_Way.xml"/>-->
         
-        <property name="points2joins.xml" value="points2joins.xml"/>
+            <property name="points2joins.xml" value="points2joins.xml"/>
             <property name="ways2joins.xml" value="ways2joins.xml"/>
              <property name="ways_asText.xml" value="ways_asText.xml"/>
     
         <property name="waysLengths.xmll" value="waysLengths.xml"/>
             <property name="joins2ways_z_ID_Way.xsl" value="joins2ways_z_ID_Way.xsl"/>
              <property name="joins2ways_z_ID_Way.xml" value="joins2ways_z_ID_Way.xml"/>
+                <property name="joins2ways_z_ID_Way_tempdir" value="joins2ways_z_ID_Way"/><!-- do trzymania tempow - nie wiadomo czy potrzebne bo duzo plikow -->
             <property name="biale_plamy_joins2ways_do_paths.xsl" value="biale_plamy_joins2ways_do_paths.xsl"/>
         
             <property name="edge_joins_filled_paths_make.xsl" value="edge_joins_filled_paths_make.xsl"/>
-            
+            <property name="biale_put_xml_paths_to_mysql.php" value="biale_put_xml_paths_to_mysql.php"/>
     
         <property name="points_asText.xml" value="points_asText.xml"/>
-        <property name="points2joins.xml" value="points2joins.xml"/>
+        
         <property name="edge_joins.xml" value="edge_joins.xml"/>
         
             <property name="joins_asText_xml.xsl" value="joins_asText_xml.xsl"/>
             <property name="joins_asText_xml.xml" value="joins_asText_xml.xml"/> 
             <!-- sciezki -->
             <property name="edge_joins_filled_paths.xml" value="edge_joins_filled_paths.xml"/>
+             <property name="edge_joins_filled_paths" value="edge_joins_filled_paths"/> <!-- katalog do zapisywania sciezek -->
+              
+              
+              
+          
+            <property name="build_edge_paths_with_PE_controll_loop.xml" value="build_edge_paths_with_PE_controll_loop.xml"/>
+             <property name="build_edge_paths_with_PE_controll_loop.xsl" value="build_edge_paths_with_PE_controll_loop.xsl"/>
+                <property name="edge_paths_with_PE_controll_to_PE_collection.xsl" value="edge_paths_with_PE_controll_to_PE_collection.xsl"/>
     
             <property name="edge_paths_with_PE.xsl" value="edge_paths_with_PE.xsl"/><!-- stary-->
                 <property name="edge_paths_with_PE_controll_to_PE.xsl" value="edge_paths_with_PE_controll_to_PE.xsl"/>
+    
                 <property name="edge_paths_with_PE_controll.xsl" value="edge_paths_with_PE_controll.xsl"/><!-- nowy point matrix-->   
-                <property name="edge_paths_with_PE_controll_temp" value="edge_paths_with_PE_controll_temp"/> <!-- do oszukania silnika aby korzystac z petli i przekazywac dane do siebie -->
+                <property name="edge_paths_with_PE_controll_temp" value="edge_paths_with_PE_controll_temp"/>
+                <property name="edge_paths_with_PE_controll_paths_temp" value="edge_paths_with_PE_controll_paths_temp"/><!-- do oszukania silnika aby korzystac z petli i przekazywac dane do siebie -->
                 <property name="edge_paths_with_PE_controll_temp.alias" value="edge_paths_with_PE_controll_temp.alias"/>
     
             <property name="edge_paths_with_PE_controll.xml" value="edge_paths_with_PE_controll.xml"/>  
@@ -57,6 +103,52 @@
         
             <property name="biale_put_Cables_to_PE.php" value="biale_put_Cables_to_PE.php"/>
     
+    
+    
+    <!--<include file="${build_edge_paths_with_PE_controll_loop.xml}" optional=""/>-->
+    
+    
+    
+    <target description="shows options for project" name="help">
+        <echo> Generator for telecomunications objects - concentrations points based on constraints of prices of cable and cost of cocentrators (PE).
+            This parameters are set by variables:   Set variables ( ex. sh# ant -DPE_Price=2500 -DCable_Price=3 -Dlogic=grouped PE_and_Cables -Dmax_combinate_groups_elements=12 ) 
+            
+            or
+            # ant -DPE_Price=2500 -DCable_Price=3 -Dlogic=grouped -Dmax_combinate_groups_elements=18 build_edge_paths_with_PE_controll_loop.xml build_edge_paths_with_PE_controll_loop.xml_run edge_paths_with_PE.xml_from_collection biale_plamy_put_PE_to_mysql_php cables_from_joins_to_PE.xml biale_put_Cables_to_PE
+            
+            
+            VARIABLES
+                PE_Price - price per concentration point - default =  ${PE_Price} 
+                Cable_Price - price per one meter of cable - default = ${Cable_Price}
+                max_combinate_groups_elements   - how many combinate points/per one group  default ${max_combinate_groups_elements}
+                    - above 20 will kill CPU ( it is alwasy 2^ {$var}
+                    logic = grouped -  set for grouping every group by param  max_combinate_groups_elements
+                    logic = sorted  - use this option to minimize analyzed points in every group, which is  weighted somehow by cost PE and cable
+                     -  ( default ${logic} )
+            
+            bypass_errors - to continue transform even with errors - default = ${bypass_errors}
+            
+            
+            TARGETS
+            
+            Maintly you should start by generatong data from php script - target: biale_plamy-generate_data
+            but it destroys all cache data. 
+            
+            By target: biale_plamy-just_xsl_PE_cables
+            You just makes files: ${joins2ways_z_ID_Way.xml} ,
+            and by target:  AsTextToXml : 
+                ${ways_as_Text_z_ID_xml.xml}, ${joins_asText_xml.xml}
+                ${edge_joins.xml} , ${edge_joins_filled_paths.xml}   
+            and 
+            also : 
+            by target "PE_and_Cables"
+                  ${edge_paths_with_PE_controll.xml}, ${edge_paths_with_PE.xml}, ${biale_plamy_put_PE_to_mysql_php}
+                  ${cables_from_joins_to_PE.xml}, ${biale_put_Cables_to_PE}
+       
+        </echo>
+        
+    </target>
+    
     <target name="check" >
         <echo message="testuje check"/>
         <condition property="test_if_INPUTxml" taskname="PROCES_TO_DITA_build" value="AVIABLE">
@@ -65,7 +157,8 @@
     </target>
    
     
-    <target name="biale_plamy-generate_data">
+    <target name="biale_plamy-generate_data" description="regenerate data and make all to final">
+        <record name="${build.log}" loglevel="verbose" append="true"/>
         <!-- nowy sposob -->
         <antcall target="biale_plamy_class_regenerate.php"/>  
         
@@ -76,15 +169,7 @@
         
         <delete file="${edge_joins.xml}"/>
         <antcall target="edge_joins.xml"/>
-        
-        <delete file="${edge_joins_filled_paths.xml}"/>
-        <antcall target="edge_joins_filled_paths_make"/>
-        
-        <antcall target="edge_paths_with_PE_controll.xml"/>
-        <antcall target="edge_paths_with_PE.xml"/>
-        
-        <antcall target="biale_plamy_put_PE_to_mysql_php"/>
-        
+       
         <!--<antcall target="biale_plamy_class_findWay.php"/>-->
         <antcall target="PE_and_Cables"/>
     </target>
@@ -102,11 +187,6 @@
        
         <delete file="${edge_joins.xml}"/>
         <antcall target="edge_joins.xml"/>
-        
-        <delete file="${edge_joins_filled_paths.xml}"/>
-        <antcall target="edge_joins_filled_paths_make"/>
-        
-        
         <antcall target="PE_and_Cables"/>
     </target>
     
@@ -144,27 +224,35 @@
     
     
     <target name="check_files_for_PE_and_Cables" >
-        <echo message="czy sa wymagane pliki do wygenerowania samych PE_and_Cables"/>
+        <echo message="czy sa wymagane pliki do wygenerowania samych PE_and_Cables" />
         <condition property="files_PE_and_Cables" taskname="PE_and_Cables" value="AVIABLE">
             <available file="${points2joins.xml}" filepath="." />
-            <available file="${ways2joins.xml}" filepath="." />
+         <!--   <available file="${ways2joins.xml}" filepath="." />
             <available file="${edge_joins_filled_paths.xml}" filepath="." />
             <available file="${points_asText.xml}" filepath="." />
-            <available file="${joins2ways_z_ID_Way.xml}" filepath="." />
+            <available file="${joins2ways_z_ID_Way.xml}" filepath="." />-->
         </condition>
     </target>
     
     
-    <target name="PE_and_Cables">
-        <antcall target="edge_paths_with_PE_controll.xml"/>
-        <antcall target="edge_paths_with_PE.xml"/>
+    <target name="PE_and_Cables" depends="check_files_for_PE_and_Cables">
+        <record name="${build.log}" loglevel="verbose" append="true"/>
+        <delete file="${edge_joins_filled_paths.xml}"/>
+        <antcall target="edge_joins_filled_paths_make"/>
+        <antcall target="biale_put_xml_paths_to_mysql.php"/>
+        <antcall target="build_edge_paths_with_PE_controll_loop.xml"/>
+        <antcall target="build_edge_paths_with_PE_controll_loop.xml_run"/>
+        <antcall target="edge_paths_with_PE.xml_from_collection"/>
         <antcall target="biale_plamy_put_PE_to_mysql_php"/>
+        <!--<antcall target="edge_paths_with_PE_controll.xml"/>--><!-- to rem  -->
+        <!--<antcall target="edge_paths_with_PE_controll.xml"/>-->
         <antcall target="cables_from_joins_to_PE.xml"/>        
         <antcall target="biale_put_Cables_to_PE"/>
     </target>
     
     
     <target name="biale_plamy-prepare_sql_data.php">
+        <record name="${build.log}" loglevel="verbose" append="true"/>
         <echo message="biale_plamy_prepare_mysql_data - przygotowuje punkty xpoint"/>
         <exec executable="php" failonerror="true" dir=".">
             <arg file="${biale_plamy-prepare_sql_data.php}"/>
@@ -179,6 +267,7 @@
         <!--<antcall target="install_in_file_db_query">
             <param name="sql_query" value="select 1+1;"/>
         </antcall>-->
+        <record name="${build.log}" loglevel="verbose" append="true"/>
         <exec executable="php" failonerror="true" dir=".">
             <arg file="${biale_plamy_class_regenerate.php}"/>
         </exec>
@@ -188,6 +277,7 @@
    
    
     <target name="joins2ways_z_ID_Way.xml">
+        <record name="${build.log}" loglevel="verbose" append="true"/>
         <echo message="przygotownie z joins2ways xsl biale_plamy_joins2ways_do_paths.xsl pod katem 1  katem 1-elementowych subarrayow aby zrobic paths out ${joins2ways_z_ID_Way.xml} "/>
         <delete file="${joins2ways_z_ID_Way.xml}"/>
         <xslt basedir="./" style="${joins2ways_z_ID_Way.xsl}" in="${joins2ways.xml}"  destdir="./" out="${joins2ways_z_ID_Way.xml}" >
@@ -197,16 +287,15 @@
                 <!--<attribute name="http://saxon.sf.net/feature/initialTemplate" value="asd"/>-->
             </factory>
             <classpath location="/opt/local/share/java/saxon9he.jar"/>
-            <param name="points2ID_Way.xml"  expression="${ways2drogi.xml}"/>
             <param name="points2joins.xml"  expression="${points2joins.xml}"/>
-            <param name="points2ID_Way.xml"  expression="${ways2drogi.xml}"/>
-            
-            
+            <param name="ways2drogi.xml"  expression="${ways2drogi.xml}"/>
+            <param name="joins2ways_z_ID_Way_tempdir" expression="${joins2ways_z_ID_Way_tempdir}"/>
         </xslt>
     </target>
    
    
     <target name="joins_asText_xml.xml">
+        <record name="${build.log}" loglevel="verbose" append="true"/>
         <echo message="uporzadkowanie  Joins as text aby mialy xmlowe wspolrzedne - out ${joins_asText_xml.xml}"/>
         <delete file="${joins_asText_xml.xml}"/>
         <xslt basedir="./" style="${joins_asText_xml.xsl}" in="${joins_asText.xml}"  destdir="./" out="${joins_asText_xml.xml}" >
@@ -222,6 +311,7 @@
    
    
     <target name="edge_joins.xml">
+        <record name="${build.log}" loglevel="verbose" append="true"/>
         <echo message="przygotownie ${edge_joins.xml} z joins2ways xsl biale_plamy_joins2ways_do_paths.xsl pod katem 1  katem 1-elementowych subarrayow aby zrobic paths "/>
         <delete file="${edge_joins.xml}"/>
         <xslt basedir="./" style="${biale_plamy_joins2ways_do_paths.xsl}" in="${joins2ways_z_ID_Way.xml}"  destdir="./" out="${edge_joins.xml}" >
@@ -237,6 +327,7 @@
    
     <!-- wyznaczenie sciezek do ulozenia PE - dziala -  -->
     <target name="ways_as_Text_z_ID_xml.xml">
+        <record name="${build.log}" loglevel="verbose" append="true"/>
         <echo message="przygotownie ${ways_as_Text_z_ID_xml.xml} z joins2ways xsl biale_plamy_joins2ways_do_paths.xsl pod katem 1  katem 1-elementowych subarrayow aby zrobic paths "/>
          <delete file="${ways_as_Text_z_ID_xml.xml}"/>
          <xslt basedir="./" style="${ways_as_Text_z_ID_xml.xsl}" in="${ways_asText.xml}"  destdir="./" out="${ways_as_Text_z_ID_xml.xml}" >
@@ -249,17 +340,14 @@
              <param name="ways2drogi.xml" expression="${ways2drogi.xml}"/>
              <param name="waysLengths.xml" expression="${waysLengths.xmll}"/>
              <!--<param name="ways2joins.xml"  expression="${ways2joins.xml}"/>-->
-             
          </xslt>
-        
-        
-        
-        
      </target>
     
-    <target name="edge_joins_filled_paths_make">
+    <target name="edge_joins_filled_paths_make" description="przygotowanie sciezek do parsowania przez ${edge_paths_with_PE_controll.xsl}, male sciezki do katalogu ${edge_joins_filled_paths} oraz zbudowanie zadania do build ">
+        <record name="${build.log}" loglevel="verbose" append="true"/>
         <echo message="przygotownie ${edge_joins_filled_paths.xml} z joins2ways xsl biale_plamy_joins2ways_do_paths.xsl pod katem 1  katem 1-elementowych subarrayow aby zrobic paths "/>
         <delete file="${edge_joins_filled_paths.xml}"/>
+        <delete dir="${edge_joins_filled_paths}"/>
         <xslt basedir="./" style="${edge_joins_filled_paths_make.xsl}" in="${edge_joins.xml}"  destdir="./" out="${edge_joins_filled_paths.xml}" >
             <factory name="net.sf.saxon.TransformerFactoryImpl">    
                 <attribute name="http://saxon.sf.net/feature/xinclude-aware" value="true"/>
@@ -271,10 +359,47 @@
             <param name="joins_asText_xml.xml" expression="${joins_asText_xml.xml}"/>
             <param name="ways2joins.xml" expression="${ways2joins.xml}"/>
             <param name="joins2ways_z_ID_Way.xml" expression="${joins2ways_z_ID_Way.xml}"/>
+            <param name="edge_joins_filled_paths" expression="${edge_joins_filled_paths}"/>
+            <param name="bypass_errors" expression="${bypass_errors}"/>
         </xslt>
+
+    </target>
+    
+    <target name="build_edge_paths_with_PE_controll_loop.xml">
+        <!-- zrobimy builda dla edge_path_control -->
+        <record name="${build.log}" loglevel="verbose" append="true"/>
+        <delete file="${build_edge_paths_with_PE_controll_loop.xml}"/>
+        <xslt basedir="./" style="${build_edge_paths_with_PE_controll_loop.xsl}" in="${edge_joins_filled_paths.xml}"  destdir="./" out="${build_edge_paths_with_PE_controll_loop.xml}" >
+            <factory name="net.sf.saxon.TransformerFactoryImpl">    
+                <attribute name="http://saxon.sf.net/feature/xinclude-aware" value="true"/>
+                <!--<attribute name="http://saxon.sf.net/feature/initialMode" value="DITA_PARSE_templ"/>-->
+                <!--<attribute name="http://saxon.sf.net/feature/initialTemplate" value="asd"/>-->
+            </factory>
+            <classpath location="/opt/local/share/java/saxon9he.jar"/>
+            <param name="edge_paths_with_PE_controll_temp" expression="${edge_paths_with_PE_controll_temp}"/>
+            <param name="edge_paths_with_PE_controll_temp.alias" expression="${edge_paths_with_PE_controll_temp.alias}"/>
+            <param name="edge_paths_with_PE_controll.xsl" expression="${edge_paths_with_PE_controll.xsl}"/>
+            <param name="edge_paths_with_PE_controll.xml" expression="${edge_paths_with_PE_controll.xml}"/>
+            <param name="edge_paths_with_PE_controll_paths_temp" expression="${edge_paths_with_PE_controll_paths_temp}"/> <!-- miejsce na temp drogi -->
+            <param name="edge_joins_filled_paths" expression="${edge_joins_filled_paths}"/>
+            <param name="PE_Price" expression="${PE_Price}"/>
+            <param name="Cable_Price" expression="${Cable_Price}"/>
+            <param name="max_combinate_groups_elements" expression="${max_combinate_groups_elements}"/> <!-- po ile wezlow mamy grupowac do wyliczania kombinacji kosztow -->
+            <param name="logic" expression="${logic}"/>
+        </xslt>
+    </target>
+    
+    <target name="build_edge_paths_with_PE_controll_loop.xml_run">
+        <record name="${build.log}" loglevel="verbose" append="true"/>
+        <subant target="edge_paths_with_PE_controll_loop">
+            <file file="build_edge_paths_with_PE_controll_loop.xml"/>
+        </subant>
+        <!--<include file="${build_edge_paths_with_PE_controll_loop.xml}"/>
+        <ant antfile="${build_edge_paths_with_PE_controll_loop.xml}"/>-->
     </target>
     
     <target name="biale_put_xml_paths_to_mysql.php">
+        <record name="${build.log}" loglevel="verbose" append="true"/>
         <echo message="za pomoca ${biale_plamy_class_findWay.php} wkladam plik: ${edge_joins_filled_paths.xml} do bazy mysql "></echo>
         <exec executable="php" failonerror="true" dir=".">
             <arg file="${biale_put_xml_paths_to_mysql.php}"/>
@@ -293,6 +418,7 @@
    
     <!-- postawienie PE po trasach stare-->
     <target name="edge_paths_with_PE.xml_old">
+        <record name="${build.log}" loglevel="verbose" append="true"/>
         <echo message="Wyznaczenie PE na podstawie tras ${edge_paths_with_PE.xml} "/>
         <delete file="${edge_paths_with_PE.xml}"/>
         <xslt basedir="./" style="${edge_paths_with_PE.xsl}" in="${edge_joins_filled_paths.xml}"  destdir="./" out="${edge_paths_with_PE.xml}" >
@@ -302,48 +428,85 @@
                 <!--<attribute name="http://saxon.sf.net/feature/initialTemplate" value="asd"/>-->
             </factory>
             <classpath location="/opt/local/share/java/saxon9he.jar"/>
-            <!--<param name="dita_task_template_file_param" expression="main.dita"/>-->
+            <param name="joins2ways_z_ID_Way.xml" expression="${joins2ways_z_ID_Way.xml}"/>
         </xslt>
     </target>
     <!-- postawienie PE po trasach nowe-->
     <target name="edge_paths_with_PE_controll.xml">
-        <echo message="Wyznaczenie PE na podstawie tras ${edge_paths_with_PE.xml} nowym ${edge_paths_with_PE_controll.xsl} "/>
-        
+        <record name="${build.log}" loglevel="verbose" append="true"/>
+        <echo message="Wyznaczenie PE na podstawie tras ${edge_paths_with_PE.xml} nowym ${edge_paths_with_PE_controll.xsl}
+            z parametrami PE_Price=${PE_Price} , Cable_Price=${Cable_Price}, max_combinate_groups_elements=${max_combinate_groups_elements}, 
+            logic=${logic}. 
+            "/>
         <delete file="${edge_paths_with_PE_controll.xml}"/>
-        
-        <delete dir="${edge_paths_with_PE_controll_temp}"/>
-        <delete dir="${edge_paths_with_PE_controll_temp.alias}"/>
+         <delete dir="${edge_paths_with_PE_controll_temp}"/>
+         <delete dir="${edge_paths_with_PE_controll_temp.alias}"/>
          <mkdir dir="${edge_paths_with_PE_controll_temp}"/>
          <symlink link="${edge_paths_with_PE_controll_temp.alias}" resource="${edge_paths_with_PE_controll_temp}"/>
+                <xslt basedir="./" style="${edge_paths_with_PE_controll.xsl}" in="${edge_joins_filled_paths.xml}"  destdir="./" out="${edge_paths_with_PE_controll.xml}" >
+                   <factory name="net.sf.saxon.TransformerFactoryImpl">    
+                       <attribute name="http://saxon.sf.net/feature/xinclude-aware" value="true"/>
+                       <!--<attribute name="http://saxon.sf.net/feature/initialMode" value="DITA_PARSE_templ"/>-->
+                       <!--<attribute name="http://saxon.sf.net/feature/initialTemplate" value="asd"/>-->
+                   </factory>
+                   <classpath location="/opt/local/share/java/saxon9he.jar"/>
+                   <!--<param name="edge_paths_with_PE.xml" expression="${edge_paths_with_PE.xml}"/>-->
+                   <param name="edge_paths_with_PE_controll_temp" expression="${edge_paths_with_PE_controll_temp}"/>
+                   <param name="edge_paths_with_PE_controll_temp.alias" expression="${edge_paths_with_PE_controll_temp.alias}"/>
+                    <param name="edge_joins_filled_paths" expression="${edge_joins_filled_paths}"/>
+                    <param name="PE_Price" expression="${PE_Price}"/>
+                   <param name="Cable_Price" expression="${Cable_Price}"/>
+                   <param name="max_combinate_groups_elements" expression="${max_combinate_groups_elements}"/> <!-- po ile wezlow mamy grupowac do wyliczania kombinacji kosztow -->
+                   <param name="logic" expression="${logic}"/>
+                    
+                   <!--<xsl:param name="logic" select="'sorted'"/>--> <!-- tutaj robi grupy ale analizyje w grupie tylko wazniejsze/bardziej oblozone wezly -->
+               </xslt>
+    </target>
+    
+    
+    <!--<target name="edge_paths_with_PE_controll_loop">
+        <echo>todo wyzwolic to w petli dla edge_joins_filled_paths posortowanych od najstarszych do najmlodszych plikow</echo>
+        <xmlproperty file="${edge_joins_filled_paths_sorted.xml}"/>  
+        <!-\-<for list="${item.key}" param="item">
+            <sequential>
+                <echo>The item  id is </echo>
+            </sequential>
+        </for>-\->
+        
+    </target>-->
+   
+   
+    <target name="edge_paths_with_PE.xml">
+        <echo message="OLD - edge_paths_with_PE.xml_from_collection!!! teraz uzywac Wyznaczenie PE na podstawie tras ${edge_paths_with_PE.xml} na podstawie ${edge_paths_with_PE_controll.xml} "/>
+        <delete file="${edge_paths_with_PE.xml}"/>
         
-        <xslt basedir="./" style="${edge_paths_with_PE_controll.xsl}" in="${edge_joins_filled_paths.xml}"  destdir="./" out="${edge_paths_with_PE_controll.xml}" >
+        <xslt basedir="./" style="${edge_paths_with_PE_controll_to_PE.xsl}" in="${edge_paths_with_PE_controll.xml}"  destdir="./" out="${edge_paths_with_PE.xml}" >
             <factory name="net.sf.saxon.TransformerFactoryImpl">    
                 <attribute name="http://saxon.sf.net/feature/xinclude-aware" value="true"/>
                 <!--<attribute name="http://saxon.sf.net/feature/initialMode" value="DITA_PARSE_templ"/>-->
                 <!--<attribute name="http://saxon.sf.net/feature/initialTemplate" value="asd"/>-->
             </factory>
             <classpath location="/opt/local/share/java/saxon9he.jar"/>
-            <param name="edge_paths_with_PE.xml" expression="${edge_paths_with_PE.xml}"/>
+            <!--<param name="edge_paths_with_PE.xml" expression="${edge_paths_with_PE.xml}"/>
             <param name="edge_paths_with_PE_controll_temp" expression="${edge_paths_with_PE_controll_temp}"/>
-            <param name="edge_paths_with_PE_controll_temp.alias" expression="${edge_paths_with_PE_controll_temp.alias}"/>
+            <param name="edge_paths_with_PE_controll_temp.alias" expression="${edge_paths_with_PE_controll_temp.alias}"/>-->
         </xslt>
     </target>
    
-   
-    <target name="edge_paths_with_PE.xml">
-        <echo message="Wyznaczenie PE na podstawie tras ${edge_paths_with_PE.xml} na podstawie ${edge_paths_with_PE_controll.xml} "/>
+    <target name="edge_paths_with_PE.xml_from_collection" description="Wyznaczenie PE na podstawie tras ${edge_paths_with_PE.xml} na podstawie ${edge_paths_with_PE_controll.xml} z katalogu kolekcji: ${edge_paths_with_PE_controll_paths_temp} ">
+        <echo message="Wyznaczenie PE na podstawie tras ${edge_paths_with_PE.xml} na podstawie ${edge_paths_with_PE_controll.xml} z katalogu kolekcji: ${edge_paths_with_PE_controll_paths_temp} "/>
         <delete file="${edge_paths_with_PE.xml}"/>
         
-        <xslt basedir="./" style="${edge_paths_with_PE_controll_to_PE.xsl}" in="${edge_paths_with_PE_controll.xml}"  destdir="./" out="${edge_paths_with_PE.xml}" >
+        <!--<fileset id="edge_paths_with_PE.xml_collection" dir="${edge_paths_with_PE_controll_paths_temp}" includes="*.xml"/>-->
+        <xslt basedir="./" style="${edge_paths_with_PE_controll_to_PE_collection.xsl}"  in="${edge_joins.xml}"  destdir="./" out="${edge_paths_with_PE.xml}" >
+            <!--<fileset refid="edge_paths_with_PE.xml_collection"/>-->
             <factory name="net.sf.saxon.TransformerFactoryImpl">    
                 <attribute name="http://saxon.sf.net/feature/xinclude-aware" value="true"/>
                 <!--<attribute name="http://saxon.sf.net/feature/initialMode" value="DITA_PARSE_templ"/>-->
                 <!--<attribute name="http://saxon.sf.net/feature/initialTemplate" value="asd"/>-->
             </factory>
+            <param name="edge_paths_with_PE_controll_paths_temp" expression="${edge_paths_with_PE_controll_paths_temp}"/>
             <classpath location="/opt/local/share/java/saxon9he.jar"/>
-            <!--<param name="edge_paths_with_PE.xml" expression="${edge_paths_with_PE.xml}"/>
-            <param name="edge_paths_with_PE_controll_temp" expression="${edge_paths_with_PE_controll_temp}"/>
-            <param name="edge_paths_with_PE_controll_temp.alias" expression="${edge_paths_with_PE_controll_temp.alias}"/>-->
         </xslt>
     </target>
    
@@ -363,6 +526,11 @@
                 <!--<attribute name="http://saxon.sf.net/feature/initialTemplate" value="asd"/>-->
             </factory>
             <classpath location="/opt/local/share/java/saxon9he.jar"/>
+            <param name="edge_paths_with_PE.xml" expression="${edge_paths_with_PE.xml}"/>
+            <param name="joins_asText_xml.xml" expression="${joins_asText_xml.xml}"/>
+            <param name="edge_joins_filled_paths.xml" expression="${edge_joins_filled_paths.xml}"/>
+            <param name="points2joins.xml" expression="${points2joins.xml}"/>
+            <param name="edge_joins_filled_paths" expression="${edge_joins_filled_paths}"/>
             <!--<param name="dita_task_template_file_param" expression="main.dita"/>-->
         </xslt>
     </target>
@@ -409,7 +577,62 @@
     </target>-->
    
     <!--<target name="install_file_and_exec"/>-->
-   
+    <!--sh#: ant bootstrap -Darg1=value1 -Darg2=value2 -Darg3=value3
+        or
+        sh#: ant bootstrap -Dargs=value1,value2,value3,...
+        
+       <target name="bootstrap">
+            <echo>${arg0} ${arg1} ${arg2} </echo>
+             <exec executable="cmd">
+                <arg value="${arg0}"/>
+                <arg value="${arg1}"/>
+                <arg value="${arg2}"/>
+             </exec>
+        </target>
+    
+    -->
+    
+    <!--<taskdef uri="antlib:net.sf.antcontrib" resource="net/sf/antcontrib/antlib.xml" classpath="path/to/ant-contrib.jar"/>-->
+    
+    <!-- How to pass parameter to ant scripts?
+        
+        Using Java System Property
+    
+    You can pass a variable as a JVM argument. Assuming you have a variable named "screenShotRoot" defined like this
+    
+    ant -DscreenShotRoot=/screenshots/testcases
+    you can read it in your build.xml like this
+    
+    <property name="screenshot.root" value="${screenShotRoot}" />
+    Your ANT task can then use this root path to generate appropriate paths to your PNG files on the date expected.
+    
+    See this Apache ANT FAQ page
+    
+    Using Environment Variables
+    
+    You can also use Operating System environment variables, by setting them before calling your script. Assuming you have an environment variable named "screenShotRoot" defined like this on Windows
+    
+    SET screenShotRoot=/screenshots/testcases
+    you can read it in your build.xml like this
+    
+    <property environment="env"/>
+    <property name="screenshot.root" value="${env.screenShotRoot}" />
+    Using Properties Files
+    
+    You could also write your links into a properties file that your ANT script loads, like this
+    
+    <property file="build.properties"/>-->
+    
+    <!--<property name="biale_plamy-prepare_sql_data.php" value="biale_plamy-prepare_sql_data.php"/>-->
+    
+    <target name="mail_inform">
+        
+        <echo message="informujemy o kompletnej pracy"/>
+        <exec executable="mail" failonerror="true" dir=".">
+            <arg value="echo 'ant task done | mail ${mail_inform}'"/>
+        </exec>
+    </target>
+    
    
    
     <target name="check-info" if="test_if_INPUTxml">

+ 75 - 0
SE/dev/php-cli/build_edge_paths_with_PE_controll_loop.xsl

@@ -0,0 +1,75 @@
+<?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:param name="edge_paths_with_PE_controll_temp" select="'edge_paths_with_PE_controll_temp'"/>
+    <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.xsl" select="'edge_paths_with_PE_controll.xsl'"/>
+    <xsl:param name="edge_paths_with_PE_controll.xml" select="'edge_paths_with_PE_controll.xml'"/>
+    <xsl:param name="edge_paths_with_PE_controll_paths_temp" select="'edge_paths_with_PE_controll_paths_temp'"/>
+    
+    <xsl:param name="edge_joins_filled_paths" select="'edge_joins_filled_paths'"/>
+    <xsl:param name="PE_Price" select="2500"/>
+    <xsl:param name="Cable_Price" select="3"/>
+    <xsl:param name="max_combinate_groups_elements" select="10"/> <!-- po ile wezlow mamy grupowac do wyliczania kombinacji kosztow -->
+    <xsl:param name="logic" select="'grouped'"/>
+    
+    <xsl:output indent="yes"/>
+    <xsl:strip-space elements="*"/>
+    
+    <xsl:template match="edge_joins_filled_paths">
+        <project basedir="." name="edge_paths_with_PE_controll_loop.xml" default="edge_paths_with_PE_controll_loop">
+            <target name="edge_paths_with_PE_controll_loop">
+                <record name="build.log" loglevel="verbose" append="true"/>
+                <xsl:comment>test sort nie dziala</xsl:comment>
+                <delete dir="{$edge_paths_with_PE_controll_temp}"/>
+                <delete dir="{$edge_paths_with_PE_controll_temp.alias}"/>
+                <delete dir="{$edge_paths_with_PE_controll_paths_temp}"/>
+                <mkdir dir="{$edge_paths_with_PE_controll_paths_temp}"/>
+                <symlink link="{$edge_paths_with_PE_controll_temp.alias}" resource="{$edge_paths_with_PE_controll_temp}"/>
+                
+                
+                <xsl:variable name="item">
+                    <xsl:for-each select="item">
+                        <xsl:sort select="number(asText/@len)" order="descending"/>
+                        <item><xsl:copy-of select="@*"/></item>
+                    </xsl:for-each>
+                </xsl:variable>
+                <xsl:apply-templates select="$item"/>                
+                    
+                
+            </target>
+        </project>
+    </xsl:template>
+    
+    
+    
+    <xsl:template match="item">
+        
+        
+        <delete file="{$edge_paths_with_PE_controll_paths_temp}/{$edge_paths_with_PE_controll.xsl}.{@id}.xml"/>
+        <xslt basedir="./" style="{$edge_paths_with_PE_controll.xsl}" 
+            in="{$edge_joins_filled_paths}/{$edge_joins_filled_paths}.{@id}.xml"  destdir="./" 
+            out="{$edge_paths_with_PE_controll.xsl}.{@id}.xml" >
+            <factory name="net.sf.saxon.TransformerFactoryImpl">    
+                <attribute name="http://saxon.sf.net/feature/xinclude-aware" value="true"/>
+                <!--<attribute name="http://saxon.sf.net/feature/initialMode" value="DITA_PARSE_templ"/>-->
+                <!--<attribute name="http://saxon.sf.net/feature/initialTemplate" value="asd"/>-->
+            </factory>
+            <classpath location="/opt/local/share/java/saxon9he.jar"/>
+            <param name="edge_paths_with_PE_controll_temp" expression="{$edge_paths_with_PE_controll_temp}"/>
+            <param name="edge_paths_with_PE_controll_temp.alias" expression="{$edge_paths_with_PE_controll_temp.alias}"/>
+            <param name="PE_Price" expression="{$PE_Price}"/>
+            <param name="Cable_Price" expression="{$Cable_Price}"/>
+            <param name="max_combinate_groups_elements" expression="{$max_combinate_groups_elements}"/> <!-- po ile wezlow mamy grupowac do wyliczania kombinacji kosztow -->
+            <param name="logic" expression="{$logic}"/>
+            <param name="edge_paths_with_PE_controll_paths_temp" expression="{$edge_paths_with_PE_controll_paths_temp}"/>
+            <!--<xsl:param name="logic" select="'sorted'"/>--> <!-- tutaj robi grupy ale analizyje w grupie tylko wazniejsze/bardziej oblozone wezly --> 
+        </xslt>
+        <move file="{$edge_paths_with_PE_controll.xsl}.{@id}.xml" todir="{$edge_paths_with_PE_controll_paths_temp}"/>
+    </xsl:template>
+    
+</xsl:stylesheet>

+ 219 - 208
SE/dev/php-cli/cables_from_joins_to_PE.xsl

@@ -9,177 +9,243 @@
     
     <xsl:include href="asText.xsl"/>
     
-    <xsl:variable name="PE_candidates_dump" select="doc('edge_paths_with_PE.xml')"/>
-    <xsl:variable name="joins_asText" select="doc('joins_asText.xml')"/>
-    <xsl:variable name="edge_joins_filled_paths" select="doc('edge_joins_filled_paths.xml') "/>
-    <xsl:variable name="points2joins" select="doc('points2joins.xml')"/>
+    <xsl:param name="edge_paths_with_PE.xml" select="'edge_paths_with_PE.xml'"/>
+    <xsl:param name="joins_asText_xml.xml" select="'joins_asText_xml.xml'"/>
+    <!--<xsl:param name="edge_joins_filled_paths.xml" select="'edge_joins_filled_paths.xml'"/>-->
+    <xsl:param name="points2joins.xml" select="'points2joins.xml'"/>
+    <xsl:param name="edge_joins_filled_paths" select="'edge_joins_filled_paths'"/>
+    
+    <xsl:variable name="PE_candidates_dump" select="doc($edge_paths_with_PE.xml)"/>
+    <xsl:variable name="joins_asText_Path_Point" select="doc($joins_asText_xml.xml)"/>
+    <!--<xsl:variable name="edge_joins_filled_paths" select="doc($edge_joins_filled_paths.xml) "/>-->
+    <xsl:variable name="points2joins" select="doc($points2joins.xml)"/>
+    
     
     <!-- <joins_asText>
         <item id="0">POINT (18.7909 51.701067999083)</item>-->
     <xsl:template match="joins2ways_z_ID_Way">
         <cables_from_joins_to_PE>
-        <xsl:variable name="joins_asText_Path_Point">
+        <!--<xsl:variable name="joins_asText_Path_Point">
             <xsl:apply-templates select="$joins_asText" mode="joins_asText"/>
-        </xsl:variable>
-            
+        </xsl:variable>-->   
          <!--<xsl:copy-of select="$joins_asText_Path_Point"/>-->
-            
-        <xsl:variable name="edge_joins_filled_paths">
-            <xsl:apply-templates select="$edge_joins_filled_paths" mode="edge_joins_filled_paths"/>
-        </xsl:variable>
-            
                 <!--<xsl:copy-of select="$edge_joins_filled_paths"/>-->
-            
-            
         <!-- jedziemy po joins2ways_z_ID_Way, sprawdzamy czy jest dla niego PE_candidates_dump , jak tak, to szukamy jego PE i liczymy sciezke 
                lub probujemy rysowac zawsze od konca drogi-->
-            
           <xsl:for-each select="item">
             <xsl:variable name="ID_Way" select="@ID_Way"/>
-            <xsl:variable name="Joins" select="@id"/>
-            <xsl:variable name="ID_Point" select="@ID_Point"/>
-            <xsl:choose> 
-                <!-- trzeba sprawdzic czy join jest klientem - czy tylko PE! -->
-                <xsl:when test="not(@ID_Point)">
-                    <not_candidate><xsl:attribute name="descr" select="'this is probably join from way'"/>
-                        <xsl:attribute name="Joins" select="@id"/></not_candidate>
-                </xsl:when>
-                <xsl:when test="$PE_candidates_dump/PE_candidates_dump/LINESTRING[@ID_Way=current()/@ID_Way]">
-                    <cable_to_PE_to_be_calculated>
-                        <xsl:attribute name="ID_Way" select="@ID_Way"/>
-                        <xsl:attribute name="Joins" select="@id"/>
-                        <xsl:attribute name="ID_Point" select="@ID_Point"/>
-                         <!-- idziemy po drodze,  -->
-                        <xsl:variable name="Join_X" select="$joins_asText_Path_Point/joins_asText/item[@id=$Joins]/As_POINT_to_xml/@X"/>
-                        <xsl:variable name="Join_Y" select="$joins_asText_Path_Point/joins_asText/item[@id=$Joins]/As_POINT_to_xml/@Y"/>
-                        <xsl:attribute name="Join_X" select="$Join_X"/><xsl:attribute name="Join_Y" select="$Join_Y"/>
-                        <xsl:variable name="found_in_path_in_edge_joins_filled_path">
-                            <xsl:for-each select="$edge_joins_filled_paths/edge_joins_filled_paths/item[@id=$ID_Way]/bp:Path_Point">
-                                <xsl:variable name="diff_X" select=" number($Join_X)- number(@X)"/><xsl:variable name="diff_Y" select=" number($Join_Y)- number(@Y)"/>
-                                <xsl:variable name="bp:Path_Point" select="."/>
-                                 
-                                    <xsl:choose>
-                                        <xsl:when test="(abs($diff_X)&lt;0.0001 and abs($diff_X)&lt;0.0001) or ( @X=$Join_X and @Y=$Join_Y )">
-                                            <found_in_path_in_edge_joins_filled_path>
-                                                <xsl:attribute name="diff_X" select="$diff_X"/><xsl:attribute name="diff_Y" select="$diff_Y"/>
-                                                <xsl:attribute name="position" select="position()"/>
-                                                <!--<bp:Path_Point_var><xsl:copy-of select="$bp:Path_Point"/></bp:Path_Point_var>-->
-                                                <xsl:copy-of select="."/>
+            <xsl:variable name="ID_Join" select="@id"/>
+            <!--<xsl:variable name="pos" select=" position()"/>--> <!-- tozsamosc ulozenia z waysow -->
+            <xsl:variable name="ID_Point_count"/>  
+            <xsl:for-each select="Points">
+                <xsl:message>#41 Calculating Cable for point:<xsl:value-of select=" text()"/>; ID_Join:<xsl:value-of select="$ID_Join"/></xsl:message>
+                    <xsl:variable name="ID_Point" select=" text()"/>
+                    <xsl:variable name="edge_joins_filled_paths_xml" select="doc(concat($edge_joins_filled_paths,'/edge_joins_filled_paths.',$ID_Way,'.xml'))"/>
+                        <!-- do ustalenia gdize sa najblizsze bp:Path_Point_Cable ID_Join="45" -> Target_ID_Join  --> 
+                        <xsl:variable name="edge_paths_with_PE_controll" select="doc(concat('edge_paths_with_PE_controll_paths_temp/edge_paths_with_PE_controll.xsl.',$ID_Way,'.xml'))"/>
+                         <!-- nie tzeba - jest w foreach dla Points !- trzeba sprawdzic czy join jest klientem - czy tylko PE! -->
+                        <xsl:choose>
+                        <!--<xsl:when test="not(@ID_Point)">
+                              <not_candidate><xsl:attribute name="descr" select="'this is probably join from way'"/>
+                                  <xsl:attribute name="Joins" select="@id"/></not_candidate>
+                          </xsl:when>-->
+                            <xsl:when test="$PE_candidates_dump/PE_candidates_dump/LINESTRING/bp:Path_Point[@ID_Join=$ID_Join]">
+                                <not_candidate_is_pe><xsl:attribute name="descr" select="'this is PE '"/>
+                                    <xsl:attribute name="Joins" select="$ID_Join"/>
+                                    <xsl:copy-of select="$PE_candidates_dump/PE_candidates_dump/LINESTRING/bp:Path_Point[@ID_Join=$ID_Join]"/>
+                                </not_candidate_is_pe>
+                            </xsl:when>
+                        <xsl:otherwise>
+                            <cable_to_PE_to_be_calculated>
+                                <xsl:attribute name="ID_Way" select="$ID_Way"/>
+                                <xsl:attribute name="Joins" select="$ID_Join"/>
+                                <xsl:attribute name="ID_Point" select="$ID_Point"/>
+                                 <!-- idziemy po drodze,  -->
+                                <xsl:variable name="Join_X" select="$joins_asText_Path_Point/joins_asText_xml/item[@id=$ID_Join]/bp:Path_Point/@X"/>
+                                <xsl:variable name="Join_Y" select="$joins_asText_Path_Point/joins_asText_xml/item[@id=$ID_Join]/bp:Path_Point/@Y"/>
+                                
+                                <xsl:attribute name="Join_X" select="$Join_X"/><xsl:attribute name="Join_Y" select="$Join_Y"/>
+                                            <!--<xsl:variable name="found_in_path_in_edge_joins_filled_path">
+                                                <xsl:for-each select="$edge_joins_filled_paths_xml/edge_joins_filled_paths_xml/asText_XMl[@id=$ID_Way]/LineString">
+                                                    <xsl:variable name="diff_X" select=" number($Join_X)- number(@X)"/><xsl:variable name="diff_Y" select=" number($Join_Y)- number(@Y)"/>
+                                                    <xsl:variable name="bp:Path_Point" select="."/>
+                                                        <xsl:choose>
+                                                            <xsl:when test="(abs($diff_X)&lt;0.0001 and abs($diff_X)&lt;0.0001) or ( @X=$Join_X and @Y=$Join_Y )">
+                                                                <found_in_path_in_edge_joins_filled_path>
+                                                                    <xsl:variable name="Join_Y" select="$joins_asText_Path_Point/joins_asText_xml/item[@id=$Joins]/bp:Path_Point/@Y"/>
+                                                                    <xsl:attribute name="diff_X" select="$diff_X"/><xsl:attribute name="diff_Y" select="$diff_Y"/>
+                                                                    <xsl:attribute name="position" select="position()"/>
+                                                                    <!-\-<bp:Path_Point_var><xsl:copy-of select="$bp:Path_Point"/></bp:Path_Point_var>-\->
+                                                                    <xsl:copy-of select="."/>
+                                                                    <xsl:call-template name="detect_next_PE">
+                                                                        <xsl:with-param name="bp:Path_Point" select="$bp:Path_Point"/>
+                                                                        <xsl:with-param name="ID_Way" select="$ID_Way"/>
+                                                                        <xsl:with-param name="Pos_found" select="position()"/>
+                                                                        <xsl:with-param name="edge_joins_filled_paths" select="$edge_joins_filled_paths_xml"/>
+                                                                        <xsl:with-param name="ID_Point" select="$ID_Point"/>
+                                                                    </xsl:call-template>
+                                                                </found_in_path_in_edge_joins_filled_path>
+                                                            </xsl:when>
+                                                            <xsl:otherwise>
+                                                                <not_found>
+                                                                    <xsl:attribute name="Pos" select="position()"/>
+                                                                    <xsl:attribute name="X" select="@X"/><xsl:attribute name="Y" select="@Y"/>
+                                                                    <xsl:attribute name="srch_X" select="$Join_X"/><xsl:attribute name="srch_Y" select="$Join_Y"/>
+                                                                    <xsl:attribute name="diff_X" select="$diff_X"/><xsl:attribute name="diff_Y" select="$diff_Y"/>
+                                                                </not_found>
+                                                            </xsl:otherwise>
+                                                        </xsl:choose>
+                                                </xsl:for-each>
+                                            </xsl:variable>-->
+                                            <!--<xsl:choose>
+                                    <xsl:when test="$found_in_path_in_edge_joins_filled_path/found_in_path_in_edge_joins_filled_path">
+                                        <xsl:for-each select="$found_in_path_in_edge_joins_filled_path/found_in_path_in_edge_joins_filled_path[1]">
+                                            <xsl:sort select="count(detect_next_PE/bp:Path_Point)" order="descending"/>
+                                            <debug>
+                                                <xsl:attribute name="debug_pos" select="position()"/>
+                                                <xsl:attribute name="Path_Point_count" select="count(detect_next_PE/bp:Path_Point)"/>
+                                            </debug>
+                                            <!-\-<found_in_path_in_edge_joins_filled_path>
+                                                <xsl:attribute name="debug_pos" select="position()"/>
+                                                <xsl:copy-of select="@*"/>
                                                 <xsl:call-template name="detect_next_PE">
-                                                    <xsl:with-param name="bp:Path_Point" select="$bp:Path_Point"/>
+                                                    <xsl:with-param name="bp:Path_Point" select="bp:Path_Point_var"/>
                                                     <xsl:with-param name="ID_Way" select="$ID_Way"/>
-                                                    <xsl:with-param name="Pos_found" select="position()"/>
+                                                    <xsl:with-param name="Pos_found" select="@position"/>
                                                     <xsl:with-param name="edge_joins_filled_paths" select="$edge_joins_filled_paths"/>
                                                     <xsl:with-param name="ID_Point" select="$ID_Point"/>
                                                 </xsl:call-template>
-                                            </found_in_path_in_edge_joins_filled_path>
-                                        </xsl:when>
-                                        <xsl:otherwise>
-                                            <not_found>
-                                                <xsl:attribute name="Pos" select="position()"/>
-                                                <xsl:attribute name="X" select="@X"/><xsl:attribute name="Y" select="@Y"/>
-                                                <xsl:attribute name="srch_X" select="$Join_X"/><xsl:attribute name="srch_Y" select="$Join_Y"/>
-                                                <xsl:attribute name="diff_X" select="$diff_X"/><xsl:attribute name="diff_Y" select="$diff_Y"/>
-                                            </not_found>
-                                        </xsl:otherwise>
-                                    </xsl:choose>
-                            </xsl:for-each>
-                        </xsl:variable>
-                        <xsl:choose>
-                            <xsl:when test="$found_in_path_in_edge_joins_filled_path/found_in_path_in_edge_joins_filled_path">
-                                <xsl:for-each select="$found_in_path_in_edge_joins_filled_path/found_in_path_in_edge_joins_filled_path[1]">
-                                    <xsl:sort select="count(detect_next_PE/bp:Path_Point)" order="descending"/>
-                                    <debug>
-                                        <xsl:attribute name="debug_pos" select="position()"/>
-                                        <xsl:attribute name="Path_Point_count" select="count(detect_next_PE/bp:Path_Point)"/>
-                                    </debug>
-                                    <!--<found_in_path_in_edge_joins_filled_path>
-                                        <xsl:attribute name="debug_pos" select="position()"/>
-                                        <xsl:copy-of select="@*"/>
-                                        <xsl:call-template name="detect_next_PE">
-                                            <xsl:with-param name="bp:Path_Point" select="bp:Path_Point_var"/>
-                                            <xsl:with-param name="ID_Way" select="$ID_Way"/>
-                                            <xsl:with-param name="Pos_found" select="@position"/>
-                                            <xsl:with-param name="edge_joins_filled_paths" select="$edge_joins_filled_paths"/>
-                                            <xsl:with-param name="ID_Point" select="$ID_Point"/>
-                                        </xsl:call-template>
-                                    </found_in_path_in_edge_joins_filled_path>-->
-                                    <xsl:copy-of select="."/>
-                                </xsl:for-each>
-                                <xsl:copy-of select="$found_in_path_in_edge_joins_filled_path/not_found"/>
-                            </xsl:when>
-                            <xsl:otherwise>
-                                <xsl:copy-of select="$found_in_path_in_edge_joins_filled_path"/>
-                            </xsl:otherwise>
-                        </xsl:choose>
-                    </cable_to_PE_to_be_calculated>
-                </xsl:when>
-            </xsl:choose>
+                                            </found_in_path_in_edge_joins_filled_path>-\->
+                                            <xsl:copy-of select="."/>
+                                        </xsl:for-each>
+                                        <xsl:copy-of select="$found_in_path_in_edge_joins_filled_path/not_found"/>
+                                    </xsl:when>
+                                    <xsl:otherwise>
+                                        <xsl:copy-of select="$found_in_path_in_edge_joins_filled_path"/>
+                                    </xsl:otherwise>
+                                </xsl:choose>-->
+                                <xsl:variable name="id_path" select="$edge_joins_filled_paths_xml/edge_joins_filled_paths_xml/asText_XMl/LineString[@ID_Join=$ID_Join and @Y=$Join_Y and @Y=$Join_Y]/@id_path" />
+                                <xsl:choose>
+                                    <xsl:when test="$id_path">
+                                        <found_in_path_in_edge_joins_filled_path>
+                                            <xsl:for-each select="$edge_joins_filled_paths_xml/edge_joins_filled_paths_xml/asText_XMl/LineString[@ID_Join=$ID_Join and @Y=$Join_Y and @Y=$Join_Y]">
+                                                <xsl:call-template name="detect_next_PE_adv">
+                                                    <xsl:with-param name="ID_Point" select="$ID_Point"/>
+                                                    <xsl:with-param name="id_path" select="@id_path"/>
+                                                    <xsl:with-param name="ID_Join" select="$ID_Join"/>
+                                                    <xsl:with-param name="ID_Way" select="$ID_Way"/>
+                                                    <xsl:with-param name="edge_joins_filled_paths_xml" select="$edge_joins_filled_paths_xml"/>
+                                                </xsl:call-template>
+                                            </xsl:for-each>
+                                        </found_in_path_in_edge_joins_filled_path>
+                                    </xsl:when>
+                                    <xsl:otherwise>
+                                        <error>Not found $path
+                                            <xsl:message>Not found $path</xsl:message>
+                                        </error>
+                                    </xsl:otherwise>
+                                </xsl:choose>
+                                
+                            </cable_to_PE_to_be_calculated>
+                        </xsl:otherwise>
+                </xsl:choose>
+            </xsl:for-each>
         </xsl:for-each>
         </cables_from_joins_to_PE>
     </xsl:template>
     
-        <!-- na podstawie Joins jade do PE raz z przodudrugi raz z tylu -->
-       <xsl:template name="detect_next_PE">
-           <xsl:param name="bp:Path_Point" required="yes"/>
-           <xsl:param name="Pos_found" required="yes"/>
-           <xsl:param name="ID_Way" required="yes"/>
-           <xsl:param name="edge_joins_filled_paths" required="yes"/>
-           <xsl:param name="ID_Point" required="yes"/>
-           <!--<w_gore><xsl:attribute name="Pos_found" select="$Pos_found"/>
-               <xsl:for-each select="$edge_joins_filled_paths/edge_joins_filled_paths/item[@id=$ID_Way]/bp:Path_Point">
-                    
-                </xsl:for-each>
-            </w_gore>-->
-           
-           <xsl:variable name="Next_PE_Pos" select="min($PE_candidates_dump/PE_candidates_dump/LINESTRING[@ID_Way=$ID_Way]/bp:Path_Point[number(@Pos)&gt;number($Pos_found)]/@Pos)"/>
-           <xsl:variable name="Prev_PE_Pos" select="max($PE_candidates_dump/PE_candidates_dump/LINESTRING[@ID_Way=$ID_Way]/bp:Path_Point[number(@Pos)&lt;=number($Pos_found)]/@Pos)"/>
-           <xsl:variable name="Same_PE_Pos" select="max($PE_candidates_dump/PE_candidates_dump/LINESTRING[@ID_Way=$ID_Way]/bp:Path_Point[number(@Pos)=number($Pos_found)]/@Pos)"/>
-           <detect_next_PE>
-               <xsl:attribute name="Pos_found" select="$Pos_found"/>
-               <!--debug-->
-               <xsl:copy-of select="$PE_candidates_dump/PE_candidates_dump/LINESTRING[@ID_Way=$ID_Way]/bp:Path_Point[number(@Pos)&gt;number($Pos_found)]/@Pos"/> <!--[number(@Pos)&gt;number($Pos_found)]-->
-               <xsl:attribute name="Next_PE_Pos" select="$Next_PE_Pos"/>
-               <xsl:attribute name="Prev_PE_Pos" select="$Prev_PE_Pos"/>
-               <xsl:choose>
-                   <xsl:when test="( abs($Pos_found - $Next_PE_Pos)&lt;=abs($Pos_found - $Prev_PE_Pos)) or ( not($Prev_PE_Pos) and $Next_PE_Pos )">
-                       <xsl:attribute name="Going_to_next" select="$Next_PE_Pos"/>
-                       <xsl:variable name="Path_Point">
-                            <xsl:for-each select="$edge_joins_filled_paths/edge_joins_filled_paths/item[@id=$ID_Way]/bp:Path_Point[ position()&gt;=$Pos_found and position()&lt;=$Next_PE_Pos ]">
+    
+    <xsl:template name="detect_next_PE_adv">
+        <xsl:param name="ID_Point" required="yes"/>
+        <xsl:param name="id_path" required="yes"/>
+        <xsl:param name="ID_Join" required="yes"/>
+        <xsl:param name="ID_Way" required="yes"/>
+        <xsl:param name="edge_joins_filled_paths_xml" required="yes"/>
+        
+        <detect_next_PE>
+            <xsl:variable name="Next_PE_Pos" select="min($PE_candidates_dump/PE_candidates_dump/LINESTRING[@ID_Way=$ID_Way]/bp:Path_Point[number(@id_path)&gt;number($id_path)]/number(@id_path))"/>
+            <xsl:variable name="Prev_PE_Pos" select="max($PE_candidates_dump/PE_candidates_dump/LINESTRING[@ID_Way=$ID_Way]/bp:Path_Point[number(@id_path)&lt;=number($id_path)]/number(@id_path))"/>
+            <xsl:variable name="Same_PE_Pos" select="max($PE_candidates_dump/PE_candidates_dump/LINESTRING[@ID_Way=$ID_Way]/bp:Path_Point[number(@id_path)=number($id_path)]/number(@id_path))"/>
+            <xsl:attribute name="id_path" select="$id_path"/>
+            <xsl:attribute name="Next_PE_Pos" select="$Next_PE_Pos"/>
+            <xsl:attribute name="Prev_PE_Pos" select="$Prev_PE_Pos"/>
+            <xsl:attribute name="Same_PE_Pos" select="$Same_PE_Pos"/>
+            <xsl:variable name="Next_PE_Pos_len">
+                <xsl:choose>
+                    <xsl:when test="$Next_PE_Pos">
+                        <xsl:value-of select="sum($edge_joins_filled_paths_xml/edge_joins_filled_paths_xml/asText_XMl/LineString[number(@id_path) &gt;= number($id_path) and number(@id_path) &lt; number($Next_PE_Pos)  ]/@len)"/>
+                    </xsl:when><xsl:otherwise><xsl:value-of select="-1"/></xsl:otherwise>
+                </xsl:choose>
+            </xsl:variable>
+            <xsl:variable name="Prev_PE_Pos_len">
+                <xsl:choose>
+                    <xsl:when test="$Prev_PE_Pos">
+                        <xsl:value-of select="sum($edge_joins_filled_paths_xml/edge_joins_filled_paths_xml/asText_XMl/LineString[number(@id_path) &lt; number($id_path) and number(@id_path) &gt;= number($Prev_PE_Pos)  ]/@len)"/>
+                    </xsl:when>
+                    <xsl:otherwise><xsl:value-of select="-1"/></xsl:otherwise>
+                </xsl:choose>
+            </xsl:variable>
+            
+            <xsl:attribute name="Next_PE_Pos_len" select="$Next_PE_Pos_len"/>
+            <xsl:attribute name="Prev_PE_Pos_len" select="$Prev_PE_Pos_len"/>
+            <!--<xsl:copy-of select="$PE_candidates_dump/PE_candidates_dump/LINESTRING[@ID_Way=$ID_Way]/bp:Path_Point[number(@Pos)&gt;number($id_path)]/@Pos"/>-->
+                <xsl:variable name="Path_Point">
+                    <Path_Point>
+                    <xsl:choose>
+                        <xsl:when test="$Same_PE_Pos">
+                            <xsl:attribute name="len" select="0"/>
+                            <xsl:attribute name="debug" select="'going same'"/>
+                            <xsl:message>...Calculating to Self as PE( $Next_PE_Pos_len=<xsl:value-of select="$Next_PE_Pos_len"/>) &lt;= $Prev_PE_Pos_len=<xsl:value-of select="$Prev_PE_Pos_len"/>  </xsl:message>
+                            <xsl:attribute name="PE_ID_Join" select="$PE_candidates_dump/PE_candidates_dump/LINESTRING[@ID_Way=$ID_Way]/bp:Path_Point[number(@id_path)=number($Same_PE_Pos)]/@ID_Join"/>
+                        </xsl:when>
+                        <xsl:when test="not($Next_PE_Pos_len = '-1') and ($Prev_PE_Pos_len = '-1' or number($Next_PE_Pos_len) &lt;=  number($Prev_PE_Pos_len)) ">
+                            <xsl:attribute name="debug" select="'going next'"/>
+                            <xsl:attribute name="len" select="$Next_PE_Pos_len"/>
+                            <xsl:attribute name="PE_ID_Join" select="$PE_candidates_dump/PE_candidates_dump/LINESTRING[@ID_Way=$ID_Way]/bp:Path_Point[number(@id_path)=number($Next_PE_Pos)]/@ID_Join"/>
+                            <xsl:message>...Calculating to Next ( $Next_PE_Pos_len=<xsl:value-of select="$Next_PE_Pos_len"/>) &lt;= $Prev_PE_Pos_len=<xsl:value-of select="$Prev_PE_Pos_len"/>  </xsl:message>
+                            <xsl:for-each select="$edge_joins_filled_paths_xml/edge_joins_filled_paths_xml/asText_XMl/LineString[number(@id_path) &gt; number($id_path) and number(@id_path) &lt;= number($Next_PE_Pos)  ]">
                                 <xsl:copy-of select="."/>
                             </xsl:for-each>
-                       </xsl:variable>
-                       <xsl:copy-of select="$Path_Point"/>
-                       <xsl:call-template name="To_LINESTRING">
-                           <xsl:with-param name="Path_Point" select="$Path_Point"/>
-                       </xsl:call-template>
-                   </xsl:when>
-                   <xsl:when test="(abs($Pos_found - $Next_PE_Pos)&gt;abs($Pos_found - $Prev_PE_Pos)) or ( $Prev_PE_Pos and not($Next_PE_Pos) )">
-                       <xsl:attribute name="Going_to_prev" select="$Prev_PE_Pos"/>
-                       <xsl:variable name="Path_Point">
-                           <xsl:for-each select="$edge_joins_filled_paths/edge_joins_filled_paths/item[@id=$ID_Way]/bp:Path_Point[ position()&lt;=$Pos_found and position()&gt;=$Prev_PE_Pos ]">
-                            <xsl:copy-of select="."/>
-                        </xsl:for-each>
-                       </xsl:variable>
-                       <xsl:copy-of select="$Path_Point"/>
-                       <xsl:call-template name="To_LINESTRING">
-                           <xsl:with-param name="Path_Point" select="$Path_Point"/>
-                       </xsl:call-template>
-                   </xsl:when>
-                   <xsl:otherwise>
-                       <xsl:variable name="error">#Error 174 - nie moze byc innego wyjatku
-                           ID_Way=<xsl:value-of select="$ID_Way"/>;<xsl:value-of select="$ID_Point"/>  Pos_found=<xsl:value-of select="$Pos_found"/>; $Next_PE_Pos=<xsl:value-of select="$Next_PE_Pos"/>;
-                           $Prev_PE_Pos=<xsl:value-of select="$Prev_PE_Pos"/>; abs($Pos_found - $Next_PE_Pos)=<xsl:value-of select="abs($Pos_found - $Next_PE_Pos)"/> abs($Pos_found - $Prev_PE_Pos)=<xsl:value-of select="abs($Pos_found - $Prev_PE_Pos)"/>
-                           $Same_PE_Pos=<xsl:value-of select="$Same_PE_Pos"/>; $Pos_found=<xsl:value-of select="$Pos_found"/> ; 
-                       </xsl:variable>
-                       <xsl:message terminate="no" select="$error">
-                       <error><xsl:copy-of select="$error"/></error>
-                   </xsl:message>
-                   </xsl:otherwise>
-               </xsl:choose>
-           </detect_next_PE>
-           
-       </xsl:template>
+                        </xsl:when>
+                        <xsl:otherwise>
+                            <xsl:attribute name="len" select="$Prev_PE_Pos_len"/>
+                            <xsl:attribute name="debug" select="'going prev'"/>
+                            <xsl:attribute name="PE_ID_Join" select="$PE_candidates_dump/PE_candidates_dump/LINESTRING[@ID_Way=$ID_Way]/bp:Path_Point[number(@id_path)=number($Prev_PE_Pos)]/@ID_Join"/>
+                            <xsl:message>...Calculating to Prev ( $Next_PE_Pos_len=<xsl:value-of select="$Next_PE_Pos_len"/>) &lt;= $Prev_PE_Pos_len=<xsl:value-of select="$Prev_PE_Pos_len"/>  </xsl:message>
+                            <xsl:for-each select="$edge_joins_filled_paths_xml/edge_joins_filled_paths_xml/asText_XMl/LineString[number(@id_path) &lt; number($id_path) and number(@id_path) &gt;= number($Prev_PE_Pos)  ]">
+                                <xsl:sort select="number(@id_path)" order="descending"/>
+                                <xsl:copy-of select="."/>
+                            </xsl:for-each>
+                        </xsl:otherwise>
+                    </xsl:choose>
+                    </Path_Point>
+                </xsl:variable>
+            <xsl:copy-of select="$Path_Point/Path_Point/@*"/>
+            <!--<debug_To_LINESTRING>
+                <xsl:copy-of select="$Path_Point"/>
+            </debug_To_LINESTRING>-->
+            <xsl:choose>
+                <xsl:when test="$Path_Point/Path_Point/(bp:Path_Point|LineString)">
+                    <xsl:call-template name="To_LINESTRING">
+                        <xsl:with-param name="Path_Point" select="$Path_Point/Path_Point"/>
+                    </xsl:call-template>
+                </xsl:when>
+                <xsl:otherwise>
+                    <ERORR>pewnie sasiedzkei sciezki Neighbour do obsluzenia i ich nie znaleziono 
+                        jest info w /edge_paths_with_PE_controll/Path[1]/PointMatrixGroupPE[1]/PointMatrixGroup[1]/odpalam_liczenie[1]/koniec_wariantow[1]/bp:Path_Point_Cable[3]
+                    </ERORR>
+                    <xsl:message>ERROR nie znaleziono sciezki - moze sasiedzkie ? TODO</xsl:message>
+                    <!--<xsl:variable name=""/>-->
+                </xsl:otherwise>
+                
+            </xsl:choose>
+            
+        </detect_next_PE>
+    </xsl:template>
+    
+    
+    
+    
     
     
     
@@ -187,71 +253,16 @@
             <xsl:param name="Path_Point" required="yes"/>
             <LINESTRING>
                 <xsl:value-of select="'LINESTRING ('"/>
-            <xsl:for-each select="$Path_Point/bp:Path_Point">
-                <xsl:value-of select="concat(@X,' ',@Y)"/>
-                <xsl:if test="position()!=last()"><xsl:value-of select="', '"/></xsl:if>
-            </xsl:for-each>
+                <xsl:for-each select="$Path_Point/(bp:Path_Point|LineString)">
+                    <xsl:value-of select="concat(@X,' ',@Y)"/>
+                    <xsl:if test="position()!=last()"><xsl:value-of select="', '"/></xsl:if>
+                </xsl:for-each>
                 <xsl:value-of select="')'"/>
             </LINESTRING>
         </xsl:template>
     
-        <xsl:template match="edge_joins_filled_paths" mode="edge_joins_filled_paths">
-            <edge_joins_filled_paths>
-                <xsl:apply-templates mode="edge_joins_filled_paths"/>
-            </edge_joins_filled_paths>
-        </xsl:template>
-    
-    <xsl:template match="item" mode="edge_joins_filled_paths">
-        <item>
-            <xsl:copy-of select="@*"/>
-            <xsl:copy-of select="tried"/>
-                <xsl:variable name="Path_Point">
-                <xsl:apply-templates/>
-                </xsl:variable>
-            <xsl:copy-of select="$Path_Point/tried"/>
-            <xsl:for-each select="$Path_Point/bp:Path_Point">
-                <bp:Path_Point>
-                    <xsl:attribute name="Pos" select="position()"/>
-                    <xsl:copy-of select="@*"/>
-                </bp:Path_Point>
-            </xsl:for-each>
-        </item>
-    </xsl:template>
     
-    <xsl:template match="joins_asText" mode="joins_asText">
-        <joins_asText>
-            <xsl:apply-templates mode="joins_asText"/>
-        </joins_asText>
-    </xsl:template>
-    
-    <xsl:template match="item" mode="joins_asText">
-        <item>
-            <xsl:copy-of select="@*"/>
-            <xsl:call-template name="As_POINT_to_xml">
-                <xsl:with-param name="As_POINT" select="text()"/>
-            </xsl:call-template>
-        </item>
-    </xsl:template>
-    
-    <!-- todo do wypchniecia do funkcji ogolnych -->
-    <xsl:template name="As_POINT_to_xml">
-        <xsl:param name="As_POINT"/>
-        <xsl:variable name="As_POINT_tok" select=" substring-before( substring-after(normalize-space(.),'POINT (') , ')')  "/>
-        <!--<test1><xsl:copy-of select="$LINESTRING"/></test1>-->
-        <xsl:variable name="As_POINT_pos">
-            <xsl:for-each select="tokenize($As_POINT_tok,' ')">
-                    <pos>
-                        <xsl:attribute name="pos" select="position()"/>
-                        <xsl:value-of select="."/>
-                    </pos>
-                </xsl:for-each>
-        </xsl:variable>
-        <As_POINT_to_xml>
-            <xsl:attribute name="X" select="$As_POINT_pos/pos[@pos=1]"/>
-            <xsl:attribute name="Y" select="$As_POINT_pos/pos[@pos=2]"/>
-        </As_POINT_to_xml>
-    </xsl:template>
-    <xsl:template match="*"/>
+        <xsl:template match="*"/>
     
     
 </xsl:stylesheet>

+ 181 - 56
SE/dev/php-cli/edge_joins_filled_paths_make.xsl

@@ -18,6 +18,11 @@
     <xsl:param name="joins2ways_z_ID_Way.xml" select="'joins2ways_z_ID_Way.xml'"/>
     <xsl:variable name="joins2ways_z_ID_Way" select="doc($joins2ways_z_ID_Way.xml)"/>
     
+    <xsl:param name="edge_joins_filled_paths" select="'edge_joins_filled_paths'"/> <!-- katalog do zapisywania sciezek -->
+    
+    <xsl:param name="debug"  select="0" /> <!-- set 1 to debug -->
+    
+    <xsl:param name="bypass_errors" select=" true()"/> <!-- set to 0 if you want to secure terminate on error  -->
     
     <xsl:output indent="yes"/>
     <xsl:strip-space elements="*"/>
@@ -61,8 +66,9 @@
                         <xsl:attribute name="Join_Y1" select="$Join_Y1"/>
                         <xsl:attribute name="Join_X2" select="$Join_X2"/>
                         <xsl:attribute name="Join_Y2" select="$Join_Y2"/>
+                            
                         <xsl:variable name="Ways">
-                            <xsl:for-each select="$ways_asText_z_ID_xml/ways_asText_z_ID_xml/item[@ID_Way=$ID_Way]">
+                            <xsl:for-each select="$ways_asText_z_ID_xml/ways_asText_z_ID_xml/item[@ID_Way=$ID_Way   ]"> <!-- olanie zerowych  and not(bp:Path_Point[1]/@X= bp:Path_Point[2]/@X)  and not(bp:Path_Point[1]/@Y= bp:Path_Point[2]/@Y) TODO  -->
                                 <Way>
                                     <xsl:attribute name="id" select="@id"/>
                                     <xsl:attribute name="len" select="@len"/>
@@ -129,11 +135,12 @@
                                 </Way_next_cand>
                             </xsl:for-each>
                         </xsl:variable>
+                            <!-- todo nei wiem czy potrzebne to echo -->
                         <xsl:copy-of select="$Ways_J2_W2"/>
                         <!-- poszukamy czy Way_X2 wystepuje -->
-                    </Ways>
+                        </Ways>
                     </xsl:variable>
-                    <!--<xsl:copy-of select="$Ways"/>-->
+                    
                     <!--<xsl:variable name="Way_1_or_2">
                     <xsl:choose>
                         <xsl:when test="$Ways/Ways/Way_next_cand[1]/@Way_X2">
@@ -144,6 +151,7 @@
                     </xsl:variable>-->
                     <!--<Way_1_or_2><xsl:value-of select="$Way_1_or_2"/></Way_1_or_2>-->
                     <xsl:variable name="LineString">
+                        <xsl:message>#152 run templ PlaceWay for ID_Way=<xsl:value-of select="$ID_Way"/>;   </xsl:message>
                         <xsl:call-template name="PlaceWay">
                             <xsl:with-param name="Ways" select="$Ways"/>
                             <xsl:with-param name="Cur_X1" select="$Ways/Ways/@Join_X1"/>
@@ -169,11 +177,17 @@
                     <xsl:attribute name="len" select="$len"/>
                     <xsl:attribute name="Points_cnt" select="count($LineString/LineString/Points)"/>
                     <xsl:attribute name="Count" select=" count($LineString/LineString)"/>
+                    
+                    <xsl:if test="$debug">
+                        <debug_Ways>
+                            <xsl:copy-of select="$Ways"/>
+                        </debug_Ways>
+                    </xsl:if>
                     <!-- dodatkowo w xmlu aby bylo prosciej do przetwarzania -->
                     <!--<asText_XMl>
                             <xsl:copy-of select="$LineString"/>
                     </asText_XMl>-->
-                       <xsl:result-document href="edge_joins_filled_paths/edge_joins_filled_paths.{$ID_Way}.xml">
+                       <xsl:result-document href="{$edge_joins_filled_paths}/edge_joins_filled_paths.{$ID_Way}.xml">
                            <edge_joins_filled_paths_xml>
                                <xsl:attribute name="id" select="$ID_Way"/>
                                <xsl:attribute name="Points_cnt" select="count($LineString/LineString/Points)"/>
@@ -189,9 +203,6 @@
                             <xsl:with-param name="LineString" select="$LineString"/>
                         </xsl:call-template>
                 </asText>
-            
-       
-            
         </item>
     </xsl:template>
     
@@ -205,7 +216,11 @@
         <xsl:param name="Last_Y2" required="yes"/>
         <xsl:param name="loop" select="1"/>
         <xsl:param name="not_id" required="no"/>
+        <xsl:param name="not_id_prev" required="no" select="-1"/>
         <xsl:param name="ID_Way" required="yes"/>
+        <!--<xsl:if test="$debug">-->
+        <xsl:message>###PlaceWay(Cur_X1=<xsl:value-of select="$Cur_X1"/>,Cur_Y1=<xsl:value-of select="$Cur_Y1"/>### and not_id=<xsl:value-of select="$not_id"/>;not_id_prev=<xsl:value-of select="$not_id_prev"/>;</xsl:message>
+        <!--</xsl:if>-->
         <!--<LineString>
             <xsl:attribute name="X1" select="$Cur_X1"/>
             <xsl:attribute name="Y1" select="$Cur_Y1"/>
@@ -219,68 +234,177 @@
             <xsl:attribute name="not_id" select="$not_id"/>
         </debug>-->
         <xsl:variable name="Linestring">
-            <xsl:for-each select="$Ways/Ways/Way[@Way_X1=$Cur_X1 and @Way_Y1=$Cur_Y1 and ( not($not_id) or not(@id=$not_id)) ]">
-                <LineString>
-                    <xsl:attribute name="X" select="@Way_X2"/>
-                    <xsl:attribute name="Y" select="@Way_Y2"/>
-                    <xsl:attribute name="not_id" select="@id"/>
-                    <xsl:attribute name="len" select="@len"/>
-                    <xsl:variable name="X" select="@Way_X2"/>
-                    <xsl:variable name="Y" select="@Way_Y2"/>
-                    <xsl:for-each select="$ways2joins/ways2joins/item[@id= current()/@id]/item">
-                        <xsl:for-each select="$joins_asText_xml/joins_asText_xml/item[@id= current()/text()]/bp:Path_Point">
-                            <xsl:if test="@X=$X and @Y=$Y">
-                                <xsl:variable name="ID_Join" select="parent::node()/@id"/>
-                                <!-- punkty podpiete -->
-                                <xsl:copy-of select="$joins2ways_z_ID_Way/joins2ways_z_ID_Way/item[@id=$ID_Join]/Points"/>
-                                <!-- wyszukanie drog wychodzacych innych niz nasza z punktu -->
-                                <xsl:for-each select="$joins2ways_z_ID_Way/joins2ways_z_ID_Way/item[@id=$ID_Join]/item[not(@ID_WAY=$ID_Way)]">
-                                    <Ways>
-                                        <xsl:attribute name="ID_WAY" select="@ID_WAY"/>
-                                        <xsl:attribute name="ways_id" select="text()"/>
-                                    </Ways>
+            <!-- jezeli sa zerowe drogi -->
+            <xsl:choose>
+                <xsl:when test="$Ways/Ways/Way[ ( @Way_X1=$Cur_X1 and @Way_Y1=$Cur_Y1 or  @Way_X2=$Cur_X1 and @Way_Y2=$Cur_Y1 ) and ( not($not_id) or not(@id=$not_id))  and @Way_X1=@Way_X2 and @Way_Y1=@Way_Y2  and not(@id=$not_id_prev) ][1]">
+                    <xsl:for-each select="$Ways/Ways/Way[ ( @Way_X1=$Cur_X1 and @Way_Y1=$Cur_Y1 or  @Way_X2=$Cur_X1 and @Way_Y2=$Cur_Y1 ) and ( not($not_id) or not(@id=$not_id))  and @Way_X1=@Way_X2 and @Way_Y1=@Way_Y2  and not(@id=$not_id_prev) ][1]">
+                        <LineString>
+                            <xsl:attribute name="error" select="'zerowa droga!'"/>
+                            <xsl:attribute name="X" select="@Way_X2"/>
+                            <xsl:attribute name="Y" select="@Way_Y2"/>
+                            <xsl:attribute name="not_id" select="@id"/>
+                            <xsl:attribute name="len" select="@len"/>
+                            <!--<xsl:if test="$debug">-->
+                                <xsl:message>Try to say @Way_X1:<xsl:value-of select="@Way_X1"/>; @Way_X2:<xsl:value-of select="@Way_X2"/>; $Cur_X1:<xsl:value-of select="$Cur_X1"/>; </xsl:message>
+                                <xsl:message>PlaceWay: 1=1;2=2  count()=<xsl:value-of select="count(.)"/>; lenX:<xsl:value-of select=" round(abs(number(@Way_X1) - number($Cur_X1)) * 1000)"/>; zerowa droga dla $Cur_X1=<xsl:value-of select="$Cur_X1"/>; $Cur_Y1=<xsl:value-of select="$Cur_Y1"/> @id=<xsl:value-of select="@id"/>; $not_id=<xsl:value-of select="$not_id"/>;$not_id_prev=<xsl:value-of select="$not_id_prev"/>;</xsl:message>
+                            <!--</xsl:if>-->
+                            <xsl:attribute name="not_id_prev" select="$not_id"/>
+                            <xsl:variable name="X" select="@Way_X2"/>
+                            <xsl:variable name="Y" select="@Way_Y2"/>
+                            <xsl:for-each select="$ways2joins/ways2joins/item[@id= current()/@id]/item"> <!-- musi byc wczesniej bo atrybut sie nie doda drugi raz-->
+                                <xsl:for-each select="$joins_asText_xml/joins_asText_xml/item[@id= current()/text()]/bp:Path_Point">
+                                    <xsl:if test="@X=$X and @Y=$Y">
+                                        <xsl:variable name="ID_Join" select="parent::node()/@id"/>
+                                        <xsl:attribute name="ID_Join" select="$ID_Join"/>
+                                    </xsl:if>
                                 </xsl:for-each>
-                            </xsl:if>
-                        </xsl:for-each>
+                            </xsl:for-each>
+                            <xsl:for-each select="$ways2joins/ways2joins/item[@id= current()/@id]/item">
+                                <xsl:for-each select="$joins_asText_xml/joins_asText_xml/item[@id= current()/text()]/bp:Path_Point">
+                                    <xsl:if test="@X=$X and @Y=$Y">
+                                        <xsl:variable name="ID_Join" select="parent::node()/@id"/>
+                                        <!--<xsl:attribute name="ID_Join" select="$ID_Join"/>-->
+                                        <!-- punkty podpiete -->
+                                        <xsl:copy-of select="$joins2ways_z_ID_Way/joins2ways_z_ID_Way/item[@id=$ID_Join]/Points"/>
+                                        <!-- wyszukanie drog wychodzacych innych niz nasza z punktu -->
+                                        <xsl:for-each select="$joins2ways_z_ID_Way/joins2ways_z_ID_Way/item[@id=$ID_Join]/item[not(@ID_WAY=$ID_Way)]">
+                                            <Ways>
+                                                <xsl:attribute name="ID_WAY" select="@ID_WAY"/>
+                                                <xsl:attribute name="ways_id" select="text()"/>
+                                            </Ways>
+                                        </xsl:for-each>
+                                    </xsl:if>
+                                </xsl:for-each>
+                            </xsl:for-each>
+                        </LineString>
                     </xsl:for-each>
-                </LineString>
-            </xsl:for-each>
-            <xsl:for-each select="$Ways/Ways/Way[@Way_X2=$Cur_X1 and @Way_Y2=$Cur_Y1 and ( not($not_id) or not(@id=$not_id))  ]">
-                <LineString>
-                    <xsl:attribute name="X" select="@Way_X1"/>
-                    <xsl:attribute name="Y" select="@Way_Y1"/>
-                    <xsl:attribute name="not_id" select="@id"/>
-                    <xsl:attribute name="len" select="@len"/>
-                    <xsl:variable name="X" select="@Way_X1"/>
-                    <xsl:variable name="Y" select="@Way_Y1"/>
-                    <xsl:for-each select="$ways2joins/ways2joins/item[@id= current()/@id]/item">
-                        <xsl:for-each select="$joins_asText_xml/joins_asText_xml/item[@id= current()/text()]/bp:Path_Point">
-                            <xsl:if test="@X=$X and @Y=$Y">
-                                <xsl:variable name="ID_Join" select="parent::node()/@id"/>
-                                <!-- punkty podpiete -->
-                                <xsl:copy-of select="$joins2ways_z_ID_Way/joins2ways_z_ID_Way/item[@id=$ID_Join]/Points"/>
-                                <!-- wyszukanie drog wychodzacych innych niz nasza z punktu -->
-                                <xsl:for-each select="$joins2ways_z_ID_Way/joins2ways_z_ID_Way/item[@id=$ID_Join]/item[not(@ID_WAY=$ID_Way)]">
-                                    <Ways>
-                                        <xsl:attribute name="ID_WAY" select="@ID_WAY"/>
-                                        <xsl:attribute name="ways_id" select="text()"/>
-                                    </Ways>
+                </xsl:when>
+                <xsl:otherwise>
+                    <xsl:for-each select="$Ways/Ways/Way[@Way_X1=$Cur_X1 and @Way_Y1=$Cur_Y1 and ( not($not_id) or not(@id=$not_id))  and  not(@Way_X1=@Way_X2 and @Way_Y1=@Way_Y2)  and not(@id=$not_id_prev) ]">
+                        <LineString>
+                            <xsl:attribute name="X" select="@Way_X2"/>
+                            <xsl:attribute name="Y" select="@Way_Y2"/>
+                            <xsl:attribute name="not_id" select="@id"/>
+                            <xsl:attribute name="len" select="@len"/>
+                            <xsl:attribute name="not_id_prev" select="$not_id"/>
+                            <xsl:variable name="X" select="@Way_X2"/>
+                            <xsl:variable name="Y" select="@Way_Y2"/>
+                            
+                            <xsl:choose>
+                                <xsl:when test="number(count(@Way_X2)) &gt; number(1)"><xsl:message>#282 error count&gt; of @Way_X2<xsl:value-of select="@Way_X2"/> </xsl:message></xsl:when>
+                                <xsl:otherwise>
+                                    <!--<xsl:if test=" abs(number(@Way_X2) - number($Cur_X1)) &gt; 0.001 ">
+                                 <xsl:message>#326 too long way <xsl:value-of select="abs(number(@Way_X2) - number($Cur_X1))"/></xsl:message>
+                            </xsl:if>-->
+                                    <xsl:if test="$debug">
+                                        <xsl:message>Try to say @Way_X1:<xsl:value-of select="@Way_X1"/>; @Way_X2:<xsl:value-of select="@Way_X2"/>; $Cur_X1:<xsl:value-of select="$Cur_X1"/>; </xsl:message>
+                                        <xsl:message>PlaceWay:  1=1 count()=<xsl:value-of select="count(.)"/>; number(@Way_X2)<xsl:value-of select="@Way_X2"/>  lenX:<xsl:value-of select=" round(number(@Way_X2) - number($Cur_X1) * 100) "/>; dla $Cur_X1=<xsl:value-of select="$Cur_X1"/>; $Cur_Y1=<xsl:value-of select="$Cur_Y1"/> @id=<xsl:value-of select="@id"/>; $not_id=<xsl:value-of select="$not_id"/>;$not_id_prev=<xsl:value-of select="$not_id_prev"/>;</xsl:message>
+                                    </xsl:if>
+                                </xsl:otherwise>
+                            </xsl:choose>
+                            
+                            
+                            <xsl:for-each select="$ways2joins/ways2joins/item[@id= current()/@id]/item"> <!-- musi byc wczesniej bo atrybut sie nie doda drugi raz-->
+                                <xsl:for-each select="$joins_asText_xml/joins_asText_xml/item[@id= current()/text()]/bp:Path_Point">
+                                    <xsl:if test="@X=$X and @Y=$Y">
+                                        <xsl:variable name="ID_Join" select="parent::node()/@id"/>
+                                        <xsl:attribute name="ID_Join" select="$ID_Join"/>
+                                    </xsl:if>
+                                </xsl:for-each>
+                            </xsl:for-each>
+                            <xsl:for-each select="$ways2joins/ways2joins/item[@id= current()/@id]/item">
+                                <xsl:for-each select="$joins_asText_xml/joins_asText_xml/item[@id= current()/text()]/bp:Path_Point">
+                                    <xsl:if test="@X=$X and @Y=$Y">
+                                        <xsl:variable name="ID_Join" select="parent::node()/@id"/>
+                                        <!--<xsl:attribute name="ID_Join" select="$ID_Join"/>-->
+                                        <!-- punkty podpiete -->
+                                        <xsl:copy-of select="$joins2ways_z_ID_Way/joins2ways_z_ID_Way/item[@id=$ID_Join]/Points"/>
+                                        <!-- wyszukanie drog wychodzacych innych niz nasza z punktu -->
+                                        <xsl:for-each select="$joins2ways_z_ID_Way/joins2ways_z_ID_Way/item[@id=$ID_Join]/item[not(@ID_WAY=$ID_Way)]">
+                                            <Ways>
+                                                <xsl:attribute name="ID_WAY" select="@ID_WAY"/>
+                                                <xsl:attribute name="ways_id" select="text()"/>
+                                            </Ways>
+                                        </xsl:for-each>
+                                    </xsl:if>
                                 </xsl:for-each>
+                            </xsl:for-each>
+                        </LineString>
+                    </xsl:for-each>
+                    <xsl:for-each select="$Ways/Ways/Way[@Way_X2=$Cur_X1 and @Way_Y2=$Cur_Y1 and ( not($not_id) or not(@id=$not_id))  and ( not(@Way_X1=@Way_X2 and @Way_Y1=@Way_Y2) ) and not(@id=$not_id_prev) ]">
+                        <LineString>
+                            <xsl:attribute name="X" select="@Way_X1"/>
+                            <xsl:attribute name="Y" select="@Way_Y1"/>
+                            <xsl:attribute name="not_id" select="@id"/>
+                            <xsl:attribute name="len" select="@len"/>
+                            <xsl:attribute name="not_id_prev" select="$not_id"/>
+                            <xsl:variable name="X" select="@Way_X1"/>
+                            <xsl:variable name="Y" select="@Way_Y1"/>
+                            <xsl:if test="$debug">
+                                <xsl:message>PlaceWay: 1=2 count()=<xsl:value-of select="count(.)"/>; lenX:<xsl:value-of select=" round(number(@Way_X1) - number($Cur_X1) * 100)"/>; dla $Cur_X1=<xsl:value-of select="$Cur_X1"/>; $Cur_Y1=<xsl:value-of select="$Cur_Y1"/> @id=<xsl:value-of select="@id"/>; $not_id=<xsl:value-of select="$not_id"/>;</xsl:message>
                             </xsl:if>
-                        </xsl:for-each>
+                            <xsl:if test=" abs(number(@Way_X1) - number($Cur_X1)) &gt; 0.001 ">
+                                <xsl:message>#326 too long way <xsl:value-of select="abs(number(@Way_X1) - number($Cur_X1))"/></xsl:message>
+                            </xsl:if>
+                            <xsl:for-each select="$ways2joins/ways2joins/item[@id= current()/@id]/item"> <!-- musi byc wczesniej bo atrybut sie nie doda drugi raz-->
+                                <xsl:for-each select="$joins_asText_xml/joins_asText_xml/item[@id= current()/text()]/bp:Path_Point">
+                                    <xsl:if test="@X=$X and @Y=$Y">
+                                        <xsl:variable name="ID_Join" select="parent::node()/@id"/>
+                                        <xsl:attribute name="ID_Join" select="$ID_Join"/>
+                                    </xsl:if>
+                                </xsl:for-each>
+                            </xsl:for-each>
+                            
+                            <xsl:for-each select="$ways2joins/ways2joins/item[@id= current()/@id]/item">
+                                <xsl:for-each select="$joins_asText_xml/joins_asText_xml/item[@id= current()/text()]/bp:Path_Point">
+                                    <xsl:if test="@X=$X and @Y=$Y">
+                                        <xsl:variable name="ID_Join" select="parent::node()/@id"/>
+                                        <!-- punkty podpiete -->
+                                        <xsl:copy-of select="$joins2ways_z_ID_Way/joins2ways_z_ID_Way/item[@id=$ID_Join]/Points"/>
+                                        <!-- wyszukanie drog wychodzacych innych niz nasza z punktu -->
+                                        <xsl:for-each select="$joins2ways_z_ID_Way/joins2ways_z_ID_Way/item[@id=$ID_Join]/item[not(@ID_WAY=$ID_Way)]">
+                                            <Ways>
+                                                <xsl:attribute name="ID_WAY" select="@ID_WAY"/>
+                                                <xsl:attribute name="ways_id" select="text()"/>
+                                            </Ways>
+                                        </xsl:for-each>
+                                    </xsl:if>
+                                </xsl:for-each>
+                            </xsl:for-each>
+                        </LineString>
                     </xsl:for-each>
-                </LineString>
-            </xsl:for-each>
+                </xsl:otherwise>
+            </xsl:choose>
+            
+            
         </xsl:variable>
         <xsl:copy-of select="$Linestring"/>
         <xsl:choose>
-            <xsl:when test="$loop &gt; 100000">
-                <loop_limit/>
+            <xsl:when test="$loop &gt; 1000">
+                <loop_limit>
+                    <xsl:choose>
+                        <xsl:when test="$bypass_errors">
+                            <xsl:message terminate="no">
+                                !!!!!!!!!!!!!!!! Loop limit dla PlaceWay: 1=2  dla $Cur_X1=<xsl:value-of select="$Cur_X1"/>; $Cur_Y1=<xsl:value-of select="$Cur_Y1"/> @id=<xsl:value-of select="@id"/>; $not_id=<xsl:value-of select="$not_id"/>
+                            </xsl:message>
+                        </xsl:when>
+                        <xsl:otherwise>
+                            <xsl:message terminate="yes">
+                                !!!!!!!!!!!!!!!! Loop limit dla PlaceWay: 1=2  dla $Cur_X1=<xsl:value-of select="$Cur_X1"/>; $Cur_Y1=<xsl:value-of select="$Cur_Y1"/> @id=<xsl:value-of select="@id"/>; $not_id=<xsl:value-of select="$not_id"/>
+                            </xsl:message>
+                        </xsl:otherwise>
+                    </xsl:choose>
+                    
+                </loop_limit>
+                
             </xsl:when>
             <xsl:when test="$Linestring/LineString/@X = $Last_X2 and $Linestring/LineString/@Y = $Last_Y2 ">
                 <ostatni/>
             </xsl:when>
             <xsl:otherwise>
+                <xsl:if test="$debug">
+                    <xsl:message>call-templ with Cur_X1=<xsl:value-of select="$Linestring/LineString/@X"/>; not_id=<xsl:value-of select="$Linestring/LineString/@not_id"/>;  not_id_prev=<xsl:value-of select="$Linestring/LineString/@not_id_prev"/></xsl:message>
+                </xsl:if>
                 <xsl:call-template name="PlaceWay">
                     <xsl:with-param name="Ways" select="$Ways"/>
                     <xsl:with-param name="Cur_X1" select="$Linestring/LineString/@X"/>
@@ -288,6 +412,7 @@
                     <xsl:with-param name="Last_X2" select="$Last_X2"/>
                     <xsl:with-param name="Last_Y2" select="$Last_Y2"/>
                     <xsl:with-param name="not_id" select="$Linestring/LineString/@not_id"/>
+                    <xsl:with-param name="not_id_prev" select="$Linestring/LineString/@not_id_prev"></xsl:with-param>
                     <xsl:with-param name="loop" select="$loop+1"/>
                     <xsl:with-param name="ID_Way" select="$ID_Way"/>
                 </xsl:call-template>

+ 2 - 1
SE/dev/php-cli/edge_paths_with_PE.xsl

@@ -7,8 +7,9 @@
     
     <xsl:output indent="yes"/>
     <xsl:strip-space elements="*"/>
+    <xsl:param name="joins2ways_z_ID_Way.xml" select="'joins2ways_z_ID_Way.xml'"/>
     
-    <xsl:variable name="joins2ways_z_ID_Way" select="doc('joins2ways_z_ID_Way.xml')"/>
+    <xsl:variable name="joins2ways_z_ID_Way" select="$joins2ways_z_ID_Way.xml"/>
     
     <!--//match edge_joins_filled_paths-->
     

文件差異過大導致無法顯示
+ 625 - 120
SE/dev/php-cli/edge_paths_with_PE_controll.xsl


+ 6 - 1
SE/dev/php-cli/edge_paths_with_PE_controll_to_PE.xsl

@@ -65,7 +65,12 @@
     
     
     
-    
+    <xsl:template match="*" mode="edge_paths_with_PE.xml">
+        <xsl:message>Matched node not needed <xsl:value-of select="name()"/></xsl:message>
+    </xsl:template>
+    <xsl:template match="text()" mode="edge_paths_with_PE.xml">
+        <xsl:message>Matched text: <xsl:value-of select="."/></xsl:message>
+    </xsl:template>
     
     
     

+ 37 - 0
SE/dev/php-cli/edge_paths_with_PE_controll_to_PE_collection.xsl

@@ -0,0 +1,37 @@
+<?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:include href="edge_paths_with_PE_controll_to_PE.xsl"/>
+    
+    <xsl:output indent="yes"/>
+    <xsl:strip-space elements="*"/>
+    
+    <xsl:param name="edge_paths_with_PE_controll_paths_temp" select="'edge_paths_with_PE_controll_paths_temp'"/> <!-- katalog z PE w plikach edge_paths_with_PE_controll.xsl.312.xml -->
+    
+    <!-- jedzie po koncach sciezek i z nich przyjmuje argument ID_Way po ktorym odpytuje sie pliki z wyloczeniami punktow -->
+    
+    <!--<xsl:variable name="edge_paths_with_PE_controll" select='collection( concat($edge_paths_with_PE_controll_paths_temp,"?select=*.xml;recurse=yes"))'/>-->
+    
+    
+    
+    <xsl:template match="EdgeWayJoins">
+        <PE_candidates_dump>
+            <xsl:apply-templates/>
+        </PE_candidates_dump>
+    </xsl:template>
+    
+    
+    <xsl:template match="EdgeWayJoinsPair">
+        <xsl:variable name="edge_paths_with_PE_controll" select="doc( concat($edge_paths_with_PE_controll_paths_temp,'/edge_paths_with_PE_controll.xsl.',@ID_Way,'.xml') )"/>
+        <xsl:apply-templates select="$edge_paths_with_PE_controll" mode="edge_paths_with_PE.xml_collection"/>
+    </xsl:template>
+    
+    <xsl:template match="edge_paths_with_PE_controll" mode="edge_paths_with_PE.xml_collection">
+        <xsl:apply-templates mode="edge_paths_with_PE.xml"/>
+    </xsl:template>
+    
+</xsl:stylesheet>

+ 3 - 2
SE/dev/php-cli/joins2ways_z_ID_Way.xsl

@@ -10,6 +10,7 @@
     <xsl:variable name="ways2drogi" select="doc($ways2drogi.xml)"/>
     <xsl:param name="points2joins.xml"  select="'points2joins.xml'"/>
     <xsl:variable name="points2joins" select="doc($points2joins.xml)"/>
+    <xsl:param name="joins2ways_z_ID_Way_tempdir" select="'joins2ways_z_ID_Way'"/>
     
     
     <xsl:template match="joins2ways">
@@ -64,12 +65,12 @@
         </xsl:for-each-group>
         </xsl:variable>
         <xsl:copy-of select="$items_grouped"/>
-        <xsl:result-document href="joins2ways_z_ID_Way/joins2ways_z_ID_Way.{@id}.{@ID_Way}.xml">
+        <!--<xsl:result-document href="{$joins2ways_z_ID_Way_tempdir}/joins2ways_z_ID_Way.{@id}.{@ID_Way}.xml">
             <joins2ways_z_ID_Way>
                 <xsl:attribute name="id" select="@id"/>
                 <xsl:copy-of select="$items_grouped"/>
             </joins2ways_z_ID_Way>
-        </xsl:result-document>
+        </xsl:result-document>-->
         
     </xsl:template>
     

文件差異過大導致無法顯示
+ 0 - 0
SE/dev/php-cli/points_asText.txt


+ 9 - 0
SE/dev/php-cli/ways_as_Text_z_ID_xml.xsl

@@ -16,6 +16,11 @@
    <!-- <xsl:param name="ways2joins.xml"  select="'ways2joins.xml'"/>
     <xsl:variable name="ways2joins" select="doc($ways2joins.xml)"/>
     -->
+    <!-- trzeba dorobic aby wskazac czy koniec drogi jest z tego samego WAYa /joinsa , 
+        czyli biore droge sprawdzam do jakiego jest joina, biore joina i sprawdzam do jakiego jest waya
+        , sprawdzam jakie inne waye sa z tym joinem , szukam 
+        
+    -->
     
     <xsl:output indent="yes"/>
     <xsl:strip-space elements="*"/>
@@ -46,4 +51,8 @@
         </xsl:variable>
         <xsl:apply-templates select="$asText"/>
     </xsl:template>
+    
+    
+ 
+    
 </xsl:stylesheet>

部分文件因文件數量過多而無法顯示