[postgis-tickets] [PostGIS] #3046: topology.GetRingEdges return wrong ring when edge.next_left/right = edge

PostGIS trac at osgeo.org
Fri Feb 20 02:42:41 PST 2015


#3046: topology.GetRingEdges return wrong ring when edge.next_left/right = edge
-----------------------+----------------------------------------------------
  Reporter:  remic     |       Owner:  strk  
      Type:  defect    |      Status:  closed
  Priority:  medium    |   Milestone:        
 Component:  topology  |     Version:  2.1.x 
Resolution:  invalid   |    Keywords:        
-----------------------+----------------------------------------------------

Comment(by remic):

 Here is an example of a function that turns in the other direction (but is
 subject ot same limitation than regular getedge)


 -----------------

 DROP FUNCTION IF EXISTS topology.rc_GetRingEdges_backward( topology_name
 text, s_edge_id int) ;
 CREATE OR REPLACE FUNCTION topology.rc_GetRingEdges_backward(
 topology_name text, s_edge_id int)
 RETURNS TABLE (ordinality int, signed_edge_id INT)
  AS
 $BODY$
         /** @brief  given a signed edge, compute the ring it belongs to.
 It is a safer version than the traditionnal one, because it also work on
 flat faces
         */
         DECLARE
                 _q text ;
         BEGIN
 _q := format('
  WITH RECURSIVE edgering AS (
         WITH input_edge_id AS (
                 SELECT %1$s  as signed_edge_id
                 LIMIT 1
         )
         SELECT  signed_edge_id
                 , edge_id
                 , next_left_edge
                 , next_right_edge
         FROM input_edge_id, %2$I.edge_data as ed
         WHERE ed.next_left_edge = signed_edge_id OR ed.next_right_edge =
 signed_edge_id
         UNION
                 SELECT  CASE WHEN p.signed_edge_id = p.next_right_edge
 THEN -1*p.edge_id ELSE p.edge_id END
                         , ed.edge_id
                         , ed.next_left_edge
                         , ed.next_right_edge
                 FROM edgering AS p , %2$I.edge_data as ed
                 WHERE ed.next_left_edge =
                         CASE WHEN p.signed_edge_id = p.next_right_edge
 THEN -1*p.edge_id
                         ELSE p.edge_id END
                         OR ed.next_right_edge =
                         CASE WHEN p.signed_edge_id = p.next_right_edge
 THEN -1*p.edge_id
                         ELSE p.edge_id END
         )  --note : row_number is not safe here, it cannont guarantee the
 ordering
         SELECT (row_number() over())::int as ordinality,
 signed_edge_id::int
         FROM edgering ;',s_edge_id,topology_name);
         RETURN QUERY EXECUTE _q;
          RETURN ;
         END ;
         $BODY$
 LANGUAGE plpgsql VOLATILE;

 -----------------

-- 
Ticket URL: <http://trac.osgeo.org/postgis/ticket/3046#comment:3>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-tickets mailing list