DISTANCE macro
The DISTANCE
macro
is available in Unica Campaign and Unica Interact.
Syntax
DISTANCE(lat1, long1, lat2,
long2[, UNIT_OF_MEASURE][, PRECISION])
Parameters
lat1
The latitude of the first point, as a decimal value.
long1
The longitude of the first point, as a decimal value.
lat2
The latitude of the second point, as a decimal value.
long2
The longitude of the second point, as a decimal value.
UNIT_OF_MEASURE
An optional parameter indicating the unit of measure for the returned distance. Values are MILES or KILOMETERS. If you omit this parameter, MILES is the default.
PRECISION
An optional parameter indicating the level of precision following the decimal point for the returned distance. If you specify a precision value, the returned distance is truncated to the number of decimal places you specify. The maximum value is 5. If you omit this value, the number of decimal places is not truncated.
Description
DISTANCE
calculates the distance between two points. Latitude and
longitude are expected to be in decimal units. Always use a comma and a space to
separate numeric values. This is necessary to accommodate languages that use a comma as
a decimal separator, as shown in the second example below. It is supported to calculate
the distance between multiple points. If (lat1, long1) is a list with multiple values
and (lat2, long2) is also a list with multiple values, the distance of the first point
in list 1 and first point in list 2 is calculated as returned as the first element in
the result list, the distance of the second point in list 1 and second point in list 2
is calculated as returned as the second element in the result list, and so on, until all
the elements in either list 1 and list 2 are calculated. If list 1 has only one element,
while the list 2 has multiple elements, the distances between the element in list 1 and
all elements in list 2 are calculated.
Examples
DISTANCE (18.529747,
73.839798, 18.533511, 73.8777995, MILES, 2)
returns the
value 2.50 Miles.
DISTANCE (18,529747, 73,839798,
18,533511, 73,8777995, KILOMETERS, 1)
returns the value
4,0 kilometers.