gpt4 book ai didi

ios - 这个地理定位计算有多准确?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:49:53 25 4
gpt4 key购买 nike

我正在玩 Titanium,我正在使用这个公式来计算距离

    toRad = (x) ->
x * Math.PI / 180

toDeg = (x) ->
x * 180 / Math.PI

startingLat = hsc.models.startingPosition.latitude
startingLon = hsc.models.startingPosition.longitude
currentLat = e.coords.latitude
currentLon = e.coords.longitude
R = 6371
dLat = toRad(currentLat - startingLat)
dLon = toRad(currentLon - startingLon)
a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos(toRad(startingLat)) * Math.cos(toRad(currentLat)) *
Math.sin (dLon/2) * Math.sin(dLon/2)
c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a))
d = R * c;

hsc.models.positionUpdateCallback (d * 1093.6133) if hsc.models.positionUpdateCallback
console.log "distance is [#{d}]km"

我正在测试如下。

从A点开始。
启用跟踪。
在B点结束。
记录值(value)。清除。
启用跟踪。
回到A点。
记录值(value)

在 6 次运行中,我得到的值介于 122 和 135 之间。This tool告诉我距离是 124.9 码。

这可能就是 8 号铁杆和 7 号铁杆之间的区别,所以这是重要的人!!

编辑:我想知道我获得初始位置的方式是否有缺陷。

这是我在用户点击开始时开始跟踪的方式。

hsc.models.startTracking = (onUpdate) ->
return if hsc.models.isTracking
Ti.App.idleTimerDisabled = true;

Ti.Geolocation.setFrequency 100
Titanium.Geolocation.setAccuracy = Titanium.Geolocation.ACCURACY_BEST;
Titanium.Geolocation.setDistanceFilter 0

hsc.models.positionUpdateCallback = onUpdate
hsc.models.isTracking = true;
Ti.Geolocation.addEventListener 'location', hsc.models.locationUpdate

这是我在用户点击“结束”时的结束方式。

if hsc.models.isTracking is true
Ti.App.idleTimerDisabled = false;
hsc.models.isTracking = false
hsc.models.startingPosition = null
Ti.Geolocation.setFrequency 500000
Titanium.Geolocation.setDistanceFilter 10
Ti.Geolocation.removeEventListener 'location', hsc.models.locationUpdate

locationUpdate 我做

if not hsc.models.startingPosition
hsc.models.startingPosition = e.coords
else
#do the calculation

所以基本上我只是开始接收更新,当我收到第一个更新时,我设置初始位置。我想知道我是否需要执行初始 getCurrentPosition,然后注册位置回调处理程序。这可能会更好地处理第一次更新有点延迟的情况。

更多信息

所以我实现并尝试了新策略——获取起始位置,然后开始监听变化的事件(在第 1 步发生时不移动),我仍然看到很大的差异。我从 A -> B 跑了 134 码,然后从 B -> A 跑了 117 码。我从我家门口到日托中心跑了 2220 码,然后从我停好的车回到我家门口,跑了 2268 码。

更重要的是,坐在同一个地方,它记录了位置的变化,向上 20 码!

我一定是哪里做错了......

最佳答案

作为一名前工程技术讲师,我可以告诉您,获得准确的 GPS 定位需要的时间远不止几秒钟。在 20 码以内对于逐向街道导航来说已经足够准确了,因为该应用程序会捕捉到最近的有效街道位置。

您正在尝试执行所谓的实时运动学 GPS。即使是用于土地测量和农业设备引导的高端(数万美元)gps 单元也需要一个固定的主单元,至少需要 20 分钟才能获得稳定的位置,然后可以用于无线连接中的纠错流动站单位。在这些条件下,这些装置可以让你的距离达到几分之一英寸,而这是你并不真正需要的。

但是,我个人可以向您保证,设备在 A 点和 B 点停留的时间长短将是影响距离准确性的主要因素。

关于ios - 这个地理定位计算有多准确?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11766530/

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