【问题标题】:How to workout the Haversine formula in ColdFusion如何在 ColdFusion 中锻炼 Haversine 公式
【发布时间】:2011-07-11 09:17:48
【问题描述】:

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

维基百科有其他语言的示例 (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;
    }

【问题讨论】:

    标签: math coldfusion coldfusion-9


    【解决方案1】:

    你看过这个吗……

    http://cflib.org/udf/getHaversineDistance

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

    【讨论】:

    • 嗨,理查德,谢谢,我只是想弄清楚一些痛苦的事情;)它看起来很完美。忘记了java库! createObject("java","java.lang.Math") 更容易
    • 永远站在巨人的肩膀上 :-)
    • 我写了那个 UDF,它只是一个快速端口:movable-type.co.uk/scripts/latlong.html
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多