a.binder 9 лет назад
Родитель
Сommit
380d6bd0e1

+ 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->enableShowProgress();
 	$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(42366, 42376);
+			$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);
+  
+
+
+	
+	
+	
+	
+	
+	
+	

+ 0 - 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
  // echo "\n<br>";
 	   //$attrs=$child->attributes("ID_Way");
-
 	   foreach($child->attributes() as $a=>$b) {
 		   //	echo "#87Child";print_r($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]['ID_Way']=$ID_Way;
 		   $cables_from_joins_to_PE_arr[$id_j]['ID_Point']=$ID_Point;
-
-
-
 	   }
 }