Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 886115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:01:02+00:00 2026-05-15T13:01:02+00:00

I am developing an application that computes the distance travelled by the person. I

  • 0

I am developing an application that computes the distance travelled by the person. I am testing it on a iPad (Device-3.2). My iPad is using WiFi to get the current location. The results are highly inaccurate even though i have filtered the values. I don’t know if GPS will give me accurate results. I am pasting the entire code below. Please verify the code and in case of errors please let me know. It would b very helpful if some one test the code on iPhone(3g) or iPad(3g). If not possible then just check the logic…..also i want to compute the calories burnt ..is there any formula to do so..? I have made simple view based project…..and used a distance label in nib file to set distance value but distance is updating at a very rapid rate….please correct it.




    //  iPacometerViewController.h
    @interface iPacometerViewController : UIViewController {
    CLLocationManager *locationManager;
    CLLocation *oldLocat;
    CLLocation *newLocat;
    IBOutlet UILabel *distanceLabel;
    }

    @property(nonatomic,assign)IBOutlet UILabel *distanceLabel;
    @property(nonatomic,retain)CLLocationManager *locationManager;
    @property(nonatomic,retain)CLLocation *oldLocat;
    @property(nonatomic,retain)CLLocation *newLocat;

-(void)computeDistanceFrom:(CLLocation *)oldL tO:(CLLocation *)newL;

@end

//  iPacometerViewController.m

#import "iPacometerviewController.h"

@implementation iPacometerViewController

static double distance = 0.0;
@synthesize locationManager;
@synthesize oldLocat;
@synthesize newLocat;
@synthesize distanceLabel;


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
       [super viewDidLoad];

    //initializing location manager
    locationManager =[[CLLocationManager alloc]init];
    locationManager.delegate = self;
    locationManager.distanceFilter = 150.0f;
    locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    [locationManager startUpdatingLocation];
    oldLocat = [[CLLocation alloc]init];
    newLocat = [[CLLocation alloc]init];
}


- (void)locationManager:(CLLocationManager *)manager
                  didUpdateToLocation:(CLLocation *)newLocation
                  fromLocation:(CLLocation *)oldLocation
         {

    if (newLocation.horizontalAccuracy  60.0) return;   // data is too long ago, don't use it

    NSLog(@"oldd %@",oldLocation);
    self.oldLocat = oldLocation;
    self.newLocat = newLocation;
    if(oldLocat!=nil)
    {
    [self computeDistanceFrom:oldLocat tO:newLocat];
    }
}


-(void)computeDistanceFrom:(CLLocation *)oldL tO:(CLLocation *)newL
         {
    NSLog(@"oldd %@",oldL);
    NSLog(@"new %@",newL);

    CLLocationDistance currentDistance = [oldL distanceFromLocation:newL];
    NSLog(@"you have travel=%f",currentDistance);   
        distance = distance + currentDistance;
    double distanceInKm = distance/1000;
    NSString *distanceLabelValue = [NSString stringWithFormat:@"%1.2f Kms",distanceInKm];
    distanceLabel.text = distanceLabelValue;
}   

- (void)didReceiveMemoryWarning {
     // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
     // Release any cached data, images, etc that aren't in use.
}



- (void)dealloc {
        //[mapView release];
    [oldloct release];
    [newLocat release];
    [locationManager release];
    [super dealloc];
}
@end

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T13:01:03+00:00Added an answer on May 15, 2026 at 1:01 pm

    your logic is fine. Its the iPhone’s logic that is bad.

    There are two main issues that I see when writing this sort of code.

    1) What I call poisoned points. These are cached points that the iPhone reports erroneously. You can check for them by dropping any points where the timestamp is the same as or earlier than the latest point. It may also be worth recording a frequency of visits to a point. The poisoned points tend to be visited time and time again (maybe 5 times) each time as a jump from your real track. If you can spot them, you can rule them out.

    2) Accuracy – especially height changes. Look at the horizontal and vertical accuracy figures returned with each point. And look at the height. If they are inaccurate, then the velocity and therefore distance traveled will be too. One cause of bad distances is if one end of your pair has an altitude, and the other does not: the “not” gets classed as zero – so if you are 200m above the sea level at the time you have just travelled 200m without moving!

    To improve accuracy, you may be better off writing your own great circle distance algorithm (or even simple Pythagoras given the distances are small) which ignores height, or just doing some better filtering on the points you use.

    I’m struggling to find a reliable way of measuring location, distance & speed with the iPhone (3GS). and iPad or Touch is just going to be worse I guess.

    If you can drop me a mail at andrew dot hawken at fiftyeggs dot co dot uk I will send you my raw iPhone logging software. It would be great if you can run it for a couple of trips and let me have the results – I’m trying to solve the same problem, but only have GPS datasets to work on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing the application that stores current user and user's role to session
Please help. I am developing a swing application that can open reports made using
I am developing a browser application that is sensitive to the current date. Throughout
I started developing an application for a FEZ Panda device, using the .NET Micro
I am developing an application that will run on 64 bit computers. However, we
I'm developing application that can be useful only in my country(Ukraine). In Ukraine people
I've been developing an application that handles accounts and transactions made over these accounts.
I'm developing an application that requires FAST semantic role tagging in java. Can you
I am developing an application that receives a stream of audio samples from a
I am developing a application that uses core data. In my application i would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.