2016-09-28 6 views
1

フォトライブラリーから2つの日付とI am getting the images successfullyの範囲でイメージを取得しようとしています。iOSのPHAssetを使用して画像の緯度と経度を取得する方法は?

また、以下のコードを使用して画像の情報も取得しています。

PHContentEditingInputRequestOptions *options = [[PHContentEditingInputRequestOptions alloc] init]; 
     options.networkAccessAllowed = YES; //download asset metadata from iCloud if needed 

     [asset requestContentEditingInputWithOptions:options completionHandler:^(PHContentEditingInput *contentEditingInput, NSDictionary *info) { 
      CIImage *fullImage = [CIImage imageWithContentsOfURL:contentEditingInput.fullSizeImageURL]; 

      //NSLog(@"fullImage=%@", fullImage.properties.description); 


     }]; 

しかし、画像情報は私に文字列形式を与えます。

私はそれをNSDictionary形式に変換しようとしました。

画像の緯度および経度はどのように取得できますか?

取得するための別の方法があるかどうかの情報は

は、事前にありがとう私を助けてください

答えて

1

あなたはすでにあなたが言うように、あなたが持っている(PHAssetsを持っている場合は何もする必要はありませんそれらを正常に検索しました)。

必要なものは.location PHAssetのプロパティです。基本的にCLLocationのインスタンスです。すでに正常にPHFetchResultを得ているので、今あなたがPHAssetオブジェクトを取得し、利用可能な場合、それから位置情報を取得するためにそれを反復処理する必要があり、

asset.location.coordinate.longitude 

または

asset.location.coordinate.latitude 

を:あなたはそれが好き使用することができます。 、辞書の形でPHAssetからGPS情報を取得し、このメソッドを追加するには:

-(NSMutableDictionary *) getGPSInformationForAsset: (PHAsset *) asset 
{ 
    NSString *longitude = [NSString stringWithFormat:@"%f",asset.location.coordinate.longitude]; 
    NSString *latitude = [NSString stringWithFormat:@"%f",asset.location.coordinate.latitude]; 
    NSMutableDictionary *dic = [[NSMutableDictionary alloc] init]; 
    [dic setValue:longitude forKey:@"longitude"];//Perform proper validation here for whatever your requirements are 
    [dic setValue:latitude forKey:@"latitude"]; 
    return dic; 
} 

今のように、このメソッドを使用します。それだ

NSMutableDictionary *coordinatesDictionary = [self getGPSInformationForAsset:asset]; 

、あなたは辞書で緯度と経度を得ました。

関連する問題