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

+ 110 - 33
SE/dev/php-cli/edge_joins_filled_paths_make.xsl

@@ -11,6 +11,13 @@
     <xsl:param name="joins_asText_xml.xml" select="'joins_asText_xml.xml'"/>
     <xsl:variable name="joins_asText_xml" select="doc($joins_asText_xml.xml)"/>
     
+   
+    <xsl:param name="ways2joins.xml" select="'ways2joins.xml'"/>
+    <xsl:variable name="ways2joins" select="doc($ways2joins.xml)"/>
+    
+    <xsl:param name="joins2ways_z_ID_Way.xml" select="'joins2ways_z_ID_Way.xml'"/>
+    <xsl:variable name="joins2ways_z_ID_Way" select="doc($joins2ways_z_ID_Way.xml)"/>
+    
     
     <xsl:output indent="yes"/>
     <xsl:strip-space elements="*"/>
@@ -47,9 +54,8 @@
                 <xsl:variable name="Join_X2" select="$bp:Joins/bp:Joins[@position=2]/@X"/>
                 <xsl:variable name="Join_Y2" select="$bp:Joins/bp:Joins[@position=2]/@Y"/>
                 <!-- na podstawie joina ustalamy jego wspolrzedne -->
-                
                 <xsl:variable name="Ways">
-                <Ways>
+                    <Ways>
                     <xsl:attribute name="Join_X1" select="$Join_X1"/>
                     <xsl:attribute name="Join_Y1" select="$Join_Y1"/>
                     <xsl:attribute name="Join_X2" select="$Join_X2"/>
@@ -58,6 +64,7 @@
                         <xsl:for-each select="$ways_asText_z_ID_xml/ways_asText_z_ID_xml/item[@ID_Way=$ID_Way]">
                             <Way>
                                 <xsl:attribute name="id" select="@id"/>
+                                <xsl:attribute name="len" select="@len"/>
                                 <xsl:variable name="bp:Path_Point">
                                     <xsl:for-each select="bp:Path_Point">
                                     <bp:Path_Point>
@@ -78,7 +85,6 @@
                         </xsl:for-each> 
                     </xsl:variable>
                     <xsl:copy-of select="$Ways"/>
-                    
                     <!-- teraz trzeba wiedziec ktory punkt wziac z drogi - czy pierwszy czy drugi jaki pasuje do pary -->
                     <xsl:variable name="Ways_J1_W1">
                         <xsl:for-each select="$Ways/Way[@Way_X1=$Join_X1 and @Way_Y1=$Join_Y1]">
@@ -143,32 +149,38 @@
                         <xsl:with-param name="Cur_Y1" select="$Ways/Ways/@Join_Y1"/>
                         <xsl:with-param name="Last_X2" select="$Ways/Ways/@Join_X2"/>
                         <xsl:with-param name="Last_Y2" select="$Ways/Ways/@Join_Y2"/>
+                        <xsl:with-param name="ID_Way" select="$ID_Way"/>
                         <!--<xsl:with-param name="Way_1_or_2" select="$Way_1_or_2"/>-->
                         <!--<xsl:with-param name="not_id" select="$Ways/Ways/Way_next_cand/@id"/>-->
                     </xsl:call-template>
                 </xsl:variable>
-                <xsl:call-template name="AsText_XML">
-                    <xsl:with-param name="LineString" select="$LineString"/>
-                </xsl:call-template>
+                <xsl:variable name="len" select="sum($LineString/LineString/@len)"/>
+                <xsl:attribute name="len" select="$len"/>
+                <xsl:attribute name="Points_cnt" select="count($LineString/LineString/Points)"/>
+                <!-- dodatkowo w xmlu aby bylo prosciej do przetwarzania -->
+                <!--<asText_XMl>
+                        <xsl:copy-of select="$LineString"/>
+                </asText_XMl>-->
+                   <xsl:result-document href="edge_joins_filled_paths/edge_joins_filled_paths.{$ID_Way}.xml">
+                       <edge_joins_filled_paths_xml>
+                           <xsl:attribute name="id" select="$ID_Way"/>
+                           <xsl:attribute name="Points_cnt" select="count($LineString/LineString/Points)"/>
+                           <asText_XMl>
+                               <xsl:attribute name="len" select="$len"/>
+                               <xsl:attribute name="id" select="$ID_Way"/>
+                               <xsl:attribute name="Points_cnt" select="count($LineString/LineString/Points)"/>
+                               <xsl:copy-of select="$LineString"/>
+                           </asText_XMl>
+                       </edge_joins_filled_paths_xml>
+                   </xsl:result-document>
+                    <xsl:call-template name="AsText">
+                        <xsl:with-param name="LineString" select="$LineString"/>
+                    </xsl:call-template>
             </asText>
         </item>
     </xsl:template>
     
     
-   
-    <xsl:template name="AsText_XML">
-        <xsl:param name="LineString" required="yes"/>
-        <xsl:value-of select="'LINESTRING ('"/>
-        <xsl:for-each select="$LineString/LineString">
-            <xsl:value-of select="concat(@X,' ',@Y)"/>
-            <xsl:if test="not(position()= last())">
-                <xsl:value-of select="', '"/>
-            </xsl:if>
-        </xsl:for-each>
-        <xsl:value-of select="')'"/>
-    </xsl:template>
-    
-    
     <xsl:template name="PlaceWay">
         <xsl:param name="Ways" required="yes"/>
         <xsl:param name="Cur_X1" required="yes"/>
@@ -178,6 +190,7 @@
         <xsl:param name="Last_Y2" required="yes"/>
         <xsl:param name="loop" select="1"/>
         <xsl:param name="not_id" required="no"/>
+        <xsl:param name="ID_Way" required="yes"/>
         <!--<LineString>
             <xsl:attribute name="X1" select="$Cur_X1"/>
             <xsl:attribute name="Y1" select="$Cur_Y1"/>
@@ -191,20 +204,58 @@
             <xsl:attribute name="not_id" select="$not_id"/>
         </debug>-->
         <xsl:variable name="Linestring">
-        <xsl:for-each select="$Ways/Ways/Way[@Way_X1=$Cur_X1 and @Way_Y1=$Cur_Y1 and ( not($not_id) or not(@id=$not_id)) ]">
-            <LineString>
-                <xsl:attribute name="X" select="@Way_X2"/>
-                <xsl:attribute name="Y" select="@Way_Y2"/>
-                <xsl:attribute name="not_id" select="@id"/>
-            </LineString>
-        </xsl:for-each>
+            <xsl:for-each select="$Ways/Ways/Way[@Way_X1=$Cur_X1 and @Way_Y1=$Cur_Y1 and ( not($not_id) or not(@id=$not_id)) ]">
+                <LineString>
+                    <xsl:attribute name="X" select="@Way_X2"/>
+                    <xsl:attribute name="Y" select="@Way_Y2"/>
+                    <xsl:attribute name="not_id" select="@id"/>
+                    <xsl:attribute name="len" select="@len"/>
+                    <xsl:variable name="X" select="@Way_X2"/>
+                    <xsl:variable name="Y" select="@Way_Y2"/>
+                    <xsl:for-each select="$ways2joins/ways2joins/item[@id= current()/@id]/item">
+                        <xsl:for-each select="$joins_asText_xml/joins_asText_xml/item[@id= current()/text()]/bp:Path_Point">
+                            <xsl:if test="@X=$X and @Y=$Y">
+                                <xsl:variable name="ID_Join" select="parent::node()/@id"/>
+                                <!-- punkty podpiete -->
+                                <xsl:copy-of select="$joins2ways_z_ID_Way/joins2ways_z_ID_Way/item[@id=$ID_Join]/Points"/>
+                                <!-- wyszukanie drog wychodzacych innych niz nasza z punktu -->
+                                <xsl:for-each select="$joins2ways_z_ID_Way/joins2ways_z_ID_Way/item[@id=$ID_Join]/item[not(@ID_WAY=$ID_Way)]">
+                                    <Ways>
+                                        <xsl:attribute name="ID_WAY" select="@ID_WAY"/>
+                                        <xsl:attribute name="ways_id" select="text()"/>
+                                    </Ways>
+                                </xsl:for-each>
+                            </xsl:if>
+                        </xsl:for-each>
+                    </xsl:for-each>
+                </LineString>
+            </xsl:for-each>
             <xsl:for-each select="$Ways/Ways/Way[@Way_X2=$Cur_X1 and @Way_Y2=$Cur_Y1 and ( not($not_id) or not(@id=$not_id))  ]">
-            <LineString>
-                <xsl:attribute name="X" select="@Way_X1"/>
-                <xsl:attribute name="Y" select="@Way_Y1"/>
-                <xsl:attribute name="not_id" select="@id"/>
-            </LineString>
-        </xsl:for-each>
+                <LineString>
+                    <xsl:attribute name="X" select="@Way_X1"/>
+                    <xsl:attribute name="Y" select="@Way_Y1"/>
+                    <xsl:attribute name="not_id" select="@id"/>
+                    <xsl:attribute name="len" select="@len"/>
+                    <xsl:variable name="X" select="@Way_X1"/>
+                    <xsl:variable name="Y" select="@Way_Y1"/>
+                    <xsl:for-each select="$ways2joins/ways2joins/item[@id= current()/@id]/item">
+                        <xsl:for-each select="$joins_asText_xml/joins_asText_xml/item[@id= current()/text()]/bp:Path_Point">
+                            <xsl:if test="@X=$X and @Y=$Y">
+                                <xsl:variable name="ID_Join" select="parent::node()/@id"/>
+                                <!-- punkty podpiete -->
+                                <xsl:copy-of select="$joins2ways_z_ID_Way/joins2ways_z_ID_Way/item[@id=$ID_Join]/Points"/>
+                                <!-- wyszukanie drog wychodzacych innych niz nasza z punktu -->
+                                <xsl:for-each select="$joins2ways_z_ID_Way/joins2ways_z_ID_Way/item[@id=$ID_Join]/item[not(@ID_WAY=$ID_Way)]">
+                                    <Ways>
+                                        <xsl:attribute name="ID_WAY" select="@ID_WAY"/>
+                                        <xsl:attribute name="ways_id" select="text()"/>
+                                    </Ways>
+                                </xsl:for-each>
+                            </xsl:if>
+                        </xsl:for-each>
+                    </xsl:for-each>
+                </LineString>
+            </xsl:for-each>
         </xsl:variable>
         <xsl:copy-of select="$Linestring"/>
         <xsl:choose>
@@ -223,6 +274,7 @@
                     <xsl:with-param name="Last_Y2" select="$Last_Y2"/>
                     <xsl:with-param name="not_id" select="$Linestring/LineString/@not_id"/>
                     <xsl:with-param name="loop" select="$loop+1"/>
+                    <xsl:with-param name="ID_Way" select="$ID_Way"/>
                 </xsl:call-template>
             </xsl:otherwise>
         </xsl:choose>
@@ -230,5 +282,30 @@
         
     </xsl:template>
     
+   
+    <!--<xsl:template name="AsText_XML">
+        <xsl:param name="LineString" required="yes"/>
+        <xsl:for-each select="$LineString/LineString">
+            <PathPoint>
+                <xsl:copy-of select="@*"/>
+            </PathPoint>
+        </xsl:for-each>
+    </xsl:template>-->
+    
+    <xsl:template name="AsText">
+        <xsl:param name="LineString" required="yes"/>
+        <xsl:value-of select="'LINESTRING ('"/>
+        <xsl:for-each select="$LineString/LineString">
+            <xsl:value-of select="concat(@X,' ',@Y)"/>
+            <xsl:if test="not(position()= last())">
+                <xsl:value-of select="', '"/>
+            </xsl:if>
+        </xsl:for-each>
+        <xsl:value-of select="')'"/>
+    </xsl:template>
+    
+    
+    
+    
     
 </xsl:stylesheet>

+ 0 - 0
SE/dev/php-cli/edge_joins_filled_paths.xsl → SE/dev/php-cli/edge_paths_with_PE.xsl


+ 124 - 0
SE/dev/php-cli/edge_paths_with_PE_controll.xsl

@@ -0,0 +1,124 @@
+<?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:param name="PE_Price" select="1500"/>
+    <xsl:param name="Cable_Price" select="10"/>
+    
+    <!-- bedziemy od najdluzszej drogi starac sie rozmiescic PE w oparciu o rozmieszczenie klientow oraz odleglosci  -->
+    
+    
+    
+    <xsl:template match="edge_joins_filled_paths">
+        
+        <xsl:variable name="edge_joins_filled_paths_len">
+            <xsl:for-each select="item">
+                <xsl:sort select="number(asText/@len)" order="descending"/>
+                <Path>
+                    <xsl:attribute name="id" select="@id"/>
+                    <xsl:attribute name="len" select="asText/@len"/>
+                    <xsl:attribute name="Points_cnt" select="asText/@Points_cnt"/>
+                </Path>
+            </xsl:for-each>
+        </xsl:variable>
+        
+        <edge_paths_with_PE_controll>
+           <xsl:apply-templates select="$edge_joins_filled_paths_len"/>
+        </edge_paths_with_PE_controll>
+    </xsl:template>
+    
+    
+    <xsl:template match="Path">
+        
+        <Path>
+            <xsl:attribute name="Points_cnt" select="@Points_cnt"/>
+        <!--<xsl:variable name="edge_joins_filled_paths" select="collection( 'edge_joins_filled_paths?select=*.xml;recurse=yes')"/>-->
+        <xsl:variable name="edge_joins_filled_path" select=" doc(concat('edge_joins_filled_paths/edge_joins_filled_paths.',@id,'.xml'))"/>
+        <!--<EdgeWayJoinsPair>
+            <xsl:copy-of select="$edge_joins_filled_path"></xsl:copy-of>
+        </EdgeWayJoinsPair>-->
+        
+        <!-- liczmy najwieksza roznice odleglosci miedzy punktami -->
+        
+        
+        <!-- rozmieszczamy prawidlowo PE na danej trasie -->
+        <xsl:variable name="EconomicDistanceCut">
+            <EconomicDistanceCut>
+                
+                    <xsl:for-each select="$edge_joins_filled_path/edge_joins_filled_paths_xml/asText_XMl/LineString">
+                        <distance>
+                            <xsl:attribute name="pos" select="position()"/>
+                            <xsl:attribute name="not_id" select="@not_id"/>
+                            <xsl:attribute name="len" select="@len"/>
+                            <xsl:variable name="Points" select="count(Points)"/>
+                            <xsl:variable name="Ways" select="count(Ways)"/>
+                        <xsl:choose>
+                            <xsl:when test="Points or Ways">
+                                <xsl:attribute name="point_count" select="$Points + $Ways"/>
+                            </xsl:when>
+                        </xsl:choose>
+                        </distance>
+                    </xsl:for-each>
+            </EconomicDistanceCut>
+        </xsl:variable>
+        <!--<xsl:copy-of select="$EconomicDistanceCut"/>-->
+            <xsl:variable name="EconomicDistanceCut2">
+                <EconomicDistanceCut2>
+                    <xsl:for-each select="$EconomicDistanceCut/EconomicDistanceCut/distance">
+                        <distance2>
+                            <xsl:attribute name="distance" select="sum( $EconomicDistanceCut/EconomicDistanceCut/distance[number(@pos )&lt;  number(current()/@pos )]/@len)"/>
+                            <!-- suma do poprzedniego pkt tylko dla tych co maja pkt-->
+                            <xsl:choose>
+                                <xsl:when test="@point_count&gt;0">
+                                    <xsl:variable name="max_pos_z_pkt" select="max($EconomicDistanceCut/EconomicDistanceCut/distance[
+                                        number(@pos )&lt;  number(current()/@pos ) and number(@point_count)&gt;0
+                                        ]/@pos)"/>
+                                    <xsl:attribute name="max_pos_z_pkt" select="$max_pos_z_pkt"/>
+                                    <xsl:variable name="disttopkt" select="sum( $EconomicDistanceCut/EconomicDistanceCut/distance[
+                                        number(@pos )&lt;  number(current()/@pos )
+                                        and number(@pos) &gt;= number($max_pos_z_pkt) 
+                                        ]/@len)"/>
+                                    <xsl:attribute name="disttopkt" select="$disttopkt" />
+                                    <xsl:variable name="cost_dist" select="$Cable_Price * $disttopkt * @point_count"/>
+                                    <xsl:attribute name="cost_dist" select="$cost_dist"/>
+                                    <xsl:if test="$cost_dist &gt; $PE_Price">
+                                        <xsl:attribute name="cut_by_pe" select="1"/>
+                                    </xsl:if>
+                                </xsl:when>
+                            </xsl:choose>
+                            
+                            <xsl:copy-of select="@point_count"/>
+                            <xsl:copy-of select="@pos"/>
+                            <xsl:copy-of select="@len"/>
+                        </distance2>
+                    </xsl:for-each>
+                </EconomicDistanceCut2>
+            </xsl:variable>
+            
+            <xsl:copy-of select="$EconomicDistanceCut2"/>
+            
+            <PointMatrix>
+                <xsl:for-each-group select="$EconomicDistanceCut2/EconomicDistanceCut2/distance2" group-starting-with="@cut_by_pe">
+                    <PointMatrixGr>
+                        <xsl:for-each select=" current-group()">
+                            <PointMatrix_rec>
+                                <xsl:copy-of select="."></xsl:copy-of>
+                            </PointMatrix_rec>
+                        </xsl:for-each>
+                    </PointMatrixGr>
+                </xsl:for-each-group>
+            </PointMatrix>
+            
+            
+            
+        </Path>
+    </xsl:template>
+    
+    
+</xsl:stylesheet>

+ 17 - 21
SE/dev/php-cli/joins2ways_z_ID_Way.xsl

@@ -7,9 +7,10 @@
     <xsl:output indent="yes"/>
     <xsl:strip-space elements="*"/>
     <xsl:param name="ways2drogi.xml"  select="'ways2drogi.xml'"/>
-    <!--<xsl:variable name="ways_2ID_Way" select="doc($ways_2ID_Way.xml)"/>-->
     <xsl:variable name="ways2drogi" select="doc($ways2drogi.xml)"/>
-    <xsl:variable name="points2joins" select="doc('points2joins.xml')"/>
+    <xsl:param name="points2joins.xml"  select="'points2joins.xml'"/>
+    <xsl:variable name="points2joins" select="doc($points2joins.xml)"/>
+    
     
     <xsl:template match="joins2ways">
         <joins2ways_z_ID_Way>
@@ -17,14 +18,20 @@
                 <xsl:apply-templates/>
             </xsl:variable>
             <xsl:for-each select="$joins2ways/item">
-                <!--<xsl:sort select="number(@ID_Way)"/>-->
                 <xsl:copy-of select="."/>
+                <xsl:result-document href="joins2ways_z_ID_Way/joins2ways_z_ID_Way.{@id}.xml">
+                    <joins2ways_z_ID_Way>
+                        <xsl:attribute name="id" select="@id"/>
+                        <xsl:copy-of select="."/>
+                    </joins2ways_z_ID_Way>
+                </xsl:result-document>
             </xsl:for-each>
         </joins2ways_z_ID_Way>
     </xsl:template>
     <xsl:template match="item">
         <xsl:variable name="item" select="."/>
         <xsl:variable name="ID_Point" select="$points2joins/points2joins/item[text()= current()/@id]/@id"/>
+        <xsl:variable name="id" select="@id"/>
         <xsl:variable name="items">
             <xsl:for-each select="item">
                         <item>
@@ -34,6 +41,11 @@
                                 <xsl:attribute name="ID_Point" select="$ID_Point"/>
                             </xsl:if>
                             <xsl:attribute name="item_copied_pos" select="position()"/>
+                            <!-- moze miec wiecej punktow-->
+                            <xsl:for-each select="$points2joins/points2joins/item[text()= $id]">
+                                <Points><xsl:value-of select=" text()"/></Points>
+                            </xsl:for-each>
+
                             <xsl:for-each select="$item/item">
                                 <xsl:element name="item">
                                     <xsl:attribute name="id" select="@id"/>
@@ -50,26 +62,10 @@
                 <xsl:copy-of select="@*"/>
                 <!--<xsl:attribute name="ID_Way_count" select="$ID_Way_count"/>-->
                 <xsl:copy-of select="item"/>
+                <xsl:copy-of select="Points"/>
             </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: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>
     

+ 8 - 0
SE/dev/php-cli/joins_asText_xml.xsl

@@ -6,6 +6,10 @@
     version="2.0">
     
     <xsl:import href="asText.xsl"/>
+    
+    <xsl:param name="points2joins.xml"  select="'points2joins.xml'"/>
+    <xsl:variable name="points2joins" select="doc($points2joins.xml)"/>
+    
     <xsl:output indent="yes"/>
     <xsl:strip-space elements="*"/>
     
@@ -19,6 +23,10 @@
     <xsl:template match="item">
         <item>
             <xsl:copy-of select="@id"/>
+            <xsl:variable name="ID_Point" select="$points2joins/points2joins/item[@id= current()/@id]/text()"/>
+            <xsl:if test="$ID_Point">
+                <xsl:attribute name="ID_Point" select="$ID_Point"/>    
+            </xsl:if>
             <xsl:variable name="asText">
                 <asText>
                     <xsl:value-of select="text()"/>

+ 9 - 0
SE/dev/php-cli/ways_as_Text_z_ID_xml.xsl

@@ -9,6 +9,14 @@
     <xsl:param name="ways2drogi.xml" select="'ways2drogi.xml'"/>
     <xsl:variable name="ways2drogi" select="doc($ways2drogi.xml)"/>
     
+    <xsl:param name="waysLengths.xml" select="'waysLengths.xml'"/>
+    <xsl:variable name="waysLengths" select="doc($waysLengths.xml)"/>
+    
+    
+   <!-- <xsl:param name="ways2joins.xml"  select="'ways2joins.xml'"/>
+    <xsl:variable name="ways2joins" select="doc($ways2joins.xml)"/>
+    -->
+    
     <xsl:output indent="yes"/>
     <xsl:strip-space elements="*"/>
     
@@ -24,6 +32,7 @@
         <xsl:copy-of select="@*"/>
             <xsl:attribute name="pos" select="position()"/>
             <xsl:attribute name="ID_Way" select="$ways2drogi/ways2drogi/item[@id= current()/@id]/text()"/>
+            <xsl:attribute name="len" select="$waysLengths/waysLengths/item[@id= current()/@id]/ round(text())"/>
         <xsl:apply-templates/>
         </item>
     </xsl:template>