瀏覽代碼

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

Piotr Labudda 9 年之前
父節點
當前提交
cff6a43cd5

+ 185 - 10
SE/dev/php-cli/biale_plamy_joins2ways_do_paths.xsl

@@ -26,13 +26,108 @@
     -->
     
     <xsl:template match="joins2ways_z_ID_Way">
-        <xsl:variable name="EdgeWayJoinsPair_cand">
+        <!--<xsl:variable name="EdgeWayJoinsPair_cand">
             <xsl:apply-templates mode="joins"/>
+        </xsl:variable>-->
+        <!--<xsl:variable name="joins2ways_z_ID_Way" select="."/>-->
+        <!--<xsl:copy-of select="$EdgeWayJoinsPair_cand"></xsl:copy-of>-->
+        <!--<xsl:choose>
+            <xsl:when test="$EdgeWayJoinsPair_cand/EdgeWayJoinsPair_cand[@ID_Way=current()/@ID_Way]">
+                <JESTOK></JESTOK>
+            </xsl:when>
+            <xsl:otherwise>
+                
+            </xsl:otherwise>
+        </xsl:choose>-->
+        <!--<xsl:copy-of select="$EdgeWayJoinsPair_cand/no_EdgeWayJoinsPair"></xsl:copy-of>-->
+        <xsl:variable name="guess_edges">
+            
+                <xsl:for-each select="item">
+                    <guess_join>
+                        <xsl:attribute name="ID_Way" select="@ID_Way"/>
+                        <xsl:variable name="ID_Way">
+                            <xsl:choose>
+                                <xsl:when test="@ID_Way"><xsl:value-of select="@ID_Way"/></xsl:when>
+                                <xsl:otherwise><xsl:value-of select="0"/></xsl:otherwise>
+                            </xsl:choose>
+                        </xsl:variable>
+                        <xsl:apply-templates select="." mode="joins_not_way">
+                            <xsl:with-param name="ID_Way" select="$ID_Way"/>
+                        </xsl:apply-templates>
+                    </guess_join>
+                </xsl:for-each>
+               
         </xsl:variable>
-        <xsl:variable name="joins2ways_z_ID_Way" select="."/>
         
         <EdgeWayJoins>
-            <xsl:for-each-group select="$EdgeWayJoinsPair_cand/EdgeWayJoinsPair_cand" group-by="@ID_Way">
+            <!--<xsl:for-each-group select="$EdgeWayJoinsPair_cand/no_EdgeWayJoinsPair" group-by="@ID_Way">
+                <EdgeWayJoinsPair>
+                    <xsl:attribute name="ID_Way" select="@ID_Way"/>
+                    <xsl:variable name="ID_Way" select="@ID_Way"/>
+                    <xsl:variable name="Joins_miss">
+                        <xsl:for-each select="$joins2ways_z_ID_Way/item[@ID_Way=$ID_Way and count( child::node())&gt;1 ]">
+                            <!-\- 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: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"/>-\->
+                                <bp:Joins>
+                                     <xsl:attribute name="Joins" select="current()/@id_join_found"/>
+                                </bp:Joins>
+                                <!-\-</missed>-\->
+                            </xsl:when>
+                        </xsl:choose>
+                    </xsl:for-each>
+                </EdgeWayJoinsPair>
+            </xsl:for-each-group>-->
+            <xsl:for-each-group select="item" group-by="@ID_Way">
+                <xsl:variable name="ID_Way" select="@ID_Way"/>
+                
+                <EdgeWayJoinsPair>
+                    <xsl:attribute name="ID_Way" select="@ID_Way"/>
+                    <!--<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">
+                        <bp:Joins>
+                            <xsl:attribute name="Joins" select="@joins"/>
+                        </bp:Joins>
+                    </xsl:for-each>
+                    <!--<xsl:for-each select="current-group()">
+                        <!-\-<GROUP><xsl:copy-of select="item("></xsl:copy-of></GROUP>-\->
+                        <xsl:choose>
+                                <xsl:when test=" position()=1 or position()=last()">
+                                    <bp:Joins>
+                                        <xsl:attribute name="Joins" select="@id"/>
+                                    </bp:Joins>
+                                </xsl:when>
+                            </xsl:choose>
+                    </xsl:for-each>-->
+                </EdgeWayJoinsPair>
+            </xsl:for-each-group>
+            <!--<xsl:for-each-group select="$EdgeWayJoinsPair_cand/EdgeWayJoinsPair_cand" group-by="@ID_Way">
                 <EdgeWayJoinsPair>
                     <xsl:attribute name="ID_Way" select="@ID_Way"/>
                     <xsl:variable name="ID_Way" select="@ID_Way"/>
@@ -46,7 +141,7 @@
                                 <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-->
+                                            <!-\- szukamy joinsa ktory ma joina do innego waysa-\->
                                             <xsl:variable name="Join_ID" select="@id"/>
                                             <xsl:for-each select="item">
                                                 <ways>
@@ -56,7 +151,7 @@
                                             </xsl:for-each>
                                         </xsl:for-each>
                                     </xsl:variable>
-                                    <!--<xsl:copy-of select="$Joins_miss"></xsl:copy-of>-->
+                                    <!-\-<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"/>
@@ -69,14 +164,14 @@
                                             </xsl:for-each>
                                         </xsl:for-each>
                                     </xsl:variable>
-                                    <!--<xsl:copy-of select="$Ways_miss"/>-->
+                                    <!-\-<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"/>-->
+                                                <!-\-<missed>-\->
+                                                    <!-\-<xsl:attribute name="Joins" select="@id_join"/>-\->
                                                     <xsl:attribute name="Joins" select="current()/@id_join_found"/>
-                                                <!--</missed>-->
+                                                <!-\-</missed>-\->
                                             </xsl:when>
                                         </xsl:choose>
                                     </xsl:for-each>
@@ -85,7 +180,7 @@
                         </xsl:choose>
                     </xsl:for-each>
                 </EdgeWayJoinsPair>
-            </xsl:for-each-group>
+            </xsl:for-each-group>-->
         </EdgeWayJoins>
     </xsl:template>
     
@@ -94,15 +189,95 @@
         
     </xsl:template>
     
+    <xsl:template match="item" mode="joins_not_way">
+        <xsl:param name="ID_Way" required="yes"/>
+        <xsl:variable name="count_our_way">
+            <xsl:for-each select="item">
+                <xsl:element name="count_our_way">
+                    <xsl:choose>
+                        <xsl:when test="@ID_WAY=$ID_Way">1</xsl:when>
+                        <xsl:otherwise>0</xsl:otherwise>
+                    </xsl:choose>
+                </xsl:element>
+            </xsl:for-each>
+        </xsl:variable>
+          <see>
+                <xsl:copy-of select="."/>
+              <inside>   
+                  <xsl:attribute name="count_our"   select="count(item[@ID_WAY=$ID_Way])"/>
+                  <count_our_way_val>
+                  <xsl:copy-of select="$count_our_way"/>
+                  </count_our_way_val>
+                <xsl:for-each select="item[@ID_WAY!=$ID_Way]">
+                  <xsl:element name="EdgeWayJoinsPair_cand">
+                      <xsl:attribute name="joins" select="../@id"/>
+                      <xsl:attribute name="ID_Way" select="../@ID_Way"/>
+                  </xsl:element>  
+              </xsl:for-each>
+              </inside>
+        </see>
+        <xsl:variable name="if_item_not_in_way">
+            <xsl:for-each select="item">
+                <xsl:choose>
+                    <xsl:when test="not(@ID_WAY=$ID_Way)">
+                        <xsl:element name="EdgeWayJoinsPair_cand">
+                        <xsl:attribute name="joins" select="../@id"/>
+                        <xsl:attribute name="ID_Way" select="../@ID_Way"/>
+                    </xsl:element></xsl:when>
+                </xsl:choose>
+                
+                
+            </xsl:for-each>
+        </xsl:variable>
+        <xsl:choose>
+            <xsl:when test="count(item)=1">
+                <xsl:element name="EdgeWayJoinsPair_cand">
+                    <xsl:attribute name="pos" select="position()"/>
+                    <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:when test="$if_item_not_in_way/EdgeWayJoinsPair_cand and count(item[@ID_WAY=$ID_Way])&lt;2">
+                <xsl:element name="EdgeWayJoinsPair_cand">
+                    <xsl:attribute name="debug" select="'has other way'"/>
+                    <xsl:attribute name="joins" select="@id"/>
+                    <xsl:attribute name="ID_Way" select="@ID_Way"/>
+                    <xsl:attribute name="ways">
+                        <xsl:for-each select="item/text()">
+                            <xsl:value-of select=" concat(.,' ')"/> 
+                        </xsl:for-each>
+                    </xsl:attribute>
+                    <!--<xsl:attribute name="ways" select="item/text()" separator="', '" />-->
+                </xsl:element>
+            </xsl:when>
+        </xsl:choose>
+    </xsl:template>
+    
     <xsl:template match="item" mode="joins">
+        <!--<xsl:param name="second_turn" />-->
         <xsl:choose>
+            <!--<xsl:when test="count(item[@ID_WAY=current()/@ID_Way])&gt;1">
+                <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:when test="count(item)=1">
                 <xsl:element name="EdgeWayJoinsPair_cand">
+                    <xsl:attribute name="pos" select="position()"/>
                     <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:when test="count(../item[@ID_Way=current()/@ID_Way]) and count( child::node()=1)">
+                <xsl:element name="no_EdgeWayJoinsPair">
+                    <xsl:attribute name="ID_Way" select="@ID_Way"/>
+                </xsl:element>
+
+            </xsl:when>-->
             <!--<xsl:when test="count(item)=2">
                 <xsl:element name="EdgeWayJoinsPair_cand">
                     <xsl:attribute name="joins" select="@id"/>

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

@@ -127,11 +127,14 @@ foreach($cables_from_joins_to_PE->xpath('cable_to_PE_to_be_calculated') as $chil
 		   //	echo "#87Child";print_r($b[0]);
 		   if($a=='ID_Way') $ID_Way=$b[0];
 		    if($a=='Joins') $Joins=$b[0];
+		    if($a=='ID_Point') $ID_Point=$b[0];
+
 		   //if($a=='Count') $Count=$b[0];
 	   }
 	  //echo $child->getName() . ": " . " ID_Way: ".$ID_Way. " : ";
 	   settype($ID_Way, "integer");
 	   settype($Joins, "integer");
+	   settype($ID_Point, "integer");
 
 	   foreach($child->xpath('found_in_path_in_edge_joins_filled_path') as $Path_Point_xml)  {
 		//   detect_next_PE/LINESTRING
@@ -143,6 +146,8 @@ foreach($cables_from_joins_to_PE->xpath('cable_to_PE_to_be_calculated') as $chil
 		   $cables_from_joins_to_PE_arr[$id_j]['LINESTRING']=$LINESTRING;
 		   $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;
+
 
 
 	   }
@@ -158,8 +163,9 @@ unset($ID_Way);
 
 foreach($cables_from_joins_to_PE_arr as $id_j=>$Path_Point_val) {
 		
-		$sql_Path_Point_val="insert into Rozdzielcza_test_bzyk_Cables_to_PE (the_geom,ID_Way)
-		     values (ST_GeomFromText('".$Path_Point_val['LINESTRING']."'),'".$Path_Point_val['ID_Way']."'   )   ";
+		$sql_Path_Point_val="insert into Rozdzielcza_test_bzyk_Cables_to_PE (the_geom,ID_Way,ID_Point)
+		     values (ST_GeomFromText('".$Path_Point_val['LINESTRING']."'),'".$Path_Point_val['ID_Way']."',
+		     '".$Path_Point_val['ID_Point']."'   )   ";
 		    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);

+ 1 - 3
SE/dev/php-cli/biale_put_PE_to_mysql.php

@@ -94,10 +94,8 @@ foreach($edge_paths_with_PE->children() as $child)  {
 	   }
 	  //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');
@@ -129,7 +127,7 @@ foreach($edge_paths_with_PE_arr as $ID_Way=>$Path_Point) {
 		     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);
+		   if( strlen($Path_Point_val['X'])>1 and   strlen($Path_Point_val['Y'])>1 ) DB::getPDO()->query($sql_Path_Point_val);
 		    //else echo "#296 path nie wygenerowalo sie !! dla ".$ID_Way." i pkt ".$pkt_A." , ".$pkt_B." \n";
 		}		
 	

+ 30 - 78
SE/dev/php-cli/build__biale_plamy.xml

@@ -54,14 +54,7 @@
         <!-- tymczasowy rem bo dziala -->
         <antcall target="biale_plamy_paths_to_findways_php"/>
         
-        <antcall target="biale_plamy_from_paths_php_to_place_PE"/>
-        <!-- tymczasowy rem bo skryptu nie ma -->
-        <antcall target="biale_plamy_put_PE_to_mysql_php"/>
-        
-        <antcall target="biale_plamy_analyze_shortest_and_trace_cables"/>
-        
-        <!--Tymczasowa zatrzymanie bo nie chodzi na zdalnym - plik juz jest-->
-        <antcall target="biale_put_Cables_to_PE"/>
+        <antcall target="PE_and_Cables"/>
         
     </target>
     
@@ -85,6 +78,29 @@
     </target>
     
     
+    
+    <target name="check_files_for_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">
+            <available file="${points2joins.xml}" filepath="." />
+            <available file="${ways2joins.xml}" filepath="." />
+            <available file="${edge_joins_filled_paths.xml}" filepath="." />
+            <available file="${points_asText.xml}" filepath="." />
+            <available file="${joins2ways_z_ID_Way.xml}" filepath="." />
+        </condition>
+    </target>
+    
+    
+    <target name="PE_and_Cables">
+        <antcall target="biale_plamy_from_paths_php_to_place_PE"/>
+        <!-- tymczasowy rem bo skryptu nie ma -->
+        <antcall target="biale_plamy_put_PE_to_mysql_php"/>
+        <antcall target="biale_plamy_analyze_shortest_and_trace_cables"/>        
+        <!--Tymczasowa zatrzymanie bo nie chodzi na zdalnym - plik juz jest-->
+        <antcall target="biale_put_Cables_to_PE"/>
+    </target>
+    
+    
     <target name="biale_plamy_prepare_mysql_data">
         <echo message="biale_plamy_prepare_mysql_data "/>
         <exec executable="php" failonerror="true" dir=".">
@@ -102,10 +118,11 @@
             <arg file="${biale_plamy-generate_data.php}"/>
         </exec>
         <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 "/>
+        <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}" >
             <factory name="net.sf.saxon.TransformerFactoryImpl">    
                 <attribute name="http://saxon.sf.net/feature/xinclude-aware" value="true"/>
@@ -119,6 +136,7 @@
    
     <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 "/>
+        <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}" >
             <factory name="net.sf.saxon.TransformerFactoryImpl">    
                 <attribute name="http://saxon.sf.net/feature/xinclude-aware" value="true"/>
@@ -141,6 +159,7 @@
     <!-- postawienie PE po trasach -->
     <target name="biale_plamy_from_paths_php_to_place_PE">
         <echo message="Wyznaczenie PE na podstawie tras  "/>
+        <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}" >
             <factory name="net.sf.saxon.TransformerFactoryImpl">    
                 <attribute name="http://saxon.sf.net/feature/xinclude-aware" value="true"/>
@@ -160,6 +179,7 @@
     
     <!-- przeliczenie dla kazdego PE z trasy punktu przeciecia i wybranie najkrotszej i wygenerowania kabla -->
     <target name="biale_plamy_analyze_shortest_and_trace_cables">
+        <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}" >
             <factory name="net.sf.saxon.TransformerFactoryImpl">    
                 <attribute name="http://saxon.sf.net/feature/xinclude-aware" value="true"/>
@@ -218,73 +238,5 @@
         <echo message="Using default XML object on input from file ${INPUT} . "/>
     </target>
     
-    <target name="PROCES_TO_DITA_build" depends="check-info">
-        <echo message="PROCES_TO_DITA_build to ${test_if_INPUTxml}"/>
-        <!-- przyklad z uzywaniem saxona ktorego wczesniej trzeba pobrac z port install saxon -->
-        <!--<xslt style="copy-no-xml.xsl" in="${INPUT}" out="${Test_z_getfeature_do_parse__noxml.xml}"> <!-\- {Test_z_getfeature_do_parse__noxml.xml"-\->
-            <factory name="net.sf.saxon.TransformerFactoryImpl">    
-                <attribute name="http://saxon.sf.net/feature/xinclude-aware" value="true"/>
-            </factory>
-            <classpath location="/opt/local/share/java/saxon9he.jar"/>
-        </xslt>-->
-        <!--<xslt style="copy-no-xml.xsl" in="main.dita" out="${main__noxml.dita}"/>-->
-        <!--<concat destfile="${tmp.xml}" append="true" encoding="UTF-8" > 
-            <string>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
-                &lt;root&gt;</string>
-            <file file="${Test_z_getfeature_do_parse__noxml.xml}"  />
-            <file file="${main__noxml.dita}"/>
-            <string>&lt;/root&gt;</string>
-        </concat>-->  
-        
-        <!-- parsuje main.dita aby wiedziec, jaki proces jest zalaczany do danego zaglebienia aby wygenerowac docelowy plik dita z zaglebieniami -->
-        <xslt basedir="./" style="${parse_dita_templ.xsl}" in="${INPUT}"  destdir="./" out="out.dita" >
-            <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="dita_task_template_file_param" expression="main.dita"/>-->
-        </xslt>
-        
-        <!-- tymczasowe rem dla zrobienia akcji wyzej -->
-        <!--<xslt basedir="./" style="${PROCES_INCLUDE.xsl}" in="${INPUT}"  destdir="./" out="out.dita" >
-            <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="PROCES_INCLUDE"/>
-                <!-\-<attribute name="http://saxon.sf.net/feature/initialTemplate" value="asd"/>-\->
-            </factory>
-            <classpath location="/opt/local/share/java/saxon9he.jar"/>
-            <!-\-<param name="dita_task_template_file_param" expression="main.dita"/>-\->
-        </xslt>--> 
-        
-        
-        
-        <!--<property name="dita.dir" location="/Library/Server/Web/Data/Sites/Default/SE/stuff/dita-ot-2.3.3/bin/dita"/>-->
-        <!--<exec executable="${dita.dir}" dir=".">
-            <arg value="-i"/>
-            <arg value="${out_task.dita}" />
-            <arg value="-f" />
-            <arg value="pdf"/>
-            <arg value="-o"/>
-            <arg value="out"/>
-        </exec>-->
-        
-        <!--<exec  executable="bash" dir="." outputproperty="out_task_file">
-            <arg value="-c"/>
-            <arg value="echo ${out_task.dita} |sed 's/^.*\///'"/>
-        </exec>-->
-        
-        <!--<propertyregex  property="out_file" input="${out_task.dita}" regexp="$.*/(.*)" select="\1."/>-->
-        <!--<loadfile property="result" srcFile="out/${out_task_file}.pdf"/>-->
-        <!--<echo message="input was : ${input}"/>-->
-        <!--<echo message="${result}"/>-->
-        <!--<propertyregex 
-            name="test"
-            property="current.target.dir"
-            input="com.element.subelement"
-            regexp="\."
-            replace="/"
-            global="true" />-->
-    </target>
+    
 </project>

+ 65 - 28
SE/dev/php-cli/cables_from_joins_to_PE.xsl

@@ -35,51 +35,87 @@
                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="Joins" select="@id"/>
+            <xsl:variable name="ID_Point" select="@ID_Point"/>
             <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 test="not(@ID_Point)">
+                    <not_candidate><xsl:attribute name="descr" select="'this is probably join from way'"/>
+                        <xsl:attribute name="Joins" select="@id"/></not_candidate>
                 </xsl:when>
                 <xsl:when test="$PE_candidates_dump/PE_candidates_dump/LINESTRING[@ID_Way=current()/@ID_Way]">
                     <cable_to_PE_to_be_calculated>
                         <xsl:attribute name="ID_Way" select="@ID_Way"/>
                         <xsl:attribute name="Joins" select="@id"/>
-                       
-                        
+                        <xsl:attribute name="ID_Point" select="@ID_Point"/>
                          <!-- 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/item[@id=$ID_Way]/bp:Path_Point">
-                            <xsl:variable name="diff_X" select=" number($Join_X)- number(@X)"/><xsl:variable name="diff_Y" select=" number($Join_Y)- number(@Y)"/>
-                            <xsl:variable name="bp:Path_Point" select="."/>
-                            <xsl:choose>
-                                <xsl:when test="(abs($diff_X)&lt;0.0001 and abs($diff_X)&lt;0.0001) or ( @X=$Join_X and @Y=$Join_Y )">
-                                    <found_in_path_in_edge_joins_filled_path>
-                                        <xsl:attribute name="diff_X" select="$diff_X"/><xsl:attribute name="diff_Y" select="$diff_Y"/>
-                                        <xsl:attribute name="position" select="position()"/>
-                                        <xsl:copy-of select="."/>
+                        <xsl:variable name="found_in_path_in_edge_joins_filled_path">
+                            <xsl:for-each select="$edge_joins_filled_paths/edge_joins_filled_paths/item[@id=$ID_Way]/bp:Path_Point">
+                                <xsl:variable name="diff_X" select=" number($Join_X)- number(@X)"/><xsl:variable name="diff_Y" select=" number($Join_Y)- number(@Y)"/>
+                                <xsl:variable name="bp:Path_Point" select="."/>
+                                 
+                                    <xsl:choose>
+                                        <xsl:when test="(abs($diff_X)&lt;0.0001 and abs($diff_X)&lt;0.0001) or ( @X=$Join_X and @Y=$Join_Y )">
+                                            <found_in_path_in_edge_joins_filled_path>
+                                                <xsl:attribute name="diff_X" select="$diff_X"/><xsl:attribute name="diff_Y" select="$diff_Y"/>
+                                                <xsl:attribute name="position" select="position()"/>
+                                                <!--<bp:Path_Point_var><xsl:copy-of select="$bp:Path_Point"/></bp:Path_Point_var>-->
+                                                <xsl:copy-of select="."/>
+                                                <xsl:call-template name="detect_next_PE">
+                                                    <xsl:with-param name="bp:Path_Point" select="$bp:Path_Point"/>
+                                                    <xsl:with-param name="ID_Way" select="$ID_Way"/>
+                                                    <xsl:with-param name="Pos_found" select="position()"/>
+                                                    <xsl:with-param name="edge_joins_filled_paths" select="$edge_joins_filled_paths"/>
+                                                    <xsl:with-param name="ID_Point" select="$ID_Point"/>
+                                                </xsl:call-template>
+                                            </found_in_path_in_edge_joins_filled_path>
+                                        </xsl:when>
+                                        <xsl:otherwise>
+                                            <not_found>
+                                                <xsl:attribute name="Pos" select="position()"/>
+                                                <xsl:attribute name="X" select="@X"/><xsl:attribute name="Y" select="@Y"/>
+                                                <xsl:attribute name="srch_X" select="$Join_X"/><xsl:attribute name="srch_Y" select="$Join_Y"/>
+                                                <xsl:attribute name="diff_X" select="$diff_X"/><xsl:attribute name="diff_Y" select="$diff_Y"/>
+                                            </not_found>
+                                        </xsl:otherwise>
+                                    </xsl:choose>
+                            </xsl:for-each>
+                        </xsl:variable>
+                        
+                        <xsl:choose>
+                            <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:sort select="count(detect_next_PE/bp:Path_Point)" order="descending"/>
+                                    <debug>
+                                        <xsl:attribute name="debug_pos" select="position()"/>
+                                        <xsl:attribute name="Path_Point_count" select="count(detect_next_PE/bp:Path_Point)"/>
+                                    </debug>
+                                    <!--<found_in_path_in_edge_joins_filled_path>
+                                        <xsl:attribute name="debug_pos" select="position()"/>
+                                        <xsl:copy-of select="@*"/>
                                         <xsl:call-template name="detect_next_PE">
-                                            <xsl:with-param name="bp:Path_Point" select="$bp:Path_Point"/>
+                                            <xsl:with-param name="bp:Path_Point" select="bp:Path_Point_var"/>
                                             <xsl:with-param name="ID_Way" select="$ID_Way"/>
-                                            <xsl:with-param name="Pos_found" select="position()"/>
+                                            <xsl:with-param name="Pos_found" select="@position"/>
                                             <xsl:with-param name="edge_joins_filled_paths" select="$edge_joins_filled_paths"/>
+                                            <xsl:with-param name="ID_Point" select="$ID_Point"/>
                                         </xsl:call-template>
-                                    </found_in_path_in_edge_joins_filled_path>
-                                </xsl:when>
-                                <xsl:otherwise>
-                                    <not_found>
-                                        <xsl:attribute name="Pos" select="position()"/>
-                                        <xsl:attribute name="X" select="@X"/><xsl:attribute name="Y" select="@Y"/>
-                                        <xsl:attribute name="srch_X" select="$Join_X"/><xsl:attribute name="srch_Y" select="$Join_Y"/>
-                                        <xsl:attribute name="diff_X" select="$diff_X"/><xsl:attribute name="diff_Y" select="$diff_Y"/>
-                                    </not_found>
-                                </xsl:otherwise>
-                            </xsl:choose>
-                        </xsl:for-each>
+                                    </found_in_path_in_edge_joins_filled_path>-->
+                                    
+                                    <xsl:copy-of select="."/>
+                                    
+                                </xsl:for-each>
+                                <xsl:copy-of select="$found_in_path_in_edge_joins_filled_path/not_found"/>
+                            </xsl:when>
+                            <xsl:otherwise>
+                                <xsl:copy-of select="$found_in_path_in_edge_joins_filled_path"/>
+                            </xsl:otherwise>
+                        </xsl:choose>
                     </cable_to_PE_to_be_calculated>
                 </xsl:when>
             </xsl:choose>
@@ -93,6 +129,7 @@
            <xsl:param name="Pos_found" required="yes"/>
            <xsl:param name="ID_Way" required="yes"/>
            <xsl:param name="edge_joins_filled_paths" required="yes"/>
+           <xsl:param name="ID_Point" required="yes"/>
            <!--<w_gore><xsl:attribute name="Pos_found" select="$Pos_found"/>
                <xsl:for-each select="$edge_joins_filled_paths/edge_joins_filled_paths/item[@id=$ID_Way]/bp:Path_Point">
                     

+ 26 - 14
SE/dev/php-cli/edge_joins_filled_paths.xsl

@@ -8,7 +8,7 @@
     <xsl:output indent="yes"/>
     <xsl:strip-space elements="*"/>
     
-    <xsl:variable name="test"/>
+    <xsl:variable name="joins2ways_z_ID_Way" select="doc('joins2ways_z_ID_Way.xml')"/>
     
     <!--//match edge_joins_filled_paths-->
     
@@ -17,6 +17,9 @@
         <xsl:variable name="PE_track">
             <xsl:apply-templates/>
         </xsl:variable>
+        <!--<PE_track>
+            <xsl:copy-of select="$PE_track"/>
+        </PE_track>-->
         <xsl:variable name="PE_track">
             <xsl:for-each select="$PE_track/LINESTRING">
                 <LINESTRING>
@@ -27,17 +30,22 @@
                     <bp:Path_Point>
                         <xsl:copy-of select="@*"/>
                          <xsl:attribute name="Pos" select="position()"/>
-                         <xsl:attribute name="X" select="pos[@pos=2]"/>
-                         <xsl:attribute name="Y" select="pos[@pos=3]"/>
+                        <xsl:choose>
+                            <xsl:when test=" string-length(pos[@pos=1]/text())&gt;1">
+                                <xsl:attribute name="X" select="pos[@pos=1]"/>
+                                <xsl:attribute name="Y" select="pos[@pos=2]"/>
+                            </xsl:when>
+                            <xsl:otherwise>
+                                <xsl:attribute name="X" select="pos[@pos=2]"/>
+                                <xsl:attribute name="Y" select="pos[@pos=3]"/>
+                            </xsl:otherwise>
+                        </xsl:choose>
                     </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>-->
             <!--<SRC>
             <xsl:copy-of select="$PE_track"/>
             </SRC>-->
@@ -53,8 +61,12 @@
     <xsl:template name="dumb_frequency">
         <xsl:param name="Count"/>
         <xsl:param name="distance"/>
+        <xsl:param name="ID_Point_count"/>
         <xsl:choose>
-            <xsl:when test="$Count&lt;2">
+            <xsl:when test="$ID_Point_count=0">
+                <xsl:value-of select="0"/>
+            </xsl:when>
+            <!--<xsl:when test="$Count&lt;2">
                 <xsl:value-of select="2"/>
             </xsl:when>
             <xsl:when test="$Count&lt;3">
@@ -65,9 +77,9 @@
             </xsl:when>
             <xsl:when test="$Count&lt;15">
                 <xsl:value-of select="5"/>
-            </xsl:when>
+            </xsl:when>-->
             <xsl:when test="$Count&lt;20">
-                <xsl:value-of select="10"/>
+                <xsl:value-of select="$Count - 1"/>
             </xsl:when>
             <xsl:when test="$Count&lt;30">
                 <xsl:value-of select="15"/>
@@ -76,34 +88,33 @@
                 <xsl:value-of select="20"/>
             </xsl:otherwise>
         </xsl:choose>        
-        
-        
     </xsl:template>
     
     <xsl:template name="PE_candidates_dump">
         <xsl:param name="edge_paths_with_PE" required="yes"/>
         <xsl:param name="dumb_frequency" select="20"/>
+        <xsl:param name="clients_xpoint_count"/> <!--Ile jest na trasie punktow klienckich  -->
         <!--<PE_candidates_dump>-->
             <xsl:attribute name="desc" select="'brakuje ominiecia punktow ways tylko do przylaczy i analizy dlugosci'"/>
             <xsl:for-each select="$edge_paths_with_PE/LINESTRING">
                 <LINESTRING>
                 <xsl:variable name="Count" select="@Count"/>
+                <xsl:variable name="ID_Point_count" select="@ID_Point_count"/>
                 <xsl:variable name="ID_Way" select="@ID_Way"/>
                 <xsl:variable name="distance" select="@distance"/>
                 <xsl:variable name="dumb_frequency">
                     <xsl:call-template name="dumb_frequency">
                         <xsl:with-param name="Count" select="$Count"/>
+                        <xsl:with-param name="ID_Point_count" select="$ID_Point_count"/>
                         <xsl:with-param name="distance" select="$distance"/>
                     </xsl:call-template>
                 </xsl:variable>
                 <xsl:attribute name="ID_Way" select="$ID_Way"/>
                 <xsl:copy-of select="@*"/>
-                 
                  <xsl:attribute name="dumb_frequency" select="$dumb_frequency"/>
-                    
                     <xsl:for-each select="bp:Path_Point">
                         <xsl:choose>
-                            <xsl:when test="@Pos mod $dumb_frequency = 0">
+                            <xsl:when test="(@Pos mod $dumb_frequency = 0 ) and $dumb_frequency &gt;0">
                                 <xsl:copy-of select="."/>
                             </xsl:when>
                         </xsl:choose>
@@ -119,6 +130,7 @@
             <xsl:when test="asText">
                 <LINESTRING>
                     <xsl:attribute name="ID_Way" select="@id"/>
+                    <xsl:attribute name="ID_Point_count" select="count($joins2ways_z_ID_Way/joins2ways_z_ID_Way/item[@ID_Way=current()/@id and @ID_Point])"/>
                     <xsl:attribute name="distance" select="distance/text()"/>
                       <xsl:apply-templates/>
                 </LINESTRING>

+ 54 - 4
SE/dev/php-cli/joins2ways_z_ID_Way.xsl

@@ -4,22 +4,72 @@
     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:param name="ways_2ID_Way.xml"  select="'ways_2ID_Way.xml'"/>
     <xsl:variable name="ways_2ID_Way" select="doc($ways_2ID_Way.xml)"/>
+    <xsl:variable name="points2joins" select="doc('points2joins.xml')"/>
     
     <xsl:template match="joins2ways">
         <joins2ways_z_ID_Way>
-            <xsl:apply-templates/>
+            <xsl:variable name="joins2ways">
+                <xsl:apply-templates/>
+            </xsl:variable>
+            <xsl:for-each select="$joins2ways/item">
+                <!--<xsl:sort select="number(@ID_Way)"/>-->
+                <xsl:copy-of select="."/>
+            </xsl:for-each>
         </joins2ways_z_ID_Way>
     </xsl:template>
     <xsl:template match="item">
-        <item>
+        <xsl:variable name="item" select="."/>
+        <xsl:variable name="ID_Point" select="$points2joins/points2joins/item[text()= current()/@id]/@id"/>
+        <xsl:variable name="items">
+            <xsl:for-each select="item">
+                        <item>
+                            <xsl:copy-of select="$item/@*"/>
+                            <xsl:attribute name="ID_Way" select="$ways_2ID_Way/ways_2ID_Way/item[@id=current()/text()]/text()"/>
+                            <xsl:if test="$ID_Point">
+                                <xsl:attribute name="ID_Point" select="$ID_Point"/>
+                            </xsl:if>
+                            <xsl:attribute name="item_copied_pos" select="position()"/>
+                            <xsl:for-each select="$item/item">
+                                <xsl:element name="item">
+                                    <xsl:attribute name="id" select="@id"/>
+                                    <xsl:attribute name="ID_WAY" select="$ways_2ID_Way/ways_2ID_Way/item[@id=current()/text()]/text()"/>
+                                    <xsl:copy-of select="text()"/>
+                                </xsl:element>
+                            </xsl:for-each>
+                        </item>
+            </xsl:for-each>
+        </xsl:variable>
+        
+        <xsl:for-each-group select="$items/item" group-by="@ID_Way">
+            <item>
+                <xsl:copy-of select="@*"/>
+                <!--<xsl:attribute name="ID_Way_count" select="$ID_Way_count"/>-->
+                <xsl:copy-of select="item"/>
+            </item>
+        </xsl:for-each-group>
+        <!--<item>
             <xsl:copy-of select="@*"/>
             <xsl:if test="$ways_2ID_Way/ways_2ID_Way/item[@id=current()/item[1]/text()]/text()">
                 <xsl:attribute name="ID_Way" select="$ways_2ID_Way/ways_2ID_Way/item[@id=current()/item[1]/text()]/text()"/>
             </xsl:if>
-            <xsl:copy-of select="item"/>
-        </item>
+            <xsl:if test="$points2joins/points2joins/item[text()= current()/@id]">
+                <xsl:attribute name="ID_Point" select="$points2joins/points2joins/item[text()= current()/@id]/@id"/>
+            </xsl:if>
+            <xsl:for-each select="item">
+                <xsl:element name="item">
+                    <xsl:attribute name="id" select="@id"/>
+                    <xsl:attribute name="ID_WAY" select="$ways_2ID_Way/ways_2ID_Way/item[@id=current()/text()]/text()"/>
+                    <xsl:copy-of select="text()"/>
+                </xsl:element>
+            </xsl:for-each>
+            
+        </item>-->
+        <!-- dorzucenie do joins sztucznie joinow jako ze pochodza z innych ID_Way -->
+        
     </xsl:template>
     
 </xsl:stylesheet>