如何计算从给定点(经度,纬度)给定半径内的所有点(经度,纬度)? [英] how to calculate all points(longitude,latitude) within a given radius from given point (longitude,latitude)?

查看:157
本文介绍了如何计算从给定点(经度,纬度)给定半径内的所有点(经度,纬度)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个给定的点(经度,纬度),我想要得到所有的点范围,让我们说在给定点的5英里半径?

解决方案

我只是在这里猜测,但我认为你需要找到一种不同的方法。如果您尝试使用Foursquare,Google地图等查找当前位置5英里范围内的地点,我想您会发现这些服务不能计算所有点在这个半径,然后匹配他们在这些点的地方。

在代码背后可能会有一些智能这样做...


  1. 获取用户当前位置

  2. 找到郊区(或失败者,找到城市)找到当前位置。还可以找到与此相邻的所有周边郊区。

  3. 在这些郊区中查找所有地点,并计算他们离当前用户位置的距离
  4. li>

这种过程是这些服务可以使用的一种潜在方法。这涉及地点比较的一小部分,这相对较快地执行。此外,地图上的地点通常还会有一个与之相关的郊区/城市,因此对于地点的数据库查询会很快,因为会有涉及郊区的索引。

如果你的目标是做这样的事情,我会尝试找出一个不同的方法来比较点,而不是简单地计算你的半径的一切。



当然,也有很多特定的算法可以更好地计算这些,但这不是我的专业领域,而且更适合于另一个论坛。我并不是想说这是做这件事的最好方式,但还有很多其他方式可以依靠已知的位置数据,这将比您的建议要求更快更明智。


I have a given point (longitude,latitude) and I want to get all the points ranges that comes lets say 5 miles radius in given point?

解决方案

I'm just guessing here, but I think you'll need to find a different approach. If you're trying to do something like Foursquare, Google Maps, etc where it finds places within a 5-mile radius of your current location, I think you'll find that these services don't calculate all the points in that radius and then match them up to places at those points.

There would probably be some smarts behind the code that do something like this...

  1. Get the users current location
  2. Find the suburb (or failing that, find the city) that the current location exists in. Also find all the surrounding suburbs adjacent to this one.
  3. Find all the places within those suburbs, and calculate how far they are away from the current user location

This kind of process is one potential method that could be employed by these services. This deals with small subset of place comparisons, which is relatively quick to perform. Also, places on a map usually have a suburb/city associated with them anyway, so database lookups for places would be rather quick, as there would be an index that involves the suburb.

If you're aim is to do something like this, I would try to figure out a different way to compare points rather than simply trying to calculate everything in your radius.

And of course, there would also be plenty of specific algorithms for calculating this better, but that's not my area of expertise, and would be better suited to another forum. I'm not trying to say that this is the best way to do it, but there's plenty of other ways to do it that rely on known location data which would be quicker and smarter than your suggested requirement.

这篇关于如何计算从给定点(经度,纬度)给定半径内的所有点(经度,纬度)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆