2016-11-10 11 views
0

AVAsset (또는 AVURLAsset)은 AVMetadataCommonKeyLocation의 공통 키일 수있는 배열의 AVMetadataItem을 배열에 포함합니다. 해당 항목의AVMetadataItem의 GPS 문자열을 CLLocation으로 변환

값은 같은 형식으로 표시 문자열 :

+ 39.9410-075.2040 + 007.371/

어떻게 당신이 CLLocation에 해당 문자열을 변환합니까?

답변

0

좋아요. 문자열이 ISO 6709 형식이며, 관련 Apple 샘플 코드를 찾은 후에 알아 냈습니다.

+ (NSString*)iso6709StringFromCLLocation:(CLLocation*)location 
{ 
    //Comes in like 
    //+39.9410-075.2040+007.371/ 
    //Goes out like 
    //+39.9410-075.2040/ 
    if (location) { 
     return [NSString stringWithFormat:@"%+08.4f%+09.4f/", 
      location.coordinate.latitude, 
      location.coordinate.longitude]; 
    } else { 
     return nil; 
    } 
} 
: 여기에 다시 변환하는 코드입니다, 또한 AVLocationPlayer

:

NSString* locationDescription = [item stringValue]; 

NSString *latitude = [locationDescription substringToIndex:8]; 
NSString *longitude = [locationDescription substringWithRange:NSMakeRange(8, 9)]; 

CLLocation* location = [[CLLocation alloc] initWithLatitude:latitude.doubleValue 
                longitude:longitude.doubleValue]; 

다음은 애플 샘플 코드입니다