[postgis-tickets] [PostGIS] #4758: ERROR: XX000: SQL/MM Spatial exception - geometry crosses edge 2, LOCATION: pg_error, lwgeom_pg.c:250

PostGIS trac at osgeo.org
Fri Oct 16 23:42:25 PDT 2020


#4758: ERROR:  XX000: SQL/MM Spatial exception - geometry crosses edge 2,
LOCATION:  pg_error, lwgeom_pg.c:250
-----------------------+---------------------------
  Reporter:  laopsahl  |      Owner:  strk
      Type:  defect    |     Status:  closed
  Priority:  blocker   |  Milestone:  PostGIS 3.1.0
 Component:  topology  |    Version:  3.0.x
Resolution:  fixed     |   Keywords:
-----------------------+---------------------------

Comment (by laopsahl):

 Great fix. Thanks, Sandro.


 == Status Topology Errors

 ****This patch removed all the 'Spatial exception - geometry crosses edge'
 from the test where I added about 20 million edges. I also reduced other
 errors a lot.

 Before the last fix

 {{{
 count |                     d_msg
 -------+-----------------------------------------------
      9 | SQL/MM Spatial exception - non-existent edge
      1 | Side-location conflict: new edge starts in fa
      1 | Invalid edge (no two distinct vertices exist)
     41 | SQL/MM Spatial exception - curve not simple
    122 | SQL/MM Spatial exception - geometry crosses e
 (6 rows)

 }}}

 After the last fix


 {{{
  count |                     d_msg
 -------+-----------------------------------------------
      2 | Invalid edge (no two distinct vertices exist)
     12 | SQL/MM Spatial exception - curve not simple

 }}}

 **I also test did test on another dataset with 1.5 mill edges and there I
 did not get anyTopology Exception of any kind, they where all gone.
 **


 Before we had this error list.
 {{{
  count |                     d_msg
 -------+-----------------------------------------------
      3 | SQL/MM Spatial exception - non-existent edge
      6 | SQL/MM Spatial exception - curve not simple
      1 | SQL/MM Spatial exception - geometry crosses a
     15 | SQL/MM Spatial exception - geometry crosses e
 (5 rows)

 }}}


 == Performance

 Before this patch I used around 12 hours to ad the 20 million rows and now
 it used around 1 hour more, but may also be related to other people also
 testing on this server.


 == Problem description

 I also have made a short sum up of problem, because different people tends
 put different meanings in the same words, when I talk to them.

 I now try to define as is used Postgis Topology where we have faces, edges
 and nodes.

 Vertex : Any point not only nodes (before I have mixed the usage of vertex
 and nodes)
 Node : A Vertex where 2 or more edges meet .
 Edge : A line with a start node and end node and zero or more vertexes
 between
 Edge segment :  A line with only 2 vertexes.

 If we look at this case
 [https://trac.osgeo.org/postgis/attachment/ticket/4758/intersection.png] ,
 the long black edge is added first.

 What's important here is that when adding the next line which is the short
 black line, the red node can't be added where it was, because then you can
 never add an edge that generate a node at the blue vertex, without
 starting to move already exiting nodes.

 Now when adding the short black line, a vertex close to blue vertex is
 generated. This new vertex will become a node because two edges will now
 meet there, when the second line is added.

 This means that the long black edge is split into two edges, but for all
 practical purposes it still a straight line, but it's now made up of two
 edges and not one as it was originally.

 By doing this we can add the red line without any error if we snap lower
 vertex to the blue node when adding the red line.

 All these changes are done inside a tolerance of 1-e06.

 The result before and after is here
 [https://trac.osgeo.org/postgis/attachment/ticket/4758/ar5_solution_4758.png]

 Thanks a lot, this problem been bugging mee for many years.

-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/4758#comment:22>
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