From f429ed8b079b04c88c46aec80e5ed0de194be0ef Mon Sep 17 00:00:00 2001 From: rolux Date: Sun, 18 Aug 2013 11:56:48 +0200 Subject: [PATCH] add geo.split_geoname --- ox/geo.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ox/geo.py b/ox/geo.py index f879bfe..66967eb 100644 --- a/ox/geo.py +++ b/ox/geo.py @@ -1929,3 +1929,19 @@ def normalize_country_name(country_name): name = country['name'] break return name and name.decode('utf-8') + +def split_geoname(geoname): + if isinstance(geoname, unicode): + geoname = geoname.encode('utf-8') + countries = [ + 'Bonaire, Sint Eustatius and Saba', + 'Saint Helena, Ascension and Tristan da Cunha' + ] + for country in countries: + if geoname.endswith(country): + geoname = geoname.replace(country, country.replace(', ', '; ')) + split = geoname.split(', ') + for country in countries: + if geoname.endswith(country.replace(', ', '; ')): + split[-1] = country + return split