简体   繁体   中英

GPS value pulled from iOS image is not showing proper Positive or Negative

I am developing an iPhone app which will pull the GPS data from a photo that is taken. I have everything working pretty well for this function, but I have noticed that the GPS data being returned is not showing the proper + or - to the coordinate values. For example, I get this output in the log:

"{GPS}" =     {
    Altitude = "33.0329";
    DOP = 65;
    Latitude = "64.84069";
    LatitudeRef = N;
    Longitude = "32.41367";
    LongitudeRef = W;
    TimeStamp = "2014:01:04 14:47:01";
};

When I take the latitude and longitude on and use a reverse geolocation mapping, I get some place on the other side of the world. After looking into it, I see that the value:

Longitude = "32.41367";

should be:

Longitude = "-32.41367";

It was simply missing the negative. Any ideas as to why this may be happening? Here are some code samples that are building the above output:

    UIImage *image =  [info objectForKey:UIImagePickerControllerOriginalImage];
    NSData *jpeg = UIImageJPEGRepresentation(image,image.scale);
    CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)jpeg, NULL);
    NSDictionary *metadata = (__bridge NSDictionary *)CGImageSourceCopyPropertiesAtIndex(source,0,NULL);
    NSMutableDictionary *mutableMetadata = [metadata mutableCopy];

    [mutableMetadata setLocation:self.currentLocation];

    CFStringRef UTI = CGImageSourceGetType(source);
    NSMutableData *data = [NSMutableData data];
    CGImageDestinationRef destination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef) data, UTI, 1, NULL);
    CGImageDestinationAddImageFromSource(destination,source, 0, (__bridge CFDictionaryRef) mutableMetadata);
    BOOL success = CGImageDestinationFinalize(destination);

    NSLog(@"This is the log value that was referenced above: %@",mutableMetadata);

N and E have positive values S and W have negative values

However Google Maps knows how to map these if you just put the references in the coordinates. For example in Google Maps (50.53467,-100.45646) equals N50.53467W100.45646

Just a guess, but LongitudeRef = W might means negative. Seeing that westward longitude has negative values.

Martijn is correct lat lon values are more often written as N30.xxx and E97.xxx The letter represents the hemisphere. When converted to decimal degrees the NSEW are converted to +/-. Not sure why but it seem Google choose to convert the GPS output, which is likely in NMEA using HDD.MMMMM and kept the hemisphere character.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM