gpt4 book ai didi

iphone - 在 Xcode 4.2 中使用 GPX 路线或轨道进行测试

转载 作者:技术小花猫 更新时间:2023-10-29 11:04:32 24 4
gpt4 key购买 nike

在 Xcode 4.2 中,是否有人成功使用 GPX 路线或轨道来测试依赖于移动的位置感知应用程序?我已经能够让它在 GPX 文件中使用单个航路点,甚至可以让它迭代一系列航路点,但我无法让它以提供速度和路线信息的方式跟随轨道.我尝试过驾驶时录制的轨迹、手工制作的路线和轨迹,以及使用 Trailrunner 制作的路线。

可能只是这个功能不可用,但 Apple 确实在模拟器中提供了高速公路驱动器。我希望能够在设备上和我可以指定的位置执行类似的操作。有人有什么想法吗?

最佳答案

最好的方法是创建您自己的模拟器类来读取文件并生成 CLLocation 事件,这让您可以完全控制。 GPX 文件不包含速度和航向,因此您必须自己计算它们。我使用的基本模拟循环是:

Simulate{
if (!eof) {
Read the next waypoint
Calculate distance, dt (delta time), bearing and speed (distance/dt) from the previous waypoint

Generate a CLLocation object and call the didUpdateToLocation delegate method
Peek at the next waypoint and calculate next_dt
Scale next_dt // as desired for faster playback (e.g. dt/2 would be 2x)
Start an NSTimer with next_dt as the duration
}
}

When the timer fires, call Simulate again

注意:直到最近,合成 CLLocations 还是有些问题,因为 CLLocation 是不可变的,而且 init 方法无法设置速度和航向。这已在 iOS 4.2 中得到修复。

关于iphone - 在 Xcode 4.2 中使用 GPX 路线或轨道进行测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7798489/

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