如何计算一个位置,另一个(C#)之间的距离/接近 [英] How do I calculate distance/proximity between one location and another (c#)

查看:275
本文介绍了如何计算一个位置,另一个(C#)之间的距离/接近的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我想知道如何当用户进入的接近非常准确地说另一个指定位置为30英尺,可能有很多的指定位置所以会是什么最好的办法是计算?

Hi I'm wondering how to calculate very accurately when a user gets into proximity of say 30 feet of another specified location, there may be many specified locations so what would the best way to do be ?

*示例场景;移动应用程序用户移动到它的应用程序之一的接近(30英尺)的许多指定位置。(我将如何计算2个位置之间的接近,即移动用户和其他地点)

*example scenario; mobile app user moves into proximity (30 ft) of one of its apps many specified locations..(how would I calculate that proximity between 2 locations ie the mobile user and other locations)

在此先感谢

推荐答案

,最好的办法是使用一个空间功能的数据结构来存储的位置,以测试该列表中。本身的距离上使用净到处记载公知的公式来计算(大圆距离 地理距离,的 vincenty的公式 ...)

the best approach is to use a "spatially enabled" data structure to store the list of locations to test. the distance in itself is computed using well-known formulas documented everywhere on the net (great circle distance, geographical distance, vincenty's formulae...)

的最简单的这种结构是 kd树的:它允许存储一组坐标并迅速找到最近的点给定的位置。结构是容易掌握,操作是很容易的程序(你甚至可以找到哪些做这一切的库),它是足够快的移动需求。

the easiest such structure is the kd-tree: it allows to store a set of coordinates and to quickly find the nearest point to a given location. the structure is easy to grasp, the operations are quite easy to program (you may even find a library which does all this), and it is fast enough for mobile needs.

不是kd树等,你的问题的决心,最近邻搜索,这是有据可查的上维基百科的。你会发现有大量的数据结构来存储你的位置,并寻找最近的位置。

other than a kd-tree, your problem resolve to a nearest-neighbor search, which is well documented on wikipedia. you will find there plenty of data structures to store your locations, and to search for the nearest location.

在任何情况下,不执行全搜索(您的当前位置比较整套存储位置)。这种算法的时间复杂度在很大程度上取决于你测试位置的数量,让你少相比,你越快找到一个解决方案。一个全搜索涉及过多的比较,并且如果与设备的处理。第功率位置的数量过高,则会使移动设备抓取下降到停止寻找最近的位置之前。

in any case, do NOT perform a full-search (comparing your current location to the whole set of stored locations). the time complexity of such an algorithm depends heavily on the number of location you test, the less comparison you make, the faster you find a solution. a full-search involves too many comparison, and if the number of location is too high compared to the procesing power of your device, you will make a mobile device crawl down to a halt before finding the nearest location.

这篇关于如何计算一个位置,另一个(C#)之间的距离/接近的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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