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

[FIX] handle USA json country names via conversion of _ to - #137

Merged
merged 2 commits into from
Jun 27, 2022
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
30 changes: 30 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,36 @@
"100",
"-om"
]
},
{
"name": "american_samoa #135",
"type": "python",
"request": "launch",
"module": "wahoomc",
"console": "integratedTerminal",
"args": [
"cli",
"-co",
"american_samoa",
"-c",
"-md",
"100",
]
},
{
"name": "commonwealth_of_the_northern_mariana_islands #135",
"type": "python",
"request": "launch",
"module": "wahoomc",
"console": "integratedTerminal",
"args": [
"cli",
"-co",
"commonwealth_of_the_northern_mariana_islands",
"-c",
"-md",
"100",
]
}
]
}
17 changes: 15 additions & 2 deletions wahoomc/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,20 @@
'western_sahara': 'morocco',
'qatar': 'gcc-states',
'åland': 'finland',
'new_mexico': 'new-mexico'
'new_mexico': 'new-mexico',
'american_samoa': 'samoa',
'commonwealth_of_the_northern_mariana_islands': 'american-oceania',
'northern_mariana_islands': 'american-oceania',
'new_york': 'new-york',
'new_hampshire': 'new-hampshire',
'new_jersey': 'new-jersey',
'rhode_island': 'rhode-island',
'district_of_columbia': 'district-of-columbia',
'north_carolina': 'north-carolina',
'south_carolina': 'south-carolina',
'north_dakota': 'north-dakota',
'south_dakota': 'south-dakota',
'west_virginia': 'west-virginia'
}

continents = ['europe', 'unitedstates', 'north-america', 'south-america', 'asia', 'oceania',
Expand Down Expand Up @@ -166,7 +179,7 @@
'pakistan', 'philippines', 'russian federation', 'south-korea', 'sri-lanka', 'syria',
'taiwan', 'tajikistan', 'thailand', 'turkmenistan', 'uzbekistan', 'vietnam', 'yemen']

australiaoceania_geofabrik = ['american oceania', 'australia', 'cook islands', 'fiji',
australiaoceania_geofabrik = ['american-oceania', 'australia', 'cook islands', 'fiji',
'île de clipperton', 'kiribati', 'marshall islands', 'micronesia', 'nauru',
'new caledonia', 'new zealand', 'niue', 'palau', 'papua new guinea',
'pitcairn islands', 'polynesie-francaise', 'samoa', 'solomon islands', 'tokelau',
Expand Down
21 changes: 7 additions & 14 deletions wahoomc/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,29 +64,22 @@ def download_file(target_filepath, url, is_zip):

def get_osm_pbf_filepath_url(country):
"""
evaluate a countries' OSM file URL and download filepath
build the geofabrik download url to a countries' OSM file and download filepath
"""

# get .osm.pbf region of country
url = build_url_for_country_osm_pbf_download(country)
map_file_path = os.path.join(
USER_MAPS_DIR, f'{country}' + '-latest.osm.pbf')
# return URL and download filepath
return map_file_path, url


def build_url_for_country_osm_pbf_download(country):
"""
build the geofabrik download url to a countries' OSM file
"""
transl_c = const_fct.translate_country_input_to_geofabrik(country)
region = const_fct.get_geofabrik_region_of_country(country)
if region != 'no':
url = 'https://download.geofabrik.de/' + region + \
'/' + transl_c + '-latest.osm.pbf'
else:
url = 'https://download.geofabrik.de/' + transl_c + '-latest.osm.pbf'
return url

map_file_path = os.path.join(
USER_MAPS_DIR, f'{transl_c}' + '-latest.osm.pbf')

# return URL and download filepath
return map_file_path, url


class Downloader:
Expand Down