Ver código fonte

generowanie ways recznie

a.binder 9 anos atrás
pai
commit
9d0270612e

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

@@ -109,6 +109,7 @@
                 
                 
                 <EdgeWayJoinsPair>
                 <EdgeWayJoinsPair>
                     <xsl:attribute name="ID_Way" select="@ID_Way"/>
                     <xsl:attribute name="ID_Way" select="@ID_Way"/>
+                    <!-- debug -->
                     <!--<xsl:copy-of select="$guess_edges/guess_join[@ID_Way=$ID_Way]"></xsl:copy-of>-->
                     <!--<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">
                     <xsl:for-each select="$guess_edges/guess_join[@ID_Way=$ID_Way]/EdgeWayJoinsPair_cand">
                         <bp:Joins>
                         <bp:Joins>

+ 186 - 14
SE/dev/php-cli/edge_joins_filled_paths_make.xsl

@@ -29,34 +29,206 @@
             <xsl:variable name="ID_Way" select="@ID_Way"/>
             <xsl:variable name="ID_Way" select="@ID_Way"/>
             <asText>
             <asText>
                 <xsl:variable name="bp:Joins">
                 <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()/@id]/bp:Path_Point/@X"/>
-                        <xsl:copy-of select="$joins_asText_xml/joins_asText_xml/item[@id= current()/@id]/bp:Path_Point/@Y"/>
-                        <xsl:attribute name="position" select="position()"/>
-                    </bp:Joins>
-                </xsl:for-each>
+                    <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: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_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_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_X2" select="$bp:Joins/bp:Joins[@position=2]/@X"/>
                 <xsl:variable name="Join_Y2" select="$bp:Joins/bp:Joins[@position=2]/@Y"/>
                 <xsl:variable name="Join_Y2" select="$bp:Joins/bp:Joins[@position=2]/@Y"/>
                 <!-- na podstawie joina ustalamy jego wspolrzedne -->
                 <!-- na podstawie joina ustalamy jego wspolrzedne -->
                 
                 
-                <!-- teraz trzeba wiedziec ktory punkt wziac z drogi - czy pierwszy czy drugi jaki pasuje do pary -->
+                <xsl:variable name="Ways">
                 <Ways>
                 <Ways>
-                    <xsl:for-each select="$ways_asText_z_ID_xml/ways_asText_z_ID_xml/item[@ID_Way=$ID_Way]/bp:Path_Point">
-                        <bp:Path_Point>
-                            <xsl:copy-of select="@*"/>
-                        </bp:Path_Point>
-                </xsl:for-each> 
+                    <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: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>
                 </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="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>
             </asText>
             </asText>
         </item>
         </item>
     </xsl:template>
     </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"/>
+        <xsl:param name="Cur_Y1" required="yes"/>
+        <!--<xsl:param name="Way_1_or_2" required="yes"/>-->
+        <xsl:param name="Last_X2" required="yes"/>
+        <xsl:param name="Last_Y2" required="yes"/>
+        <xsl:param name="loop" select="1"/>
+        <xsl:param name="not_id" required="no"/>
+        <!--<LineString>
+            <xsl:attribute name="X1" select="$Cur_X1"/>
+            <xsl:attribute name="Y1" select="$Cur_Y1"/>
+        </LineString>-->
+        <!--<xsl:choose>
+            <xsl:when test="$Way_1_or_2"></xsl:when>
+        </xsl:choose>-->
+        <!--<debug>
+            <xsl:attribute name="Cur_X1" select="$Cur_X1"/>
+            <xsl:attribute name="Cur_Y1" select="$Cur_Y1"/>
+            <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_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>
+        </xsl:variable>
+        <xsl:copy-of select="$Linestring"/>
+        <xsl:choose>
+            <xsl:when test="$loop &gt; 100000">
+                <loop_limit/>
+            </xsl:when>
+            <xsl:when test="$Linestring/LineString/@X = $Last_X2 and $Linestring/LineString/@Y = $Last_Y2 ">
+                <ostatni/>
+            </xsl:when>
+            <xsl:otherwise>
+                <xsl:call-template name="PlaceWay">
+                    <xsl:with-param name="Ways" select="$Ways"/>
+                    <xsl:with-param name="Cur_X1" select="$Linestring/LineString/@X"/>
+                    <xsl:with-param name="Cur_Y1" select="$Linestring/LineString/@Y"/>
+                    <xsl:with-param name="Last_X2" select="$Last_X2"/>
+                    <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:call-template>
+            </xsl:otherwise>
+        </xsl:choose>
+        
+        
+    </xsl:template>
     
     
     
     
 </xsl:stylesheet>
 </xsl:stylesheet>