This is an old revision of the document!


DRAFT

Omnidex SQL Function: $DISTANCE

Description

$DISTANCE calculates the distance between two geographical points.

Syntax

$distance(lat1, long1, lat2, long2, options)
Options:
  • Units of measure
  • MILES (default)
  • NAUTICALMILES
  • KILOMETERS
  • YARDS
  • FEET
  • METERS
Default hemisphere
  • LAT_HEMISPHERE=[N | S]
  • LONG_HEMISPHERE=[E | W]

Examples

Simple distance between two longitude and latitude points:

select $distance(40.0, -105.0, 41.0, -106.0) 
    from $omnidex 

Compare latitudes and longitudes in a table against constant latitude and longitude:

select $distance(40.0, -105.0, latitude, longitude), latitude, longitude,
    from geo
    where $distance(40.0, -105.0, latitude, longitude) < 10

Compare latitudes and longitudes in a table against single latitude and longitude derived from a nested query:

select latitude, longitude,
    from geo
    where $distance((select latitude, longitude from zipcodes 
    where zip = ‘80301’),
    latitude, longitude) < 10

Compare latitudes and longitudes in a table against multiple latitudes and longitudes derived from a nested query:

select latitude, longitude,
    from geo
    where $distance((select 	latitude, longitude 
    from zipcodes 
    where region = ‘MT’),
    latitude, longitude) < 10
 
Back to top
dev/sql/functions/distance.1260369214.txt.gz · Last modified: 2016/06/28 22:38 (external edit)