Changes between Initial Version and Version 1 of UsersWikiplpgsqlfunctionsDistance


Ignore:
Timestamp:
Sep 29, 2009, 9:16:52 PM (15 years ago)
Author:
robe
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • UsersWikiplpgsqlfunctionsDistance

    v1 v1  
     1
     2{{{
     3--
     4-- ST_DWithin_Sphere(lonlat-point, lonlat-point, radius-in-meters) returns boolean
     5--
     6-- Meters/Degree @ 60N: select 1/distance_sphere('POINT(0
     760)','POINT(1 60)') = 1.79866403673916e-05
     8--
     9CREATE OR REPLACE FUNCTION ST_DWithin_Sphere(geometry, geometry, float8)
     10        RETURNS boolean
     11        AS 'SELECT $1 && ST_Expand($2,$3 * 1.79866403673916e-05) AND
     12$2 && ST_Expand($1,$3 * 1.79866403673916e-05) AND ST_Distance_Sphere($1, $2) < $3'
     13        LANGUAGE 'SQL' IMMUTABLE;
     14
     15
     16}}}