I need to take a photo with the camera and get its GPS coordinates but the problem is that metadata dictionary is no returning the {GPS} key and I don't know why... I have set locations permissions.
我需要用相机拍照,得到它的GPS坐标,但问题是元数据字典不返回{GPS}键,我不知道为什么……我有设置地点的权限。
This is the output:
这是输出:
{
DPIHeight = 72;
DPIWidth = 72;
Orientation = 6;
"{Exif}" = {
ApertureValue = "2.27500704749987";
BrightnessValue = "2.351449770880873";
ColorSpace = 1;
DateTimeDigitized = "2016:02:17 16:00:38";
DateTimeOriginal = "2016:02:17 16:00:38";
ExposureBiasValue = "0.00390625";
ExposureMode = 0;
ExposureProgram = 2;
ExposureTime = "0.06666666666666667";
FNumber = "2.2";
Flash = 24;
FocalLenIn35mmFilm = 29;
FocalLength = "4.15";
ISOSpeedRatings = (
40
);
LensMake = Apple;
LensModel = "iPhone 6 Plus back camera 4.15mm f/2.2";
LensSpecification = (
"4.15",
"4.15",
"2.2",
"2.2"
);
MeteringMode = 5;
PixelXDimension = 3264;
PixelYDimension = 2448;
SceneType = 1;
SensingMethod = 2;
ShutterSpeedValue = "3.907056515078773";
SubjectArea = (
1631,
1223,
1795,
1077
);
SubsecTimeDigitized = 603;
SubsecTimeOriginal = 603;
WhiteBalance = 0;
};
"{MakerApple}" = {
1 = 2;
12 = (
"0.453125",
"0.234375"
);
13 = 7;
14 = 0;
15 = 2;
16 = 1;
2 = <15038e01 c6000802 47013f00 4c002600 3d002f00 1e002000 22003300 25005d00 d3004401 81002402 36013a00 30004f00 49002e00 2f002900 78004100 28005300 74000401 4c004f02 da005300 46002a00 29002600 45003700 8d003f00 27004c00 8100e400 29008902 b6003c00 3f002a00 50002800 1d002400 3c003600 3c004500 e6003601 2600d002 a6003100 3d004f00 20002d00 31002500 2a002d00 2d003d00 a800f300 26001003 63003b00 55002100 30003100 4d003400 40004500 30003700 9c00c400 3b004503 88002900 3f002b00 64002b00 1d002b00 3f003f00 32003100 a600b300 ae003603 54004b00 45002700 1f007400 2e002b00 3e003a00 36002c00 cd00e200 82011e03 6e002500 47003000 50003d00 2a003200 3f003800 3c002b00 0e01a901 0303db02 4d005300 4b003000 24002e00 22003300 41003600 40002a00 1701c602 9e03bc02 5d002600 37002f00 2e007d00 28003800 48003300 48002900 8d010e02 9c039a02 45007000 56006000 41001d00 2b003e00 4f003200 55002a00 75017201 52036002 3f004a00 35003100 29003500 2e004000 55003500 5f002b00 cb00d901 68023202 46005000 54007b00 3c007b00 31004500 5f003a00 64002b00 d0014a02 fc021e01 39005a00 2a003200 34002500 33004800 6a004000 65002c00 6201f301 b4029401 40005300 6b004c00 3c006f00 38004700 71004c00 64002e00>;
3 = {
epoch = 0;
flags = 1;
timescale = 1000000000;
value = 1612615985791;
};
4 = 1;
5 = 128;
6 = 114;
7 = 1;
8 = (
"-0.008151573",
"-0.7535641",
"-0.6700104"
);
9 = 531;
};
"{TIFF}" = {
DateTime = "2016:02:17 16:00:38";
Make = Apple;
Model = "iPhone 6 Plus";
Software = "8.2";
XResolution = 72;
YResolution = 72;
};
}
}
And this is my code:
这是我的代码:
// Función a la que se llama cuando el picker es devuelto con un elemento multimedia
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
if let image = info[UIImagePickerControllerOriginalImage] as? UIImage{
if let data = UIImagePNGRepresentation(image){
let metadata = info[UIImagePickerControllerMediaMetadata] as! NSDictionary
debugPrint(metadata)
}
}
}
I am testing with iOS 9. Hope you can help me. Thanks!
我正在测试iOS 9。希望你能帮助我。谢谢!
1 个解决方案
#1
1
I order for the image to have the location, the location service must be active. Then with the following code you can get its coordinates when they exist.
我命令图像有位置,位置服务必须是活动的。然后使用下面的代码,您可以在它们存在的时候得到它的坐标。
if picker.sourceType == UIImagePickerControllerSourceType.PhotoLibrary
{
if let currentLat = pickedLat as CLLocationDegrees?
{
self.latitude = pickedLat!
self.longitude = pickedLong!
}
else
{
var library = ALAssetsLibrary()
library.enumerateGroupsWithTypes(ALAssetsGroupAll, usingBlock: { (group, stop) -> Void in
if (group != nil) {
println("Group is not nil")
println(group.valueForProperty(ALAssetsGroupPropertyName))
group.enumerateAssetsUsingBlock { (asset, index, stop) in
if asset != nil
{
if let location: CLLocation = asset.valueForProperty(ALAssetPropertyLocation) as CLLocation!
{ let lat = location.coordinate.latitude
let long = location.coordinate.longitude
self.latitude = lat
self.longitude = lat
println(lat)
println(long)
}
}
}
} else
{
println("The group is empty!")
}
})
{ (error) -> Void in
println("problem loading albums: \(error)")
}
}
}
Hope it helps.
希望它可以帮助。
From Christian https://*.com/a/26842206/2269679
从基督教https://*.com/a/26842206/2269679
#1
1
I order for the image to have the location, the location service must be active. Then with the following code you can get its coordinates when they exist.
我命令图像有位置,位置服务必须是活动的。然后使用下面的代码,您可以在它们存在的时候得到它的坐标。
if picker.sourceType == UIImagePickerControllerSourceType.PhotoLibrary
{
if let currentLat = pickedLat as CLLocationDegrees?
{
self.latitude = pickedLat!
self.longitude = pickedLong!
}
else
{
var library = ALAssetsLibrary()
library.enumerateGroupsWithTypes(ALAssetsGroupAll, usingBlock: { (group, stop) -> Void in
if (group != nil) {
println("Group is not nil")
println(group.valueForProperty(ALAssetsGroupPropertyName))
group.enumerateAssetsUsingBlock { (asset, index, stop) in
if asset != nil
{
if let location: CLLocation = asset.valueForProperty(ALAssetPropertyLocation) as CLLocation!
{ let lat = location.coordinate.latitude
let long = location.coordinate.longitude
self.latitude = lat
self.longitude = lat
println(lat)
println(long)
}
}
}
} else
{
println("The group is empty!")
}
})
{ (error) -> Void in
println("problem loading albums: \(error)")
}
}
}
Hope it helps.
希望它可以帮助。
From Christian https://*.com/a/26842206/2269679
从基督教https://*.com/a/26842206/2269679