Skip to content

Commit

Permalink
Use short name for thoroughfare if it's used in the formatted address
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Chae committed Oct 29, 2015
1 parent 85ef3da commit da8c361
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions SVGeocoder/SVPlacemark.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,14 @@ - (id)initWithDictionary:(NSDictionary *)result {
if([types containsObject:@"street_number"])
self.subThoroughfare = [component objectForKey:@"long_name"];

if([types containsObject:@"route"])
self.thoroughfare = [component objectForKey:@"long_name"];
if([types containsObject:@"route"]) {
NSString *shortName = [component objectForKey:@"short_name"];
if ([self.formattedAddress rangeOfString:shortName].location != NSNotFound) {
self.thoroughfare = shortName;
} else {
self.thoroughfare = [component objectForKey:@"long_name"];
}
}

if([types containsObject:@"administrative_area_level_3"] || [types containsObject:@"sublocality"] || [types containsObject:@"neighborhood"])
self.subLocality = [component objectForKey:@"long_name"];
Expand Down

0 comments on commit da8c361

Please sign in to comment.