- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我需要获得至少 10 赫兹的更新用户位置,以便在驾驶时在 MapBox for iOS 中平滑地动画位置。由于 Core Location 每秒只提供一个点,我认为我需要做一些预测。
我试过了ikalman但是当每秒更新一次并以 10 赫兹查询时,它似乎没有任何区别。
请问我该如何解决?
最佳答案
您要寻找的是外推法,而不是内插法。
我真的非常惊讶互联网上关于外推的资源如此之少。如果您想了解更多,您应该阅读一些数值方法/数学书籍并自己实现算法。
也许简单的线性外推就足够了?
// You need two last points to extrapolate
-(double) getExtrapolatedValueAt:(double)x withPointA:(Point*)A andPointB(Point*)B
{
// X is time, Y is either longtitute or latitude.
return A.y + ( x - A.x ) / (B.x - A.x) * (B.y - A.y);
}
-(Point*) getExtrapolatedPointAtTime:(double)X fromLatitudeA:(Point*)latA andLatitudeB:(Point*)latB andLongtitudeA:(Point*)longA andLongtitudeB:(Coord*)longB
{
double extrapolatedLatitude = [self getExtraploatedValueAt:X withPointA:latA andPointB:latB];
double extrapolatedLongtitude = [self getExtrapolatedValueAt:X withPointA:longA andPointB:longB];
Coord* extrapolatedPoint = [Coord new];
extrapolatedPoint.longtitude = extrapolatedLongtitude;
extrapolatedPoint.latitude = extrapolatedLatitude;
return extrapolatedPoint;
}
不确定我的功能是否正确,但你可以在这里查看: http://en.wikipedia.org/wiki/Extrapolation
这真的很容易。
您应该实现线性外推法。如果您发现线性外推法不够用(例如对于曲线),您应该迭代并使用其他一些外推算法对其进行更改。
另一种方法是在动画中延迟 1 秒,并使用插值在两个已知点之间制作动画。我不知道这是否适合您的用例。
关于ios - 插值和预测 CLLocationManager,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28024109/
我在主线程上调用 -[CLLocationManager requestWhenInUseAuthorization]。我已经设置了我的委托(delegate),并在 info.plist 中为 NS
这是我的代码,显示 map 上当前位置的警报和蓝点: MapName.h #import #import #import @interface MapName : UIViewControlle
我怎样才能不出错地执行以下操作? locationManager.delegate = self 行表示它不能 Cannot assign value of type '(APPLocationMan
我需要一直跟踪用户位置(但不要耗尽电池电量)。 我了解在应用程序终止后获取更新的唯一方法是使用 startMonitoringSignificantLocationChanges。 来自苹果关于 st
在我的标题中放置 CLLocationManager *locationManager; @property (nonatomic, retain) CLLocationManager *locati
我正在按照几个教程中的描述实现 CLLocationManager。 一切工作正常,直到 LocationManager 收到第二次更新。然后就会发生内存泄漏。 Instruments 告诉我,泄漏的
我正在尝试获取 iOS 设备(特别是我的 iPhone)上的当前位置。 我正在使用this苹果的例子。 调用 stopUpdatingLocations 之前的超时时间是 60 秒。 当我将desir
是否可以在后台“挂起” cllocationmanager? 我试图停止管理器,然后在特定时间在后台重新启动它。这可能吗?我尝试停止管理器并启动 nstimer,但它不起作用,因为 nstimer 不
如果我有一个选项卡栏应用程序,并计划在不同的选项卡中使用核心位置,是否有一个好的通用位置来放置用于分配/初始化 CLLocationManager 的代码,并在调用 startUpdatingLoca
我有一个 Mac 应用程序,想要使用核心位置,但是,当我没有使用 wifi 但使用以太网电缆连接时,核心位置 (CLLocationManager) 报告操作无法完成。 确切的错误消息是 The op
我正在开发一个跟踪应用程序,它需要在 map 上显示跟踪路径。当我开始更新位置并且安装后没有移动设备时,locationManagar报告错误的位置更新, 我正在根据报告的位置点绘制路线, 另外当用户
从iOS9开始,我们在CCLocationManager中遇到了一些奇怪的问题。 iOS 7-8没有问题。怪异的位置会导致应用程序出错。该应用程序在开车时使用,我们有大约50位TestFlight测试
我正在使用 CLLocationManager要访问用户位置,以下委托(delegate)方法返回不准确的坐标 -(void)locationManager:(CLLocationManager *)
我的应用程序中有一个映射功能。它属于选项卡栏 Controller 选项卡之一。 我遇到的问题是该应用程序在启动后立即要求位置权限。 在用户真正进入应用程序的 map 部分之前,我不想用与位置相关的问
我有一个 iOS 应用程序,它是一个选项卡式应用程序,带有 3 个 View Controller ,所有这些都需要知道手机何时进入特定地理区域。 我们监控的区域是在运行时通过 Web 界面提供的,因
当我尝试尝试 LBS 应用程序时,我遇到了问题。在模拟器中测试时,它似乎工作。然后,我在 iPhone 上试了一下。它没有按预期工作。 当我启动应用程序时,它显示了我的位置纬度、经度、距离等所有信息。
我有两个不同的类,其中之一是 LocationService,仅用于确定位置。问题是我不知道为什么它不更新坐标变量。 View Controller : import UIKit class View
我是 swift 新手 - 目前,当我第一次通过 override func awakeFromNib() 在 init 上调用 setupLocationManager() 时,我的当前位置仅在控制
我正在阅读 application:didFinishLaunchingWithOptions:方法并从 NSHipster 中发现以下代码: @import CoreLocation; @inter
位置管理器使用辅助 GPS 来确定用户的位置,使用来自 wifi 和蜂窝适配器的信息来提高返回位置的准确性和电池效率。但是,该文档没有明确说明为此使用 wifi/手机信号信息是否涉及任何可能消耗用户手
我是一名优秀的程序员,十分优秀!