Java:计算大量位置之间的距离和性能

发布于 2024-09-04 06:31:12 字数 457 浏览 6 评论 0原文

我正在创建一个应用程序,它将告诉用户大量点距其当前位置有多远。

每个点都有一个经度和纬度。

我读过这篇文章 http://www.movable-type.co.uk/scripts/latlong。 html

并看到了这篇文章 当您知道经度时计算距离(以米为单位) java 中的纬度

有许多计算(50-200)需要进行。

如果速度比这些计算的准确性更重要,那么哪一个最好?

I'm creating an application that will tell a user how far away a large number of points are from their current position.

Each point has a longitude and latitude.

I've read over this article
http://www.movable-type.co.uk/scripts/latlong.html

and seen this post
Calculate distance in meters when you know longitude and latitude in java

There are a number of calculations (50-200) that need carried about.

If speed is more important than the accuracy of these calculations, which one is best?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

带刺的爱情 2024-09-11 06:31:13

您发布的两个链接使用相同的球面几何公式来计算距离,因此我预计它们的运行速度不会有显着差异。此外,它们的计算成本并不高,因此,如果您在现代硬件上运行,即使在几百次迭代的规模上,我也不认为这会成为问题。

The two links that you posted use the same spherical geometry formula to calculate the distances, so I would not expect there to be a significant difference between their running speed. Also, they are not really computationally expensive, so I would not expect it to be a problem, even on the scale of a few hundred iterations, if you are running on modern hardware.

夜雨飘雪 2024-09-11 06:31:12

这是 O(n)
不用担心性能。除非每次计算都花费太长时间(事实并非如此)。

this is O(n)
Dont worry about performance. unless every single calculation takes too long (which it isnt).

梦中楼上月下 2024-09-11 06:31:12

正如 Imre 所说,这是 O(n) 或线性的,这意味着无论值如何不同或执行多少次,算法中的计算每次迭代都会花费相同的时间。然而,我不同意余弦球面定律的实际变量较少,算法中执行的计算意味着使用的资源较少。因此,我会选择那个,因为唯一不同的速度是可用的计算机资源。 (注意:尽管除非在非常旧/慢的机器上,否则几乎不会被注意到)

基于意见的判决:余弦球面定律

As Imre said this is O(n), or linear, meaning that no matter how the values differ or how many times you do it the calculations in the algorithm will take the same amount of time for each iteration. However, I disagree in the context that the Spherical Law of Cosines has less actual variables and calculations being performed in the algorithm meaning that less resources are being used. Hence, I would choose that one because the only thing that will differ speed would be the computer resources available. (note: although it will be barely noticable unless on a really old/slow machine)

Verdict based on opinion: Spherical Law of Cosines

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文