2016-08-15 110 views
0

我嘗試了很多不同的方式,並且在各種方式中,我似乎都失去了現有資產位置上已有的一些信息。從字典中填充CLLocation對象

我正在創建資產的修改副本,並希望將該資產可用的位置信息複製到其修改後的副本中。但CLLocation中可用的方法沒有可用於現有Assets GPS的所有字段。這裏是什麼,是從現有資產:

 "{GPS}" =    { 
      Altitude = "50.4666666666667"; 
      GPSVersion =     (
       2, 
       3, 
       0, 
       0 
      ); 
      ImgDirection = "265.8132992327366"; 
      ImgDirectionRef = T; 
      Latitude = "58.5314"; 
      LatitudeRef = N; 
      Longitude = "21.5112"; 
      LongitudeRef = W; 
      MapDatum = "WGS-84"; 
      Speed = "2.053334425692282"; 
      SpeedRef = K; 
     }; 

與大多數選項的方法可用CLLocation下是如下:

[loc initWithCoordinate:<#(CLLocationCoordinate2D)#> 
     altitude:<#(CLLocationDistance)#> 
     horizontalAccuracy:<#(CLLocationAccuracy)#> 
     verticalAccuracy:<#(CLLocationAccuracy)#> 
     course:<#(CLLocationDirection)#> 
     speed:<#(CLLocationSpeed)#> 
     timestamp:<#(nonnull NSDate *)#>]; 

我仍然似乎失去「ImgDirectionRef」,「LatitudeRef」,「LongitudeRef」 ,'MatDatum','GPSVersion'。

有誰知道我還能做些什麼來確保CLLocation被完全複製到修改後的資產。提前致謝。

回答

0

您需要子類CLLocation以存儲不屬於CLLocation的額外值。例如

#import <CoreLocation/CoreLocation.h> 
@interface CustomLocation : CLLocation 

@property NSInteger ImgDirectionRef; 
//etc 

@end 

然後

CustomLocation *loc; 
[loc initWithCoordinate:<#(CLLocationCoordinate2D)#> 
    altitude:<#(CLLocationDistance)#> 
    horizontalAccuracy:<#(CLLocationAccuracy)#> 
    verticalAccuracy:<#(CLLocationAccuracy)#> 
    course:<#(CLLocationDirection)#> 
    speed:<#(CLLocationSpeed)#> 
    timestamp:<#(nonnull NSDate *)#>]; 

loc.ImgDirectionRef = 123; // your value here 
// set extra values here