gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 18:50:44 25 4
gpt4 key购买 nike

我在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com