Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated countries geo json #6

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions APOfflineReverseGeocoding/APCountry.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* @return APCountry
*/
+ (instancetype)countryWithGEODictionary:(NSDictionary *)dictionary;
+ (instancetype _Nonnull)countryWithGEODictionary:(NSDictionary * _Nonnull)dictionary;

/**
* Designated initializer.
Expand All @@ -27,34 +27,34 @@
*
* @return APCountry
*/
- (instancetype)initWithGeoDictionary:(NSDictionary *)dictionary NS_DESIGNATED_INITIALIZER;
- (instancetype _Nullable)initWithGeoDictionary:(NSDictionary * _Nonnull)dictionary NS_DESIGNATED_INITIALIZER;

/* Represents country 3 digits code ISO 3166-1 Alpha 3 */
@property (nonatomic, copy, readonly) NSString *code;
@property (nonatomic, copy, readonly, nullable) NSString *code;

/* Represents country 2 digits code ISO 3166-1 Alpha 2 */
@property (nonatomic, copy, readonly) NSString *shortCode;
@property (nonatomic, copy, readonly, nullable) NSString *shortCode;

/* Represents country name */
@property (nonatomic, copy, readonly) NSString *name;
@property (nonatomic, copy, readonly, nullable) NSString *name;

/* Represents country name in current locale */
@property (nonatomic, copy, readonly) NSString *localizedName;
@property (nonatomic, copy, readonly, nullable) NSString *localizedName;

/* Represents country currency code */
@property (nonatomic, copy, readonly) NSString *currencyCode;
@property (nonatomic, copy, readonly, nullable) NSString *currencyCode;

/* Represents country currency symbol */
@property (nonatomic, copy, readonly) NSString *currencySymbol;
@property (nonatomic, copy, readonly, nullable) NSString *currencySymbol;

/* Represents country calendar */
@property (nonatomic, strong, readonly) NSCalendar *calendar;
@property (nonatomic, strong, readonly, nullable) NSCalendar *calendar;

@end

@interface APCountry (Unavailable)

- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype _Nullable)init NS_UNAVAILABLE;
+ (instancetype _Nullable)new NS_UNAVAILABLE;

@end
@end
4 changes: 2 additions & 2 deletions APOfflineReverseGeocoding/APCountry.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ - (instancetype)initWithGeoDictionary:(NSDictionary *)dictionary
self = [super init];
if (self) {
/* Set default values */
_code = dictionary[@"id"];
_name = dictionary[@"properties"][@"name"];
_code = dictionary[@"properties"][@"ISO_A3"];
_name = dictionary[@"properties"][@"NAME"];

/* Extract additional info from the code */
APCountryInfoBuilder *infoBuilder = [APCountryInfoBuilder builderWithCountryCode:_code];
Expand Down
2 changes: 1 addition & 1 deletion APOfflineReverseGeocoding/APReverseGeocoding.m
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ - (NSDictionary *)geoJSON
if (!error) {
_geoJSON = [parsedJSON copy];
} else {
[NSException raise:@"Cannot parse JSON." format:@"JSON URL - %@\nError:%@", self.url, parsedJSON];
[NSException raise:@"Cannot parse JSON." format:@"JSON URL - %@\nError:%@", self.url, error];
}
}
return _geoJSON;
Expand Down
441 changes: 248 additions & 193 deletions APOfflineReverseGeocoding/GeoJSON/countries.geo.json
100755 → 100644

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ - (void)testCountryImported {

NSString *countryId = @"USA";
NSString *countryName = @"United States";
NSDictionary *geoDictionary = @{@"id":countryId, @"properties":@{@"name":countryName}};

NSDictionary *geoDictionary = @{@"properties":@{@"NAME":countryName, @"ISO_A3": countryId}};

APCountry *country = [APCountry countryWithGEODictionary:geoDictionary];
XCTAssertEqual(country.code, countryId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ - (void)testURLImported {
/* Multipolygon */
- (void)testNewYorkCoordinatesGeocodesUSA
{
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(40.7142700, -74.0059700);
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(40.61643493, -73.99224019);
APReverseGeocoding *geocoding = [APReverseGeocoding defaultGeocoding];
APCountry *country = [geocoding geocodeCountryWithCoordinate:coordinate];

Expand All @@ -44,6 +44,26 @@ - (void)testKievCoordinatesGeocodesUkraine
XCTAssertTrue([country.code isEqualToString:@"UKR"]);
}

/* Polygon */
- (void)testSingaporeCoordinatesGeocodesSingapore
{
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(1.352083, 103.819839);
APReverseGeocoding *geocoding = [APReverseGeocoding defaultGeocoding];
APCountry *country = [geocoding geocodeCountryWithCoordinate:coordinate];

XCTAssertTrue([country.code isEqualToString:@"SGP"]);
}

/* Polygon */
- (void)testHongkongCoordinatesGeocodesHongkong
{
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(22.396427, 114.109497);
APReverseGeocoding *geocoding = [APReverseGeocoding defaultGeocoding];
APCountry *country = [geocoding geocodeCountryWithCoordinate:coordinate];

XCTAssertTrue([country.code isEqualToString:@"HKG"]);
}

- (void)testPerformanceNewYorkGeocoding {

[self measureBlock:^{
Expand Down