- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我一直在使用 MapBox 绘制 map 和用户在 map 上的位置。在使用位置引擎的同时,我订阅了位置更改。位置更改的问题是它们每秒发生一次(最多),而且我的用户大多开车,所以记录的位置经常落后。
我意识到即使记录的位置落后,显示用户当前位置的标记似乎总是准确的。我想知道是否有可能获得当前位置标记的“估计”位置。
此外,根据 mapbox 的文档,我可以使用 ProgressChangeListener
获得更准确的位置(也更频繁)。我尝试以这种方式设置,但没有成功。
val nav = MapboxNavigation(this,getString(R.string.access_token))
nav.addProgressChangeListener { location, routeProgress ->
Timber.tag("GPSDEBUG").d("GOT LOC UPDATE on ${System.currentTimeMillis()} with ${location.longitude},${location.latitude}")
}
nav.startNavigation(DirectionsRoute.fromJson(""))
显然 MapBox 不喜欢空旷的道路或虚假的导航。
在我尝试其他建议(例如使用卡尔曼算法“估计”缺失位置)之前,如果能得到反馈,我会很高兴。
最终:主要目标是即使在高速情况下也能检索准确的 GPS 坐标。
最佳答案
我的解决方案是计算点 A 和点 B 之间的缺失位置,知道 GPS 提供更新的最大速率是 1 秒。在现实生活中,当人们在高速公路上高速行驶时,我不得不扣除 3 到 4 分。
private fun processMissingPoints() {
val stepInMeters = lastUsedLocation.distanceTo(lastKnownLocation) / (numberOfMissingPoints).toDouble()
val bearing = lastUsedLocation.bearingTo(lastKnownLocation)
missingPoints.forEach{ point ->
val newCoordinates = getNewCoordinates(lastUsedLocation.latitude , lastUsedLocation.longitude,stepInMeters*(index+1), bearing.toDouble())
}
}
/**
* http://www.movable-type.co.uk/scripts/latlong.html#dest-point
* Given a start point, initial bearing, and distance, this will calculate the destination
* point and final bearing travelling along a (shortest distance) great circle arc.
*/
private fun getNewCoordinates(latitude: Double,longitude: Double,distanceInMetres: Double,bearing: Double) : LatLng{
val brngRad = toRadians(bearing)
val latRad = toRadians(latitude)
val lonRad = toRadians(longitude)
val earthRadiusInMetres = 6371000
val distFrac = distanceInMetres / earthRadiusInMetres
val latitudeResult = asin(sin(latRad) * cos(distFrac) + cos(latRad) * sin(distFrac) * cos(brngRad))
val a = atan2(sin(brngRad) * sin(distFrac) * cos(latRad), cos(distFrac) - sin(latRad) * sin(latitudeResult))
val longitudeResult = (lonRad + a + 3 * PI) % (2 * PI) - PI
return LatLng(toDegrees(latitudeResult),toDegrees(longitudeResult))
}
关于android - 高速获取用户位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59197472/
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 3 年前。 Improve th
作为练习,我正在尝试使用 Thread.sleep 作为计时器并使用 JMF 作为声音来使用 Java 创建一个节拍器。它运行良好,但出于某种原因,JMF 似乎只能以每分钟最多 207 拍的速度播放声
有谁知道对用户浏览器进行基准测试的快速方法?它不需要那么准确。 我开始在我们的软件平台中使用 Javascript 执行越来越多的密集型任务,我担心性能在旧浏览器上会成为一个问题,所以我想要的是我可以
我的数据看起来像每帧 1000 万个数值(实数 + 二进制)(想想数组,即数组的一行中有 1000 万个元素)并且大约有 100 帧/秒。一种时间序列。 我的挑战是: (1) 存储——数据量 (2)
在使用 Android 时,我丢失了传入 USB 数据流上的数据,而在 Windows 中读取同一设备/流时我不会丢失这些数据。 (我知道 Android 不是实时操作系统,但 Windows 也不是
在我目前正在做的一个C#项目中,我们试图计算网络上大量文件的MD5(当前pot是270万,客户端pot可能超过1000万)。随着我们处理的文件数量的增加,速度成为问题。 我们这样做的原因是为了验证文件
我一直在尝试使用 XSLT 在最有效的时间内从 XML 文档获取 CSV 数据。以下是我的示例 XML Raagu Hoskote
如果标题听起来令人困惑,我很抱歉,如果您在这段描述后有更好的想法,请随时提出建议。 简而言之,我在 Linux 上使用 PHP 以及以下假设的文件/代码: job.php: if(setting_ge
对最多 1000 万个 7 位数字进行排序。约束条件:1M RAM,高速。几秒就好。 [编辑:来自提问者的评论:输入值不同] 使用位图数据结构可以很好地解决这个问题。 这意味着我需要一个字符串,它的长
我是一名优秀的程序员,十分优秀!