From e81cc77c7e2a386fd101a7b93481d691d400a1c7 Mon Sep 17 00:00:00 2001 From: Benjamin Kreuscher Date: Sat, 5 Nov 2022 15:34:36 +0100 Subject: [PATCH 01/12] new function to access files from user repo or PyPI installation --- wahoomc/constants_functions.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/wahoomc/constants_functions.py b/wahoomc/constants_functions.py index 0d1f2545..684c9cf4 100644 --- a/wahoomc/constants_functions.py +++ b/wahoomc/constants_functions.py @@ -12,6 +12,7 @@ from wahoomc import constants from wahoomc.constants import RESOURCES_DIR from wahoomc.constants import TOOLING_WIN_DIR +from wahoomc.constants import USER_WAHOO_MC log = logging.getLogger('main-logger') @@ -174,3 +175,25 @@ def get_tag_wahoo_xml_path(tag_wahoo_xml): return path_tag_wahoo_xml raise TagWahooXmlNotFoundError + + +def get_absolute_dir_user_or_repo(folder, file=''): + """ + return the absolute path to the folder (and file) in this priorization + 1. user dir + 2. wahoomc package dir + + Priorization is important later on because user- should always be used in favor of repo-dir! + """ + absolute_paths = [] + if file: + absolute_paths.append(os.path.join( + USER_WAHOO_MC, '_config', folder, file)) + absolute_paths.append(os.path.join( + RESOURCES_DIR, folder, file)) + else: + absolute_paths.append(os.path.join(USER_WAHOO_MC, folder)) + absolute_paths.append(os.path.join( + RESOURCES_DIR, '_config', folder)) + + return absolute_paths From 30b4e9e554f3479d11421fd8f244ced8025f5950 Mon Sep 17 00:00:00 2001 From: Benjamin Kreuscher Date: Sat, 5 Nov 2022 15:35:15 +0100 Subject: [PATCH 02/12] access tag-wahoo xml from user dir in favor of PyPI installtion --- wahoomc/constants_functions.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wahoomc/constants_functions.py b/wahoomc/constants_functions.py index 684c9cf4..f43f30ee 100644 --- a/wahoomc/constants_functions.py +++ b/wahoomc/constants_functions.py @@ -166,13 +166,13 @@ def get_tooling_win_path(path_in_tooling_win): def get_tag_wahoo_xml_path(tag_wahoo_xml): """ return path to tag-wahoo xml file if the file exists + - from the user directory "USER_WAHOO_MC/_config/tag_wahoo_adjusted/tag_wahoo_xml" + - 2ndly from the PyPI installation: "RESOURCES_DIR/tag_wahoo_adjusted/tag_wahoo_xml" """ - path_tag_wahoo_xml = os.path.join( - RESOURCES_DIR, "tag_wahoo_adjusted", tag_wahoo_xml) - - if os.path.exists(path_tag_wahoo_xml): - return path_tag_wahoo_xml + for path in get_absolute_dir_user_or_repo("tag_wahoo_adjusted", tag_wahoo_xml): + if os.path.exists(path): + return path raise TagWahooXmlNotFoundError From 5f52fae143505d8b27e6c1fe76fe24fb48873ae1 Mon Sep 17 00:00:00 2001 From: Benjamin Kreuscher Date: Sat, 5 Nov 2022 22:01:27 +0100 Subject: [PATCH 03/12] read tags-to-keep from .json instead of constants.py - incl. changing unittests to not mock variables but files and cleaning up the file --- tests/test_constants.py | 63 ++++++----------- wahoomc/constants.py | 29 -------- wahoomc/constants_functions.py | 9 ++- wahoomc/resources/tags-to-keep.json | 106 ++++++++++++++++++++++++++++ 4 files changed, 134 insertions(+), 73 deletions(-) create mode 100644 wahoomc/resources/tags-to-keep.json diff --git a/tests/test_constants.py b/tests/test_constants.py index b20d2f88..17fc9c52 100644 --- a/tests/test_constants.py +++ b/tests/test_constants.py @@ -3,7 +3,7 @@ """ import os import unittest -from mock import patch +import mock from wahoomc.constants_functions import translate_country_input_to_geofabrik, translate_tags_to_keep, \ @@ -43,43 +43,18 @@ def test_translated_countries_no_mapping(self): self.assertEqual(expected, transl_c) -tags_universal_simple = { +tags_universal_simple = {"TAGS_TO_KEEP_UNIVERSAL": { 'access': '', 'area': 'yes' -} +}} -tags_universal_adv = { +tags_universal_adv = {"TAGS_TO_KEEP_UNIVERSAL": { 'access': '', 'area': 'yes', 'bicycle': '', 'bridge': '', 'foot': ['ft_yes', 'foot_designated'] -} - -tags_universal_full = { - 'access': '', - 'area': 'yes', - 'bicycle': '', - 'bridge': '', - 'foot': ['ft_yes', 'foot_designated'], - 'highway': ['abandoned', 'bus_guideway', 'disused', 'bridleway', 'byway', 'construction', 'cycleway', 'footway', 'living_street', 'motorway', 'motorway_link', 'path', 'pedestrian', 'primary', 'primary_link', 'residential', 'road', 'secondary', 'secondary_link', 'service', 'steps', 'tertiary', 'tertiary_link', 'track', 'trunk', 'trunk_link', 'unclassified'], - 'natural': ['coastline', 'nosea', 'sea', 'beach', 'land', 'scrub', 'water', 'wetland', 'wood'], - 'leisure': ['park', 'nature_reserve'], - 'railway': ['abandoned', 'bus_guideway', 'disused', 'funicular', 'light_rail', 'miniature', 'narrow_gauge', 'preserved', 'rail', 'subway', 'tram'], - 'surface': '', - 'tracktype': '', - 'tunnel': '', - 'waterway': ['canal', 'drain', 'river', 'riverbank'], - 'wood': 'deciduous' -} - -name_tags_universal_full = { - 'admin_level': '2', - 'area': 'yes', - 'mountain_pass': '', - 'natural': '', - 'place': ['city', 'hamlet', 'island', 'isolated_dwelling', 'islet', 'locality', 'suburb', 'town', 'village', 'country'] -} +}} class TestTranslateTags(unittest.TestCase): @@ -87,48 +62,55 @@ class TestTranslateTags(unittest.TestCase): tests for translating tags-constants between the universal format and OS-specific formats """ - @patch('wahoomc.constants.TAGS_TO_KEEP_UNIVERSAL', tags_universal_simple) - def test_translate_tags_to_keep_simple_macos(self): + @ mock.patch("wahoomc.file_directory_functions.json.load") + @ mock.patch("wahoomc.open") + def test_translate_tags_to_keep_simple_macos(self, mock_open, mock_json_load): """ Test translating tags to keep from universal format to macOS """ tags = ['access', 'area=yes'] + mock_json_load.return_value = tags_universal_simple transl_tags = translate_tags_to_keep() self.assertEqual(tags, transl_tags) - @patch('wahoomc.constants.TAGS_TO_KEEP_UNIVERSAL', tags_universal_simple) - def test_translate_tags_to_keep_simple_win(self): + @ mock.patch("wahoomc.file_directory_functions.json.load") + @ mock.patch("wahoomc.open") + def test_translate_tags_to_keep_simple_win(self, mock_open, mock_json_load): """ Test translating tags to keep from universal format to Windows """ tags_win = 'access= area=yes' + mock_json_load.return_value = tags_universal_simple transl_tags = translate_tags_to_keep(sys_platform='Windows') self.assertEqual(tags_win, transl_tags) - @patch('wahoomc.constants.TAGS_TO_KEEP_UNIVERSAL', tags_universal_adv) - def test_translate_tags_to_keep_adv_macos(self): + @ mock.patch("wahoomc.file_directory_functions.json.load") + @ mock.patch("wahoomc.open") + def test_translate_tags_to_keep_adv_macos(self, mock_open, mock_json_load): """ Test translating tags to keep from universal format to macOS """ tags = ['access', 'area=yes', 'bicycle', 'bridge', 'foot=ft_yes, foot_designated'] + mock_json_load.return_value = tags_universal_adv transl_tags = translate_tags_to_keep() self.assertEqual(tags, transl_tags) - @patch('wahoomc.constants.TAGS_TO_KEEP_UNIVERSAL', tags_universal_adv) - def test_translate_tags_to_keep_adv_win(self): + @ mock.patch("wahoomc.file_directory_functions.json.load") + @ mock.patch("wahoomc.open") + def test_translate_tags_to_keep_adv_win(self, mock_open, mock_json_load): """ Test translating tags to keep from universal format to Windows """ tags_win = 'access= area=yes bicycle= bridge= foot=ft_yes =foot_designated' + mock_json_load.return_value = tags_universal_adv transl_tags = translate_tags_to_keep(sys_platform='Windows') self.assertEqual(tags_win, transl_tags) - # @patch('wahoomc.constants.TAGS_TO_KEEP_UNIVERSAL', tags_universal_full) def test_translate_tags_to_keep_full_macos(self): """ Test translating tags to keep from universal format to macOS // all "tags to keep" @@ -144,7 +126,6 @@ def test_translate_tags_to_keep_full_macos(self): transl_tags = translate_tags_to_keep() self.assertEqual(tags, transl_tags) - # @patch('wahoomc.constants.TAGS_TO_KEEP_UNIVERSAL', tags_universal_full) def test_translate_tags_to_keep_full_win(self): """ Test translating tags to keep from universal format to Windows // all "tags to keep" @@ -154,7 +135,6 @@ def test_translate_tags_to_keep_full_win(self): transl_tags = translate_tags_to_keep(sys_platform='Windows') self.assertEqual(tags_win, transl_tags) - # @patch('wahoomc.constants.NAME_TAGS_TO_KEEP_UNIVERSAL', name_tags_universal_full) def test_translate_name_tags_to_keep_full_macos(self): """ Test translating name tags to keep from universal format to Windows // all "name tags to keep" @@ -165,7 +145,6 @@ def test_translate_name_tags_to_keep_full_macos(self): transl_tags = translate_tags_to_keep(name_tags=True) self.assertEqual(names_tags, transl_tags) - # @patch('wahoomc.constants.NAME_TAGS_TO_KEEP_UNIVERSAL', name_tags_universal_full) def test_translate_name_tags_to_keep_full_win(self): """ Test translating name tags to keep from universal format to macOS // all "name tags to keep" diff --git a/wahoomc/constants.py b/wahoomc/constants.py index 89a69546..587809a8 100644 --- a/wahoomc/constants.py +++ b/wahoomc/constants.py @@ -244,32 +244,3 @@ # Special_regions like (former) colonies where the map of the wanted region is not present in the map of the parent country. # example Guadeloupe, it's Geofabrik parent country is France but Guadeloupe is not located within the region covered by the map of France. special_regions = ['guadeloupe', 'guyane', 'martinique', 'mayotte', 'reunion'] - -# Tags to keep -TAGS_TO_KEEP_UNIVERSAL = { - 'access': '', - 'area': 'yes', - 'bicycle': '', - 'bridge': '', - 'foot': ['ft_yes', 'foot_designated'], - 'amenity': ['fuel', 'cafe', 'drinking_water'], - 'shop': ['bakery', 'bicycle'], - 'highway': ['abandoned', 'bus_guideway', 'disused', 'bridleway', 'byway', 'construction', 'cycleway', 'footway', 'living_street', 'motorway', 'motorway_link', 'path', 'pedestrian', 'primary', 'primary_link', 'residential', 'road', 'secondary', 'secondary_link', 'service', 'steps', 'tertiary', 'tertiary_link', 'track', 'trunk', 'trunk_link', 'unclassified'], - 'natural': ['coastline', 'nosea', 'sea', 'beach', 'land', 'scrub', 'water', 'wetland', 'wood'], - 'landuse': ['forest', 'commercial', 'industrial', 'residential', 'retail'], - 'leisure': ['park', 'nature_reserve'], - 'railway': ['rail', 'tram', 'station', 'stop'], - 'surface': '', - 'tracktype': '', - 'tunnel': '', - 'waterway': ['canal', 'drain', 'river', 'riverbank'], - 'wood': 'deciduous' -} - -NAME_TAGS_TO_KEEP_UNIVERSAL = { - 'admin_level': '2', - 'area': 'yes', - 'mountain_pass': '', - 'natural': '', - 'place': ['city', 'hamlet', 'island', 'isolated_dwelling', 'islet', 'locality', 'suburb', 'town', 'village', 'country'] -} diff --git a/wahoomc/constants_functions.py b/wahoomc/constants_functions.py index f43f30ee..43ec7983 100644 --- a/wahoomc/constants_functions.py +++ b/wahoomc/constants_functions.py @@ -13,6 +13,7 @@ from wahoomc.constants import RESOURCES_DIR from wahoomc.constants import TOOLING_WIN_DIR from wahoomc.constants import USER_WAHOO_MC +from wahoomc.file_directory_functions import read_json_file_generic log = logging.getLogger('main-logger') @@ -111,10 +112,14 @@ def translate_tags_to_keep(name_tags=False, sys_platform=''): tags_modif = [] + # read tags-to-keep from .json + tags_from_json = read_json_file_generic( + os.path.join(RESOURCES_DIR, 'tags-to-keep.json')) + if not name_tags: - universal_tags = constants.TAGS_TO_KEEP_UNIVERSAL + universal_tags = tags_from_json['TAGS_TO_KEEP_UNIVERSAL'] else: - universal_tags = constants.NAME_TAGS_TO_KEEP_UNIVERSAL + universal_tags = tags_from_json['NAME_TAGS_TO_KEEP_UNIVERSAL'] for tag, value in universal_tags.items(): to_append = transl_tag_value(sys_platform, separator, tag, value) diff --git a/wahoomc/resources/tags-to-keep.json b/wahoomc/resources/tags-to-keep.json new file mode 100644 index 00000000..91505267 --- /dev/null +++ b/wahoomc/resources/tags-to-keep.json @@ -0,0 +1,106 @@ +{ + "TAGS_TO_KEEP_UNIVERSAL": { + "access": "", + "area": "yes", + "bicycle": "", + "bridge": "", + "foot": [ + "ft_yes", + "foot_designated" + ], + "amenity": [ + "fuel", + "cafe", + "drinking_water" + ], + "shop": [ + "bakery", + "bicycle" + ], + "highway": [ + "abandoned", + "bus_guideway", + "disused", + "bridleway", + "byway", + "construction", + "cycleway", + "footway", + "living_street", + "motorway", + "motorway_link", + "path", + "pedestrian", + "primary", + "primary_link", + "residential", + "road", + "secondary", + "secondary_link", + "service", + "steps", + "tertiary", + "tertiary_link", + "track", + "trunk", + "trunk_link", + "unclassified" + ], + "natural": [ + "coastline", + "nosea", + "sea", + "beach", + "land", + "scrub", + "water", + "wetland", + "wood" + ], + "landuse": [ + "forest", + "commercial", + "industrial", + "residential", + "retail" + ], + "leisure": [ + "park", + "nature_reserve" + ], + "railway": [ + "rail", + "tram", + "station", + "stop" + ], + "surface": "", + "tracktype": "", + "tunnel": "", + "waterway": [ + "canal", + "drain", + "river", + "riverbank" + ], + "wood": "deciduous" + }, + "NAME_TAGS_TO_KEEP_UNIVERSAL": { + "admin_level": "2", + "area": "yes", + "mountain_pass": "", + "natural": "", + "place": [ + "city", + "hamlet", + "island", + "isolated_dwelling", + "islet", + "locality", + "suburb", + "town", + "village", + "country" + ] + } +} \ No newline at end of file From 14541722a1ca2ade18e8e8daf9862272325a5a1d Mon Sep 17 00:00:00 2001 From: Benjamin Kreuscher Date: Mon, 7 Nov 2022 20:06:13 +0100 Subject: [PATCH 04/12] access tags-to-keep .json from user dir in favor of PyPI installtion --- wahoomc/constants_functions.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/wahoomc/constants_functions.py b/wahoomc/constants_functions.py index 43ec7983..92c5aeb5 100644 --- a/wahoomc/constants_functions.py +++ b/wahoomc/constants_functions.py @@ -22,6 +22,10 @@ class TagWahooXmlNotFoundError(Exception): """Raised when the specified tag-wahoo xml file does not exist""" +class TagsToKeepNotFoundError(Exception): + """Raised when the specified tags to keep .json file does not exist""" + + def get_region_of_country(county): """ returns the region / continent of a given country @@ -112,9 +116,14 @@ def translate_tags_to_keep(name_tags=False, sys_platform=''): tags_modif = [] - # read tags-to-keep from .json - tags_from_json = read_json_file_generic( - os.path.join(RESOURCES_DIR, 'tags-to-keep.json')) + # read tags-to-keep .json from user-dir in favor of python installation + for path in get_absolute_dir_user_or_repo('', file='tags-to-keep.json'): + if os.path.exists(path): + tags_from_json = read_json_file_generic(path) + break + + if not tags_from_json: + raise TagsToKeepNotFoundError if not name_tags: universal_tags = tags_from_json['TAGS_TO_KEEP_UNIVERSAL'] From 45c797109b5a905b52f566ea779d03a122ecff52 Mon Sep 17 00:00:00 2001 From: Benjamin Kreuscher Date: Sat, 12 Nov 2022 16:44:35 +0100 Subject: [PATCH 05/12] force using .json file from repo for unittests for unittesting it makes not sense to read the user-dir. The result would not be equal in all cases --- tests/test_constants.py | 9 +++++---- wahoomc/constants_functions.py | 18 +++++++++++++----- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/tests/test_constants.py b/tests/test_constants.py index 17fc9c52..4146d0fb 100644 --- a/tests/test_constants.py +++ b/tests/test_constants.py @@ -123,7 +123,7 @@ def test_translate_tags_to_keep_full_macos(self): 'leisure=park, nature_reserve', 'railway=rail, tram, station, stop', 'surface', 'tracktype', 'tunnel', 'waterway=canal, drain, river, riverbank', 'wood=deciduous'] - transl_tags = translate_tags_to_keep() + transl_tags = translate_tags_to_keep(use_repo=True) self.assertEqual(tags, transl_tags) def test_translate_tags_to_keep_full_win(self): @@ -132,7 +132,8 @@ def test_translate_tags_to_keep_full_win(self): """ tags_win = 'access= area=yes bicycle= bridge= foot=ft_yes =foot_designated amenity=fuel =cafe =drinking_water shop=bakery =bicycle highway=abandoned =bus_guideway =disused =bridleway =byway =construction =cycleway =footway =living_street =motorway =motorway_link =path =pedestrian =primary =primary_link =residential =road =secondary =secondary_link =service =steps =tertiary =tertiary_link =track =trunk =trunk_link =unclassified natural=coastline =nosea =sea =beach =land =scrub =water =wetland =wood landuse=forest =commercial =industrial =residential =retail leisure=park =nature_reserve railway=rail =tram =station =stop surface= tracktype= tunnel= waterway=canal =drain =river =riverbank wood=deciduous' - transl_tags = translate_tags_to_keep(sys_platform='Windows') + transl_tags = translate_tags_to_keep( + sys_platform='Windows', use_repo=True) self.assertEqual(tags_win, transl_tags) def test_translate_name_tags_to_keep_full_macos(self): @@ -142,7 +143,7 @@ def test_translate_name_tags_to_keep_full_macos(self): names_tags = ['admin_level=2', 'area=yes', 'mountain_pass', 'natural', 'place=city, hamlet, island, isolated_dwelling, islet, locality, suburb, town, village, country'] - transl_tags = translate_tags_to_keep(name_tags=True) + transl_tags = translate_tags_to_keep(name_tags=True, use_repo=True) self.assertEqual(names_tags, transl_tags) def test_translate_name_tags_to_keep_full_win(self): @@ -153,7 +154,7 @@ def test_translate_name_tags_to_keep_full_win(self): names_tags_win = 'admin_level=2 area=yes mountain_pass= natural= place=city =hamlet =island =isolated_dwelling =islet =locality =suburb =town =village =country' transl_tags = translate_tags_to_keep( - name_tags=True, sys_platform='Windows') + name_tags=True, sys_platform='Windows', use_repo=True) self.assertEqual(names_tags_win, transl_tags) diff --git a/wahoomc/constants_functions.py b/wahoomc/constants_functions.py index 92c5aeb5..ce89f979 100644 --- a/wahoomc/constants_functions.py +++ b/wahoomc/constants_functions.py @@ -104,7 +104,7 @@ def translate_country_input_to_geofabrik(county): return c_translated -def translate_tags_to_keep(name_tags=False, sys_platform=''): +def translate_tags_to_keep(name_tags=False, sys_platform='', use_repo=False): """ translates the given tags to format of the operating system. """ @@ -117,10 +117,18 @@ def translate_tags_to_keep(name_tags=False, sys_platform=''): tags_modif = [] # read tags-to-keep .json from user-dir in favor of python installation - for path in get_absolute_dir_user_or_repo('', file='tags-to-keep.json'): - if os.path.exists(path): - tags_from_json = read_json_file_generic(path) - break + # evaluate path first: user-dir in favor of PyPI installation + if not use_repo: + for path in get_absolute_dir_user_or_repo('', file='tags-to-keep.json'): + if os.path.exists(path): + break + # force using file from repo - used in unittests for equal output + else: + path = get_absolute_dir_user_or_repo( + '', file='tags-to-keep.json')[1] + + # read the tags from the evaluated path above + tags_from_json = read_json_file_generic(path) if not tags_from_json: raise TagsToKeepNotFoundError From d2f3a33e1bde7aa55b211ca14813aeda6e8a0fa4 Mon Sep 17 00:00:00 2001 From: Benjamin Kreuscher Date: Sat, 12 Nov 2022 16:52:06 +0100 Subject: [PATCH 06/12] delete tag-wahoo .xml files I am not aware of what they do they are coming from https://github.com/treee111/wahooMapsCreator/pull/38 and https://github.com/treee111/wahooMapsCreator/pull/34 but might most probably not be used actually. With this PR, users can have their own tag-wahoo .xml file in the user-directory --- .../tag_wahoo_adjusted/tag-wahoo-hidrive2.xml | 117 -------------- .../tag_wahoo_adjusted/tag-wahoo-v12.xml | 116 ------------- .../tag_wahoo_adjusted/tag-wahoo_2.xml | 152 ------------------ 3 files changed, 385 deletions(-) delete mode 100644 wahoomc/resources/tag_wahoo_adjusted/tag-wahoo-hidrive2.xml delete mode 100644 wahoomc/resources/tag_wahoo_adjusted/tag-wahoo-v12.xml delete mode 100644 wahoomc/resources/tag_wahoo_adjusted/tag-wahoo_2.xml diff --git a/wahoomc/resources/tag_wahoo_adjusted/tag-wahoo-hidrive2.xml b/wahoomc/resources/tag_wahoo_adjusted/tag-wahoo-hidrive2.xml deleted file mode 100644 index ee2644d8..00000000 --- a/wahoomc/resources/tag_wahoo_adjusted/tag-wahoo-hidrive2.xml +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/wahoomc/resources/tag_wahoo_adjusted/tag-wahoo-v12.xml b/wahoomc/resources/tag_wahoo_adjusted/tag-wahoo-v12.xml deleted file mode 100644 index 85520a22..00000000 --- a/wahoomc/resources/tag_wahoo_adjusted/tag-wahoo-v12.xml +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/wahoomc/resources/tag_wahoo_adjusted/tag-wahoo_2.xml b/wahoomc/resources/tag_wahoo_adjusted/tag-wahoo_2.xml deleted file mode 100644 index d01a327d..00000000 --- a/wahoomc/resources/tag_wahoo_adjusted/tag-wahoo_2.xml +++ /dev/null @@ -1,152 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 8972d7467b850d5a35412bd778af9398feaed246 Mon Sep 17 00:00:00 2001 From: Benjamin Kreuscher Date: Sat, 12 Nov 2022 21:34:10 +0100 Subject: [PATCH 07/12] move initialization of dirs and version adjustments up - initialization needed for windows tooling. Needs to be before check of required programs --- wahoomc/main.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/wahoomc/main.py b/wahoomc/main.py index 2a71210e..55292ff5 100644 --- a/wahoomc/main.py +++ b/wahoomc/main.py @@ -29,6 +29,8 @@ def run(): logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.INFO) + initialize_work_directories() + adjustments_due_to_breaking_changes() check_installation_of_required_programs() # handle GUI and CLI processing via one function and different cli-calls @@ -40,9 +42,6 @@ def run(): # Is there something to do? o_input_data.is_required_input_given_or_exit(issue_message=True) - adjustments_due_to_breaking_changes() - initialize_work_directories() - o_osm_data = OsmData() # Check for not existing or expired files. Mark for download, if dl is needed o_downloader = o_osm_data.process_input_of_the_tool(o_input_data) From 33743a5e186c2e86fa747e6914339c7f3d891165 Mon Sep 17 00:00:00 2001 From: Benjamin Kreuscher Date: Sat, 12 Nov 2022 21:56:52 +0100 Subject: [PATCH 08/12] correction of user-dir vs. repo-dir - incl. usage of constant for user config directory - incl. creation of user config directory on start --- wahoomc/constants.py | 1 + wahoomc/constants_functions.py | 8 ++++---- wahoomc/setup_functions.py | 2 ++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/wahoomc/constants.py b/wahoomc/constants.py index 587809a8..67d27f2e 100644 --- a/wahoomc/constants.py +++ b/wahoomc/constants.py @@ -14,6 +14,7 @@ USER_DL_DIR, 'land-polygons-split-4326', 'land_polygons.shp') GEOFABRIK_PATH = os.path.join(USER_DL_DIR, 'geofabrik.json') USER_OUTPUT_DIR = os.path.join(USER_WAHOO_MC, '_tiles') +USER_CONFIG_DIR = os.path.join(USER_WAHOO_MC, '_config') # Python Package - wahooMapsCreator directory WAHOO_MC_DIR = os.path.dirname(__file__) diff --git a/wahoomc/constants_functions.py b/wahoomc/constants_functions.py index ce89f979..593f06fc 100644 --- a/wahoomc/constants_functions.py +++ b/wahoomc/constants_functions.py @@ -12,7 +12,7 @@ from wahoomc import constants from wahoomc.constants import RESOURCES_DIR from wahoomc.constants import TOOLING_WIN_DIR -from wahoomc.constants import USER_WAHOO_MC +from wahoomc.constants import USER_CONFIG_DIR from wahoomc.file_directory_functions import read_json_file_generic log = logging.getLogger('main-logger') @@ -210,12 +210,12 @@ def get_absolute_dir_user_or_repo(folder, file=''): absolute_paths = [] if file: absolute_paths.append(os.path.join( - USER_WAHOO_MC, '_config', folder, file)) + USER_CONFIG_DIR, folder, file)) absolute_paths.append(os.path.join( RESOURCES_DIR, folder, file)) else: - absolute_paths.append(os.path.join(USER_WAHOO_MC, folder)) + absolute_paths.append(os.path.join(USER_CONFIG_DIR, folder)) absolute_paths.append(os.path.join( - RESOURCES_DIR, '_config', folder)) + RESOURCES_DIR, folder)) return absolute_paths diff --git a/wahoomc/setup_functions.py b/wahoomc/setup_functions.py index a9f149a8..0332bf70 100644 --- a/wahoomc/setup_functions.py +++ b/wahoomc/setup_functions.py @@ -21,6 +21,7 @@ from wahoomc.constants import USER_DL_DIR from wahoomc.constants import USER_MAPS_DIR from wahoomc.constants import USER_OUTPUT_DIR +from wahoomc.constants import USER_CONFIG_DIR from wahoomc.constants import VERSION log = logging.getLogger('main-logger') @@ -36,6 +37,7 @@ def initialize_work_directories(): os.makedirs(USER_DL_DIR, exist_ok=True) os.makedirs(USER_MAPS_DIR, exist_ok=True) os.makedirs(USER_OUTPUT_DIR, exist_ok=True) + os.makedirs(USER_CONFIG_DIR, exist_ok=True) def move_old_content_into_new_dirs(): From 8ca2a709a9e48c2f62ce883adc12377359444979 Mon Sep 17 00:00:00 2001 From: Benjamin Kreuscher Date: Sat, 12 Nov 2022 23:16:55 +0100 Subject: [PATCH 09/12] new init function to copy files from python package to user dir --- .vscode/launch.json | 8 ++++ wahoomc/__main__.py | 2 +- wahoomc/file_directory_functions.py | 69 ++++++++++++++++++++++++++++ wahoomc/init/__init__.py | 0 wahoomc/init/__main__.py | 7 +++ wahoomc/input.py | 19 ++++++++ wahoomc/main.py | 71 ++++++++++++++++------------- wahoomc/setup_functions.py | 21 ++++++++- 8 files changed, 162 insertions(+), 35 deletions(-) create mode 100644 wahoomc/init/__init__.py create mode 100644 wahoomc/init/__main__.py diff --git a/.vscode/launch.json b/.vscode/launch.json index 7abd21d5..412f06b6 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -149,6 +149,14 @@ "-h" ] }, + { + "name": "cli.init", + "type": "python", + "request": "launch", + "module": "wahoomc.init", + "console": "integratedTerminal", + "args": [] + }, { "name": "x/y: 133/88 (germany&france)", "type": "python", diff --git a/wahoomc/__main__.py b/wahoomc/__main__.py index d2deeee8..a503c24e 100644 --- a/wahoomc/__main__.py +++ b/wahoomc/__main__.py @@ -4,4 +4,4 @@ from wahoomc import main if __name__ == '__main__': - main.run() + main.run("run") diff --git a/wahoomc/file_directory_functions.py b/wahoomc/file_directory_functions.py index 8ea54442..cee115c9 100644 --- a/wahoomc/file_directory_functions.py +++ b/wahoomc/file_directory_functions.py @@ -47,6 +47,9 @@ def move_content(src_folder_name, dst_path): """ copy files from source directory of to destination directory delete source directory afterwards + + similar function to copy_or_move_files_and_folder but without user-request when overwriting + and only support for directories """ # build path to old folder on the same level as wahooMapsCreator par_dir = os.path.abspath(os.path.join(os.path.join( @@ -200,3 +203,69 @@ def delete_o5m_pbf_files_in_folder(folder): os.remove(os.path.join(folder, file)) except OSError: pass + + +def copy_or_move_files_and_folder(from_path, to_path, delete_from_dir=False): + """ + copy content from source directory to destination directory + optionally delete source directory afterwards + + similar function to move_content but with user-request when overwriting and support for files + """ + # check if from path/file exists at all + if os.path.exists(from_path): + + # given path is a directory + if os.path.isdir(from_path): + # first create the to-directory if not already there + os.makedirs(to_path, exist_ok=True) + + for item in os.listdir(from_path): + from_item = os.path.join(from_path, item) + to_item = os.path.join(to_path, item) + + # copy directory + if os.path.isdir(from_item): + copy_directory_w_user_input(from_item, to_item) + + # copy file + else: + copy_file_w_user_input(from_item, to_item) + + # given path is a file + else: + copy_file_w_user_input(from_path, to_path) + + # directory + if delete_from_dir: + shutil.rmtree(from_path) + + +def copy_directory_w_user_input(from_item, to_item): + """ + copy content from source directory to destination directory + """ + if not os.path.isdir(to_item): + shutil.copytree(from_item, to_item) + else: + val = input(f"{to_item} exists already. Overwrite? (y/n):") + if val == 'y': + shutil.copytree(from_item, to_item) + log.info('! %s overwritten', to_item) + else: + log.debug('! %s not copied, exists already.', to_item) + + +def copy_file_w_user_input(from_item, to_item): + """ + copy source file to destination file + """ + if not os.path.isfile(to_item): + shutil.copy2(from_item, to_item) + else: + val = input(f"{to_item} exists already. Overwrite? (y/n):") + if val == 'y': + shutil.copy2(from_item, to_item) + log.info('! %s overwritten', to_item) + else: + log.debug('! %s not copied, exists already.', to_item) diff --git a/wahoomc/init/__init__.py b/wahoomc/init/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/wahoomc/init/__main__.py b/wahoomc/init/__main__.py new file mode 100644 index 00000000..963b73d9 --- /dev/null +++ b/wahoomc/init/__main__.py @@ -0,0 +1,7 @@ +""" +can be directly called via `python -m wahoomc.init -h` +""" +from wahoomc import main + +if __name__ == '__main__': + main.run("init") diff --git a/wahoomc/input.py b/wahoomc/input.py index 871419e7..6e84cca3 100644 --- a/wahoomc/input.py +++ b/wahoomc/input.py @@ -114,6 +114,25 @@ def process_call_of_the_tool(): return o_input_data +def cli_init(): + """ + Provides cli for initialization of user directory + """ + + parser = argparse.ArgumentParser( + description='Copy config files to user directory') + parser.add_argument('-v', '--verbose', action='store_true', + help="output debug logger messages") + + args = parser.parse_args() + + # cli processing + o_input_data = InputData() + o_input_data.verbose = args.verbose + + return o_input_data + + def create_checkbox(self, default_value, description, row): """ this is a reuse function for creating checkboxes. diff --git a/wahoomc/main.py b/wahoomc/main.py index 55292ff5..9bc8b4e9 100644 --- a/wahoomc/main.py +++ b/wahoomc/main.py @@ -7,10 +7,10 @@ import logging # import custom python packages -from wahoomc.input import process_call_of_the_tool +from wahoomc.input import process_call_of_the_tool, cli_init from wahoomc.setup_functions import initialize_work_directories, \ check_installation_of_required_programs, write_config_file, \ - adjustments_due_to_breaking_changes + adjustments_due_to_breaking_changes, copy_jsons_from_repo_to_user from wahoomc.osm_maps_functions import OsmMaps from wahoomc.osm_maps_functions import OsmData @@ -21,7 +21,7 @@ # + means additional comment in a working-unit -def run(): +def run(run_level): """ main program run """ @@ -33,50 +33,57 @@ def run(): adjustments_due_to_breaking_changes() check_installation_of_required_programs() - # handle GUI and CLI processing via one function and different cli-calls - o_input_data = process_call_of_the_tool() + if run_level == 'init': + o_input_data = cli_init() + else: + # handle GUI and CLI processing via one function and different cli-calls + o_input_data = process_call_of_the_tool() if o_input_data.verbose: logging.getLogger().setLevel(logging.DEBUG) - # Is there something to do? - o_input_data.is_required_input_given_or_exit(issue_message=True) + if run_level == 'init': + copy_jsons_from_repo_to_user('tag_wahoo_adjusted') + copy_jsons_from_repo_to_user('.', 'tags-to-keep.json') + else: + # Is there something to do? + o_input_data.is_required_input_given_or_exit(issue_message=True) - o_osm_data = OsmData() - # Check for not existing or expired files. Mark for download, if dl is needed - o_downloader = o_osm_data.process_input_of_the_tool(o_input_data) + o_osm_data = OsmData() + # Check for not existing or expired files. Mark for download, if dl is needed + o_downloader = o_osm_data.process_input_of_the_tool(o_input_data) - # Download files marked for download - o_downloader.download_files_if_needed() + # Download files marked for download + o_downloader.download_files_if_needed() - o_osm_maps = OsmMaps(o_osm_data) + o_osm_maps = OsmMaps(o_osm_data) - # Filter tags from country osm.pbf files' - o_osm_maps.filter_tags_from_country_osm_pbf_files() + # Filter tags from country osm.pbf files' + o_osm_maps.filter_tags_from_country_osm_pbf_files() - # Generate land - o_osm_maps.generate_land() + # Generate land + o_osm_maps.generate_land() - # Generate sea - o_osm_maps.generate_sea() + # Generate sea + o_osm_maps.generate_sea() - # Split filtered country files to tiles - o_osm_maps.split_filtered_country_files_to_tiles() + # Split filtered country files to tiles + o_osm_maps.split_filtered_country_files_to_tiles() - # Merge splitted tiles with land an sea - o_osm_maps.merge_splitted_tiles_with_land_and_sea( - o_input_data.process_border_countries) + # Merge splitted tiles with land an sea + o_osm_maps.merge_splitted_tiles_with_land_and_sea( + o_input_data.process_border_countries) - # Creating .map files - o_osm_maps.create_map_files(o_input_data.save_cruiser, - o_input_data.tag_wahoo_xml) + # Creating .map files + o_osm_maps.create_map_files(o_input_data.save_cruiser, + o_input_data.tag_wahoo_xml) - # Zip .map.lzma files - o_osm_maps.make_and_zip_files('.map.lzma', o_input_data.zip_folder) + # Zip .map.lzma files + o_osm_maps.make_and_zip_files('.map.lzma', o_input_data.zip_folder) - # Make Cruiser map files zip file - if o_input_data.save_cruiser is True: - o_osm_maps.make_and_zip_files('.map', o_input_data.zip_folder) + # Make Cruiser map files zip file + if o_input_data.save_cruiser is True: + o_osm_maps.make_and_zip_files('.map', o_input_data.zip_folder) # run was successful --> write config file write_config_file() diff --git a/wahoomc/setup_functions.py b/wahoomc/setup_functions.py index 0332bf70..ffd7cfb7 100644 --- a/wahoomc/setup_functions.py +++ b/wahoomc/setup_functions.py @@ -14,8 +14,8 @@ # import custom python packages from wahoomc.file_directory_functions import move_content, write_json_file_generic, \ - read_json_file_generic, delete_o5m_pbf_files_in_folder -from wahoomc.constants_functions import get_tooling_win_path + read_json_file_generic, delete_o5m_pbf_files_in_folder, copy_or_move_files_and_folder +from wahoomc.constants_functions import get_tooling_win_path, get_absolute_dir_user_or_repo from wahoomc.constants import USER_WAHOO_MC from wahoomc.constants import USER_DL_DIR @@ -180,3 +180,20 @@ def read_version_last_run(): version_last_run = None return version_last_run + + +def copy_jsons_from_repo_to_user(folder, file=''): + """ + copies files from wahoomc repo/package to the user-directory + """ + absolute_paths = get_absolute_dir_user_or_repo(folder, file) + + log.debug('# Copy "%s" files from repo to directory if not existing: %s', + folder, absolute_paths[0]) + + # copy files of gitcommon package directory to user directory + copy_or_move_files_and_folder( + absolute_paths[1], absolute_paths[0], delete_from_dir=False) + + log.info('# Copy "%s" files from repo or gitcommon to directory if not existing: %s : OK', + folder, absolute_paths[0]) From 0d89f2d2cdcac2894e7e367e9c4d6a252d80af12 Mon Sep 17 00:00:00 2001 From: Benjamin Kreuscher Date: Sun, 13 Nov 2022 09:15:05 +0100 Subject: [PATCH 10/12] fix pylint findings --- tests/test_constants.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_constants.py b/tests/test_constants.py index 4146d0fb..0ee6a2e4 100644 --- a/tests/test_constants.py +++ b/tests/test_constants.py @@ -64,7 +64,7 @@ class TestTranslateTags(unittest.TestCase): @ mock.patch("wahoomc.file_directory_functions.json.load") @ mock.patch("wahoomc.open") - def test_translate_tags_to_keep_simple_macos(self, mock_open, mock_json_load): + def test_translate_tags_to_keep_simple_macos(self, mock_open, mock_json_load): # pylint: disable=unused-argument """ Test translating tags to keep from universal format to macOS """ @@ -76,7 +76,7 @@ def test_translate_tags_to_keep_simple_macos(self, mock_open, mock_json_load): @ mock.patch("wahoomc.file_directory_functions.json.load") @ mock.patch("wahoomc.open") - def test_translate_tags_to_keep_simple_win(self, mock_open, mock_json_load): + def test_translate_tags_to_keep_simple_win(self, mock_open, mock_json_load): # pylint: disable=unused-argument """ Test translating tags to keep from universal format to Windows """ @@ -88,7 +88,7 @@ def test_translate_tags_to_keep_simple_win(self, mock_open, mock_json_load): @ mock.patch("wahoomc.file_directory_functions.json.load") @ mock.patch("wahoomc.open") - def test_translate_tags_to_keep_adv_macos(self, mock_open, mock_json_load): + def test_translate_tags_to_keep_adv_macos(self, mock_open, mock_json_load): # pylint: disable=unused-argument """ Test translating tags to keep from universal format to macOS """ @@ -101,7 +101,7 @@ def test_translate_tags_to_keep_adv_macos(self, mock_open, mock_json_load): @ mock.patch("wahoomc.file_directory_functions.json.load") @ mock.patch("wahoomc.open") - def test_translate_tags_to_keep_adv_win(self, mock_open, mock_json_load): + def test_translate_tags_to_keep_adv_win(self, mock_open, mock_json_load): # pylint: disable=unused-argument """ Test translating tags to keep from universal format to Windows """ From 3f847a818fe73e1b55248705eb7efb5a2efc935c Mon Sep 17 00:00:00 2001 From: Benjamin Kreuscher Date: Sun, 13 Nov 2022 23:52:30 +0100 Subject: [PATCH 11/12] insert user-dir to docu and shorten README --- README.md | 12 ++++++------ docs/TAGS_ON_MAP_AND_DEVICE.md | 35 ++++++++++++++++++++++++++++------ docs/USAGE.md | 19 ++++++++++++++++-- 3 files changed, 52 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 9b435409..bc38f4a7 100644 --- a/README.md +++ b/README.md @@ -12,19 +12,16 @@

-

Wahoo Maps Creator

+

wahooMapsCreator

-A tool to create up-to-date maps for your Wahoo BOLTv1 and BOLTv2, ROAM, ROAMv2 and ELEMNT! +wahooMapsCreator is a tool to create up-to-date maps for your Wahoo BOLTv1 and BOLTv2, ROAM, ROAMv2 and ELEMNT! It runs on Windows, macOS as well as on Linux! -## Basic Overview -WahooMapsCreator is a tool to create maps based on the latest OSM data for your Wahoo devices. You can generate maps for the countries you like and you can control which OSM-tags are included. +You can generate maps for the countries you like and you can control which OSM-tags are included based on latest OSM data. The maps of your device may be old because Wahoo did not release a newer version in the last years. -OSM maps are constantly updated. With this program, the updated maps can be used on our Wahoo. - # Get it running The instructions are intended to be suitable for beginners. @@ -33,6 +30,9 @@ If anything is unclear or seams wrong, write an [:pencil2: issue](https://github ## Brand-New: Get POIs displayed on your Wahoo! [:cookie: here](docs/USAGE.md#pois---points-of-interest) +## Brand-New: Control OSM tags to be included in your maps! +[:wrench: here](docs/USAGE.md#user-specific-configuration) + ## Download and Install required programs Using Anaconda to setup a virtual Python environment is the fastest way to get wahooMapsCreator running! diff --git a/docs/TAGS_ON_MAP_AND_DEVICE.md b/docs/TAGS_ON_MAP_AND_DEVICE.md index c9ce748a..c9f94b8c 100644 --- a/docs/TAGS_ON_MAP_AND_DEVICE.md +++ b/docs/TAGS_ON_MAP_AND_DEVICE.md @@ -1,18 +1,32 @@ # OSM-tags during map creation and on your device #### Table of contents +- [Order of generating maps](#order-of-generating-maps) - [Zoom levels and scale](#zoom-levels-and-scale) -- [File tag-wahoo.xml](#file-tag-wahooxml) - - [Attribute "zoom-appear"](#attribute-zoom-appear) +- [Files used in map processing](#files-used-in-map-processing) + - [File tags-to-keep.json](#file-tags-to-keepjson) + - [File tag-wahoo.xml](#file-tag-wahooxml) + - [Attribute "zoom-appear"](#attribute-zoom-appear) + - [Combination of tags-to-keep.json and tag-wahoo.xml](#combination-of-tags-to-keepjson-and-tag-wahooxml) - [Device-Theme](#device-theme) - [Attribute "zoom-min"](#attribute-zoom-min) - [Copy the theme to the device](#copy-the-theme-to-the-device) - [Use the theme in cruiser](#use-the-theme-in-cruiser) -- [Combination of tag-wahoo.xml and device-theme](#combination-of-tag-wahooxml-and-device-theme) + - [Combination of tag-wahoo.xml and device-theme](#combination-of-tag-wahooxml-and-device-theme) - [Adjustments of the device themes](#adjustments-of-the-device-themes) - [mapsforge-bolt.xml](#mapsforge-boltxml) +# Order of generating maps +There are mainly 4 steps to process maps from raw OSM data to the final maps for the Wahoo device. You'll find them in the following list with links to the files you can control yourself. + +1. Filter relevant OSM tags from raw OSM country files - [tags-to-keep.json](#file-tags-to-keepjson) +2. Create different map increments per tile: OSM map, land and sea +3. Merge these map increments into a merged .osm.pbf file +4. Create .map file while applying tag-wahoo.xml to the merged .osm.pbf file - [tag-wahoo.xml](#file-tag-wahooxml) + +For a OSM tag in the map to be displayed on your Wahoo device, it needs to be rendered using the [device theme](#device-theme). + # Zoom levels and scale | Zoom level | Scale | | ---------- | :---: | @@ -26,15 +40,24 @@ That information were derived from cruiser on macOS. It needs to be checked if the zoom level and scale on cruiser and Wahoo device is exactly the same or if there is a difference. -# File tag-wahoo.xml +# Files used in map processing +## File tags-to-keep.json +The `tags-to-keep.json` file controls which tags and name-tags will stay on the map. This happens to keep the file of the generated maps low by filtering out out all other information from the downloaded OSM maps. + +## File tag-wahoo.xml The `tag-wahoo.xml` files defines how to proceed wit OSM-elements during map generation. The OSM-tags defined in the tag-wahoo.xml are stored in the map file. E.g. roads, locations, ... -## Attribute "zoom-appear" +### Attribute "zoom-appear" Each entry has a "zoom-appear" attribute, which defines from which zoom level onwards the element will be stored in the map. If zoom-appear is set to 13, the OSM-tag will be stored in the 500m, 200m and 100m zoom levels and therefore could be rendered. +### Combination of tags-to-keep.json and tag-wahoo.xml +To bring a certain OSM tag to your generated maps they have to be included in both files. You can have a look at existing OSM tags to get +1. `tags-to-keep.json` to not be filtered out +2. `tag-wahoo.xml` to be included in the generated maps + # Device-Theme The device theme defines, which OSM-tags are rendered on the device. In cruiser, you can also apply the device theme to preview generated maps on your computer. @@ -60,7 +83,7 @@ See [here](COPY_TO_WAHOO.md#Copy-device-theme) You should always use the corresponding theme in cruiser if you preview generated maps on your computer. Because the theme kind of determines what you're gonna see, you want to preview what later on will be visible on the device. -# Combination of tag-wahoo.xml and device-theme +## Combination of tag-wahoo.xml and device-theme This zoom-appear in combination with the settings in the theme on the device (which can also be applied in cruiser) controls when certain elements are shown on our BOLT/ROAM etc (zoom-min). If a element is included in the map beginning from zoom level 10 (zoom-appear in tag-wahoo.xml) but on the device only displayed beginning with zoom level 12 (zoom-min in mapsforge-bolt.xml), the element is only displayed beginning zoom level 12. diff --git a/docs/USAGE.md b/docs/USAGE.md index a0b59a91..ac19902c 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -1,7 +1,7 @@ # Usage of wahooMapsCreator #### Table of contents - [Usage of wahooMapsCreator](#usage-of-wahoomapscreator) - - [Always activate environment first](#always-activate-environment-first) + - [Always activate environment first](#always-activate-environment-first) - [Run wahooMapsCreator for your country](#run-wahoomapscreator-for-your-country) - [GUI (Graphical User Interface)](#gui-graphical-user-interface) - [CLI (Command Line Interface)](#cli-command-line-interface) @@ -9,6 +9,7 @@ - [Main arguments](#main-arguments) - [Examples](#examples) - [POIs - Points of Interest](#pois---points-of-interest) + - [User specific configuration](#user-specific-configuration) # Usage of wahooMapsCreator wahooMapsCreator can be used in two different ways: @@ -17,7 +18,10 @@ wahooMapsCreator can be used in two different ways: Both ways support the same arguments to be used for the map-creation process. You can choose the arguments via GUI or as [CLI-arguments](#advanced-cli-usage). -### Always activate environment first +## Always activate environment first +``` +conda activate gdal-user +``` ## Run wahooMapsCreator for your country It might be a good idea to run wahooMapsCreator first for a small country e.g. Malta to check if everything is running fine. @@ -79,3 +83,14 @@ Actually, wahooMapsCreator includes fuel stations, backeries, cafes and railway 3. Activate VTM rendering if needed - [see here](COPY_TO_WAHOO.md#activate-vtm-rendering) - see also: https://github.com/treee111/wahooMapsCreator/wiki/Enable-hidden-features + +## User specific configuration +You can control popular configuration with your own files in the home directory `wahooMapsCreatorData/_config`. + +Actually, it is possible to control which OSM tags will stay on the map while filtering tags ([documentation](TAGS_ON_MAP_AND_DEVICE.md#file-tags-to-keepjson)) with `~/wahooMapsCreatorData/_config/tags-to-keep.json` . Furthermore, you can control which and how OSM tags will be included in the generated maps with tag-wahoo .xml ([documentation](TAGS_ON_MAP_AND_DEVICE.md#file-tag-wahooxml)) in directory `~/wahooMapsCreatorData/_config/tag_wahoo_adjusted/` and specify the file via `-tag` argument or via GUI. + +You can start the tool with `python -m wahoomc.init` to copy the files from the python module to the user directory. You'll have a structure and can change the files to your needs. + +The tool searches for configuration in your home directory first and secondly (fallback) in the python installation. If a file is in both directories with the same name, the file of the user directory will be used. + +The structure of `~/wahooMapsCreatorData/_config/tag_wahoo_adjusted/` is analogue to the one in the repo: `wahooMapsCreatorwahoomc/resources`. From 7d9226aae9a21fbf19ea083f1cc428325722a057 Mon Sep 17 00:00:00 2001 From: Benjamin Kreuscher Date: Sun, 13 Nov 2022 23:55:31 +0100 Subject: [PATCH 12/12] insert table of arguments --- docs/USAGE.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/USAGE.md b/docs/USAGE.md index ac19902c..890fb310 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -46,10 +46,27 @@ Examples: - for Ireland: `python -m wahoomc cli -co ireland` ## Advanced CLI-Usage -The script supports many arguments via command line. +wahooMapsCreator supports many arguments via command line. For a list of all supported arguments, run: - `python -m wahoomc cli -h` + +wahooMapsCreator provides following arguments. + +| Option | Description | Mandatory | Default Value | +| :-------- | :-------------------------------------------------------------------------------------------------------------- | :-------- | :------------------ | +| gui / cli | Start graphical user interface to select options or run the tool via command line interface. | X | - | +| -co / -xy | Country to create maps or X/Y coordinates to create maps for. X/Y as `133/35`. | X | - | +| -md | Maximum age of source maps and other files in days. | - | 24 | +| -nbc | Do not process border countries of tiles involving more than one country. Only useful when processing a country | - | false | +| -fd | Force download of files. Download all files new. | - | false | +| -fp | Force processing of files. Create all files new. | - | false | +| -c | Save uncompressed maps for Cruiser. | - | false | +| -tag | File with tags to keep in the output. | - | `tag-wahoo-poi.xml` | +| -gt | Calculate tiles based on geofabrik index-v1.json file. | - | false | +| -z | Zip the country (and country-maps) folder. | - | false | +| -v | Output debug logger messages. | - | false | + ### Main arguments **Create maps for a country** - `python -m wahoomc cli -co `