[postgis-tickets] [PostGIS] #3949: Infinite (?) loop in distance calculation

PostGIS trac at osgeo.org
Thu Dec 21 13:28:58 PST 2017


#3949: Infinite (?) loop in distance calculation
----------------------+---------------------------
  Reporter:  pramsey  |      Owner:  nicklas
      Type:  defect   |     Status:  assigned
  Priority:  high     |  Milestone:  PostGIS 2.4.3
 Component:  postgis  |    Version:  trunk
Resolution:           |   Keywords:
----------------------+---------------------------

Comment (by nicklas):

 Ok, I don't think this is a bug. This is just the nightmare situation for
 the "faster" code.

 Actually in this case it was slightly faster to go the brute force way.

 Your query finished in 2min 46 sec.

 But I also compared it with brute force. I cheeted and just moved the
 northern geoemtry to south west to make the bounding boxes overlap and
 tested with just 1 calculation, not both ways like your query.

 Then:


 {{{
 --"faster" code
 select st_distance(a.geom, b.geom) from
 (select * from inf_distance where gid = 7) a,
 (select * from inf_distance where gid = 37) b
 1 min 25 sec
 }}}

 and

 {{{
 create table t as select gid, geom from inf_distance

 update t set geom = ST_Translate(geom, -1, -1) where gid = 37;

 --brute force code because overlapping bboxes
 select st_distance(a.geom, b.geom) from
 (select * from t where gid = 7) a,
 (select * from t where gid = 37) b
 1 min 19 sec
 }}}

 Those geometries is a nightmare because the geometries is so close and
 most of the vertex-points is on the facing side to the other geometry.
 Then it takes a lot of iteration before it can be sure there is no other
 possible shorter combination.

 That is why we want the tree-based code :-)

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