Sfoglia il codice sorgente

nie wszystkie drogi sie wyliczaja jak trzeba, prawie dziala

a.binder 9 anni fa
parent
commit
0b1c7245e3

+ 185 - 14
SE/dev/php-cli/biale_plamy-find_ways.php

@@ -1,6 +1,13 @@
 <?php
 $_SERVER['SERVER_NAME'] = 'biuro.biall-net.pl';
+
+
+//when used in /Library/Server/Web/Data/Sites/bzyk-biale-plamy-php-temp/SE/dev on biuro.biall-net.pl
+if( file_exists ( "../../se-lib/bootstrap.php"))
 require("../../se-lib/bootstrap.php");
+//when used in  in native SE
+else require("../../../../SE-production-git/SE/se-lib/bootstrap.php");
+
 Lib::loadClass("Vendor_Geophp");
 
 
@@ -68,6 +75,38 @@ $joins_asText = unserialize(file_get_contents('joins_asText.txt'));
 $ways_asText = unserialize(file_get_contents('ways_asText.txt'));
 $points_asText = unserialize(file_get_contents('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];
+	   }
+}
+
+//print_r($edge_joins_path);
+
 
 
 function joins2lineString($joins_keys) {
@@ -130,23 +169,155 @@ function findJoinInDB($id) {
 	} else return null;
 }
 
+
+
+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);
+	        }
+        }
+     }
+}
+
 #echo joins2lineString($res = findWay(100,110))->asText();
 #echo joins2lineString($res = findWay(25690,20134))->asText();
-$timeStart = microtime();
 #$path = joins2lineString(findWay(25690,23039));
-$path = joins2lineString(findWay(findJoinInDB(142),findJoinInDB(147)));
-$timeEnd = microtime();
-
-if ($path) {
-	echo $path->asText()."\n";
-	echo "Dlugosc: ".$path->greatCircleLength()."\n";
-} else echo "Brak drogi";
-echo $ways_asText[141];
-
-list($usecStart, $secStart) = explode(" ", $timeStart);
-list($usecEnd, $secEnd) = explode(" ", $timeEnd);
-$diff = $secEnd - $secStart + $usecEnd - $usecStart;
-echo "\n\nCzas liczenia: ".$diff." s\n";
+
+
+
+//$path = joins2lineString(findWay(findJoinInDB(49),findJoinInDB(50)));
+
+
+//generujemy path do $edge_joins_filled_paths
+ 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 = 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)
+		     values (ST_GeomFromText('".$edge_joins_filled_paths[$ID_Way]['asText']."'),'".$ID_Way."'   )   ";
+		    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);
+  
+
+
+//test
+ 	$timeStart = microtime();
+ 	$res = findWay(389,404);
+ 	$path=joins2lineString($res)->asText();
+	$timeEnd = microtime();
+		
+		if ($path) {
+			echo $path."\n";
+		} else echo "Brak drogi";
+		
+		list($usecStart, $secStart) = explode(" ", $timeStart);
+		list($usecEnd, $secEnd) = explode(" ", $timeEnd);
+		$diff = $secEnd - $secStart + $usecEnd - $usecStart;
+		echo "\n\nCzas liczenia: ".$diff." s\n";
+		
+		  	
+		$distance = 0;
+		foreach ($res as $way_key) {
+			$distance += Vendor_Geophp::load($ways_asText[$way_key], 'wkt')->greatCircleLength();
+		}
+		print_r($res);
+		echo "Distance: ".$distance."m\n";
+//eof test
+echo "\n<br>test2";
+
+
+
+
+//test
+ 	$timeStart = microtime();
+ 	$res = findWay(389,404);
+ 	$path=joins2lineString($res)->asText();
+	$timeEnd = microtime();
+		
+		if ($path) {
+			
+						echo $path."\n";
+		} else echo "Brak drogi";
+		
+		list($usecStart, $secStart) = explode(" ", $timeStart);
+		list($usecEnd, $secEnd) = explode(" ", $timeEnd);
+		$diff = $secEnd - $secStart + $usecEnd - $usecStart;
+		echo "\n\nCzas liczenia: ".$diff." s\n";
+		
+		  	
+		$distance = 0;
+		foreach ($res as $way_key) {
+			$distance += Vendor_Geophp::load($ways_asText[$way_key], 'wkt')->greatCircleLength();
+		}
+		print_r($res);
+		echo "Distance: ".$distance."m\n";
+//eof test
+
+
 
 //$distance = 0;
 //foreach ($res as $way_key) {

+ 41 - 0
SE/dev/php-cli/biale_plamy-prepare_sql_data.php

@@ -0,0 +1,41 @@
+<?php
+	ini_set('display_errors', 'On');
+error_reporting(E_ALL);
+$_SERVER['SERVER_NAME'] = 'biuro.biall-net.pl';
+//when used in /Library/Server/Web/Data/Sites/bzyk-biale-plamy-php-temp/SE/dev on biuro.biall-net.pl
+if( file_exists ( "../../se-lib/bootstrap.php"))
+require("../../se-lib/bootstrap.php");
+//when used in  in native SE
+else require("../../../../SE-production-git/SE/se-lib/bootstrap.php");
+
+Lib::loadClass("Vendor_Geophp");
+
+
+
+$db = DB::getDB();
+$sql="create temporary table Rozdzielcza_test_bzyk_punkty_adresowe_temp select * from Rozdzielcza_test_bzyk_punkty_adresowe;
+
+-- 1 Dorobiona funkcja do pokazywania ID_Way
+update Rozdzielcza_test_bzyk_punkty_adresowe_temp t1 set t1.the_geom_nearest_way=test_find_nearest_way(t1.ID);
+update Rozdzielcza_test_bzyk_punkty_adresowe_temp t1 set t1.ID_Way=test_find_nearest_way_ID(t1.ID);
+
+ update Rozdzielcza_test_bzyk_punkty_adresowe t1 join Rozdzielcza_test_bzyk_punkty_adresowe_temp t2 on t1.ID = t2.ID set  t1.the_geom_nearest_way=t2.the_geom_nearest_way , t1.ID_Way=t2.ID_Way ;
+
+-- 3
+drop table Rozdzielcza_test_bzyk_punkty_adresowe_temp;
+
+update Rozdzielcza_test_bzyk_punkty_adresowe set the_geom_xpoint=test_find_xpoint(the_geom,the_geom_nearest_way); 
+
+-- co to jest ten point? - to punt na drodze odpowiadajacy najblizszej
+-- 4
+
+truncate table  Rozdzielcza_test_bzyk_przylacza;
+
+insert into Rozdzielcza_test_bzyk_przylacza (the_geom,ID_Way) select
+ linefromtext(concat('linestring(',x(the_geom),' ',y(the_geom),',',x(the_geom_xpoint),' ',y(the_geom_xpoint),')')) , 
+ ID from Rozdzielcza_test_bzyk_punkty_adresowe;
+ ";
+
+ $result = DB::getPDO()->fetchall($sql);
+ 
+ if($result) echo "res OK!";

+ 6 - 1
SE/dev/php-cli/build__biale_plamy.xml

@@ -20,6 +20,11 @@
         <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="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_paths_with_PE.xml" value="edge_paths_with_PE.xml"/><!--     biale_plamy_from_paths_php_to_place_PE
+ -->
     
     <target name="check" >
         <echo message="testuje check"/>
@@ -84,7 +89,7 @@
         </xslt>
     </target>
    
-    <!-- wyznaczenie sciezek do ulozenia PE-->
+    <!-- wyznaczenie sciezek do ulozenia PE - dziala-->
     <target name="biale_plamy_paths_to_findways_php"></target>
    
     <!-- postawienie PE po trasach -->

+ 85 - 0
SE/dev/php-cli/edge_joins_filled_paths.xsl

@@ -0,0 +1,85 @@
+<?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:output indent="yes"/>
+    <xsl:strip-space elements="*"/>
+    
+    <xsl:variable name="test"/>
+    
+    <!--//match edge_joins_filled_paths-->
+    
+    
+    <xsl:template match="edge_joins_filled_paths">
+        <xsl:variable name="PE_track">
+            <xsl:apply-templates/>
+        </xsl:variable>
+        <xsl:variable name="PE_track">
+            <xsl:for-each select="$PE_track/LINESTRING">
+                <LINESTRING>
+                    <xsl:attribute name="Count" select="count(*)"/>
+                    <xsl:copy-of select="@*"/>
+                    <xsl:copy-of select="test1"/>
+                    <xsl:for-each select="bp:Path_Point">
+                    <bp:Path_Point>
+                        <xsl:copy-of select="@*"/>
+                         <xsl:attribute name="Pos" select="position()"/>
+                         <xsl:copy-of select="."/>
+                    </bp:Path_Point>
+                    </xsl:for-each>
+                </LINESTRING>
+            </xsl:for-each>
+        </xsl:variable>
+        <edge_paths_with_PE>
+            <!--<PE_track>
+                <xsl:copy-of select="$PE_track"/>
+            </PE_track>-->
+            <xsl:copy-of select="$PE_track"/>
+        </edge_paths_with_PE>
+    </xsl:template>
+
+    
+    <xsl:template match="item">
+        <xsl:choose>
+            <xsl:when test="asText">
+                <LINESTRING>
+                    <xsl:attribute name="ID_Way" select="@id"/>
+                    <xsl:attribute name="distance" select="distance/text()"/>
+                      <xsl:apply-templates/>
+                </LINESTRING>
+            </xsl:when>
+            <xsl:otherwise>
+                <bp:Path_Not_Found>
+                    <xsl:attribute name="ID_Way" select="@id"/>
+                </bp:Path_Not_Found>
+            </xsl:otherwise>
+        </xsl:choose>
+    </xsl:template>
+    
+    
+    <!--<asText>LINESTRING (18.636657356658 51.253416226324, 18.6366871 51.253538999079, 18.6367062
+        51.253605499079, 18.6368933 51.25441199908, 18.6369493 51.254670399079, 18.6370223
+        51.254905799079, 18.6370965 51.255053899079, 18.6371814 51.255153699079, 18.637252
+        51.255236599079, 18.63765 51.255476599079, 18.6386978 51.255913099079, 18.6414059
+        51.257032799079, 18.6449346 51.25849289908, 18.6467805 51.25926169908, 18.64743915153
+        51.259545049387)</asText>-->
+    <xsl:template match="asText">
+        <xsl:variable name="LINESTRING" select=" substring-before( substring-after(.,'LINESTRING (') , ')')  "/>
+            <test1><xsl:copy-of select="$LINESTRING"/></test1>
+            <xsl:for-each select="tokenize($LINESTRING,', ')">
+                <bp:Path_Point>
+                 <test2><xsl:copy-of select="."/></test2>
+                <xsl:for-each select="tokenize(.,' ')">
+                    <pos>
+                        <xsl:attribute name="pos" select="position()"/>
+                        <xsl:value-of select="."/>
+                    </pos>
+                </xsl:for-each>
+                </bp:Path_Point>
+            </xsl:for-each>
+    </xsl:template>
+    
+</xsl:stylesheet>

File diff suppressed because it is too large
+ 0 - 0
SE/dev/php-cli/joins_asText.txt


File diff suppressed because it is too large
+ 0 - 0
SE/dev/php-cli/points2joins.txt


File diff suppressed because it is too large
+ 0 - 0
SE/dev/php-cli/ways_asText.txt


Some files were not shown because too many files changed in this diff