This is an Objective-C Module to reverse geocode country without any geocoding service API, the reverse geocoding is done offline using static country polygon data from a JSON file. Light weight reverse geocoder that uses approximated country boundaries. The method will return the country name for a given latitude and longitude.
The country reverse geocoder files are available in the ReverseGeocodeCountry
folder.
Add the following files to your project:
- ReverseGeocodeCountry.h
- ReverseGeocodeCountry.m
- ReverseGeocodeCountry.json
Initializing object:
ReverseGeocodeCountry *reverseGeocode = [[ReverseGeocodeCountry alloc] init];
Method to get Reverse Geocoded Country Name:
- (NSString*) getCountry: (float) lat : (float) lng;
lat
and lng
are the latitude and longitude of the point to be reverse geocoded and the method will return the country name string or an empty string if there is no country in the reverse geocoded point.
Example:
NSString *countryName = [reverseGeocode getCountry:lat :lng];
There is a iOS sample project countrymap
included in this repo which uses the ReverseGeocodeCountry
module to update the name of country based on where the map is dragged.
The JSON data for country polygon and the reverse geocoding algorithm used in this module was implemented based on the country-reverse-geocoding nodejs module available at https://github.com/teleportd/country-reverse-geocoding
ReverseGeocodeCountry is licensed under the terms of the MIT License