How to Train Haversin Formula in ColdFusion

I cannot find examples in the Haversin CF formula (the formula for calculating the distances between two points on a sphere from their longitude and latitude).

Wikipedia has examples in other languages ​​(http://en.wikipedia.org/wiki/Haversine_formula), but not in CF.

The interpretation in CF is lower by another developer, internal and not fully tested. I am interested to see how others calculated this in CF. I would also be interested to receive opinions on the example below, how this can be simplified.

var variables.intEarthRadius = 6371;    // in km

var local.decRadius = arguments.radius / 1000;  // convert radius given in metres to kilometres

var local.latMax = arguments.latitude + degree(local.decRadius / variables.intEarthRadius);
var local.latMin = arguments.latitude - degree(local.decRadius / variables.intEarthRadius);

var local.lngMax = arguments.longitude + degree(local.decRadius / variables.intEarthRadius / cos(radian(arguments.latitude)));
var local.lngMin = arguments.longitude - degree(local.decRadius / variables.intEarthRadius / cos(radian(arguments.latitude)));





private numeric function degree(required numeric radian) hint="I convert radians to degrees." {
        return arguments.radian * 180 / pi();
    }

    private numeric function radian(required numeric degrees) hint="I convert degrees to radians."  {
        return arguments.degrees * pi() / 180;
    }
+5
source share
1 answer

You looked at it ...

http://cflib.org/udf/getHaversineDistance

( URL- CFLib.org )

+6

All Articles