[postgis-tickets] [PostGIS] #3949: Infinite (?) loop in distance calculation
PostGIS
trac at osgeo.org
Fri Dec 22 03:39:28 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):
Just to further illustrate the characteristics of the algorithm
If you move the geometries further apart it will be faster because of the
angels between different vertex-points. It makes it easier to order the
points in a straight line:
{{{
drop table if exists t; create table t as select gid, geom from
inf_distance;
update t set geom = ST_Translate(geom, -20, -20) where gid = 7;
select st_distance(a.geom, b.geom) from
(select * from t where gid = 7) a,
(select * from t where gid = 37) b
3 sec
}}}
and when facing the opposite side of the geometries towards each other
instead it starts to go really fast (brute force would still use 1 min 19
sec on this)
{{{
drop table if exists t; create table t as select gid, geom from
inf_distance;
update t set geom = ST_Translate(geom, -20, -20) where gid = 37;
select st_distance(a.geom, b.geom) from
(select * from t where gid = 7) a,
(select * from t where gid = 37) b
32 ms
}}}
This makes todays distance function very unpredictable from a user
perspective.
But that is limitations of the algorithm and I guess it anyway is
preferable over brute force since it gives such a great boost in cases
where it fits. About distance between the geometries it is the relation
between the geometries related to the "width" of the geometries from the
other geometries perspective that matters. So small geometries (not few
points but small) requires a shorter distance to work well.
This makes sense if looking at the wiki-post about the method
https://trac.osgeo.org/postgis/wiki/NewDistCalcGeom2Geom
--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/3949#comment:7>
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