Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue in finding the speed when using CLLocationManager
    primarykey
    data
    text
    <p>I am developing a speedometer application in iPhone. I have used CLLocationManager(GPS based) to measure the speed of a vehicle. But i don't get accurate speed. I have tried all the filtering methods given in various stackoverflow discussions. But i don't get any improvement. At times, the speed reaches to a greater value(>400kmph).</p> <p>I dont know what goes wrong. Please suggest me any code to get the accurate speed.</p> <p>Thanks in advance,</p> <p>I have followed the below mentioned stack over flow discussions</p> <p><a href="https://stackoverflow.com/questions/1994018/measuring-velocity-via-iphone-sdk">Measuring velocity via iPhone SDK</a></p> <p><a href="https://stackoverflow.com/questions/1081219/optimizing-cllocationmanager-corelocation-to-retrieve-data-points-faster-on-the-i">Optimizing CLLocationManager/CoreLocation to retrieve data points faster on the iPhone</a></p> <p><a href="https://stackoverflow.com/questions/1391589/cllocation-speed">CLLocation speed</a></p> <p><a href="https://stackoverflow.com/questions/1180050/why-is-my-cllocation-speed-so-inaccurate">Why is my CLLocation speed so inaccurate?</a></p> <p>I have currently implemented the following code:</p> <pre><code>//locationManager declaration in ViewDidLoad locManager=[[CLLocationManager alloc]init]; locManager.delegate =self; [locManager startUpdatingLocation]; - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { NSTimeInterval locationAge = abs([newLocation.timestamp timeIntervalSinceNow]); if (locationAge &gt; 5.0) return; if (newLocation.speed &lt; 0 || newLocation.horizontalAccuracy &lt; 0) return; if ((newLocation.horizontalAccuracy &lt; (oldLocation.horizontalAccuracy - 10.0)) || (newLocation.horizontalAccuracy &lt; 50.0)|| (newLocation.horizontalAccuracy &lt;= 150.0)) { if(oldLocation != nil) { CLLocationDistance distanceChange = [newLocation distanceFromLocation:oldLocation]; NSTimeInterval sinceLastUpdate = [newLocation.timestamp timeIntervalSinceDate:oldLocation.timestamp]; double calculatedSpeed; calculatedSpeed = (distanceChange / sinceLastUpdate)*3.6; // to convert the speed into kmph. } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload