- Introduction to WorkXpress
- Building Your Application
- Examples and Best Practices
- Technical Manual
The Distance Between function (DISTANCE_BETWEEN) calculates the distance between two points on Earth using the decimal longitude and latitude for each point. The distance is a calculation of the great-circle distance or “as the crow flies” using the “Spherical Law of Cosines”
The Distance Between function has five parameters, four of which are required:
Allowed Inputs: field value or number
The first required parameter is the decimal number that represents the latitude of the start point. The maximum and minimum values are 90 to -90. The value for this is usually the latitude field part of an address field with geolocation enabled.
Allowed Inputs: field value or a number
The second required parameter is the decimal number that represents the longitude of the start point. The maximum and minimum values are 180 to -180. The value for this is usually the longitude field part of an address field with geolocation enabled.
Allowed Inputs: field value or a number
The third required parameter is the decimal number that represents the latitude of the end point. The maximum and minimum values are 90 to -90. The value for this is usually the latitude field part of an address field with geolocation enabled.
Allowed Inputs: field value or a text string
The fourth required parameter is the decimal number that represents the longitude of the edit point. The maximum and minimum values are 180 to -180. The value for this is usually the longitude field part of an address field with geolocation enabled.
Allowed Inputs: omitted, mi, or km
The fifth parameter is optional and determines the units returned for the distance calculation. If this parameter is omitted the miles will be used.
The output of the Distance Between function is number representing the distance between two points in the units requested.
For example the distance between 304 Market St. Harrisburg, PA and 304 Market St. San Francisco CA would be calculated by DISTANCE_BETWEEN(40.261081,-76.880648,37.792335,-122.397622) will result in 2422.34723361 and DISTANCE_BETWEEN(40.261081,-76.880648,37.792335,-122.397622,“km”) will result in 3898.14958963.