math - 如何在 ColdFusion 中锻炼 Haversine 公式

标签 math coldfusion coldfusion-9

我在 Haversine 公式的 CF 中找不到任何示例(用于计算球体上两点之间的经度和纬度距离的公式)。

Wikipeda 有其他语言的示例 (http://en.wikipedia.org/wiki/Haversine_formula),但在 CF 中没有。

下面是另一位内部开发人员对 CF 的解释,未经过充分测试。我很想知道其他人是如何在 CF 中计算出来的。我也有兴趣就下面的示例获得关于如何简化它的意见。

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;
    }

最佳答案

你看过这个...

http://cflib.org/udf/getHaversineDistance

(自 CFLib.org 切换到静态站点生成器后的新 URL)

关于math - 如何在 ColdFusion 中锻炼 Haversine 公式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6648054/

相关文章:

C:如何将多位数字分解成单独的变量?

Javascript:将 Math.sqrt 转换为 int?

javascript - 我的算法是错误的还是正确的,只是需要调整?

javascript - Coldfusion 的 cfpdfform 的 PHP 等价物

SQL Select 语句在两个列表之间

templates - 如何防止Coldfusion将cfform.js注入(inject)head部分?

coldfusion - 如何处理对非常常见的关键字的搜索

javascript - 计算负数的立方根

coldfusion - cfdump 组件方法值,而不是组件结构

oauth - 如何在 ColdFusion 9 中签署 Quickbooks 在线 API 请求?