[postgis-devel] [PostGIS] #231: New distance-calculations proposal
PostGIS
trac at osgeo.org
Fri Oct 30 16:59:40 PDT 2009
#231: New distance-calculations proposal
--------------------------+-------------------------------------------------
Reporter: nicklas | Owner: robe
Type: enhancement | Status: assigned
Priority: medium | Milestone: postgis 1.5.0
Component: postgis | Version:
Resolution: | Keywords:
--------------------------+-------------------------------------------------
Comment (by nicklas):
As I have mentioned, I have had an idea about better subgeometry-handling
in the distance-calculations. Now I have come up with a first try.[[BR]]
[[BR]]
What it does, simplified is:[[BR]]
1) unwinds all subgeometries and puts them in a list without
hiearchy.[[BR]]
2) calculates bboxes for the subgeometries[[BR]]
3) order geometries from distances between bboxes[[BR]]
4) calculates real distances in list order until distance between bboxes
is bigger than smallest found distance between real geometries.
[[BR]][[BR]]
For single geometries this might give a little overhead, but it doesn't
seem to be noticable. There are still som things to do to let the single
geometries passing by.
[[BR]][[BR]]
The best thing about this I think is the possibility to collect a lot of
geometries and fast get the distance or with shortestline get a line to
the closest geometry.
[[BR]]
One examples to show why I belive in the idea.
From the dataset Regina put in #137
[[BR]]
To find the closest point in the rest of USA from Alaska we can then do:
[[BR]]
{{{
select st_distance(a.the_geom, b.the_geom),
st_endpoint(st_shortestline(a.the_geom, b.the_geom)) as the_geom
from
(select st_collect(the_geom) as the_geom
from us.states where state != 'Alaska') a,
(select the_geom as the_geom
from us.states where state = 'Alaska') b
}}}
Querytime at my laptop is less than 400ms and then we have compared alaska
with 52 other states.
[[BR]]
The patch subgeomhandling applies to my spike
[[BR]]
It is probably not stable yet, but is it a good idea?
[[BR]]
/Nicklas
--
Ticket URL: <http://trac.osgeo.org/postgis/ticket/231#comment:36>
PostGIS <http://trac.osgeo.org/postgis/>
PostGIS
More information about the postgis-devel
mailing list