@@ -38,6 +38,18 @@ - (id)initWithImage:(NSData *)image atLocation:(CGPoint)location withDelegate:(i
38
38
self.image = image;
39
39
self.location = location;
40
40
41
+ NSString *localeIdentifier = [[NSLocale currentLocale ] localeIdentifier ];
42
+ NSRegularExpression * regex = [NSRegularExpression regularExpressionWithPattern: @" @.*"
43
+ options: NSRegularExpressionCaseInsensitive
44
+ error: nil ];
45
+ NSString *localeIdentifierWithoutCalendar = [regex stringByReplacingMatchesInString: localeIdentifier
46
+ options: 0
47
+ range: NSMakeRange (0 , [localeIdentifier length ])
48
+ withTemplate: @" " ];
49
+
50
+ self.locale = localeIdentifierWithoutCalendar;
51
+ self.language = [[NSLocale preferredLanguages ] objectAtIndex: 0 ];
52
+
41
53
self.placemark = placemark;
42
54
self.deviceId = deviceId;
43
55
@@ -49,24 +61,19 @@ - (id)initWithImage:(NSData *)image atLocation:(CGPoint)location withDelegate:(i
49
61
50
62
- (NSDictionary *)buildRequestParameters
51
63
{
52
- NSString *localeIdentifier = [[NSLocale currentLocale ] localeIdentifier ];
53
- NSRegularExpression * regex = [NSRegularExpression regularExpressionWithPattern: @" @.*"
54
- options: NSRegularExpressionCaseInsensitive
55
- error: nil ];
56
- NSString *localeIdentifierWithoutCalendar = [regex stringByReplacingMatchesInString: localeIdentifier
57
- options: 0
58
- range: NSMakeRange (0 , [localeIdentifier length ])
59
- withTemplate: @" " ];
60
64
61
65
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary: @{
62
- @" image_request[locale]" : localeIdentifierWithoutCalendar,
63
- @" image_request[language]" : [[NSLocale preferredLanguages ] objectAtIndex: 0 ],
64
- @" image_request[device_id]" : self.deviceId ,
66
+ @" image_request[locale]" : self.locale ,
67
+ @" image_request[language]" : self.language ,
65
68
@" image_request[latitude]" : [NSNumber numberWithDouble: self .placemark.coordinate.latitude],
66
69
@" image_request[longitude]" : [NSNumber numberWithDouble: self .placemark.coordinate.longitude],
67
70
@" image_request[altitude]" : [NSNumber numberWithDouble: self .placemark.altitude]
68
71
}];
69
72
73
+ if (self.deviceId != nil ) {
74
+ [params setValue: self .deviceId forKey: @" image_request[device_id]" ];
75
+ }
76
+
70
77
if (self.location .x != 0.000000 || self.location .y != 0.000000 ) {
71
78
NSString *focusX = [[NSString alloc ]initWithFormat:@" %f " , self .location.x];
72
79
[params setValue: focusX forKey: @" focus[x]" ];
0 commit comments