[postgis] distance(geometry,geometry) now in the CVS version

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[postgis] distance(geometry,geometry) now in the CVS version

David Blasby-3
The distance() function is now in the CVS version.  

I've also put in expand(BOX3D,double d) which returns a new bbox which
is exanded d unit in all directions.

ie.
select expand('BOX3D(0 0 0, 100 100 100)', 100.0);
              expand              
-----------------------------------
 BOX3D(-100 -100 -100,200 200 200)
(1 row)


also, because there's an auto-convesion between geometry and box3d, you
can;

select expand('POINT(0 0 0)'::GEOMETRY, 100.0);
              expand              
-----------------------------------
 BOX3D(-100 -100 -100,100 100 100)



This will allow you to do an index search using distances more easily.  
Lets say you take "A" as your base feature you're searching for nearby
objects;

select * from <table> where  distance(A,<geom_col>) <100 and  
<geom_col> && expand(A, 100) ;


<geom_col> && expand(A, 100):
        this does an index scan on the table looking for features that might be
100 units or less away from A.  It'll quickly filter out far away
features.

distance(A,<geom_col>) <100
        this returns true if the min distance from A to the geometry is less
than 100 units


dave

------------------------ Yahoo! Groups Sponsor ---------------------~-->
Small business owners...
Tell us what you think! http://promo2.yahoo.com/sbin/Yahoo!_BusinessNewsletter/survey.cgi
http://us.click.yahoo.com/vO1FAB/txzCAA/ySSFAA/PhFolB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
[hidden email]

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/