Prechádzať zdrojové kódy

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

Piotr Labudda 9 rokov pred
rodič
commit
95dc942c4d

+ 3 - 1
SE/dev/php-cli/biale_plamy-find_ways.php

@@ -142,7 +142,9 @@ function findWay($joinA, $joinB, $path = array()) {
 				foreach ($subPaths as $key => $subPath) {
 				foreach ($subPaths as $key => $subPath) {
 					$distance_cur = 0;
 					$distance_cur = 0;
 					foreach ($subPath as $way_key) {
 					foreach ($subPath as $way_key) {
-						$distance_cur += Vendor_Geophp::load($ways_asText[$way_key], 'wkt')->length();
+						$way = Vendor_Geophp::load($ways_asText[$way_key], 'wkt');
+						if ($way) $distance_cur += Vendor_Geophp::load($ways_asText[$way_key], 'wkt')->length();
+						else $distance_cur += 999;
 					}
 					}
 					if (!$shortestKey || ($shortestKey && $distance_cur < $distance)) {
 					if (!$shortestKey || ($shortestKey && $distance_cur < $distance)) {
 						$shortestKey = $key;
 						$shortestKey = $key;

+ 0 - 97
SE/dev/php-cli/biale_plamy-find_ways_old.php

@@ -1,97 +0,0 @@
-<?php
-$_SERVER['SERVER_NAME'] = 'biuro.biall-net.pl';
-require("../../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();   
-
-function pointsDistance($a, $b) {
-	$line = new LineString(array($a, $b));
-	return $line->length();
-}
-
-$ways2joins = unserialize(file_get_contents('ways2joins.txt'));
-$joins2ways = unserialize(file_get_contents('joins2ways.txt'));
-$points2joins = unserialize(file_get_contents('points2joins.txt'));
-$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'));
-
-
-
-function findWay($joinA, $joinB, $path = array()) {
-	global $ways2joins, $joins2ways, $points2joins, $ways_asText, $points_asText, $res;
-//echo implode('->',$path)."\n\n";
-	if ($joinA == $joinB) $res[] = $path;
-	else {
-		foreach ($joins2ways[$joinA] as $way_key) {
-			if (!in_array($way_key, $path)) {
-//				$joins = $ways2joins[$way_key];
-//				$back_join_subkey = array_search($join_key, $joins);
-//				$new_join_subkey = 1 - $back_join_subkey;
-//				$new_join = $joins[$new_join_subkey];
-				$new_join = $ways2joins[$way_key][1 - array_search($joinA,  $ways2joins[$way_key])];
-				findWay($new_join, $joinB, array_merge($path,array($way_key)));
-			}
-		}
-	}
-}
-
-findWay(100,110);
-print_r($res);

+ 36 - 0
SE/dev/php-cli/biale_plamy-schema.xsd

@@ -137,4 +137,40 @@ do przeanalizowania przez biale_plamy_joins2ways_do_paths.xsl</xs:documentation>
             <xs:element name="findWay" type="bp:findWay"/>
             <xs:element name="findWay" type="bp:findWay"/>
         </xs:sequence>
         </xs:sequence>
     </xs:group>
     </xs:group>
+    <xs:element name="DrogiCut">
+        <xs:annotation>
+            <xs:documentation>Z Bzyk_test_drogi_
+Pociete drogi DUze przez male drogi, dowiazujace do wiekszych</xs:documentation>
+        </xs:annotation>
+        <xs:complexType>
+            <xs:sequence>
+                <xs:element name="ID_Way"/>
+                <xs:element name="ID_Way_A">
+                    <xs:annotation>
+                        <xs:documentation>Numer drogi do ktorej jest powiazane zakonczenie drogi CUT</xs:documentation>
+                    </xs:annotation>
+                    <xs:complexType>
+                        <xs:sequence>
+                            <xs:element name="Path_to_P1">
+                                <xs:complexType>
+                                    <xs:attribute name="Lenght"/>
+                                </xs:complexType>
+                            </xs:element>
+                            <xs:element name="Path_to_P2"/>
+                        </xs:sequence>
+                        <xs:attribute name="ID_Way"/>
+                    </xs:complexType>
+                </xs:element>
+                <xs:element name="ID_Way_B">
+                    <xs:complexType>
+                        <xs:sequence>
+                            <xs:element name="Path_to_P1"/>
+                            <xs:element name="Path_to_P2"/>
+                        </xs:sequence>
+                    </xs:complexType>
+                </xs:element>
+            </xs:sequence>
+            <xs:attribute name="ID_Way"/>
+        </xs:complexType>
+    </xs:element>
 </xs:schema>
 </xs:schema>

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

@@ -6,6 +6,8 @@
     version="2.0">
     version="2.0">
    <!--<xsl:param name=""></xsl:param>-->
    <!--<xsl:param name=""></xsl:param>-->
    
    
+    <xsl:variable name="ways2joins" select="doc('ways2joins.xml')"/>
+   
    <xsl:output indent="yes"/>
    <xsl:output indent="yes"/>
    <xsl:strip-space elements="*"/>
    <xsl:strip-space elements="*"/>
     <!--example input
     <!--example input
@@ -27,14 +29,60 @@
         <xsl:variable name="EdgeWayJoinsPair_cand">
         <xsl:variable name="EdgeWayJoinsPair_cand">
             <xsl:apply-templates mode="joins"/>
             <xsl:apply-templates mode="joins"/>
         </xsl:variable>
         </xsl:variable>
+        <xsl:variable name="joins2ways_z_ID_Way" select="."/>
+        
         <EdgeWayJoins>
         <EdgeWayJoins>
             <xsl:for-each-group select="$EdgeWayJoinsPair_cand/EdgeWayJoinsPair_cand" group-by="@ID_Way">
             <xsl:for-each-group select="$EdgeWayJoinsPair_cand/EdgeWayJoinsPair_cand" group-by="@ID_Way">
                 <EdgeWayJoinsPair>
                 <EdgeWayJoinsPair>
                     <xsl:attribute name="ID_Way" select="@ID_Way"/>
                     <xsl:attribute name="ID_Way" select="@ID_Way"/>
+                    <xsl:variable name="ID_Way" select="@ID_Way"/>
                     <xsl:for-each select="current-group()">
                     <xsl:for-each select="current-group()">
+                        <xsl:variable name="EdgeJoinFound" select="@joins"/>
                         <bp:Joins>
                         <bp:Joins>
                             <xsl:attribute name="Joins" select="@joins"/>
                             <xsl:attribute name="Joins" select="@joins"/>
                         </bp:Joins>
                         </bp:Joins>
+                        <xsl:choose>
+                            <xsl:when test=" count( current-group())&lt;2">
+                                <bp:Joins>
+                                    <xsl:variable name="Joins_miss">
+                                        <xsl:for-each select="$joins2ways_z_ID_Way/item[@ID_Way=$ID_Way and count( child::node())=2 ]">
+                                            <!-- szukamy joinsa ktory ma joina do innego waysa-->
+                                            <xsl:variable name="Join_ID" select="@id"/>
+                                            <xsl:for-each select="item">
+                                                <ways>
+                                                    <xsl:attribute name="id_join" select="$Join_ID"/>
+                                                    <xsl:attribute name="id_way" select="text()"/>
+                                                </ways>
+                                            </xsl:for-each>
+                                        </xsl:for-each>
+                                    </xsl:variable>
+                                    <!--<xsl:copy-of select="$Joins_miss"></xsl:copy-of>-->
+                                    <xsl:variable name="Ways_miss">
+                                        <xsl:for-each select="$Joins_miss/ways">
+                                            <xsl:variable name="id_join" select="@id_join"/>
+                                            <xsl:variable name="id_way_test" select="@id_way"/>
+                                            <xsl:for-each select="$ways2joins/ways2joins/item[@id=$id_way_test]/item">
+                                                <found_joins_in_ways>
+                                                    <xsl:attribute name="id_join" select="$id_join"/>
+                                                    <xsl:attribute name="id_join_found" select="text()"/>
+                                                </found_joins_in_ways>
+                                            </xsl:for-each>
+                                        </xsl:for-each>
+                                    </xsl:variable>
+                                    <!--<xsl:copy-of select="$Ways_miss"/>-->
+                                    <xsl:for-each select="$Ways_miss/found_joins_in_ways[not(@id_join_found=$EdgeJoinFound)]">
+                                        <xsl:choose>
+                                            <xsl:when test="not($Joins_miss/ways[@id_join=current()/@id_join_found])">
+                                                <!--<missed>-->
+                                                    <!--<xsl:attribute name="Joins" select="@id_join"/>-->
+                                                    <xsl:attribute name="Joins" select="current()/@id_join_found"/>
+                                                <!--</missed>-->
+                                            </xsl:when>
+                                        </xsl:choose>
+                                    </xsl:for-each>
+                                </bp:Joins>
+                            </xsl:when>
+                        </xsl:choose>
                     </xsl:for-each>
                     </xsl:for-each>
                 </EdgeWayJoinsPair>
                 </EdgeWayJoinsPair>
             </xsl:for-each-group>
             </xsl:for-each-group>
@@ -42,6 +90,10 @@
     </xsl:template>
     </xsl:template>
     
     
     
     
+    <xsl:template match="item" mode="miss_join">
+        
+    </xsl:template>
+    
     <xsl:template match="item" mode="joins">
     <xsl:template match="item" mode="joins">
         <xsl:choose>
         <xsl:choose>
             <xsl:when test="count(item)=1">
             <xsl:when test="count(item)=1">
@@ -51,6 +103,13 @@
                     <xsl:attribute name="ways" select="item/text()"/>
                     <xsl:attribute name="ways" select="item/text()"/>
                 </xsl:element>
                 </xsl:element>
             </xsl:when>
             </xsl:when>
+            <!--<xsl:when test="count(item)=2">
+                <xsl:element name="EdgeWayJoinsPair_cand">
+                    <xsl:attribute name="joins" select="@id"/>
+                    <xsl:attribute name="ID_Way" select="@ID_Way"/>
+                    <xsl:attribute name="ways" select="item/text()"/>
+                </xsl:element>
+            </xsl:when>-->
         </xsl:choose>
         </xsl:choose>
     </xsl:template>
     </xsl:template>
 
 

+ 23 - 2
SE/dev/php-cli/build__biale_plamy.xml

@@ -13,7 +13,9 @@
         <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"/>
         <property name="ways_2ID_Way.xml" value="ways_2ID_Way.xml"/>
         <property name="ways_2ID_Way.xml" value="ways_2ID_Way.xml"/>
-    
+        <property name="points2joins.xml" value="points2joins.xml"/>
+            <property name="ways2joins.xml" value="ways2joins.xml"/>
+             <property name="ways_asText.xml" value="ways_asText.xml"/>
             <property name="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"/>
@@ -28,7 +30,7 @@
             
             
             <property name="cables_from_joins_to_PE.xsl" value="cables_from_joins_to_PE.xsl"/>
             <property name="cables_from_joins_to_PE.xsl" value="cables_from_joins_to_PE.xsl"/>
             <property name="cables_from_joins_to_PE.xml" value="cables_from_joins_to_PE.xml"/><!-- xml do wygenerowania  -->
             <property name="cables_from_joins_to_PE.xml" value="cables_from_joins_to_PE.xml"/><!-- xml do wygenerowania  -->
-    
+        
             <property name="biale_put_Cables_to_PE.php" value="biale_put_Cables_to_PE.php"/>
             <property name="biale_put_Cables_to_PE.php" value="biale_put_Cables_to_PE.php"/>
     
     
     <target name="check" >
     <target name="check" >
@@ -40,6 +42,7 @@
     
     
     <target name="biale_plamy-generate_data" >
     <target name="biale_plamy-generate_data" >
         
         
+         
         
         
         <antcall target="biale_plamy-generate_data_sql"/>
         <antcall target="biale_plamy-generate_data_sql"/>
         
         
@@ -62,6 +65,24 @@
         
         
     </target>
     </target>
     
     
+    <target name="clean">
+        <delete file="${points2joins.xml}"/>
+        <delete file="${ways2joins.xml}"/>
+        <delete file="${ways_asText.xml}"/>
+        <delete file="${joins_asText.xml}"/>
+        <delete file="${joins2ways_z_ID_Way.xml}"/>
+        <delete file="${edge_joins.xml}"/>
+        <delete file="${joins2ways.xml}"/>
+        <delete file="${points2ID_Way.xml}"/>
+        <delete file="${ways_2ID_Way.xml}"/>
+        <delete file="${joins2ways_z_ID_Way.xml}"/>
+        <delete file="${points_asText.xml}"/>
+        <delete file="${points2joins.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}"/>
+    </target>
     
     
     
     
     <target name="biale_plamy_prepare_mysql_data">
     <target name="biale_plamy_prepare_mysql_data">

+ 11 - 3
SE/dev/php-cli/cables_from_joins_to_PE.xsl

@@ -12,6 +12,7 @@
     <xsl:variable name="PE_candidates_dump" select="doc('edge_paths_with_PE.xml')"/>
     <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="joins_asText" select="doc('joins_asText.xml')"/>
     <xsl:variable name="edge_joins_filled_paths" select="doc('edge_joins_filled_paths.xml') "/>
     <xsl:variable name="edge_joins_filled_paths" select="doc('edge_joins_filled_paths.xml') "/>
+    <xsl:variable name="points2joins" select="doc('points2joins.xml')"/>
     
     
     <!-- <joins_asText>
     <!-- <joins_asText>
         <item id="0">POINT (18.7909 51.701067999083)</item>-->
         <item id="0">POINT (18.7909 51.701067999083)</item>-->
@@ -32,14 +33,21 @@
             
             
         <!-- 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:choose>
+            <xsl:variable name="ID_Way" select="@ID_Way"/>
+            <xsl:variable name="Joins" select="@id"/>
+            <xsl:choose> 
+                <!-- trzeba sprawdzic czy join jest klientem - czy tylko PE! -->
+                <xsl:when test="not($points2joins/points2joins/item/text()=$Joins)">
+                    <not_candidate><xsl:attribute name="descr" select="'this is probably join from way'"/></not_candidate>
+                </xsl:when>
                 <xsl:when test="$PE_candidates_dump/PE_candidates_dump/LINESTRING[@ID_Way=current()/@ID_Way]">
                 <xsl:when test="$PE_candidates_dump/PE_candidates_dump/LINESTRING[@ID_Way=current()/@ID_Way]">
                     <cable_to_PE_to_be_calculated>
                     <cable_to_PE_to_be_calculated>
                         <xsl:attribute name="ID_Way" select="@ID_Way"/>
                         <xsl:attribute name="ID_Way" select="@ID_Way"/>
                         <xsl:attribute name="Joins" select="@id"/>
                         <xsl:attribute name="Joins" select="@id"/>
-                        <xsl:variable name="ID_Way" select="@ID_Way"/>
-                        <xsl:variable name="Joins" select="@ID_Way"/>
+                       
                         
                         
                          <!-- idziemy po drodze,  -->
                          <!-- 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_X" select="$joins_asText_Path_Point/joins_asText/item[@id=$Joins]/As_POINT_to_xml/@X"/>