Skip to content
Merged
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
25 changes: 25 additions & 0 deletions tests/test_constants_geofabrik.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,31 @@ def test_regions_of_geofabrik(self):
self.assertCountEqual(geofabrik_regions,
regions_geofabrik)

def test_continents_of_geofabrik(self):
"""
the continent selection must only contain the continents - the geofabrik
entries without a parent. Countries like 'germany' and sub-regions of a
country like 'baden-wuerttemberg' are part of geofabrik_regions but must
not show up here
"""
continents = self.o_geofabrik_json.get_continents()

self.assertCountEqual(continents,
['africa', 'antarctica', 'asia', 'australia-oceania',
'central-america', 'europe', 'north-america',
'south-america', 'russia'])

# no returned entry has a parent
for continent in continents:
self.assertNotIn(
'parent', self.o_geofabrik_json.geofabrik_overview[continent])

# countries and their sub-regions are regions but no continents
for entry in ['germany', 'france', 'united-kingdom', 'canada',
'baden-wuerttemberg', 'bayern', 'england', 'nunavut']:
self.assertIn(entry, self.o_geofabrik_json.geofabrik_regions)
self.assertNotIn(entry, continents)

def test_reading_geofabrik_parent(self):
"""
go through all files in the wahoo_mc/resources/json directory
Expand Down
10 changes: 10 additions & 0 deletions wahoomc/geofabrik_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ def read_geofabrik_json_file(self):

return raw_json, geofabrik_overview, geofabrik_region_overview, geofabrik_regions

def get_continents(self):
"""
return the continents - the geofabrik entries without a parent

geofabrik_regions can not be used for this because it holds every map
having children. Besides the continents these are countries like
'germany' and even sub-regions of a country like 'baden-wuerttemberg'
"""
return sorted(self.geofabrik_region_overview)

def get_geofabrik_parent_country(self, id_no):
"""
Get the parent map/region of a country from the already loaded json data
Expand Down
8 changes: 4 additions & 4 deletions wahoomc/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,13 @@ def __init__(self, parent, oInputData):

# Labels
self.lab_top = tk.Label(
self, text="Select continent/country and country/region to create a map")
self.lab_continent = tk.Label(self, text="Select continent/country:")
self.lab_country = tk.Label(self, text='Select country/region:')
self, text="Select continent and country to create a map")
self.lab_continent = tk.Label(self, text="Select continent:")
self.lab_country = tk.Label(self, text='Select country:')

# Comboboxes
self.cb_continent = ttk.Combobox(
self, values=GeofabrikJson().geofabrik_regions, state="readonly")
self, values=GeofabrikJson().get_continents(), state="readonly")
self.cb_continent.current(0) # pre-select first entry in combobox
self.cb_continent.bind("<<ComboboxSelected>>", self.callback_continent)

Expand Down
Loading