模拟低和高GPS精度 [英] Simulate Low and Hight Gps Accuracy

查看:193
本文介绍了模拟低和高GPS精度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一个.gpx文件来模拟IOS模拟器上的路由,现在我想模拟水平精度,我该如何做到这一点? p

如下是摘录我的.gpx文件:

 <?xml version =1.0?> 
< gpx>
< wpt lat = - 23.772830lon = - 46.689820/> //如何增加水平精度7米,例如
< / gpx>

如果我运行所有gps点返回水平精度5米,否则我可以改变它。我从viewController中调用了一个方法(我的是一个按钮,但显然你可以使用一个gestureRecognizer或者其他的方法)。



我将viewController设置为LocationManagerDelegate,但您可以放入您正在使用的代理而不是self。

   - (IBAction)simulateAccuracy:(id)sender {
CLLocationCoordinate2D newCoor = CLLocationCoordinate2DMake(someLat,someLng);
CLLocation * newLoc = [[CLLocation alloc] initWithCoordinate:newCoor altitude:someAlt
horizo​​ntalAccuracy:TheAccuracyYouWantToTest verticalAccuracy:ditto timestamp:nil];
NSArray * newLocation = [[NSArray alloc] initWithObjects:newLoc,nil];
[self locationManager:myLocationManager didUpdateLocations:newLocation];
}


I did a .gpx file to simulate a route on IOS simulator, now i wanna simulate the horizontal accuracy how I can do this?

as follow is an excerpt of my .gpx file:

<?xml version="1.0"?>
<gpx>
    <wpt lat="-23.772830" lon="-46.689820"/> //how add horizontal accuracy 7 meters for example
    <wpt lat="-23.774450" lon="-46.692570"/> //and here horizontal accuracy of 2 metters for example
    <wpt lat="-23.773450" lon="-46.693530"/> //and here 19 meters
</gpx> 

if I run all gps points return horizontal accuracy of 5 meters, I can change this otherwise.

解决方案

I did this with a method call from the viewController (mine is a button, but obviously you could use a gestureRecognizer or whatever).

I have my viewController set as the LocationManagerDelegate, but you can put in the delegate you're using instead of "self"

- (IBAction)simulateAccuracy:(id)sender {
    CLLocationCoordinate2D newCoor = CLLocationCoordinate2DMake(someLat, someLng);
    CLLocation *newLoc = [[CLLocation alloc]    initWithCoordinate:newCoor altitude:someAlt
    horizontalAccuracy:TheAccuracyYouWantToTest verticalAccuracy:ditto timestamp:nil];
    NSArray *newLocation = [[NSArray alloc] initWithObjects:newLoc,nil];
    [self locationManager:myLocationManager didUpdateLocations:newLocation];
}

这篇关于模拟低和高GPS精度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆