gpt4 book ai didi

iphone - Xcode中使用GPX模拟位置变化时,有没有办法控制速度?

转载 作者:IT王子 更新时间:2023-10-29 08:02:16 27 4
gpt4 key购买 nike

我在 Xcode 4.2 中使用以下 GPX 文件来模拟位置更改。它运行良好,但我无法控制位置变化的速度。邮票似乎不起作用。有人对此有解决方案吗?

<?xml version="1.0"?>
<gpx version="1.1" creator="Xcode">
<wpt lat="37.331705" lon="-122.030237"></wpt>
<wpt lat="37.331705" lon="-122.030337"></wpt>
<wpt lat="37.331705" lon="-122.030437"></wpt>
<wpt lat="37.331705" lon="-122.030537"></wpt>
</gpx>

最佳答案

Xcode 支持使用 GPX 文件模拟速度变化。

Provide one or more waypoints containing a latitude/longitude pair. If you provide one waypoint, Xcode will simulate that specific location. If you provide multiple waypoints, Xcode will simulate a route visitng each waypoint.

Optionally provide a time element for each waypoint. Xcode will interpolate movement at a rate of speed based on the time elapsed between each waypoint. If you do not provide a time element, then Xcode will use a fixed rate of speed. Waypoints must be sorted by time in ascending order.

这样写:

<wpt lat="39.96104510" lon="116.4450860">
<time>2010-01-01T00:00:00Z</time>
</wpt>
<wpt lat="39.96090940" lon="116.4451400">
<time>2010-01-01T00:00:05Z</time>
</wpt>
...
<wpt lat="39.96087240" lon="116.4450430">
<time>2010-01-01T00:00:09Z</time>
</wpt>

大约-1速度

CoreLocation 对象的速度在模拟期间将始终为 -1。一个可能的解决方法是保存最后一个位置然后自己计算速度。示例代码:

CLLocationSpeed speed = location.speed;
if (speed < 0) {
// A negative value indicates an invalid speed. Try calculate manually.
CLLocation *lastLocation = self.lastLocation;
NSTimeInterval time = [location.timestamp timeIntervalSinceDate:lastLocation.timestamp];

if (time <= 0) {
// If there are several location manager work at the same time, an outdated cache location may returns and should be ignored.
return;
}

CLLocationDistance distanceFromLast = [lastLocation distanceFromLocation:location];
if (distanceFromLast < DISTANCE_THRESHOLD
|| time < DURATION_THRESHOLD) {
// Optional, dont calculate if two location are too close. This may avoid gets unreasonable value.
return;
}
speed = distanceFromLast/time;
self.lastLocation = location;
}

关于iphone - Xcode中使用GPX模拟位置变化时,有没有办法控制速度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9439495/

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