DRAFT

Omnidex SQL Function: $DISTANCE

Description

$DISTANCE calculates the distance between two geographical points.

Syntax

$distance(lat1, long1, lat2, long2, options)
Options:
Default hemisphere

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