-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathwahoo_map_creator.py
86 lines (63 loc) · 2.27 KB
/
wahoo_map_creator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
"""
executable file to create up-to-date map-files for the Wahoo ELEMNT and Wahoo ELEMNT BOLT
"""
#!/usr/bin/python
# import official python packages
import multiprocessing
import sys
# import custom python packages
from common_resources.osm_maps_functions import OsmMaps
########### Configurable Parameters
# Maximum age of source maps or land shape files before they are redownloaded
MAX_DAYS_OLD = 14
# Calculate also border countries of input country or not
CALC_BORDER_COUNTRIES = True
# Force download of source maps and the land shape file
# If False use Max_Days_Old to check for expired maps
# If True force redownloading of maps and landshape
FORCE_DOWNLOAD = False
# Force (re)processing of source maps and the land shape file
# If False use Max_Days_Old to check for expired maps
# If True force processing of maps and landshape
FORCE_PROCESSING = False
# Save uncompressed maps for Cruiser
SAVE_CRUISER = 0
# Number of threads to use in the mapwriter plug-in
THREADS = str(multiprocessing.cpu_count() - 1)
if int(THREADS) < 1:
THREADS = 1
# Or set it manually to:
#threads = 1
#print(f'threads = {threads}/n')
# Number of workers for the Osmosis read binary fast function
WORKERS = '1'
########### End of Configurable Parameters
# logging
# # means top-level command
# ! means error
# + means additional comment in a working-unit
if len(sys.argv) != 2:
print(f'! Usage: {sys.argv[0]} Country name part of a .json file.')
sys.exit()
oOSMmaps = OsmMaps(FORCE_PROCESSING, WORKERS, SAVE_CRUISER)
# Read json file
# Check for expired land polygons file and download, if too old
# Check for expired .osm.pbf files and download, if too old
oOSMmaps.process_input(sys.argv[1], CALC_BORDER_COUNTRIES)
oOSMmaps.check_and_download_files(MAX_DAYS_OLD, FORCE_DOWNLOAD)
# Filter tags from country osm.pbf files'
oOSMmaps.filter_tags_from_country_osm_pbf_files()
# Generate land
oOSMmaps.generate_land()
# Generate sea
oOSMmaps.generate_sea()
# Split filtered country files to tiles
oOSMmaps.split_filtered_country_files_to_tiles()
# Merge splitted tiles with land an sea
oOSMmaps.merge_splitted_tiles_with_land_and_sea()
# Creating .map files
oOSMmaps.create_map_files(THREADS)
# Zip .map.lzma files
oOSMmaps.zip_map_files()
# Make Cruiser map files zip file
oOSMmaps.make_cruiser_files()