如何计算步行时两点之间的距离(没有GPS)
当我到达目的地纬度和经度时,android 的 distanceTo() 和 distanceBetween() 函数会给出结果。但我需要涵盖纬度和经度可能不会改变的情况(例如,如果我走在周围有高楼的街道上,进入建筑物或通过更多转弯步行短距离)。对于这些条件如何在android中计算距离?
当我搜索 stackoverflow 其他答案时,我浏览了
我尝试了以下答案。该代码很好,但是当我每次尝试通过该代码计算距离时,即使我没有走路,它也会给出一个恒定值。
请帮我计算两点之间的距离
The android's distanceTo() and distanceBetween() function gives results when I reach the destination lat and lon. But I need to cover the case when latitude and longitude may not be changed (e.g. if I walk in the street with high buildings around, enter the building or walk short distance by taking more turns). For those conditions how to calculate distance in android?
When I was searching through stackoverflow others answers, I gone through here.
I tried the following answer. The code is good and fine but when I tried to calculate distance by that code everytime it gives a constant value even when I am not walking.
Please help me in calculating the distance between two points
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您进入建筑物时,您会看到 GPS 纬度/经度,但之后它不会改变,因为没有 GPS 覆盖。所以,问题是如何处理这样的情况,只有最后一个位置。我会这样处理这个有趣的问题:
也使用 WiFi 网络信息来定位(不仅仅是 GPS)。
使用传感器。您有方向和加速传感器。我记得有些手机具有步数计数功能(我在索尼爱立信上有这个功能,没有 GPS)。
加速器传感器可以为您提供人是否在移动的信息,并帮助您计算步数(您需要进行一些平均步距值估计)。您可以轻松判断人是否在电梯内,是上行还是下行,并粗略估计楼层数。
方向传感器可以为您提供有关移动方向变化(在拐角处转弯)的信息。
基于 GSM 信号强度的位置。来自
android.telephony
的 NeighboringCellInfo 为您提供有关您周围小区的 RSSI(接收信号强度指示)的信息,但为了基于三角测量准确计算位置(大约 50 m 精度),您需要基站的准确位置站(如果没有运营商的支持,您将无法获得这些站)。据了解,这种估计可能有多么不准确,但我认为没有其他方法。
无论如何,这些都是可以带来很多有趣的探索/开发的东西。
When you enter the building you have GPS lat/long, but after that it will not change because there is no GPS coverage. So, question is how to handle such a case, having just last position. I would approach that interesting issue this way:
Use WiFi networks info for location as well (not just GPS).
Use sensors. You have orientation and accelerator sensors. I remember some phones having feature of number of steps counting (I had that on SonyEricsson without GPS).
Accelerator sensor may give you info if person is moving and help you to count the number of steps (you need to take some average step distance value estimate). You can easily conclude if person is in the elevator, and if he is going up or down, and roughly estimate number of floors.
Orientation sensor may give you info about direction of movement change (turning around the corner).
GSM signal strength based location. NeighboringCellInfo from
android.telephony
gives you information about RSSI (Received Signal Strength Indication) for cells around you, but for accurate calculation of the position (approx 50 m precision) based on triangulation you need exact position of Base stations (which you cannot get without support from the operator).It is understood how inaccurate such estimation may be, but I see no other approach.
In any case, stuff for lots of fun exploring/developing.