Procházet zdrojové kódy

Merge branch 'master' of ssh://biuro.biall-net.pl:2222/plabudda/se

Conflicts:
	SE/dev/php-cli/biale_plamy_class_usage.php
Mariusz Muszyński před 9 roky
rodič
revize
0ad33b9e26

+ 30 - 0
SE/dev/php-cli/asText.xsl

@@ -34,4 +34,34 @@
             </bp:Path_Point>
             </bp:Path_Point>
         </xsl:for-each>
         </xsl:for-each>
     </xsl:template>
     </xsl:template>
+    
+    
+    <xsl:template match="asText" mode="POINT">
+        <xsl:variable name="LINESTRING" select=" substring-before( substring-after(normalize-space(.),'POINT (') , ')')  "/>
+        <!--<test1><xsl:copy-of select="$LINESTRING"/></test1>-->
+        <xsl:for-each select="tokenize($LINESTRING,',')">
+            <bp:Path_Point>
+                <!--<xsl:attribute name="test2" select="."/>-->
+                <xsl:variable name="pos">
+                    <xsl:for-each select="tokenize(.,' ')">
+                        <pos>
+                            <xsl:attribute name="pos" select="position()"/>
+                            <xsl:value-of select="."/>
+                        </pos>
+                    </xsl:for-each>
+                </xsl:variable>
+                <xsl:choose>
+                    <xsl:when test="string-length($pos/pos[@pos=1]/text())&gt;0">
+                        <xsl:attribute name="X" select="$pos/pos[@pos=1]"/>
+                        <xsl:attribute name="Y" select="$pos/pos[@pos=2]"/>
+                    </xsl:when>
+                    <xsl:otherwise>
+                        <xsl:attribute name="X" select="$pos/pos[@pos=2]"/>
+                        <xsl:attribute name="Y" select="$pos/pos[@pos=3]"/>
+                    </xsl:otherwise>
+                </xsl:choose>
+                <!--<test3><xsl:copy-of select="$pos"/></test3>-->
+            </bp:Path_Point>
+        </xsl:for-each>
+    </xsl:template>
 </xsl:stylesheet>
 </xsl:stylesheet>

+ 148 - 4
SE/dev/php-cli/biale_plamy_class_findWay.php

@@ -6,8 +6,152 @@ require("biale_plamy_class.php");
 	$test = new bialePlamy(array("pointsTable"=>"Rozdzielcza_test2_bzyk_punkty_adresowe", "origWaysTable"=>"Rozdzielcza_test2_bzyk_drogi"));
 	$test = new bialePlamy(array("pointsTable"=>"Rozdzielcza_test2_bzyk_punkty_adresowe", "origWaysTable"=>"Rozdzielcza_test2_bzyk_drogi"));
 	//$test->enableShowProgress();
 	//$test->enableShowProgress();
 	$test->loadCache();
 	$test->loadCache();
-	$joins = $test->findWay(42366, 42376);
-	$lineStringObj = $test->joins2lineString($joins);
-	$lineString_asText = $lineStringObj->asText();
-	echo $lineString_asText;
+	
+	
+function array_to_xml( $data, &$xml_data ) {
+    foreach( $data as $key => $value ) {
+        $key_="";
+        
+        if( is_numeric($key) ){
+            $key_ = 'item';
+        }
+        
+        if( is_array($value) ) {
+            $subnode = $xml_data->addChild($key_);
+			$subnode->addAttribute('id', $key);
+            array_to_xml($value, $subnode);
+        } else {
+	       // $test_expl=explode(" ", $value);
+					//preg_match('/[a-zA-Z]/', $value[0])
+	        //if($key_=="" and !isset($test_expl[1])  )  $key_=htmlspecialchars("$value");
+	        //czy nie jest jeden element array
+	        if($key_=="" and  count($data[$key]==1)) {
+		   		 $subnode=$xml_data->addChild("$key",htmlspecialchars("$value"));
+		    } else  
+            $subnode=$xml_data->addChild("$key_",htmlspecialchars("$value"));
+            if( is_numeric($key) ){
+	            $subnode->addAttribute('id', $key);
+	        }
+        }
+     }
+}
 
 
+	
+	
+	
+	
+$ways2joins = unserialize(file_get_contents('/tmp/save_ways2joins.txt'));
+$joins2ways = unserialize(file_get_contents('/tmp/save_joins2ways.txt'));
+$points2joins = unserialize(file_get_contents('/tmp/save_points2joins.txt'));
+$joins_asText = unserialize(file_get_contents('/tmp/save_joins_asText.txt'));
+$ways_asText = unserialize(file_get_contents('/tmp/save_ways_asText.txt'));
+$points_asText = unserialize(file_get_contents('/tmp/save_points_asText.txt'));
+
+$edge_joins=simplexml_load_file("edge_joins.xml");
+$edge_joins->registerXPathNamespace('bp', 'https://procesy5.pl/biale_plamy-schema.xsd');
+
+//print_r($edge_joins);
+foreach($edge_joins->children() as $child)  {
+ // echo "\n<br>";
+	   //$attrs=$child->attributes("ID_Way");
+
+	   foreach($child->attributes() as $a=>$b) {
+		   //	echo "#87Child";print_r($b[0]);
+		   $ID_Way=$b[0];
+	   }
+	  //echo $child->getName() . ": " . " ID_Way: ".$ID_Way. " : ";
+	
+	   $id_j=0; 
+	   settype($ID_Way, "integer");
+	   //$ID_Way=var_dump($ID_Way);
+	   
+	 //  echo "#88Child:"; print_r($ID_Way);
+	   //$edge_joins_path['ID_Way'][$attrs['ID_Way']]=array();
+	   foreach($child->children('https://procesy5.pl/biale_plamy-schema.xsd') as $edge_joins_xml)  {
+		   $id_j++;
+		   $attrs_join=$edge_joins_xml->attributes();
+		   //echo " #93 ID_Join ".$attrs_join["Joins"]." ";
+		   $Join=$attrs_join["Joins"][0];
+		   settype($Join, "integer");
+		   $edge_joins_path[$ID_Way][$id_j]=$attrs_join["Joins"][0];
+	   }
+}
+
+	
+	
+	
+	
+	/////////
+	
+	 DB::getPDO()->query("truncate table Rozdzielcza_test_bzyk_paths");
+
+unset($ID_Way);
+
+$edge_joins_filled_paths=array();
+foreach($edge_joins_path as $ID_Way=>$Joins_arr) {
+	settype($ID_Way, "integer");
+	$edge_joins_filled_paths[$ID_Way]['tried']=1;
+	if(isset($Joins_arr[1]) and isset($Joins_arr[2]))  {
+			   $pkt_A=$Joins_arr[1];$pkt_B=$Joins_arr[2];
+			   settype($pkt_A, "integer"); settype($pkt_B, "integer");
+
+		echo "\n<br> Generuje dla ID_Way:".$ID_Way." i joins ".$pkt_A." , ".$pkt_B." ";
+		unset($res);unset($path);
+		
+		
+		{
+	
+			$res = $test->findWay($pkt_A, $pkt_B);
+			$lineStringObj = $test->joins2lineString($res);
+			$path = $lineStringObj->asText();
+		
+		}
+		
+		//$res = findWay($pkt_A,$pkt_B);
+		//$path = joins2lineString($res)->asText();
+		//   joins2lineString(findWay(389,404));
+		settype($path, "string");
+		$edge_joins_filled_paths[$ID_Way]['asText'] = $path;
+			$distance = 0;
+				foreach ($res as $way_key) {
+					if(isset($ways_asText[$way_key]))
+					$distance += Vendor_Geophp::load($ways_asText[$way_key], 'wkt')->greatCircleLength();
+				}
+		$edge_joins_filled_paths[$ID_Way]['distance'] = $distance;
+		//joins2lineString(findWay($Joins_arr[1],$Joins_arr[2]));
+		//joins2lineString($res = findWay($joinAB['A'],$joinAB['B']))->asText();
+		$sql_insert_path="insert into Rozdzielcza_test_bzyk_paths (the_geom,ID_Way, A_RECORD_CREATE_DATE )
+		     values (ST_GeomFromText('".$edge_joins_filled_paths[$ID_Way]['asText']."'),'".$ID_Way."' , now()   )   ";
+		    echo "#216Query path ins:: ".$sql_insert_path." , distance:".$distance." ";
+		    if(strlen($edge_joins_filled_paths[$ID_Way]['asText'])>2)
+		      DB::getPDO()->query($sql_insert_path);
+		    else echo "#296 path nie wygenerowalo sie !! dla ".$ID_Way." i pkt ".$pkt_A." , ".$pkt_B." \n";
+
+	} else echo "\n#220 droga nie ma koncow ID_Way::".$ID_Way;
+}
+
+
+echo "<br>\n edge_joins_filled_paths:";
+print_r($edge_joins_filled_paths);
+
+
+//save
+ 	unset($xml_data);
+
+file_put_contents('edge_joins_filled_paths.txt',serialize($edge_joins_filled_paths));
+ 	ob_start();print_r($edge_joins_filled_paths); $contents = ob_get_contents();ob_end_clean();  
+ 	file_put_contents('edge_joins_filled_paths_print_r.txt',$contents);
+ 	$xml_data = new SimpleXMLElement('<?xml version="1.0"?><edge_joins_filled_paths></edge_joins_filled_paths>');
+ 	array_to_xml($edge_joins_filled_paths,$xml_data);
+ 	print $xml_data->asXML("edge_joins_filled_paths.xml");
+ 	unset($xml_data);
+  
+
+
+	
+	
+	
+	
+	
+	
+	

+ 1 - 0
SE/dev/php-cli/biale_plamy_joins2ways_do_paths.xsl

@@ -109,6 +109,7 @@
                 
                 
                 <EdgeWayJoinsPair>
                 <EdgeWayJoinsPair>
                     <xsl:attribute name="ID_Way" select="@ID_Way"/>
                     <xsl:attribute name="ID_Way" select="@ID_Way"/>
+                    <!-- debug -->
                     <!--<xsl:copy-of select="$guess_edges/guess_join[@ID_Way=$ID_Way]"></xsl:copy-of>-->
                     <!--<xsl:copy-of select="$guess_edges/guess_join[@ID_Way=$ID_Way]"></xsl:copy-of>-->
                     <xsl:for-each select="$guess_edges/guess_join[@ID_Way=$ID_Way]/EdgeWayJoinsPair_cand">
                     <xsl:for-each select="$guess_edges/guess_join[@ID_Way=$ID_Way]/EdgeWayJoinsPair_cand">
                         <bp:Joins>
                         <bp:Joins>

+ 2 - 4
SE/dev/php-cli/biale_put_Cables_to_PE.php

@@ -122,7 +122,6 @@ $id_j=0;
 foreach($cables_from_joins_to_PE->xpath('cable_to_PE_to_be_calculated') as $child)  { //cable_to_PE_to_be_calculated
 foreach($cables_from_joins_to_PE->xpath('cable_to_PE_to_be_calculated') as $child)  { //cable_to_PE_to_be_calculated
  // echo "\n<br>";
  // echo "\n<br>";
 	   //$attrs=$child->attributes("ID_Way");
 	   //$attrs=$child->attributes("ID_Way");
-
 	   foreach($child->attributes() as $a=>$b) {
 	   foreach($child->attributes() as $a=>$b) {
 		   //	echo "#87Child";print_r($b[0]);
 		   //	echo "#87Child";print_r($b[0]);
 		   if($a=='ID_Way') $ID_Way=$b[0];
 		   if($a=='ID_Way') $ID_Way=$b[0];
@@ -147,9 +146,6 @@ 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]['Joins']=$Joins;
 		   $cables_from_joins_to_PE_arr[$id_j]['ID_Way']=$ID_Way;
 		   $cables_from_joins_to_PE_arr[$id_j]['ID_Way']=$ID_Way;
 		   $cables_from_joins_to_PE_arr[$id_j]['ID_Point']=$ID_Point;
 		   $cables_from_joins_to_PE_arr[$id_j]['ID_Point']=$ID_Point;
-
-
-
 	   }
 	   }
 }
 }
 
 
@@ -168,7 +164,9 @@ foreach($cables_from_joins_to_PE_arr as $id_j=>$Path_Point_val) {
 		     '".$Path_Point_val['ID_Point']."'   )   ";
 		     '".$Path_Point_val['ID_Point']."'   )   ";
 		    echo "#216Query path ins:: ".$sql_Path_Point_val."  ";
 		    echo "#216Query path ins:: ".$sql_Path_Point_val."  ";
 		    //if(strlen($edge_joins_filled_paths[$ID_Way]['asText'])>2)
 		    //if(strlen($edge_joins_filled_paths[$ID_Way]['asText'])>2)
+		    if(strlen($Path_Point_val['LINESTRING'])>1) 
 		      DB::getPDO()->query($sql_Path_Point_val);
 		      DB::getPDO()->query($sql_Path_Point_val);
+		    else echo " ERROR blad danych!!! dla ID_Point:".$Path_Point_val['ID_Point'];
 		    //else echo "#296 path nie wygenerowalo sie !! dla ".$ID_Way." i pkt ".$pkt_A." , ".$pkt_B." \n";
 		    //else echo "#296 path nie wygenerowalo sie !! dla ".$ID_Way." i pkt ".$pkt_A." , ".$pkt_B." \n";
 			
 			
 	
 	

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 28 - 0
SE/dev/php-cli/biale_put_xml_paths_to_mysql.php


+ 148 - 34
SE/dev/php-cli/build__biale_plamy.xml

@@ -9,7 +9,11 @@
     <property name="biale_plamy_class.php" value="biale_plamy_class.php"/>
     <property name="biale_plamy_class.php" value="biale_plamy_class.php"/>
     <property name="biale_plamy-prepare_sql_data.php" value="biale_plamy-prepare_sql_data.php"/>
     <property name="biale_plamy-prepare_sql_data.php" value="biale_plamy-prepare_sql_data.php"/>
     <property name="biale_plamy-generate_data.php" value="biale_plamy-generate_data.php"/>
     <property name="biale_plamy-generate_data.php" value="biale_plamy-generate_data.php"/>
-    <property name="biale_plamy-find_ways.php" value="biale_plamy-find_ways.php"/>
+    
+    <property name="ways_as_Text_z_ID_xml.xsl" value="ways_as_Text_z_ID_xml.xsl"/>
+    <property name="ways_as_Text_z_ID_xml.xml" value="ways_as_Text_z_ID_xml.xml"/>
+    
+    <property name="biale_plamy_class_findWay.php" value="biale_plamy_class_findWay.php"/><!--<property name="biale_plamy-find_ways.php" value="biale_plamy-find_ways.php"/>-->
         <property name="joins_asText.xml" value="joins_asText.xml"/>
         <property name="joins_asText.xml" value="joins_asText.xml"/>
         <property name="joins2ways.xml" value="joins2ways.xml"/>
         <property name="joins2ways.xml" value="joins2ways.xml"/>
         <property name="points2ID_Way.xml" value="points2ID_Way.xml"/>
         <property name="points2ID_Way.xml" value="points2ID_Way.xml"/>
@@ -21,9 +25,17 @@
             <property name="joins2ways_z_ID_Way.xsl" value="joins2ways_z_ID_Way.xsl"/>
             <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.xml" value="joins2ways_z_ID_Way.xml"/>
             <property name="biale_plamy_joins2ways_do_paths.xsl" value="biale_plamy_joins2ways_do_paths.xsl"/>
             <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="points_asText.xml" value="points_asText.xml"/>
         <property name="points_asText.xml" value="points_asText.xml"/>
         <property name="points2joins.xml" value="points2joins.xml"/>
         <property name="points2joins.xml" value="points2joins.xml"/>
         <property name="edge_joins.xml" value="edge_joins.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.xml" value="edge_joins_filled_paths.xml"/>
             <property name="edge_joins_filled_paths.xsl" value="edge_joins_filled_paths.xsl"/>
             <property name="edge_joins_filled_paths.xsl" value="edge_joins_filled_paths.xsl"/>
     
     
@@ -44,15 +56,17 @@
     
     
     <target name="biale_plamy-generate_data" >
     <target name="biale_plamy-generate_data" >
         <!-- stary sposob -->
         <!-- stary sposob -->
-        <antcall target="biale_plamy_prepare_mysql_data"/>        
-        <antcall target="biale_plamy-generate_data_sql"/>
+        <antcall target="biale_plamy-prepare_sql_data.php"/>        
+        <antcall target="biale_plamy-generate_data.php"/>
         <echo message="odpalam biale_plamy-generate_data "/>
         <echo message="odpalam biale_plamy-generate_data "/>
         <delete file="${joins2ways_z_ID_Way.xml}"/>
         <delete file="${joins2ways_z_ID_Way.xml}"/>
-        <antcall target="biale_plamy_points2ID_Way_do_Joins"/>
+        <antcall target="joins2ways_z_ID_Way.xml"/>
+        
         <delete file="${edge_joins.xml}"/>
         <delete file="${edge_joins.xml}"/>
-        <antcall target="biale_plamy_joins2ways_do_paths"/>
+        <antcall target="edge_joins.xml"/>
+        
         <!-- tymczasowy rem bo dziala -->
         <!-- tymczasowy rem bo dziala -->
-        <antcall target="biale_plamy_paths_to_findways_php"/>
+        <antcall target="biale_plamy_class_findWay.php"/>
         <antcall target="PE_and_Cables"/>
         <antcall target="PE_and_Cables"/>
     </target>
     </target>
     
     
@@ -60,35 +74,77 @@
     
     
     <target name="biale_plamy-generate_data_by_nosql">
     <target name="biale_plamy-generate_data_by_nosql">
         <!-- nowy sposob -->
         <!-- nowy sposob -->
-        <antcall target="biale_plamy_prepare_php_data_by_class"/>  <delete file="${joins2ways_z_ID_Way.xml}"/>
-        <antcall target="biale_plamy_points2ID_Way_do_Joins"/>
+        <antcall target="biale_plamy_class.php"/>  
+        
+        <delete file="${joins2ways_z_ID_Way.xml}"/>
+        <antcall target="joins2ways_z_ID_Way.xml"/>
+        
+        <antcall target="AsTextToXml"/>
+        
+        <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="biale_plamy_class_findWay.php"/>-->
+        <antcall target="PE_and_Cables"/>
+    </target>
+    
+   
+    
+    
+    <target name="biale_plamy-just_xsl_PE_cables">
+        <!-- nowy sposob -->
+          
+        <delete file="${joins2ways_z_ID_Way.xml}"/>
+        <antcall target="joins2ways_z_ID_Way.xml"/>
+        
+        <antcall target="AsTextToXml"/>
+       
         <delete file="${edge_joins.xml}"/>
         <delete file="${edge_joins.xml}"/>
-        <antcall target="biale_plamy_joins2ways_do_paths"/>
-        <antcall target="biale_plamy_paths_to_findways_php"/>
+        <antcall target="edge_joins.xml"/>
+        
+        <delete file="${edge_joins_filled_paths.xml}"/>
+        <antcall target="edge_joins_filled_paths_make"/>
+        
+        <antcall target="biale_plamy_class_findWay.php"/><!-- to jest szukanie path mega wolne -->
         <antcall target="PE_and_Cables"/>
         <antcall target="PE_and_Cables"/>
     </target>
     </target>
     
     
+    <target name="AsTextToXml">
+        <delete file="${ways_as_Text_z_ID_xml.xml}"/>
+        <antcall target="ways_as_Text_z_ID_xml.xml"/>
+        
+        <delete file="${joins_asText_xml.xml}"/>
+        <antcall  target="joins_asText_xml.xml"/>
+    </target>
+    
+    
     <target name="clean">
     <target name="clean">
+        <delete file="${joins2ways_z_ID_Way.xml}"/>
+        <delete file="${edge_joins_filled_paths.xml}"/>
+        <delete file="${edge_paths_with_PE.xml}"/>
+        <delete file="${cables_from_joins_to_PE.xml}"/>
+        <delete file="${joins_asText_xml.xml}"/>
+        <delete file="${ways_as_Text_z_ID_xml.xml}"/>
+    </target>
+    
+    <target name="clean_input">
+        <delete file="${points2ID_Way.xml}"/>
         <delete file="${points2joins.xml}"/>
         <delete file="${points2joins.xml}"/>
         <delete file="${ways2joins.xml}"/>
         <delete file="${ways2joins.xml}"/>
         <delete file="${ways_asText.xml}"/>
         <delete file="${ways_asText.xml}"/>
         <delete file="${joins_asText.xml}"/>
         <delete file="${joins_asText.xml}"/>
-        <delete file="${joins2ways_z_ID_Way.xml}"/>
         <delete file="${edge_joins.xml}"/>
         <delete file="${edge_joins.xml}"/>
         <delete file="${joins2ways.xml}"/>
         <delete file="${joins2ways.xml}"/>
-        <delete file="${points2ID_Way.xml}"/>
         <delete file="${ways2drogi.xmll}"/>
         <delete file="${ways2drogi.xmll}"/>
-        <delete file="${joins2ways_z_ID_Way.xml}"/>
         <delete file="${points_asText.xml}"/>
         <delete file="${points_asText.xml}"/>
-        <delete file="${points2joins.xml}"/>
         <delete file="${edge_joins.xml}"/>
         <delete file="${edge_joins.xml}"/>
-        <delete file="${edge_joins_filled_paths.xml}"/>
-        <delete file="${edge_paths_with_PE.xml}"/>
-        <delete file="${cables_from_joins_to_PE.xml}"/>
+        <delete file="${points2joins.xml}"/>
     </target>
     </target>
     
     
     
     
-    
     <target name="check_files_for_PE_and_Cables" >
     <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">
         <condition property="files_PE_and_Cables" taskname="PE_and_Cables" value="AVIABLE">
@@ -102,23 +158,23 @@
     
     
     
     
     <target name="PE_and_Cables">
     <target name="PE_and_Cables">
-        <antcall target="biale_plamy_from_paths_php_to_place_PE"/>
+        <antcall target="edge_paths_with_PE.xml"/>
         <!-- tymczasowy rem bo skryptu nie ma -->
         <!-- tymczasowy rem bo skryptu nie ma -->
         <antcall target="biale_plamy_put_PE_to_mysql_php"/>
         <antcall target="biale_plamy_put_PE_to_mysql_php"/>
-        <antcall target="biale_plamy_analyze_shortest_and_trace_cables"/>        
+        <antcall target="cables_from_joins_to_PE.xml"/>        
         <!--Tymczasowa zatrzymanie bo nie chodzi na zdalnym - plik juz jest-->
         <!--Tymczasowa zatrzymanie bo nie chodzi na zdalnym - plik juz jest-->
         <antcall target="biale_put_Cables_to_PE"/>
         <antcall target="biale_put_Cables_to_PE"/>
     </target>
     </target>
     
     
     
     
-    <target name="biale_plamy_prepare_mysql_data">
+    <target name="biale_plamy-prepare_sql_data.php">
         <echo message="biale_plamy_prepare_mysql_data - przygotowuje punkty xpoint"/>
         <echo message="biale_plamy_prepare_mysql_data - przygotowuje punkty xpoint"/>
         <exec executable="php" failonerror="true" dir=".">
         <exec executable="php" failonerror="true" dir=".">
             <arg file="${biale_plamy-prepare_sql_data.php}"/>
             <arg file="${biale_plamy-prepare_sql_data.php}"/>
         </exec>
         </exec>
     </target>
     </target>
     
     
-    <target name="biale_plamy_prepare_php_data_by_class">
+    <target name="biale_plamy_class.php">
         <echo message=" przygotowuje punkty xpoint przez biale_plamy_class.php"/>
         <echo message=" przygotowuje punkty xpoint przez biale_plamy_class.php"/>
         <exec executable="php" failonerror="true" dir=".">
         <exec executable="php" failonerror="true" dir=".">
             <arg file="${biale_plamy_class.php}"/>
             <arg file="${biale_plamy_class.php}"/>
@@ -127,7 +183,7 @@
    
    
    
    
    
    
-    <target name="biale_plamy-generate_data_sql">
+    <target name="biale_plamy-generate_data.php">
         <!--<antcall target="install_in_file_db_query">
         <!--<antcall target="install_in_file_db_query">
             <param name="sql_query" value="select 1+1;"/>
             <param name="sql_query" value="select 1+1;"/>
         </antcall>-->
         </antcall>-->
@@ -137,8 +193,10 @@
         <echo message="Teraz Przelec arraya joins2ways pod katem 1-elementowych subarrayow"/>
         <echo message="Teraz Przelec arraya joins2ways pod katem 1-elementowych subarrayow"/>
     </target> 
     </target> 
    
    
-    <target name="biale_plamy_points2ID_Way_do_Joins">
-        <echo message="przygotownie z joins2ways xsl biale_plamy_joins2ways_do_paths.xsl pod katem 1  katem 1-elementowych subarrayow aby zrobic paths "/>
+   
+   
+    <target name="joins2ways_z_ID_Way.xml">
+        <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}"/>
         <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}" >
         <xslt basedir="./" style="${joins2ways_z_ID_Way.xsl}" in="${joins2ways.xml}"  destdir="./" out="${joins2ways_z_ID_Way.xml}" >
             <factory name="net.sf.saxon.TransformerFactoryImpl">    
             <factory name="net.sf.saxon.TransformerFactoryImpl">    
@@ -151,8 +209,24 @@
         </xslt>
         </xslt>
     </target>
     </target>
    
    
-    <target name="biale_plamy_joins2ways_do_paths">
-        <echo message="przygotownie z joins2ways xsl biale_plamy_joins2ways_do_paths.xsl pod katem 1  katem 1-elementowych subarrayow aby zrobic paths "/>
+   
+    <target name="joins_asText_xml.xml">
+        <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}" >
+            <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="points2ID_Way.xml"  expression="${ways2drogi.xml}"/>-->
+        </xslt>
+    </target>
+   
+   
+    <target name="edge_joins.xml">
+        <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}"/>
         <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}" >
         <xslt basedir="./" style="${biale_plamy_joins2ways_do_paths.xsl}" in="${joins2ways_z_ID_Way.xml}"  destdir="./" out="${edge_joins.xml}" >
             <factory name="net.sf.saxon.TransformerFactoryImpl">    
             <factory name="net.sf.saxon.TransformerFactoryImpl">    
@@ -165,17 +239,56 @@
         </xslt>
         </xslt>
     </target>
     </target>
    
    
-    <!-- wyznaczenie sciezek do ulozenia PE - dziala-->
-    <target name="biale_plamy_paths_to_findways_php">
+    <!-- wyznaczenie sciezek do ulozenia PE - dziala -  -->
+    <target name="ways_as_Text_z_ID_xml.xml">
+        <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}" >
+             <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="ways2drogi.xml" expression="${ways2drogi.xml}"/>
+         </xslt>
+     </target>
+    
+    <target name="edge_joins_filled_paths_make">
+        <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}"/>
+        <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"/>
+                <!--<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="ways_as_Text_z_ID_xml.xml" expression="${ways_as_Text_z_ID_xml.xml}"/>
+            <param name="joins_asText_xml.xml" expression="${joins_asText_xml.xml}"/>
+        </xslt>
+    </target>
+    
+    <target name="biale_put_xml_paths_to_mysql.php">
+        <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=".">
         <exec executable="php" failonerror="true" dir=".">
-            <arg file="${biale_plamy-find_ways.php}"/>
+            <arg file="${biale_put_xml_paths_to_mysql.php}"/>
         </exec>
         </exec>
-        <!-- to wyrzuca edge_joins_filled_paths.xml-->
     </target>
     </target>
+    
+    <target name="biale_plamy_class_findWay.php">
+        <!-- to jest szukanie path mega wolne -->
+         <exec executable="php" failonerror="true" dir=".">
+             <arg file="${biale_plamy_class_findWay.php}"/>
+         </exec>
+         <!-- to wyrzuca edge_joins_filled_paths.xml-->
+     </target>
+    
+   
    
    
     <!-- postawienie PE po trasach -->
     <!-- postawienie PE po trasach -->
-    <target name="biale_plamy_from_paths_php_to_place_PE">
-        <echo message="Wyznaczenie PE na podstawie tras  "/>
+    <target name="edge_paths_with_PE.xml">
+        <echo message="Wyznaczenie PE na podstawie tras ${edge_paths_with_PE.xml} "/>
         <delete file="${edge_paths_with_PE.xml}"/>
         <delete file="${edge_paths_with_PE.xml}"/>
         <xslt basedir="./" style="${edge_joins_filled_paths.xsl}" in="${edge_joins_filled_paths.xml}"  destdir="./" out="${edge_paths_with_PE.xml}" >
         <xslt basedir="./" style="${edge_joins_filled_paths.xsl}" in="${edge_joins_filled_paths.xml}"  destdir="./" out="${edge_paths_with_PE.xml}" >
             <factory name="net.sf.saxon.TransformerFactoryImpl">    
             <factory name="net.sf.saxon.TransformerFactoryImpl">    
@@ -195,7 +308,7 @@
     </target>
     </target>
     
     
     <!-- przeliczenie dla kazdego PE z trasy punktu przeciecia i wybranie najkrotszej i wygenerowania kabla -->
     <!-- przeliczenie dla kazdego PE z trasy punktu przeciecia i wybranie najkrotszej i wygenerowania kabla -->
-    <target name="biale_plamy_analyze_shortest_and_trace_cables">
+    <target name="cables_from_joins_to_PE.xml">
         <delete file="${cables_from_joins_to_PE.xml}"/>
         <delete file="${cables_from_joins_to_PE.xml}"/>
         <xslt basedir="./" style="${cables_from_joins_to_PE.xsl}" in="${joins2ways_z_ID_Way.xml}"  destdir="./" out="${cables_from_joins_to_PE.xml}" >
         <xslt basedir="./" style="${cables_from_joins_to_PE.xsl}" in="${joins2ways_z_ID_Way.xml}"  destdir="./" out="${cables_from_joins_to_PE.xml}" >
             <factory name="net.sf.saxon.TransformerFactoryImpl">    
             <factory name="net.sf.saxon.TransformerFactoryImpl">    
@@ -209,6 +322,7 @@
     </target>
     </target>
    
    
     <target name="biale_put_Cables_to_PE">
     <target name="biale_put_Cables_to_PE">
+        <echo message="Wgrywam Kable z pliku ${cables_from_joins_to_PE.xml} do bazy danych "></echo>
         <exec executable="php" failonerror="true" dir=".">
         <exec executable="php" failonerror="true" dir=".">
             <arg file="${biale_put_Cables_to_PE.php}"/>
             <arg file="${biale_put_Cables_to_PE.php}"/>
         </exec>
         </exec>

+ 13 - 13
SE/dev/php-cli/cables_from_joins_to_PE.xsl

@@ -34,7 +34,6 @@
         <!-- jedziemy po joins2ways_z_ID_Way, sprawdzamy czy jest dla niego PE_candidates_dump , jak tak, to szukamy jego PE i liczymy sciezke 
         <!-- 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-->
                lub probujemy rysowac zawsze od konca drogi-->
             
             
-            
           <xsl:for-each select="item">
           <xsl:for-each select="item">
             <xsl:variable name="ID_Way" select="@ID_Way"/>
             <xsl:variable name="ID_Way" select="@ID_Way"/>
             <xsl:variable name="Joins" select="@id"/>
             <xsl:variable name="Joins" select="@id"/>
@@ -86,7 +85,6 @@
                                     </xsl:choose>
                                     </xsl:choose>
                             </xsl:for-each>
                             </xsl:for-each>
                         </xsl:variable>
                         </xsl:variable>
-                        
                         <xsl:choose>
                         <xsl:choose>
                             <xsl:when test="$found_in_path_in_edge_joins_filled_path/found_in_path_in_edge_joins_filled_path">
                             <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:for-each select="$found_in_path_in_edge_joins_filled_path/found_in_path_in_edge_joins_filled_path[1]">
@@ -106,9 +104,7 @@
                                             <xsl:with-param name="ID_Point" select="$ID_Point"/>
                                             <xsl:with-param name="ID_Point" select="$ID_Point"/>
                                         </xsl:call-template>
                                         </xsl:call-template>
                                     </found_in_path_in_edge_joins_filled_path>-->
                                     </found_in_path_in_edge_joins_filled_path>-->
-                                    
                                     <xsl:copy-of select="."/>
                                     <xsl:copy-of select="."/>
-                                    
                                 </xsl:for-each>
                                 </xsl:for-each>
                                 <xsl:copy-of select="$found_in_path_in_edge_joins_filled_path/not_found"/>
                                 <xsl:copy-of select="$found_in_path_in_edge_joins_filled_path/not_found"/>
                             </xsl:when>
                             </xsl:when>
@@ -138,9 +134,11 @@
            
            
            <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="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="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>
            <detect_next_PE>
                <xsl:attribute name="Pos_found" select="$Pos_found"/>
                <xsl:attribute name="Pos_found" select="$Pos_found"/>
-               <!--<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)]-->
+               <!--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="Next_PE_Pos" select="$Next_PE_Pos"/>
                <xsl:attribute name="Prev_PE_Pos" select="$Prev_PE_Pos"/>
                <xsl:attribute name="Prev_PE_Pos" select="$Prev_PE_Pos"/>
                <xsl:choose>
                <xsl:choose>
@@ -168,14 +166,16 @@
                            <xsl:with-param name="Path_Point" select="$Path_Point"/>
                            <xsl:with-param name="Path_Point" select="$Path_Point"/>
                        </xsl:call-template>
                        </xsl:call-template>
                    </xsl:when>
                    </xsl:when>
-                   
-                   <xsl:otherwise><xsl:message terminate="yes">#Error 111 - nie moze byc innego wyjatku
-                       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)"/>
-                   </xsl:message></xsl:otherwise>
+                   <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>
                </xsl:choose>
            </detect_next_PE>
            </detect_next_PE>
            
            

+ 234 - 0
SE/dev/php-cli/edge_joins_filled_paths_make.xsl

@@ -0,0 +1,234 @@
+<?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="ways_as_Text_z_ID_xml.xml" select="'ways_as_Text_z_ID_xml.xml'"/>
+    <xsl:variable name="ways_asText_z_ID_xml" select="doc($ways_as_Text_z_ID_xml.xml)"/>
+    
+    <xsl:param name="joins_asText_xml.xml" select="'joins_asText_xml.xml'"/>
+    <xsl:variable name="joins_asText_xml" select="doc($joins_asText_xml.xml)"/>
+    
+    
+    <xsl:output indent="yes"/>
+    <xsl:strip-space elements="*"/>
+    
+    <xsl:template match="EdgeWayJoins">
+        <edge_joins_filled_paths>
+            <xsl:attribute name="stylesheet" select="'edge_joins_filled_paths_make.xsl'"/>
+        <xsl:apply-templates/>
+        </edge_joins_filled_paths>
+    </xsl:template>
+    
+    
+    <xsl:template match="EdgeWayJoinsPair">
+        <item>
+            <xsl:attribute name="id" select="@ID_Way"/>
+            <xsl:variable name="ID_Way" select="@ID_Way"/>
+            <asText>
+                <xsl:variable name="bp:Joins">
+                    <xsl:for-each select="bp:Joins">
+                        <bp:Joins>
+                            <xsl:copy-of select="@*"/>
+                            <xsl:copy-of select="$joins_asText_xml/joins_asText_xml/item[@id= current()/@Joins]/bp:Path_Point/@X"/>
+                            <xsl:copy-of select="$joins_asText_xml/joins_asText_xml/item[@id= current()/@Joins]/bp:Path_Point/@Y"/>
+                            <xsl:attribute name="position" select="position()"/>
+                            <!--<xsl:copy-of select="$joins_asText_xml/joins_asText_xml/item[@id= current()/@id]/"/>-->
+                        </bp:Joins>
+                    </xsl:for-each>
+                </xsl:variable>
+                <!--<Joins>
+                    <xsl:copy-of select="$bp:Joins"/>
+                </Joins>-->
+                <xsl:variable name="Join_X1" select="$bp:Joins/bp:Joins[@position=1]/@X"/>
+                <xsl:variable name="Join_Y1" select="$bp:Joins/bp:Joins[@position=1]/@Y"/>
+                <xsl:variable name="Join_X2" select="$bp:Joins/bp:Joins[@position=2]/@X"/>
+                <xsl:variable name="Join_Y2" select="$bp:Joins/bp:Joins[@position=2]/@Y"/>
+                <!-- na podstawie joina ustalamy jego wspolrzedne -->
+                
+                <xsl:variable name="Ways">
+                <Ways>
+                    <xsl:attribute name="Join_X1" select="$Join_X1"/>
+                    <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]">
+                            <Way>
+                                <xsl:attribute name="id" select="@id"/>
+                                <xsl:variable name="bp:Path_Point">
+                                    <xsl:for-each select="bp:Path_Point">
+                                    <bp:Path_Point>
+                                        <xsl:copy-of select="@*"/>
+                                        <xsl:attribute name="position" select="position()"/>
+                                    </bp:Path_Point>
+                                    </xsl:for-each>
+                                </xsl:variable>
+                               <!-- <xsl:variable name="Way_X1" select="$bp:Path_Point/bp:Path_Point[@position=1]/@X"/>
+                                <xsl:variable name="Way_Y1" select="$bp:Path_Point/bp:Path_Point[@position=1]/@Y"/>
+                                <xsl:variable name="Way_X2" select="$bp:Path_Point/bp:Path_Point[@position=2]/@X"/>
+                                <xsl:variable name="Way_Y2" select="$bp:Path_Point/bp:Path_Point[@position=2]/@Y"/>-->
+                                <xsl:attribute name="Way_X1" select="$bp:Path_Point/bp:Path_Point[@position=1]/@X"/>
+                                <xsl:attribute name="Way_Y1" select="$bp:Path_Point/bp:Path_Point[@position=1]/@Y"/>
+                                <xsl:attribute name="Way_X2" select="$bp:Path_Point/bp:Path_Point[@position=2]/@X"/>
+                                <xsl:attribute name="Way_Y2" select="$bp:Path_Point/bp:Path_Point[@position=2]/@Y"/>
+                            </Way>
+                        </xsl:for-each> 
+                    </xsl:variable>
+                    <xsl:copy-of select="$Ways"/>
+                    
+                    <!-- teraz trzeba wiedziec ktory punkt wziac z drogi - czy pierwszy czy drugi jaki pasuje do pary -->
+                    <xsl:variable name="Ways_J1_W1">
+                        <xsl:for-each select="$Ways/Way[@Way_X1=$Join_X1 and @Way_Y1=$Join_Y1]">
+                            <Way_next_cand>
+                                <xsl:copy-of select="@id"/>
+                                <xsl:copy-of select="@Way_X2"/>
+                                <xsl:copy-of select="@Way_Y2"/>
+                            </Way_next_cand>
+                        </xsl:for-each>
+                    </xsl:variable>
+                    <xsl:copy-of select="$Ways_J1_W1"/>
+                    
+                    <xsl:variable name="Ways_J2_W1">
+                        <xsl:for-each select="$Ways/Way[@Way_X1=$Join_X2 and @Way_Y1=$Join_Y2]">
+                            <Way_next_cand>
+                                <xsl:copy-of select="@id"/>
+                                <xsl:copy-of select="@Way_X2"/>
+                                <xsl:copy-of select="@Way_Y2"/>
+                            </Way_next_cand>
+                        </xsl:for-each>
+                    </xsl:variable>
+                    <xsl:copy-of select="$Ways_J2_W1"/>
+                    
+                    <xsl:variable name="Ways_J1_W2">
+                        <xsl:for-each select="$Ways/Way[@Way_X2=$Join_X1 and @Way_Y2=$Join_Y1]">
+                            <Way_next_cand>
+                                <xsl:copy-of select="@id"/>
+                                <xsl:copy-of select="@Way_X1"/>
+                                <xsl:copy-of select="@Way_Y1"/>
+                            </Way_next_cand>
+                        </xsl:for-each>
+                    </xsl:variable>
+                    <xsl:copy-of select="$Ways_J1_W2"/>
+                    
+                    <xsl:variable name="Ways_J2_W2">
+                        <xsl:for-each select="$Ways/Way[@Way_X2=$Join_X2 and @Way_Y2=$Join_Y2]">
+                            <Way_next_cand>
+                                <xsl:copy-of select="@id"/>
+                                <xsl:copy-of select="@Way_X1"/>
+                                <xsl:copy-of select="@Way_Y1"/>
+                            </Way_next_cand>
+                        </xsl:for-each>
+                    </xsl:variable>
+                    <xsl:copy-of select="$Ways_J2_W2"/>
+                    <!-- poszukamy czy Way_X2 wystepuje -->
+                </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">
+                        <xsl:value-of select="1"/>
+                    </xsl:when>
+                    <xsl:otherwise><xsl:value-of select="2"/></xsl:otherwise>
+                </xsl:choose>
+                </xsl:variable>-->
+                <!--<Way_1_or_2><xsl:value-of select="$Way_1_or_2"/></Way_1_or_2>-->
+                <xsl:variable name="LineString">
+                    <xsl:call-template name="PlaceWay">
+                        <xsl:with-param name="Ways" select="$Ways"/>
+                        <xsl:with-param name="Cur_X1" select="$Ways/Ways/@Join_X1"/>
+                        <xsl:with-param name="Cur_Y1" select="$Ways/Ways/@Join_Y1"/>
+                        <xsl:with-param name="Last_X2" select="$Ways/Ways/@Join_X2"/>
+                        <xsl:with-param name="Last_Y2" select="$Ways/Ways/@Join_Y2"/>
+                        <!--<xsl:with-param name="Way_1_or_2" select="$Way_1_or_2"/>-->
+                        <!--<xsl:with-param name="not_id" select="$Ways/Ways/Way_next_cand/@id"/>-->
+                    </xsl:call-template>
+                </xsl:variable>
+                <xsl:call-template name="AsText_XML">
+                    <xsl:with-param name="LineString" select="$LineString"/>
+                </xsl:call-template>
+            </asText>
+        </item>
+    </xsl:template>
+    
+    
+   
+    <xsl:template name="AsText_XML">
+        <xsl:param name="LineString" required="yes"/>
+        <xsl:value-of select="'LINESTRING ('"/>
+        <xsl:for-each select="$LineString/LineString">
+            <xsl:value-of select="concat(@X,' ',@Y)"/>
+            <xsl:if test="not(position()= last())">
+                <xsl:value-of select="', '"/>
+            </xsl:if>
+        </xsl:for-each>
+        <xsl:value-of select="')'"/>
+    </xsl:template>
+    
+    
+    <xsl:template name="PlaceWay">
+        <xsl:param name="Ways" required="yes"/>
+        <xsl:param name="Cur_X1" required="yes"/>
+        <xsl:param name="Cur_Y1" required="yes"/>
+        <!--<xsl:param name="Way_1_or_2" required="yes"/>-->
+        <xsl:param name="Last_X2" required="yes"/>
+        <xsl:param name="Last_Y2" required="yes"/>
+        <xsl:param name="loop" select="1"/>
+        <xsl:param name="not_id" required="no"/>
+        <!--<LineString>
+            <xsl:attribute name="X1" select="$Cur_X1"/>
+            <xsl:attribute name="Y1" select="$Cur_Y1"/>
+        </LineString>-->
+        <!--<xsl:choose>
+            <xsl:when test="$Way_1_or_2"></xsl:when>
+        </xsl:choose>-->
+        <!--<debug>
+            <xsl:attribute name="Cur_X1" select="$Cur_X1"/>
+            <xsl:attribute name="Cur_Y1" select="$Cur_Y1"/>
+            <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"/>
+            </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"/>
+            </LineString>
+        </xsl:for-each>
+        </xsl:variable>
+        <xsl:copy-of select="$Linestring"/>
+        <xsl:choose>
+            <xsl:when test="$loop &gt; 100000">
+                <loop_limit/>
+            </xsl:when>
+            <xsl:when test="$Linestring/LineString/@X = $Last_X2 and $Linestring/LineString/@Y = $Last_Y2 ">
+                <ostatni/>
+            </xsl:when>
+            <xsl:otherwise>
+                <xsl:call-template name="PlaceWay">
+                    <xsl:with-param name="Ways" select="$Ways"/>
+                    <xsl:with-param name="Cur_X1" select="$Linestring/LineString/@X"/>
+                    <xsl:with-param name="Cur_Y1" select="$Linestring/LineString/@Y"/>
+                    <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="loop" select="$loop+1"/>
+                </xsl:call-template>
+            </xsl:otherwise>
+        </xsl:choose>
+        
+        
+    </xsl:template>
+    
+    
+</xsl:stylesheet>

+ 33 - 0
SE/dev/php-cli/joins_asText_xml.xsl

@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    xmlns:bp="https://procesy5.pl/biale_plamy-schema.xsd"
+    exclude-result-prefixes="xs"
+    version="2.0">
+    
+    <xsl:import href="asText.xsl"/>
+    <xsl:output indent="yes"/>
+    <xsl:strip-space elements="*"/>
+    
+    <xsl:template match="joins_asText">
+        <joins_asText_xml>
+            <xsl:apply-templates/>
+        </joins_asText_xml>    
+    </xsl:template>
+    
+     
+    <xsl:template match="item">
+        <item>
+            <xsl:copy-of select="@id"/>
+            <xsl:variable name="asText">
+                <asText>
+                    <xsl:value-of select="text()"/>
+                </asText>
+            </xsl:variable>
+            <xsl:apply-templates mode="POINT" select="$asText"/>
+        </item>
+        
+    </xsl:template>
+    
+    
+</xsl:stylesheet>

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

@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    xmlns:bp="https://procesy5.pl/biale_plamy-schema.xsd"
+    exclude-result-prefixes="xs"
+    version="2.0">
+     
+    <xsl:import href="asText.xsl"/>
+    <xsl:param name="ways2drogi.xml" select="'ways2drogi.xml'"/>
+    <xsl:variable name="ways2drogi" select="doc($ways2drogi.xml)"/>
+    
+    <xsl:output indent="yes"/>
+    <xsl:strip-space elements="*"/>
+    
+    
+    <xsl:template match="ways_asText">
+        <ways_asText_z_ID_xml>
+            <xsl:apply-templates/>
+        </ways_asText_z_ID_xml>
+    </xsl:template>
+    
+    <xsl:template match="item">
+        <item>
+        <xsl:copy-of select="@*"/>
+            <xsl:attribute name="pos" select="position()"/>
+            <xsl:attribute name="ID_Way" select="$ways2drogi/ways2drogi/item[@id= current()/@id]/text()"/>
+        <xsl:apply-templates/>
+        </item>
+    </xsl:template>
+    
+    
+    <xsl:template match="text()">
+        <xsl:variable name="asText">
+            <asText>
+                <xsl:copy-of select="."/>
+            </asText>
+        </xsl:variable>
+        <xsl:apply-templates select="$asText"/>
+    </xsl:template>
+</xsl:stylesheet>

+ 1 - 0
SE/se-lib/Core/Database/Mysql.php

@@ -466,6 +466,7 @@ class Core_Database_Mysql extends Core_Database {
 
 
 		$primaryKey = V::geti($primary, '', $sql_obj);
 		$primaryKey = V::geti($primary, '', $sql_obj);
 		if ($primaryKey <= 0) {
 		if ($primaryKey <= 0) {
+			DBG::log(['msg'=>"Missing primary key '{$primary}' in table '{$table}'!", '$sql_obj'=>$sql_obj]);
 			$this->_set_error("Missing primary key '{$primary}' in table '{$table}'!");
 			$this->_set_error("Missing primary key '{$primary}' in table '{$table}'!");
 			return -3;
 			return -3;
 		}
 		}

+ 7 - 7
SE/se-lib/Route/Debug.php

@@ -11,13 +11,13 @@ Lib::loadClass('RouteBase');
 class Route_Debug extends RouteBase {
 class Route_Debug extends RouteBase {
 
 
   public function handleAuth() {
   public function handleAuth() {
-		if (!User::logged()) {
+    if (!User::logged()) {
       throw new HttpException('Unauthorized', 401);
       throw new HttpException('Unauthorized', 401);
-		}
-		if (!User::hasAccess('dbg')) {// User::get('ADM_ADMIN_LEVEL') == 0
+    }
+    if (!User::hasAccess('dbg')) {// User::get('ADM_ADMIN_LEVEL') == 0
       throw new HttpException('Unauthorized - required dbg access', 401);
       throw new HttpException('Unauthorized - required dbg access', 401);
-		}
-	}
+    }
+  }
 
 
   public function defaultAction() {
   public function defaultAction() {
     session_write_close();
     session_write_close();
@@ -25,8 +25,8 @@ class Route_Debug extends RouteBase {
   }
   }
 
 
   public function defaultView($flashMsg = '') {
   public function defaultView($flashMsg = '') {
-		UI::gora();
-		UI::menu();
+    UI::gora();
+    UI::menu();
     UI::setTitle("Debug");
     UI::setTitle("Debug");
     try {
     try {
       echo UI::h('h1', [], [
       echo UI::h('h1', [], [

+ 70 - 0
SE/se-lib/Route/ViewTableAjax.php

@@ -176,6 +176,76 @@ class Route_ViewTableAjax extends RouteBase {
 		UI::dol();
 		UI::dol();
 	}
 	}
 
 
+	public function rmUserTableFilterAjaxAction() {
+		Response::sendTryCatchJson(array($this, 'rmUserTableFilterAjax'), $args = 'JSON_FROM_REQUEST_BODY');
+	}
+	public function rmUserTableFilterAjax($args) {
+		$namespace = V::get('namespace', '', $args);
+		$filtrName = V::get('filtrName', '', $args);
+		if (!$namespace) throw new Exception("Missing namespace");
+		if (!$filtrName) throw new Exception("Missing filtrName");
+
+		$userFltrConfKey = "tableColFilters__" . User::getLogin();
+		$currentFilters = DB::getPDO()->fetchValue(" select CONF_VAL from CRM_CONFIG where CONF_KEY = '{$userFltrConfKey}' ");
+		if (!$currentFilters) return [
+			'type' => 'warning',
+			'msg' => "Brak filtrów w bazie",
+		];
+		$currentFilters = json_decode($currentFilters, 'assoc');
+		unset($currentFilters[$namespace][$filtrName]);
+		$affeced = DB::getPDO()->update('CRM_CONFIG', 'CONF_KEY', $userFltrConfKey, [
+			'CONF_VAL' => json_encode($currentFilters)
+		]);
+		return [
+			'type' => 'success',
+			'msg' => 'Zapisano nowy filtr',
+			'data' => $currentFilters[$namespace]
+		];
+	}
+	public function addUserTableFilterAjaxAction() {
+		Response::sendTryCatchJson(array($this, 'addUserTableFilterAjax'), $args = 'JSON_FROM_REQUEST_BODY');
+	}
+	public function addUserTableFilterAjax($args) {
+		$namespace = V::get('namespace', '', $args);
+		$filtrName = V::get('filtrName', '', $args);
+		$visibleCols = V::get('visibleCols', '', $args);
+		if (!$namespace) throw new Exception("Missing namespace");
+		if (!$filtrName) throw new Exception("Missing filtrName");
+		if (!$visibleCols) throw new Exception("Missing visibleCols");
+
+		$userFltrConfKey = "tableColFilters__" . User::getLogin();
+		$currentFilters = DB::getPDO()->fetchValue(" select CONF_VAL from CRM_CONFIG where CONF_KEY = '{$userFltrConfKey}' ");
+		$currentFilters = ($currentFilters) ? json_decode($currentFilters, 'assoc') : [];
+		$currentFilters[$namespace][$filtrName] = $visibleCols;
+		$sqlFltr = json_encode($currentFilters);
+		DB::getPDO()->execSql("
+			insert into CRM_CONFIG (CONF_KEY, CONF_VAL)
+			values ('$userFltrConfKey', '{$sqlFltr}')
+			on duplicate key update CONF_VAL = '{$sqlFltr}'
+		");
+		return [
+			'type' => 'success',
+			'msg' => 'Zapisano nowy filtr',
+			'data' => $currentFilters[$namespace]
+		];
+	}
+	public function getUserTableFilterAjaxAction() {
+		Response::sendTryCatchJson(array($this, 'getUserTableFilterAjax'), $args = 'JSON_FROM_REQUEST_BODY');
+	}
+	public function getUserTableFilterAjax($args) {
+		$namespace = V::get('namespace', '', $args);
+		if (!$namespace) throw new Exception("Missing namespace");
+
+		$userFltrConfKey = "tableColFilters__" . User::getLogin();
+		$currentFilters = DB::getPDO()->fetchValue(" select CONF_VAL from CRM_CONFIG where CONF_KEY = '{$userFltrConfKey}' ");
+		$currentFilters = ($currentFilters) ? json_decode($currentFilters, 'assoc') : [];
+		return [
+			'type' => 'success',
+			'msg' => 'Odczytano filtry użytkownika',
+			'data' => (!empty($currentFilters[$namespace])) ? $currentFilters[$namespace] : []
+		];
+	}
+
 	public function revertFromHistAjaxAction() {
 	public function revertFromHistAjaxAction() {
 		Response::sendTryCatchJson(array($this, 'revertFromHistAjax'));
 		Response::sendTryCatchJson(array($this, 'revertFromHistAjax'));
 	}
 	}

+ 171 - 16
SE/se-lib/TableAjax.php

@@ -241,8 +241,10 @@ class TableAjax extends ViewAjax {
 		<?php if ($tblAjaxMap) $tblAjaxMap->printCSS(); ?>
 		<?php if ($tblAjaxMap) $tblAjaxMap->printCSS(); ?>
 		<?php if ($tblAjaxMap) $tblAjaxMap->printJS(); ?>
 		<?php if ($tblAjaxMap) $tblAjaxMap->printJS(); ?>
 		<script src="stuff/jquery-ui-1.10.4.custom.min.js"></script>
 		<script src="stuff/jquery-ui-1.10.4.custom.min.js"></script>
+		<script src="static/sweetalert2.min.js"></script>
 		<script src="static/jquery.doubleScroll.js"></script>
 		<script src="static/jquery.doubleScroll.js"></script>
 		<link rel="stylesheet" type="text/css" href="stuff/jquery-ui-smoothness/jquery-ui-1.10.4.custom.min.css">
 		<link rel="stylesheet" type="text/css" href="stuff/jquery-ui-smoothness/jquery-ui-1.10.4.custom.min.css">
+		<link rel="stylesheet" type="text/css" href="static/sweetalert2.min.css">
 		<style type="text/css">
 		<style type="text/css">
 .AjaxTable{max-width:100%;background-color:transparent;border-collapse:collapse;border-spacing:0;}
 .AjaxTable{max-width:100%;background-color:transparent;border-collapse:collapse;border-spacing:0;}
 
 
@@ -671,6 +673,15 @@ var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
 				}
 				}
 				priv.renderTable();
 				priv.renderTable();
 				priv.onWindowResize();
 				priv.onWindowResize();
+
+				{// activate saveBtn if some columns hidden
+					var selectedFilter = priv.modelColFilter_getSelected();
+					if (null === selectedFilter) {
+						priv.modelColFilter_getSaveBtn().prop("disabled", false)
+					} else {
+						priv.modelColFilter_getSaveBtn().prop("disabled", true)
+					}
+				}
 			}
 			}
 		};
 		};
 
 
@@ -1806,14 +1817,23 @@ var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
 				var span = $('<span class="caret"></span>').appendTo(btn);
 				var span = $('<span class="caret"></span>').appendTo(btn);
 				var ul = $('<ul class="dropdown-menu" style="max-height:250px;overflow:auto;">').appendTo(node);
 				var ul = $('<ul class="dropdown-menu" style="max-height:250px;overflow:auto;">').appendTo(node);
 
 
-				var columnFilters = priv.modelColFilter_getFilters();
 				var selectedFilter = priv.modelColFilter_getSelected();
 				var selectedFilter = priv.modelColFilter_getSelected();
-				$.each(columnFilters, function(idx, colFltr) {
+				priv.modelColFilter_getFilters().map(function(colFltr) {
 					var li = $('<li></li>').appendTo(ul),
 					var li = $('<li></li>').appendTo(ul),
 							selected = (selectedFilter && selectedFilter == colFltr.name)? 'checked="checked"' : '',
 							selected = (selectedFilter && selectedFilter == colFltr.name)? 'checked="checked"' : '',
 							input = '<input ' + selected + ' type="radio" style="margin:0"/>',
 							input = '<input ' + selected + ' type="radio" style="margin:0"/>',
 							a = $('<a href="#" data-col_filter="' + colFltr.name + '" style="padding:0px 20px;">' + input + ' ' + colFltr.label + '</a>').appendTo(li);
 							a = $('<a href="#" data-col_filter="' + colFltr.name + '" style="padding:0px 20px;">' + input + ' ' + colFltr.label + '</a>').appendTo(li);
+							if ('all' != colFltr && 'most_used' != colFltr) {
+								arm = $('<button data-col_filter="' + colFltr.name + '" class="pull-right btn btn-xs btn-link" style="color:red">' + '&times;' + '</a>').appendTo(a);
+								arm.on('click', priv.modelColFilter_onClickRemoveFilter)
+							}
 				});
 				});
+
+				{// if (!selectedFilter) {// save current filter
+					var li = $('<li style="text-align:center"></li>').appendTo(ul)
+					priv.modelColFilter_getSaveBtn().appendTo(li);
+				}
+
 				$('<li class="divider"></li>').appendTo(ul);
 				$('<li class="divider"></li>').appendTo(ul);
 				$.each(_data.cols, function(col, props) {
 				$.each(_data.cols, function(col, props) {
 					if (props.type != "unique" && col != 'ID') {
 					if (props.type != "unique" && col != 'ID') {
@@ -2766,7 +2786,7 @@ var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
 			jQuery(_uiNodeCont).trigger('TableAjax:render', ['head', 'body']);
 			jQuery(_uiNodeCont).trigger('TableAjax:render', ['head', 'body']);
 		};
 		};
 
 
-		priv.modelColFilter_init = function() {
+		priv.modelColFilter_init = function() {// run only once, set _state._modelColFilter {selected, filters: [ {name, label, visibleCols} ]}
 			var isAllSelected = true;
 			var isAllSelected = true;
 			if (undefined === _state._modelColFilter) {
 			if (undefined === _state._modelColFilter) {
 				var columnFilters = [];
 				var columnFilters = [];
@@ -2779,24 +2799,160 @@ var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
 					});
 					});
 					columnFilters.push(fltrAll);
 					columnFilters.push(fltrAll);
 				}
 				}
-				{
-					var fltrMostUsed = {'name': 'most_used', 'label': 'Najczęściej używane', visibleCols: []};
-					var fltrMostUsedLimit = 10;
-					$.each(_data.cols, function(col, props) {
-						if ("unique" == props.type) return;
-						if (fltrMostUsedLimit-- > 0) {
-							fltrMostUsed.visibleCols.push(col);
-						}
-					});
-					columnFilters.push(fltrMostUsed);
-				}
+				// {
+				// 	var fltrMostUsed = {'name': 'most_used', 'label': 'Najczęściej używane', visibleCols: []};
+				// 	var fltrMostUsedLimit = 10;
+				// 	$.each(_data.cols, function(col, props) {
+				// 		if ("unique" == props.type) return;
+				// 		if (fltrMostUsedLimit-- > 0) {
+				// 			fltrMostUsed.visibleCols.push(col);
+				// 		}
+				// 	});
+				// 	columnFilters.push(fltrMostUsed);
+				// }
 
 
 				_state._modelColFilter = {
 				_state._modelColFilter = {
 					selected: (isAllSelected)? 'all' : null,
 					selected: (isAllSelected)? 'all' : null,
-					filters: columnFilters
+					filters: columnFilters,
+					saveBtn: $('<button class="btn btn-xs btn-primary" disabled="disabled">Zapisz widoczne kolumny</button>')
 				};
 				};
+				_state._modelColFilter.saveBtn.on('click', priv.modelColFilter_saveBtnClicked)
+
+				fetch('<?= Request::getPathUri() . "index.php?_route=ViewTableAjax&_task=getUserTableFilterAjax" ?>', {
+					method: 'POST',
+					headers: {
+						'Content-Type': 'application/json'
+					},
+					credentials: 'same-origin',// add cookies
+					body: JSON.stringify({
+						namespace: '<?= $acl->getNamespace(); ?>',
+					})
+				}).then(function (response) {
+					return response.json()
+				}).then(function (result) {
+					if ('success' == result.type) {
+						// p5UI__notifyAjaxCallback(result)
+						_state._modelColFilter.filters = _state._modelColFilter.filters.filter(function (filter) {
+							return ('all' === filter.name || 'most_used' == filter.name)
+						}).concat(Object.keys(result.data).map(function (fltr) {
+							return {
+								name: fltr,
+								label: fltr,
+								visibleCols: result.data[fltr].split(',')
+							}
+						}))
+						jQuery(_uiNodeCont).trigger('TableAjax:render', ['foot__columnPicker']);
+					} else {
+						p5UI__notifyAjaxCallback(result)
+					}
+				}).catch(function (e) {
+					// TODO: show error ("ajax response error: " + e)
+				});
 			}
 			}
 		};
 		};
+		priv.modelColFilter_onClickRemoveFilter = function (e) {
+			e.preventDefault()
+			e.stopPropagation()
+			var filtrName = $(this).data('col_filter')
+			if (!filtrName) return
+			fetch('<?= Request::getPathUri() . "index.php?_route=ViewTableAjax&_task=rmUserTableFilterAjax" ?>', {
+				method: 'POST',
+				headers: {
+					'Content-Type': 'application/json'
+				},
+				credentials: 'same-origin',// add cookies
+				body: JSON.stringify({
+					namespace: '<?= $acl->getNamespace(); ?>',
+					filtrName: filtrName,
+				})
+			}).then(function (response) {
+				return response.json()
+			}).then(function (result) {
+				if ('success' == result.type) {
+					p5UI__notifyAjaxCallback(result)
+					var userTableFilters = result.data;// resolve(result.data)
+					_state._modelColFilter.filters = _state._modelColFilter.filters.filter(function (filter) {
+						return ('all' === filter.name || 'most_used' == filter.name)
+					}).concat(Object.keys(userTableFilters).map(function (fltr) {
+						return {
+							name: fltr,
+							label: fltr,
+							visibleCols: userTableFilters[fltr].split(',')
+						}
+					}))
+					jQuery(_uiNodeCont).trigger('TableAjax:render', ['foot__columnPicker']);
+				} else {
+					p5UI__notifyAjaxCallback(result)
+				}
+			}).catch(function (e) {
+				p5UI__notifyAjaxCallback({ type: 'error', msg: new String(e) })
+			});
+		};
+		priv.modelColFilter_saveBtnClicked = function (e) {
+			swal({
+				title: 'Zapisz widoczne kolumny',
+				html: '',
+				animation: true,
+				input: 'text',
+				inputPlaceholder: 'nazwa filtra',
+				// inputValue: null,
+				// inputAttributes: {'step': '0.01'},
+				showCancelButton: true,
+				confirmButtonText: 'Zapisz',
+				showLoaderOnConfirm: true,
+				showCloseButton: true,
+				preConfirm: function(filtrName) {
+					return new Promise(function(resolve, reject) {
+						if (!filtrName) reject('Proszę podać nazwę filtra')
+						if (filtrName.length > 255) reject('Nazwa za długa')
+						fetch('<?= Request::getPathUri() . "index.php?_route=ViewTableAjax&_task=addUserTableFilterAjax" ?>', {
+							method: 'POST',
+							headers: {
+								'Content-Type': 'application/json'
+							},
+							credentials: 'same-origin',// add cookies
+							body: JSON.stringify({
+								namespace: '<?= $acl->getNamespace(); ?>',
+								filtrName: filtrName,
+								visibleCols: Object.keys(_data.cols).filter(function(col) {
+									return !_data.cols[col].hidden
+								}).join(','),
+							})
+						}).then(function (response) {
+							return response.json()
+						}).then(function (result) {
+							if ('success' == result.type) {
+								p5UI__notifyAjaxCallback(result)
+								resolve(result.data)
+							} else {
+								p5UI__notifyAjaxCallback(result)
+								reject(result.msg || "Wystąpił błąd!")
+							}
+						}).catch(function (e) {
+							reject("ajax response error: " + e)
+						});
+			    })
+			  },
+			  allowOutsideClick: false
+			}).then(function(userTableFilters) {
+				_state._modelColFilter.filters = _state._modelColFilter.filters.filter(function (filter) {
+					return ('all' === filter.name || 'most_used' == filter.name)
+				}).concat(Object.keys(userTableFilters).map(function (fltr) {
+					return {
+						name: fltr,
+						label: fltr,
+						visibleCols: userTableFilters[fltr].split(',')
+					}
+				}))
+				jQuery(_uiNodeCont).trigger('TableAjax:render', ['head', 'body', 'foot__columnPicker']);
+			}).catch(function(e) {
+				// eg. hit Cancel
+			})
+		}
+		priv.modelColFilter_getSaveBtn = function () {
+			priv.modelColFilter_init();
+			return _state._modelColFilter.saveBtn
+		}
 		priv.modelColFilter_getFilters = function() {
 		priv.modelColFilter_getFilters = function() {
 			priv.modelColFilter_init();
 			priv.modelColFilter_init();
 			return _state._modelColFilter.filters;
 			return _state._modelColFilter.filters;
@@ -2885,7 +3041,6 @@ var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
 				//_data.cols[column].index = new priv.ext.XDate();
 				//_data.cols[column].index = new priv.ext.XDate();
 				jQuery(_uiNodeCont).trigger('TableAjax:render', ['head', 'body']);
 				jQuery(_uiNodeCont).trigger('TableAjax:render', ['head', 'body']);
 			}
 			}
-
 		};
 		};
 
 
 		priv.columnHideClicked = function(e) {
 		priv.columnHideClicked = function(e) {

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů