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

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

@@ -39,9 +39,12 @@
             <property name="joins_asText_xml.xml" value="joins_asText_xml.xml"/> 
             <!-- sciezki -->
             <property name="edge_joins_filled_paths.xml" value="edge_joins_filled_paths.xml"/>
-            <property name="edge_paths_with_PE.xsl" value="edge_paths_with_PE.xsl"/>
     
+            <property name="edge_paths_with_PE.xsl" value="edge_paths_with_PE.xsl"/><!-- stary-->
+            <property name="edge_paths_with_PE_controll.xsl" value="edge_paths_with_PE_controll.xsl"/><!-- nowy point matrix-->    
+            
             <property name="edge_paths_with_PE.xml" value="edge_paths_with_PE.xml"/><!--     biale_plamy_from_paths_php_to_place_PE-->
+         
             <property name="biale_put_PE_to_mysql.php" value="biale_put_PE_to_mysql.php"/>
             
             <property name="cables_from_joins_to_PE.xsl" value="cables_from_joins_to_PE.xsl"/>
@@ -280,8 +283,8 @@
     
    
    
-    <!-- postawienie PE po trasach -->
-    <target name="edge_paths_with_PE.xml">
+    <!-- postawienie PE po trasach stare-->
+    <target name="edge_paths_with_PE.xml_old">
         <echo message="Wyznaczenie PE na podstawie tras ${edge_paths_with_PE.xml} "/>
         <delete file="${edge_paths_with_PE.xml}"/>
         <xslt basedir="./" style="${edge_paths_with_PE.xsl}" in="${edge_joins_filled_paths.xml}"  destdir="./" out="${edge_paths_with_PE.xml}" >
@@ -294,6 +297,22 @@
             <!--<param name="dita_task_template_file_param" expression="main.dita"/>-->
         </xslt>
     </target>
+    <!-- postawienie PE po trasach nowe-->
+    <target name="edge_paths_with_PE.xml">
+        <echo message="Wyznaczenie PE na podstawie tras ${edge_paths_with_PE.xml} nowym ${edge_paths_with_PE_controll.xsl} "/>
+        <delete file="${edge_paths_with_PE.xml}"/>
+        <xslt basedir="./" style="${edge_paths_with_PE_controll.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"/>
+                <!--<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>
+    </target>
+   
+   
    
     <target name="biale_plamy_put_PE_to_mysql_php">
         <exec executable="php" failonerror="true" dir=".">
@@ -314,6 +333,7 @@
             <!--<param name="dita_task_template_file_param" expression="main.dita"/>-->
         </xslt>
     </target>
+    
    
     <target name="biale_put_Cables_to_PE">
         <echo message="Wgrywam Kable z pliku ${cables_from_joins_to_PE.xml} do bazy danych "></echo>

+ 142 - 137
SE/dev/php-cli/edge_joins_filled_paths_make.xsl

@@ -34,149 +34,154 @@
         <item>
             <xsl:attribute name="id" select="@ID_Way"/>
             <xsl:variable name="ID_Way" select="@ID_Way"/>
-            <asText>
-                <xsl:variable name="bp:Joins">
-                    <xsl:for-each select="bp:Joins">
-                        <bp:Joins>
-                            <xsl:copy-of select="@*"/>
-                            <xsl:copy-of select="$joins_asText_xml/joins_asText_xml/item[@id= current()/@Joins]/bp:Path_Point/@X"/>
-                            <xsl:copy-of select="$joins_asText_xml/joins_asText_xml/item[@id= current()/@Joins]/bp:Path_Point/@Y"/>
-                            <xsl:attribute name="position" select="position()"/>
-                            <!--<xsl:copy-of select="$joins_asText_xml/joins_asText_xml/item[@id= current()/@id]/"/>-->
-                        </bp:Joins>
-                    </xsl:for-each>
-                </xsl:variable>
-                <!--<Joins>
-                    <xsl:copy-of select="$bp:Joins"/>
-                </Joins>-->
-                <xsl:variable name="Join_X1" select="$bp:Joins/bp:Joins[@position=1]/@X"/>
-                <xsl:variable name="Join_Y1" select="$bp:Joins/bp:Joins[@position=1]/@Y"/>
-                <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>
-                    <xsl:attribute name="Join_X1" select="$Join_X1"/>
-                    <xsl:attribute name="Join_Y1" select="$Join_Y1"/>
-                    <xsl:attribute name="Join_X2" select="$Join_X2"/>
-                    <xsl:attribute name="Join_Y2" select="$Join_Y2"/>
-                    <xsl:variable name="Ways">
-                        <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>
-                                        <xsl:copy-of select="@*"/>
-                                        <xsl:attribute name="position" select="position()"/>
-                                    </bp:Path_Point>
-                                    </xsl:for-each>
-                                </xsl:variable>
-                               <!-- <xsl:variable name="Way_X1" select="$bp:Path_Point/bp:Path_Point[@position=1]/@X"/>
-                                <xsl:variable name="Way_Y1" select="$bp:Path_Point/bp:Path_Point[@position=1]/@Y"/>
-                                <xsl:variable name="Way_X2" select="$bp:Path_Point/bp:Path_Point[@position=2]/@X"/>
-                                <xsl:variable name="Way_Y2" select="$bp:Path_Point/bp:Path_Point[@position=2]/@Y"/>-->
-                                <xsl:attribute name="Way_X1" select="$bp:Path_Point/bp:Path_Point[@position=1]/@X"/>
-                                <xsl:attribute name="Way_Y1" select="$bp:Path_Point/bp:Path_Point[@position=1]/@Y"/>
-                                <xsl:attribute name="Way_X2" select="$bp:Path_Point/bp:Path_Point[@position=2]/@X"/>
-                                <xsl:attribute name="Way_Y2" select="$bp:Path_Point/bp:Path_Point[@position=2]/@Y"/>
-                            </Way>
-                        </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]">
-                            <Way_next_cand>
-                                <xsl:copy-of select="@id"/>
-                                <xsl:copy-of select="@Way_X2"/>
-                                <xsl:copy-of select="@Way_Y2"/>
-                            </Way_next_cand>
-                        </xsl:for-each>
-                    </xsl:variable>
-                    <xsl:copy-of select="$Ways_J1_W1"/>
-                    
-                    <xsl:variable name="Ways_J2_W1">
-                        <xsl:for-each select="$Ways/Way[@Way_X1=$Join_X2 and @Way_Y1=$Join_Y2]">
-                            <Way_next_cand>
-                                <xsl:copy-of select="@id"/>
-                                <xsl:copy-of select="@Way_X2"/>
-                                <xsl:copy-of select="@Way_Y2"/>
-                            </Way_next_cand>
+            <!--<xsl:attribute name="Count" select="$asText/asText/@Count"/>-->
+                <asText>
+                    <xsl:variable name="bp:Joins">
+                        <xsl:for-each select="bp:Joins">
+                            <bp:Joins>
+                                <xsl:copy-of select="@*"/>
+                                <xsl:copy-of select="$joins_asText_xml/joins_asText_xml/item[@id= current()/@Joins]/bp:Path_Point/@X"/>
+                                <xsl:copy-of select="$joins_asText_xml/joins_asText_xml/item[@id= current()/@Joins]/bp:Path_Point/@Y"/>
+                                <xsl:attribute name="position" select="position()"/>
+                                <!--<xsl:copy-of select="$joins_asText_xml/joins_asText_xml/item[@id= current()/@id]/"/>-->
+                            </bp:Joins>
                         </xsl:for-each>
                     </xsl:variable>
-                    <xsl:copy-of select="$Ways_J2_W1"/>
-                    
-                    <xsl:variable name="Ways_J1_W2">
-                        <xsl:for-each select="$Ways/Way[@Way_X2=$Join_X1 and @Way_Y2=$Join_Y1]">
-                            <Way_next_cand>
-                                <xsl:copy-of select="@id"/>
-                                <xsl:copy-of select="@Way_X1"/>
-                                <xsl:copy-of select="@Way_Y1"/>
-                            </Way_next_cand>
-                        </xsl:for-each>
+                    <!--<Joins>
+                        <xsl:copy-of select="$bp:Joins"/>
+                    </Joins>-->
+                    <xsl:variable name="Join_X1" select="$bp:Joins/bp:Joins[@position=1]/@X"/>
+                    <xsl:variable name="Join_Y1" select="$bp:Joins/bp:Joins[@position=1]/@Y"/>
+                    <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>
+                        <xsl:attribute name="Join_X1" select="$Join_X1"/>
+                        <xsl:attribute name="Join_Y1" select="$Join_Y1"/>
+                        <xsl:attribute name="Join_X2" select="$Join_X2"/>
+                        <xsl:attribute name="Join_Y2" select="$Join_Y2"/>
+                        <xsl:variable name="Ways">
+                            <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>
+                                            <xsl:copy-of select="@*"/>
+                                            <xsl:attribute name="position" select="position()"/>
+                                        </bp:Path_Point>
+                                        </xsl:for-each>
+                                    </xsl:variable>
+                                   <!-- <xsl:variable name="Way_X1" select="$bp:Path_Point/bp:Path_Point[@position=1]/@X"/>
+                                    <xsl:variable name="Way_Y1" select="$bp:Path_Point/bp:Path_Point[@position=1]/@Y"/>
+                                    <xsl:variable name="Way_X2" select="$bp:Path_Point/bp:Path_Point[@position=2]/@X"/>
+                                    <xsl:variable name="Way_Y2" select="$bp:Path_Point/bp:Path_Point[@position=2]/@Y"/>-->
+                                    <xsl:attribute name="Way_X1" select="$bp:Path_Point/bp:Path_Point[@position=1]/@X"/>
+                                    <xsl:attribute name="Way_Y1" select="$bp:Path_Point/bp:Path_Point[@position=1]/@Y"/>
+                                    <xsl:attribute name="Way_X2" select="$bp:Path_Point/bp:Path_Point[@position=2]/@X"/>
+                                    <xsl:attribute name="Way_Y2" select="$bp:Path_Point/bp:Path_Point[@position=2]/@Y"/>
+                                </Way>
+                            </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]">
+                                <Way_next_cand>
+                                    <xsl:copy-of select="@id"/>
+                                    <xsl:copy-of select="@Way_X2"/>
+                                    <xsl:copy-of select="@Way_Y2"/>
+                                </Way_next_cand>
+                            </xsl:for-each>
+                        </xsl:variable>
+                        <xsl:copy-of select="$Ways_J1_W1"/>
+                        
+                        <xsl:variable name="Ways_J2_W1">
+                            <xsl:for-each select="$Ways/Way[@Way_X1=$Join_X2 and @Way_Y1=$Join_Y2]">
+                                <Way_next_cand>
+                                    <xsl:copy-of select="@id"/>
+                                    <xsl:copy-of select="@Way_X2"/>
+                                    <xsl:copy-of select="@Way_Y2"/>
+                                </Way_next_cand>
+                            </xsl:for-each>
+                        </xsl:variable>
+                        <xsl:copy-of select="$Ways_J2_W1"/>
+                        
+                        <xsl:variable name="Ways_J1_W2">
+                            <xsl:for-each select="$Ways/Way[@Way_X2=$Join_X1 and @Way_Y2=$Join_Y1]">
+                                <Way_next_cand>
+                                    <xsl:copy-of select="@id"/>
+                                    <xsl:copy-of select="@Way_X1"/>
+                                    <xsl:copy-of select="@Way_Y1"/>
+                                </Way_next_cand>
+                            </xsl:for-each>
+                        </xsl:variable>
+                        <xsl:copy-of select="$Ways_J1_W2"/>
+                        
+                        <xsl:variable name="Ways_J2_W2">
+                            <xsl:for-each select="$Ways/Way[@Way_X2=$Join_X2 and @Way_Y2=$Join_Y2]">
+                                <Way_next_cand>
+                                    <xsl:copy-of select="@id"/>
+                                    <xsl:copy-of select="@Way_X1"/>
+                                    <xsl:copy-of select="@Way_Y1"/>
+                                </Way_next_cand>
+                            </xsl:for-each>
+                        </xsl:variable>
+                        <xsl:copy-of select="$Ways_J2_W2"/>
+                        <!-- poszukamy czy Way_X2 wystepuje -->
+                    </Ways>
                     </xsl:variable>
-                    <xsl:copy-of select="$Ways_J1_W2"/>
-                    
-                    <xsl:variable name="Ways_J2_W2">
-                        <xsl:for-each select="$Ways/Way[@Way_X2=$Join_X2 and @Way_Y2=$Join_Y2]">
-                            <Way_next_cand>
-                                <xsl:copy-of select="@id"/>
-                                <xsl:copy-of select="@Way_X1"/>
-                                <xsl:copy-of select="@Way_Y1"/>
-                            </Way_next_cand>
-                        </xsl:for-each>
+                    <!--<xsl:copy-of select="$Ways"/>-->
+                    <!--<xsl:variable name="Way_1_or_2">
+                    <xsl:choose>
+                        <xsl:when test="$Ways/Ways/Way_next_cand[1]/@Way_X2">
+                            <xsl:value-of select="1"/>
+                        </xsl:when>
+                        <xsl:otherwise><xsl:value-of select="2"/></xsl:otherwise>
+                    </xsl:choose>
+                    </xsl:variable>-->
+                    <!--<Way_1_or_2><xsl:value-of select="$Way_1_or_2"/></Way_1_or_2>-->
+                    <xsl:variable name="LineString">
+                        <xsl:call-template name="PlaceWay">
+                            <xsl:with-param name="Ways" select="$Ways"/>
+                            <xsl:with-param name="Cur_X1" select="$Ways/Ways/@Join_X1"/>
+                            <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:copy-of select="$Ways_J2_W2"/>
-                    <!-- poszukamy czy Way_X2 wystepuje -->
-                </Ways>
-                </xsl:variable>
-                <!--<xsl:copy-of select="$Ways"/>-->
-                <!--<xsl:variable name="Way_1_or_2">
-                <xsl:choose>
-                    <xsl:when test="$Ways/Ways/Way_next_cand[1]/@Way_X2">
-                        <xsl:value-of select="1"/>
-                    </xsl:when>
-                    <xsl:otherwise><xsl:value-of select="2"/></xsl:otherwise>
-                </xsl:choose>
-                </xsl:variable>-->
-                <!--<Way_1_or_2><xsl:value-of select="$Way_1_or_2"/></Way_1_or_2>-->
-                <xsl:variable name="LineString">
-                    <xsl:call-template name="PlaceWay">
-                        <xsl:with-param name="Ways" select="$Ways"/>
-                        <xsl:with-param name="Cur_X1" select="$Ways/Ways/@Join_X1"/>
-                        <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: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:variable name="len" select="sum($LineString/LineString/@len)"/>
+                    <xsl:attribute name="len" select="$len"/>
+                    <xsl:attribute name="Points_cnt" select="count($LineString/LineString/Points)"/>
+                    <xsl:attribute name="Count" select=" count($LineString/LineString)"/>
+                    <!-- 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)"/>
-                               <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>
+                               <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>
     

+ 102 - 22
SE/dev/php-cli/edge_paths_with_PE_controll.xsl

@@ -2,9 +2,13 @@
 <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:import href="PE_wariant_bit_table.xsl"/>
+    
     <xsl:output indent="yes"/>
     <xsl:strip-space elements="*"/>
     
@@ -27,19 +31,53 @@
                 </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:variable name="edge_paths_with_PE_controll">
+            <edge_paths_with_PE_controll>
+               <xsl:apply-templates select="$edge_joins_filled_paths_len" mode="PointMatrixGroup"/>
+            </edge_paths_with_PE_controll>
+        </xsl:variable>
+            <xsl:copy-of select="$edge_paths_with_PE_controll"/>
+        <xsl:result-document href="edge_paths_with_PE.xml">
+             <xsl:apply-templates select="$edge_paths_with_PE_controll" mode="edge_paths_with_PE.xml"/>
+        </xsl:result-document>
     </xsl:template>
     
     
-    <xsl:template match="Path">
-        
+    <xsl:template match="edge_paths_with_PE_controll" mode="edge_paths_with_PE.xml">
+        <PE_candidates_dump>
+            <xsl:apply-templates mode="edge_paths_with_PE.xml"/>
+        </PE_candidates_dump>
+    </xsl:template>
+    
+    
+    <xsl:template match="Path" mode="edge_paths_with_PE.xml">
+        <LINESTRING>
+            <xsl:attribute name="ID_Way" select="@id"/>
+            <xsl:attribute name="Count"  select="''"/>
+            <xsl:attribute name="ID_Point_count" select="@Points_cnt"/>
+            <xsl:attribute name="distance"/>
+            <xsl:attribute name="dumb_frequency" select="''"/>
+            <xsl:apply-templates mode="edge_paths_with_PE.xml"/>
+        </LINESTRING>
+    </xsl:template>
+    
+    
+    
+    <xsl:template match="bp:Path_Point" mode="edge_paths_with_PE.xml">
+        <xsl:copy-of select="."/>
+    </xsl:template>
+    
+    <xsl:template match="Path" mode="PointMatrixGroup">
         <Path>
+            <xsl:variable name="edge_joins_filled_path" select=" doc(concat('edge_joins_filled_paths/edge_joins_filled_paths.',@id,'.xml'))"/>
+            <xsl:attribute name="id" select="@id"/>
             <xsl:attribute name="Points_cnt" select="@Points_cnt"/>
+            <xsl:variable name="Points_cnt" select="@Points_cnt"/>
+            <xsl:attribute name="len" select="@len"/>
+            <xsl:attribute name="Count" select="count($edge_joins_filled_path/edge_joins_filled_paths_xml/asText_XMl/LineString)"/>
+            <xsl:variable name="len" select="@len"/>
         <!--<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>-->
@@ -50,7 +88,6 @@
         <!-- 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()"/>
@@ -90,6 +127,7 @@
                                     <xsl:if test="$cost_dist &gt; $PE_Price">
                                         <xsl:attribute name="cut_by_pe" select="1"/>
                                     </xsl:if>
+                                    <xsl:attribute name="not_id" select="@not_id"/>
                                 </xsl:when>
                             </xsl:choose>
                             
@@ -101,22 +139,64 @@
                 </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>
-            
+            <!--<xsl:copy-of select="$EconomicDistanceCut2"/>-->
             
+            <xsl:variable name="elements_cnt" select="count($EconomicDistanceCut2/EconomicDistanceCut2/distance2[@point_count &gt; 0])"/><!-- liczba wezlow potencjalnych licbza PE-->
+            <xsl:variable name="bit_max" select="round($len  div  ( $PE_Price div $Cable_Price ) + count($EconomicDistanceCut2/EconomicDistanceCut2/distance2[@cost_dist &gt; $PE_Price]) )"/><!-- max licbza PE-->
             
+            <!-- pogrupujemy elementy co 50 metrow -->
+            <xsl:variable name="PointMatrixGroup">
+                <PointMatrixGroup>
+                    <xsl:for-each-group select="$EconomicDistanceCut2/EconomicDistanceCut2/distance2" group-by="round( @distance div ( $PE_Price div $Cable_Price + 50 ))">
+                        <PointMatrixGroupPos>
+                            <xsl:variable name="elements_cnt_Pos" select="count(current-group()[@point_count &gt; 0])"/>
+                            <xsl:variable name="bit_max_Pos" select="round(sum( current-group()/@disttopkt )  div  ( $PE_Price div 20 ) )"/>
+                            <xsl:attribute name="distanceGr" select=" current-grouping-key()"/>
+                            <xsl:attribute name="elements_cnt_Pos" select="$elements_cnt_Pos"/>
+                            <xsl:attribute name="bit_max_Pos" select="$bit_max_Pos"/>
+                            <xsl:attribute name="point_count_Pos" select="sum(current-group()/@point_count)"/>
+                            
+                            
+                                <xsl:for-each select="current-group()">
+                                    <xsl:copy-of select="."/>
+                                </xsl:for-each>
+                        </PointMatrixGroupPos>
+                     </xsl:for-each-group>
+                </PointMatrixGroup>
+            </xsl:variable>
+            <!-- wsadzamy PE w grupach i moze w kilku wariantach - najlepiej tam gdzie jest najwiecej klientow najpierw 
+                gdzie najwiecej klientow walimy wezly - grupujemy ilosciami klientow dzielac sume drogi na ilosc przewidzianych wezlow
+            -->
+            <!-- debug -->
+            <xsl:copy-of select="$PointMatrixGroup"/>
+            <PointMatrixGroupPE>
+            <xsl:for-each select="$PointMatrixGroup/PointMatrixGroup/PointMatrixGroupPos">
+                <xsl:variable name="bit_max_Pos" select="@bit_max_Pos"/>
+                <xsl:variable name="point_count_Pos" select="@point_count_Pos"/>
+                <!-- ida kandydaci -->
+                <xsl:for-each select="distance2[ position() &lt;= $bit_max_Pos  or ( position()=1 and $point_count_Pos &gt; 0 ) ]"> <!-- jak jest maly wspolczynnik to chociaz jeden punkt jak sa punkty jakies w tej grupie -->
+                    <xsl:sort select="@cost_dist" order="descending"/>
+                    <bp:Path_Point>
+                        <xsl:attribute name="pos" select="@pos"/>
+                        <xsl:attribute name="len" select="@len"/>
+                        <xsl:attribute name="distance" select="@distance"/>
+                        <xsl:attribute name="X" select="$edge_joins_filled_path/edge_joins_filled_paths_xml/asText_XMl/LineString[@not_id = current()/@not_id]/@X"/>
+                        <xsl:attribute name="Y" select="$edge_joins_filled_path/edge_joins_filled_paths_xml/asText_XMl/LineString[@not_id = current()/@not_id]/@Y"/>
+                    </bp:Path_Point>
+                </xsl:for-each>
+            </xsl:for-each>
+            </PointMatrixGroupPE>
+            <!--<PointMatrix>
+                   <xsl:attribute name="bit_max" select="$bit_max"/>
+                <xsl:attribute name="elements_cnt" select="$elements_cnt"/>
+                
+                <xsl:attribute name="num_extr" select="count($EconomicDistanceCut2/EconomicDistanceCut2/distance2[@cost_dist &gt; $PE_Price])"/>
+                <!-\-<xsl:call-template name="PE_wariant">
+                    <xsl:with-param name="elements_cnt" select="$elements_cnt"/>
+                    <xsl:with-param name="bit_max" select="$bit_max"/>
+                </xsl:call-template>-\->
+                
+            </PointMatrix>-->
         </Path>
     </xsl:template>