Question

I'm using my new super powers to load an image from the AssetLibrary on iOS 4.+ and read the location the picture was taken. Unfortunately, I'm not sure the ALAssetPropertyLocation is valid, and sometimes it looks llike it is, when actually there's nothing in there.

For example I have

+/- 0.00m (speed -1.00 mps / course -1.00) @ 11/11/10 19:32:41 Heure normale de l\u2019Europe centrale

Which defeats my code of course:

CLLocation *loc = ((CLLocation*)[asset valueForProperty:ALAssetPropertyLocation]);
    CLLocationCoordinate2D gpsLocation = loc.coordinate;
    double acc = loc.horizontalAccuracy;
    NSLog(@"Accuracy:%f", acc);
    if(acc >0){
        detailItem.latitude = [NSNumber numberWithDouble:gpsLocation.latitude];
        detailItem.longitude = [NSNumber numberWithDouble:gpsLocation.longitude];
    }
    NSDate *time = loc.timestamp;
    if(time != nil){
        detailItem.latitude = [NSNumber numberWithDouble:gpsLocation.latitude];
        detailItem.longitude = [NSNumber numberWithDouble:gpsLocation.longitude];
    }

I usually use the accuracy, but here it's not negative.

Is that a bug, or do you think I should find the validity from another place?

Was it helpful?

Solution

OK, found it. Note for future self: look in CL for CL related functions and you will find CLLocationCoordinate2DIsValid. Much better than all horizontalAccuracy etc stuff.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top