earthdistance
module provides two different approaches to calculating great circle distances on the surface of the Earth. The one described first depends on the cube
module (which must be installed before earthdistance
can be installed). The second one is based on the built-in point
data type, using longitude and latitude for the coordinates.earth
over cube
is provided, which includes constraint checks that the value meets these restrictions and is reasonably close to the actual surface of the Earth.earth()
function. It is given in meters. But by changing this one function you can change the module to use some other units, or to use a different value of the radius that you feel is more appropriate.earth()
to return a radius of 180/pi()
so that distances are in degrees.earth()
float8
sec_to_gc(float8)
float8
gc_to_sec(float8)
float8
ll_to_earth(float8, float8)
earth
latitude(earth)
float8
longitude(earth)
float8
earth_distance(earth, earth)
float8
earth_box(earth, float8)
cube
@>
operator for points within a given great circle distance of a location. Some points in this box are further than the specified great circle distance from the location, so a second check using earth_distance
should be included in the query.point
, in which the first component is taken to represent longitude in degrees, and the second component is taken to represent latitude in degrees. Points are taken as (longitude, latitude) and not vice versa because longitude is closer to the intuitive idea of x-axis and latitude to y-axis.point
<@>
point
float8
cube
-based part of the module, units are hardwired here: changing the earth()
function will not affect the results of this operator.cube
-based representation avoids these discontinuities.\