我正在更新我的应用程序,以允许在使用 UIImagePickerControllerSourceTypeSavedPhotosAlbum 时上传照片以包含 GPS 元数据。 GPS数据的准确性非常重要。我遇到一个问题,即使用 ALAsset 导出的位置数据与在 Photoshop 中打开同一张照片时看到的照片的实际 exif 数据不同。
我在xcode中使用了两种方法读取GPS数据:
ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset) {
CLLocation *location = [myasset valueForProperty:ALAssetPropertyLocation];
latitudeString = [NSString stringWithFormat:@"%g",point.latitude];
longitudeString = [NSString stringWithFormat:@"%g",point.longitude];
}
和
ALAssetRepresentation *representation = [myasset defaultRepresentation];
NSDictionary *metadata = [representation metadata];
NSDictionary *gpsDict = [metadata objectForKey:@"{GPS}"];
NSNumber *latitudeNumber = [gpsDict objectForKey:@"Latitude"];
NSNumber *longitudeNumber = [gpsDict objectForKey:@"Longitude"];
if ([[gpsDict valueForKey:@"LatitudeRef"] isEqualToString:@"S"])
{
//latitudeNumber = -latitudeNumber;
}
if ([[gpsDict valueForKey:@"LongitudeRef"] isEqualToString:@"W"])
{
//longitudeNumber = -longitudeNumber);
}
在我用作示例的代表性照片上,上面的两组代码给出的纬度为 47.576333,可转换为 47,34,35N
如果我查看 Photoshop exif 数据 - 纬度为 47,34,59N
这些数字很接近 - 但并不相同。我的照片大约 30% 都没有出现这种情况。知道为什么吗?
编辑 - Photo shop 不给出秒数 - 它给出 34.59 分钟,这确实是准确的。
最佳答案
你的转换是错误的,photoshop更正确。
47.576333 (DEG) 转换为 47* 34.5799' (DM)。可四舍五入为 47* 34.58
这是 Photoshop 明显显示的格式。
转换为 DMS,它给出您的值:47* 34' 35"N。 (请将所有“*”替换为度数符号。)
因此,您用 DM(度分)表示法交换了 DMS(度分秒)。
关于ios - ALAsset GPS 元数据与 exif GPS 数据不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15256993/