Simulate Low and Hight Gps Accuracy

2019-06-06 08:28发布

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.

1条回答
【Aperson】
2楼-- · 2019-06-06 08:57

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];
}
查看更多
登录 后发表回答