From da8c36121d4cced43db83f930e3ac548b38996fa Mon Sep 17 00:00:00 2001 From: Andrew Chae Date: Thu, 22 Oct 2015 19:49:18 -0700 Subject: [PATCH] Use short name for thoroughfare if it's used in the formatted address --- SVGeocoder/SVPlacemark.m | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/SVGeocoder/SVPlacemark.m b/SVGeocoder/SVPlacemark.m index 1f34cb9..dea4f12 100644 --- a/SVGeocoder/SVPlacemark.m +++ b/SVGeocoder/SVPlacemark.m @@ -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"];