The distance-measuring function
The distance-measuring function is not itself a part of the operator class.
The first and second arguments of the distance
function must be the same as the first and second arguments of the
strategy function. The third argument must be INTEGER and the return
value DOUBLE PRECISION. For example, for the strategy function Nearest,
created by the following SQL statement:
CREATE FUNCTION Nearest(UDT, UDT)
RETURNS BOOLEAN
WITH (NOT VARIANT);
The associated distance function, Nearest, looks like this:
CREATE FUNCTION Nearest(UDT, UDT, INTEGER)
RETURNS DOUBLE PRECISION
WITH (NOT VARIANT);
where UDT is a user-defined data type.
In C, the distance function declaration
looks like this:
mi_double_precision *Nearest(UDT *x1,
UDT *x2,
mi_integer flags,
MI_FPARAM *fp);
The first two arguments are the objects or locations between which the function calculates the distance (or the bounding-boxes of the objects, as Distance function: Bounding boxes describes).
The third argument is not used in this version of the R-tree access method.
The DOUBLE PRECISION return value is not interpreted by the R-tree access method.