فهرست منبع

Wrzucamy juz PE slabo policzone, teraz kable

a.binder 9 سال پیش
والد
کامیت
d8cb22cbc6
3فایلهای تغییر یافته به همراه262 افزوده شده و 0 حذف شده
  1. 10 0
      .gitignore
  2. 139 0
      SE/dev/php-cli/biale_put_PE_to_mysql.php
  3. 113 0
      SE/dev/php-cli/cables_from_joins_to_PE.xsl

+ 10 - 0
.gitignore

@@ -1,2 +1,12 @@
 SE/dev/php-cli/joins2ways.txt
 SE/dev/php-cli/ways2joins.txt
+SE/dev/php-cli/edge_joins.xml
+SE/dev/php-cli/edge_joins_filled_paths.txt
+SE/dev/php-cli/edge_joins_filled_paths.xml
+SE/dev/php-cli/edge_paths_with_PE.xml
+SE/dev/php-cli/joins2ways.xml
+SE/dev/php-cli/joins2ways_print_r.txt
+SE/dev/php-cli/joins2ways_z_ID_Way.xml
+SE/dev/php-cli/points2ID_Way.txt
+SE/dev/php-cli/points2ID_Way.xml
+SE/dev/php-cli/points2ID_Way_print_r.txt

+ 139 - 0
SE/dev/php-cli/biale_put_PE_to_mysql.php

@@ -0,0 +1,139 @@
+<?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");
+
+
+
+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();   
+
+
+$edge_paths_with_PE=simplexml_load_file("edge_paths_with_PE.xml");
+$edge_paths_with_PE->registerXPathNamespace('bp', 'https://procesy5.pl/biale_plamy-schema.xsd');
+/*
+	<PE_candidates_dump xmlns:bp="https://procesy5.pl/biale_plamy-schema.xsd"
+                    desc="brakuje ominiecia punktow ways tylko do przylaczy i analizy dlugosci">
+   <LINESTRING ID_Way="3"
+               Count="15"
+               distance="1168.1143169402"
+               dumb_frequency="10">
+      <bp:Path_Point Pos="10" X="18.63765" Y="51.255476599079"/>
+   </LINESTRING>
+ */
+//print_r($edge_joins);
+$edge_paths_with_PE_arr=array();
+foreach($edge_paths_with_PE->children() as $child)  {
+ // 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];
+		   //if($a=='Count') $Count=$b[0];
+	   }
+	  //echo $child->getName() . ": " . " ID_Way: ".$ID_Way. " : ";
+	
+	  
+	   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();
+	  // $result = $xml->xpath('/a/b/c');
+	   $id_j=0; 
+	   foreach($child->xpath('bp:Path_Point') as $Path_Point_xml)  {
+		   $id_j++;
+		   $Path_Point=$Path_Point_xml->attributes();
+		   //echo " #93 ID_Join ".$attrs_join["Joins"]." ";
+		   $Path_Point['Pos']=$Path_Point['Pos'][0]; settype($Path_Point['Pos'], "integer");
+		   $Path_Point['X']=$Path_Point['X'][0]; settype($Path_Point['X'], "string");
+		   $Path_Point['Y']=$Path_Point['Y'][0]; settype($Path_Point['Y'], "string");
+		   $edge_paths_with_PE_arr[$ID_Way][$id_j]=$Path_Point;
+	   }
+}
+
+echo "\n<br>edge_paths_with_PE_arr";
+print_r($edge_paths_with_PE_arr);
+
+
+ DB::getPDO()->query("truncate table Rozdzielcza_test_bzyk_PE");
+
+unset($ID_Way);
+
+$edge_joins_filled_paths=array();
+foreach($edge_paths_with_PE_arr as $ID_Way=>$Path_Point) {
+		
+		foreach($Path_Point as $Path_Point_val) {
+		$sql_Path_Point_val="insert into Rozdzielcza_test_bzyk_PE (the_geom,ID_Way)
+		     values (ST_GeomFromText('POINT(".$Path_Point_val['X']." ".$Path_Point_val['Y'].")'),'".$ID_Way."'   )   ";
+		    echo "#216Query path ins:: ".$sql_Path_Point_val."  ";
+		    //if(strlen($edge_joins_filled_paths[$ID_Way]['asText'])>2)
+		      DB::getPDO()->query($sql_Path_Point_val);
+		    //else echo "#296 path nie wygenerowalo sie !! dla ".$ID_Way." i pkt ".$pkt_A." , ".$pkt_B." \n";
+		}		
+	
+}
+
+
+

+ 113 - 0
SE/dev/php-cli/cables_from_joins_to_PE.xsl

@@ -0,0 +1,113 @@
+<?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: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') "/>
+    <!-- <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:apply-templates select="$joins_asText" mode="joins_asText"/>
+        </xsl:variable>
+            <joins_asText_Path_Point>
+                <xsl:copy-of select="$joins_asText_Path_Point"/>
+            </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:choose>
+                <xsl:when test="$PE_candidates_dump/PE_candidates_dump/LINESTRING[@ID_Way=current()/@ID_Way]">
+                    <cable_to_PE_to_be_calculated>
+                        <xsl:attribute name="Joins" select="@id"/>
+                        <xsl:attribute name="ID_Way" select="@ID_Way"/>
+                        <xsl:variable name="ID_Way" select="@ID_Way"/>
+                        <xsl:variable name="Joins" select="@ID_Way"/>
+                        
+                         <!-- 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:for-each select="$edge_joins_filled_paths/edge_joins_filled_paths[@id=$ID_Way]/item/bp:Path_Point">
+                            <xsl:choose>
+                                <xsl:when test="@X=$Join_Y and @Y=$Join_Y">
+                                    <found_in_path_in_edge_joins_filled_path>
+                                        <xsl:copy-of select="."/>
+                                    </found_in_path_in_edge_joins_filled_path>
+                                </xsl:when>
+                            </xsl:choose>
+                        </xsl:for-each>
+                    </cable_to_PE_to_be_calculated>
+                </xsl:when>
+            </xsl:choose>
+        </xsl:for-each>
+        </cables_from_joins_to_PE>
+    </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:apply-templates/>
+        </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:stylesheet>