Argg...is CLLocation broken?

Discussion in 'iOS Programming' started by detz, Aug 9, 2008.

  1. detz macrumors 65816

    Joined:
    Jun 29, 2007
    #1
    CLLocation *test1 = [[CLLocation alloc] initWithLatitude:42.27818011 longitude: -71.39553308];

    CLLocation *test2 = [[CLLocation alloc] initWithLatitude:42.27818012 longitude: -71.39553308];

    double diff = 0;
    diff = [test1 getDistanceFrom:test2];

    diff is -347598198. I can't get this to work at all.
     
  2. slycrel macrumors newbie

    Joined:
    Jul 11, 2008
    #2
    I am using getDistanceFrom: fairly heavily and I haven't noticed any problems. However, I have been using this with locations passed back to me by locationManager:didUpdateToLocation:fromLocation:, only rarely (when my app is restarted after it has quit) do I use initWithLatitude:, though it seems to work fine there as well. It could be a precision issue, I don't know how far the location manager looks.

    Good luck.
     
  3. ben.greeley macrumors newbie

    Joined:
    Dec 13, 2010
    #3
    I'm having the same exact issue. Did you ever figure out what the cause of the issue was?
     
  4. ulbador, Dec 13, 2010
    Last edited: Dec 13, 2010

    ulbador macrumors 68000

    ulbador

    Joined:
    Feb 11, 2010
    #4
    I have a dollar. It says you are doing something like:

    NSLog(@"diff: %d",diff);

    Print a float instead:

    NSLog(@"diff: %.0f",diff);
     

Share This Page