This shows you the differences between two versions of the page.
dev:sql:functions:distance [2009/12/09 14:33] 127.0.0.1 external edit |
dev:sql:functions:distance [2016/06/28 22:38] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | {{page>:top_add&nofooter&noeditbtn}} | ||
- | <html><div align="center"><span style="color:red">DRAFT</span></div></html> | ||
- | ====== Omnidex SQL Function: $DISTANCE ====== | ||
- | {{page>:sql_bar&nofooter&noeditbtn}} | ||
- | ===== 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 | ||
- | |||
- | {{page>:bottom_add&nofooter&noeditbtn}} |