RefLib

Reference library for AI

Back

postgresql_16:9.6.15.2 Point-Based Earth Distances

PostgreSQL 16 > Appendixes > Additional Supplied Modules and Extensions > earthdistance — calculate great-circle distances > Point-Based Earth Distances

The second part of the module relies on representing Earth locations as values of type 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.

A single operator is provided, shown in (see earthdistance-point-operators).

| Operator Description | | --- | | point <@> point float8 Computes the distance in statute miles between two points on the Earth's surface. |

Note that unlike the cube-based part of the module, units are hardwired here: changing the earth() function will not affect the results of this operator.

One disadvantage of the longitude/latitude representation is that you need to be careful about the edge conditions near the poles and near +/- 180 degrees of longitude. The cube-based representation avoids these discontinuities.

Back