diff --git a/.vscode/settings.json b/.vscode/settings.json index 934c2f6d..6e439517 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -10,5 +10,11 @@ // "python.testing.nosetestsEnabled": false, "python.testing.unittestEnabled": true, "editor.formatOnSave": true, - "python.analysis.indexing": true + "python.analysis.indexing": true, + "github.copilot.enable": { + "*": false, + "plaintext": false, + "markdown": false, + "scminput": false + } } \ No newline at end of file diff --git a/README.md b/README.md index 8b5d29bf..9361f689 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,8 @@ python -m wahoomc gui ## To further adjust... * [:cookie: Get POIs displayed on your Wahoo](docs/USAGE.md#pois---points-of-interest) +* [:bike: Integrate Wandrer into the generated maps](docs/WANDRER-INTEGRATION.md) + * [:mount_fuji: Integrate contour lines into the generated maps](docs/USAGE.md#pois---points-of-interest) * [:wrench: Control OSM tags to be included in your maps ](docs/USAGE.md#user-specific-configuration) @@ -72,4 +74,4 @@ More details can be found here: [CONTRIBUTING](docs/CONTRIBUTING.md#contributing [@macdet](https://github.com/macdet) for bringing in new thoughts, testing and making this a little more public -[@vti](https://github.com/vti) for creating a GUI application to copy maps to wahoo and configure the device [POIs](https://github.com/vti/elemntary) as well as an [docker image](https://github.com/vti/wahooMapsCreator-docker) for wahooMapsCreator! \ No newline at end of file +[@vti](https://github.com/vti) for creating a GUI application to copy maps to wahoo and configure the device [POIs](https://github.com/vti/elemntary) as well as an [docker image](https://github.com/vti/wahooMapsCreator-docker) for wahooMapsCreator! diff --git a/device_themes/vtm_theme_poi/vtm-elemnt.xml b/device_themes/vtm_theme_poi/vtm-elemnt.xml index 2a6661c9..2c094682 100644 --- a/device_themes/vtm_theme_poi/vtm-elemnt.xml +++ b/device_themes/vtm_theme_poi/vtm-elemnt.xml @@ -466,13 +466,7 @@ - - - - - - @@ -730,6 +724,9 @@ + + + diff --git a/docs/QUICKSTART_ANACONDA.md b/docs/QUICKSTART_ANACONDA.md index 53cd2831..8f574de1 100644 --- a/docs/QUICKSTART_ANACONDA.md +++ b/docs/QUICKSTART_ANACONDA.md @@ -13,6 +13,7 @@ - [Create Anaconda environment](#create-anaconda-environment) - [Install wahooMapsCreator into Anaconda environment](#install-wahoomapscreator-into-anaconda-environment) - [Update wahooMapsCreator](#update-wahoomapscreator) + - [Additional programs for integrating Wandrer data](#additional-programs-to-integrate-wandrer-files) - [Additional programs for generating contour lines](#additional-programs-for-generating-contour-lines) - [Install phyghtmap](#install-phyghtmap) - [Verify phyghtmap](#verify-phyghtmap) @@ -103,6 +104,17 @@ If you want to upgrade to a version other than the release actual one, use this pip install wahoomc==2.0.0a5 --upgrade ``` +## Additional programs to integrate Wandrer files +To integrate your progress in Wandrer to the generated maps you will need to install GPSBabel + +Windows +Download and install from https://www.gpsbabel.org/download.html +Don't forget to add the path to gpsbabel.exe to the path environment variable! + +macOS / Linux +Download and install from the same link as the Windows version or use the homebrew install here +https://formulae.brew.sh/formula/gpsbabel + ## Additional programs for generating contour lines For integrating contour lines into the generated maps, some additional steps need to be taken. An additional Python packages has to be installed and you need an free account for USGS to query contour lines from. diff --git a/docs/USAGE.md b/docs/USAGE.md index 35660b03..376205a9 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -10,6 +10,7 @@ - [Main arguments](#main-arguments) - [Examples](#examples) - [POIs - Points of Interest](#pois---points-of-interest) + - [Wandrer integration](#wandrer-integration) - [Contour lines](#contour-lines) - [User specific configuration](#user-specific-configuration) @@ -80,6 +81,7 @@ If you like to run wahooMapsCreator with another value than the default, use the | -z | Zip the country (and country-maps) folder. | false | | -v | Output debug logger messages. | false | | -hdd | Use mapwriters hdd mode, 'type=hd' parameter. Slower processing, but good for low memory systems. | false | +| -dw | Integrate your Wandrer files to the maps generated. | false | ### Main arguments **Create maps for a country** @@ -115,6 +117,12 @@ Actually, wahooMapsCreator includes fuel stations, backeries, cafes and railway - [see here](COPY_TO_WAHOO.md#activate-vtm-rendering) - see also: https://github.com/treee111/wahooMapsCreator/wiki/Enable-hidden-features +## Wandrer integration +For creating maps that contain your traveled roads progress as recorded on the Wandrer site (https://wandrer.earth) do the following: +1. Enhance your Anaconda environment using [these steps](./QUICKSTART_ANACONDA.md#additional-programs-to-integrate-wandrer-files) +2. Create custom maps with the argument `-dw` like [normally](#run-wahoomapscreator-for-your-country). You will have to provide your Wandrer files in the Maps directory of your install. +3. Use a theme that renders untraveled roads. + ## Contour lines For creating maps which include contour lines and have them displayed on your Wahoo device, these steps need to be done: 1. Enhance your Anaconda environment using [these steps](./QUICKSTART_ANACONDA.md#additions-for--generating-contour-lines) diff --git a/docs/WANDRER-INTEGRATION.md b/docs/WANDRER-INTEGRATION.md new file mode 100644 index 00000000..92c58285 --- /dev/null +++ b/docs/WANDRER-INTEGRATION.md @@ -0,0 +1,89 @@ +# Adding Wandrer data to the maps +## What is Wandrer? +Wandrer is a (paid)subscription service that keeps track of which roads you have cycled and/or walked and which you have not traveled (yet). +It does this by importing tracks from your (free) Strava account. A subscription to Strava is not needed. +The free, test, version of Wandrer is limited to 50 imported Strava tracks. +More info is available in the Wandrer faq here: https://wandrer.earth/faq + +The basic idea of Strava is to motivate you by letting you 'compete' against others, but let's be honest, there comes a time when you just know you are not going to be number 1 on speed or number of attempts anymore and the motivational push of Strava fades... +Or it just doesn't do it for you anymore. + +Enter Wandrer. Instead of competing against others you can try to ride every road in a city, state/region or country etc! The motivation is to get as much roads ridden as you can. +Instead of always riding the same old roads as always, explore new areas that turn out to be around the corner. +Better yet, you can still compete against others through the leaderbord system based on distance and percentage of an area covered. + +## What does it look like? +Here you have a Cruiser screenshot of a map without Wandrer integration +
+

+ Screenshot of map without Wandrer integration +

+
+ +With Wandrer integration the same map can look like this (depending on the theme used) Untraveled roads are show as red stippled. As you can see most of the roads on the upper side of this image are 'untraveled'. +
+

+ Screenshot of map with Wandrer integration +

+
+ +An actual on device screenshot can look like this. Again untraveled roads in a red stipple. +
+

+ Ace screenshot of map with Wandrer integration +

+
+ +## OK, great! I created a Wandrer account and everything from Strava is synced. How do I create these maps? +Of course you need to do the normal WahooMapsCreator installation first: +[:rocket: Quick Start Guide to download and install required programs](docs/QUICKSTART_ANACONDA.md#download-and-install-required-programs) + +And to get you a bit familiar with the program read the following link and generate a small country like Malta for example to make sure all is set up correctly and working: +[:computer: Run wahooMapsCreator - detailled usage description](docs/USAGE.md#usage-of-wahoomapscreator) + +Next, go to the Wandrer website and open up the 'Big Map' view. Zoom in/out until the display shows the region you want to have integrated in your maps AND the download icon in the right side bar (see pointer in next image) isn't greyed out any more. +If it is greyed out, zoom in until it turns solid. If needed you can integrate multiple Wandrer maps to your map to cover a larger area or add other area's. +Now press the download icon the pointer in the next image is pointing at and take over the settings show. +
+

+ Screenshot showing how to download the Wandrer data +

+
+After pressing 'Continue' the Wandrer site will start creating your download file. When it is ready you will get an email with a download link and some additional information. + +## Phew, pulled it of, whats next? +Copy the downloaded Wandrer KMZ file(s) to the _downloads\maps folder of your WahooMapsCreator installation without changing the filenames(!) and create the map for your desired region or x/y tile as normal. +Make sure to enable the "Integrate Wandrer files" on the Advanced settings tab when using the gui or add the -dw command line option when using the cli. + +Thats it. + +Now upload the generated maps to your device as usual. +If you are not using it already, try out VTI's Elemntary app for the uploads. It makes doing these kind of things so very much easier than by using abd https://github.com/vti/elemntary +One note on it though, do not use the settings in the Hidden features section. MAP_PAN_ZOOM just does not work anymore after a Wahoo firmware update and only use VTM_RENDERING on a v1 device. i.e. Elemntary, Bolt 1 or Roam 1. +If you do use it on a unit that already uses VTM rendering (all >v1 units) it will revert to acting like a v1 unit!!! + +For people with existing installs of WahooMapsCreator, make sure to use the updated versions of tags-to-keep.json, tag-wahoo-poi.xml and the theme vtm_theme_poi\vtm-elemnt.xml. + +If you want to keep your own version of any of these files you need to update them with the, few, changes made in these files which are easily found by searching them for "wandrer" + +## Good to know: +The Wandrer kmz files you put in the maps folder are converted to osm.pbf files and the kmz file is renamed to processed-(wandrer file name). +The map, when on your device, is of cource not dynamically updated. i.e. untraveled red stippled roads will NOT magically turn 'unstippled' on the device after you ride them. +To update the untravelled status of roads you will need to re-download the region from Wandrer and re-generate the map. +When copying the new kmz file to the maps directory don't forget to remove the now obsolete old wandrer.osm.pbf file(s)! + +Multiple Wandrer files are supported but all must be added and processed in one run or be completely part of another tile. Why? two reasons, you can very easily get into the situation where +two files have a, part of, the same region. An older file can have some roads marked as untraveled and a newer file can than have the same roads marked as traveled. +The result is a conflict and most likely the roads will still be shown as untraveled. + +The other reason is more technical and more important. The osm.pbf files generated from the KML files by GPSBabel during the conversion to osm.pbf have negative way id's. +All converted files start with an id of -1 and so on which when using multiple files is a big no no. +Multiple identical id's are not allowed. + +Also some of the tools used can't handle negative id's. So during the conversion process these negative id's are converted to big positive numbers. +When converting multiple files in one run this numbering is continued among the multiple input files (if there are that is). +But each new run of WMC starts with the same large positive number again. So if you have Wandrer-file-a converted in one run and Wandrer-file-b in a next run they will again +use the same id's and it won't work (unless they cover area's from an other tile all together) + +Managing the Wandrer files in the maps folder is up to you. + diff --git a/docs/pictures/Cruiser-with-Wandrer-Screenshot.png b/docs/pictures/Cruiser-with-Wandrer-Screenshot.png new file mode 100644 index 00000000..da39ad2e Binary files /dev/null and b/docs/pictures/Cruiser-with-Wandrer-Screenshot.png differ diff --git a/docs/pictures/Cruiser-without-Wandrer-Screenshot.png b/docs/pictures/Cruiser-without-Wandrer-Screenshot.png new file mode 100644 index 00000000..747ff701 Binary files /dev/null and b/docs/pictures/Cruiser-without-Wandrer-Screenshot.png differ diff --git a/docs/pictures/Wahoo-Ace-Wandrer-Screenshot.png b/docs/pictures/Wahoo-Ace-Wandrer-Screenshot.png new file mode 100644 index 00000000..56362beb Binary files /dev/null and b/docs/pictures/Wahoo-Ace-Wandrer-Screenshot.png differ diff --git a/docs/pictures/Wandrer-download-screen.png b/docs/pictures/Wandrer-download-screen.png new file mode 100644 index 00000000..327738d1 Binary files /dev/null and b/docs/pictures/Wandrer-download-screen.png differ diff --git a/wahoomc/input.py b/wahoomc/input.py index 25bc55bc..2578c046 100644 --- a/wahoomc/input.py +++ b/wahoomc/input.py @@ -88,6 +88,8 @@ def process_call_of_the_tool(): help="output debug logger messages") options_args.add_argument('-hdd', '--hdd_mode', action='store_true', help="use mapwriter hdd mode") + options_args.add_argument('-dw', '--do_wandrer', action='store_true', + help="integrate wandrer data into map files") args = parser_top.parse_args() @@ -120,6 +122,7 @@ def process_call_of_the_tool(): o_input_data.verbose = args.verbose o_input_data.hdd_mode = args.hdd_mode + o_input_data.integrate_wandrer = args.do_wandrer return o_input_data @@ -198,6 +201,7 @@ def __init__(self): self.zip_folder = False self.save_cruiser = False self.hdd_mode = False + self.integrate_wandrer = False self.verbose = False @@ -316,6 +320,7 @@ def handle_create_map(self, event): # pylint: disable=unused-argument self.o_input_data.zip_folder = tab2.first.checkb_zip_folder_val.get() self.o_input_data.verbose = tab2.first.checkb_verbose_val.get() self.o_input_data.hdd_mode = tab2.first.checkb_mapwriter_ram_hdd_val.get() + self.o_input_data.integrate_wandrer = tab2.first.checkb_integrate_wandrer_val.get() # get text without \n in the end self.o_input_data.tag_wahoo_xml = tab2.second.input_tag_wahoo_xml.get() @@ -477,3 +482,5 @@ def __init__(self, parent, oInputData): "output debug logger messages", 4) self.checkb_mapwriter_ram_hdd_val = create_checkbox(self, oInputData.verbose, "Use mapwriter HDD mode", 5) + self.checkb_integrate_wandrer_val = create_checkbox(self, oInputData.verbose, + "Integrate Wandrer files", 6) diff --git a/wahoomc/main.py b/wahoomc/main.py index dfa17b11..52f4eb68 100644 --- a/wahoomc/main.py +++ b/wahoomc/main.py @@ -74,6 +74,9 @@ def run(run_level): o_osm_maps = OsmMaps(o_osm_data) + if o_input_data.integrate_wandrer: + o_osm_maps.prepare_wandrer_data() + # Filter tags from country osm.pbf files' o_osm_maps.filter_tags_from_country_osm_pbf_files() @@ -88,11 +91,11 @@ def run(run_level): o_osm_maps.generate_elevation(o_input_data.use_srtm1) # Split filtered country files to tiles - o_osm_maps.split_filtered_country_files_to_tiles() + o_osm_maps.split_filtered_country_files_to_tiles(o_input_data.integrate_wandrer) # Merge splitted tiles with land and sea o_osm_maps.merge_splitted_tiles_with_land_and_sea( - o_input_data.process_border_countries, o_input_data.contour) + o_input_data.process_border_countries, o_input_data.contour,o_input_data.integrate_wandrer) # Creating .map files o_osm_maps.create_map_files(o_input_data.save_cruiser, diff --git a/wahoomc/osm_maps_functions.py b/wahoomc/osm_maps_functions.py index 94128805..eb8daca5 100644 --- a/wahoomc/osm_maps_functions.py +++ b/wahoomc/osm_maps_functions.py @@ -28,6 +28,7 @@ from wahoomc.constants import VERSION from wahoomc.constants import OSMOSIS_WIN_FILE_PATH from wahoomc.constants import USER_DL_DIR +from wahoomc.constants import USER_MAPS_DIR from wahoomc.timings import Timings @@ -84,6 +85,146 @@ def __init__(self, o_osm_data): create_empty_directories( USER_OUTPUT_DIR, self.o_osm_data.tiles, self.o_osm_data.border_countries) + def prepare_wandrer_data(self): # pylint: disable=too-many-statements,too-many-branches + """_ + Find Wandrer KMZ and convert them + """ + + log.info('-' * 80) + log.info('# Convert Wandrer file(s) to osm.pbf files') + timings = Timings() + + if platform.system() == "Windows": + # Check for new Wandrer kmz files in the maps directory. Format must be wandrer*.kmz + wandrerkmz_files = glob.glob(f'{USER_MAPS_DIR}/wandrer*.kmz') + if wandrerkmz_files: + for file in wandrerkmz_files: + log.info('+ Unpacking Wandrer KMZ file %s to KML format', file) + cmd = [get_tooling_win_path('7za'), 'e', '-y', file] + run_subprocess_and_log_output( + cmd, f'! Error unzipping KMZ file: {file}', cwd=USER_MAPS_DIR) + + # Find KML files (could be more then one in a KMZ?) + wandrerkml_files = glob.glob(f'{USER_MAPS_DIR}/wandrer*.kml') + if wandrerkml_files: + for file in wandrerkml_files: + log.info('+ Converting Wandrer KML file %s to OSM.', file) + # Call gpsbabel to convert to osm example gpsbabel -w -r -t -i kml -f file-in -o osm,tag=wandrer:untraveled,tagnd=wandrer:untraveled -F file-out + cmd = ['gpsbabel', '-w', '-r', '-t', '-i', 'kml', '-f', file, '-o', + 'osm,tag=wandrer:untraveled,tagnd=wandrer:untraveled', '-F', file.replace(".kml", ".osm")] + #subprocess.run(cmd, check=True, cwd=USER_MAPS_DIR) + run_subprocess_and_log_output( + cmd, f'! Error converting KML file: {file} to OSM. Is GPSBabel installed and in the path?', cwd=USER_MAPS_DIR) + + wandrerosm_files = glob.glob(f'{USER_MAPS_DIR}/wandrer*.osm') + if wandrerosm_files: + start_way_id = 20000000000 + for file in wandrerosm_files: + log.info('+ Replacing negative ID\'s with Large positive ones in %s and converting to .osm.pbf.', file) + start_way_id_str = f"{start_way_id}" + with open(file, encoding='utf8') as fhandle: + osm_data = fhandle.read() + fhandle.close() + + osm_data = osm_data.replace("\"-", "\"" + start_way_id_str) + + with open(file, 'w', encoding='utf8') as ofhandle: + ofhandle.write(osm_data) + ofhandle.close() + + # Increase way counter for the next file. No duplicate way numbers allowed! + start_way_id = start_way_id + 10000000 + + # Convert to osm.pbf + cmd = [self.osmconvert_path] + cmd.extend(['-v', '--hash-memory=2500', '--complete-ways', '--complete-multipolygons', + '--complete-boundaries', '--drop-author', '--drop-version']) + cmd.append(file) + cmd.append('-o='+file.replace(".osm", ".osm.pbf")) + run_subprocess_and_log_output( + cmd, f'! Error converting OSM file: {file} to OSM.PBF.') + + try: + log.info('+ Removing intermediate files and renaming processed input files') + for file in wandrerkmz_files: + oldbasename = os.path.basename(file) + os.rename(file, file.replace( + oldbasename, "Processed-"+oldbasename)) + + for file in wandrerkml_files: + os.remove(file) + + for file in wandrerosm_files: + os.remove(file) + except: # pylint: disable=bare-except + pass + + # Non-Windows + else: + # Check for new Wandrer kmz files in the maps directory. Format must be wandrer*.kmz + wandrerkmz_files = glob.glob(f'{USER_MAPS_DIR}/wandrer*.kmz') + if wandrerkmz_files: + for file in wandrerkmz_files: + log.info('+ Unpacking Wandrer KMZ file %s to KML format', file) + cmd = ['unzip', '-o', file] + run_subprocess_and_log_output( + cmd, f'! Error unzipping KMZ file: {file}', cwd=USER_MAPS_DIR) + + # Find KML files (could be more then one in a KMZ?) + wandrerkml_files = glob.glob(f'{USER_MAPS_DIR}/wandrer*.kml') + if wandrerkml_files: + for file in wandrerkml_files: + log.info('+ Converting Wandrer KML file %s to OSM.', file) + # Call gpsbabel to convert to osm example gpsbabel -w -r -t -i kml -f file-in -o osm,tag=wandrer:untraveled,tagnd=wandrer:untraveled -F file-out + cmd = ['gpsbabel', '-w', '-r', '-t', '-i', 'kml', '-f', file, '-o', + 'osm,tag=wandrer:untraveled,tagnd=wandrer:untraveled', '-F', file.replace(".kml", ".osm")] + #subprocess.run(cmd, check=True, cwd=USER_MAPS_DIR) + run_subprocess_and_log_output( + cmd, f'! Error converting KML file: {file} to OSM. Is GPSBabel installed?', cwd=USER_MAPS_DIR) + + wandrerosm_files = glob.glob(f'{USER_MAPS_DIR}/wandrer*.osm') + if wandrerosm_files: + start_way_id = 20000000000 + for file in wandrerosm_files: + log.info('+ Replacing negative ID\'s with Large positive ones in %s and converting to .osm.pbf.', file) + start_way_id_str = f"{start_way_id}" + with open(file, encoding='utf8') as fhandle: + osm_data = fhandle.read() + fhandle.close() + + osm_data = osm_data.replace("\"-", "\"" + start_way_id_str) + + with open(file, 'w', encoding='utf8') as ofhandle: + ofhandle.write(osm_data) + ofhandle.close() + + # Increase way counter for the next file. No duplicate way numbers allowed! + start_way_id = start_way_id + 10000000 + + # Convert to osm.pbf + cmd = ['osmium', 'cat'] + cmd.append(file) + cmd.append('-o'+file.replace(".osm", ".osm.pbf")) + run_subprocess_and_log_output( + cmd, f'! Error converting OSM file: {file} to OSM.PBF.') + + try: + log.info('+ Removing intermediate files and renaming processed input files') + for file in wandrerkmz_files: + oldbasename = os.path.basename(file) + os.rename(file, file.replace( + oldbasename, "Processed-"+oldbasename)) + + for file in wandrerkml_files: + os.remove(file) + + for file in wandrerosm_files: + os.remove(file) + except: # pylint: disable=bare-except + pass + + log.info('+ End Convert Wandrer file(s) to osm.pbf files: OK, %s', timings.stop_and_return()) + def filter_tags_from_country_osm_pbf_files(self): # pylint: disable=too-many-statements """ Filter tags from country osm.pbf files @@ -362,7 +503,7 @@ def generate_elevation(self, use_srtm1): log.info('+ Generate contour lines for each coordinate: OK, %s', timings.stop_and_return()) - def split_filtered_country_files_to_tiles(self): + def split_filtered_country_files_to_tiles(self,process_wandrer): # pylint: disable=too-many-statements """ Split filtered country files to tiles """ @@ -371,8 +512,7 @@ def split_filtered_country_files_to_tiles(self): log.info('# Split filtered country files to tiles') timings = Timings() tile_count = 1 - for tile in self.o_osm_data.tiles: - + for tile in self.o_osm_data.tiles: # pylint: disable=too-many-nested-blocks for country, val in self.o_osm_data.border_countries.items(): if country not in tile['countries']: continue @@ -410,6 +550,24 @@ def split_filtered_country_files_to_tiles(self): run_subprocess_and_log_output( cmd, '! Error in osmconvert with country: {country}. Win/out_file_names') + if process_wandrer: + in_wandrer_files = [] + in_wandrer_files = glob.glob(os.path.join(USER_MAPS_DIR, 'wandrer*.osm.pbf')) + for wandrer_map in in_wandrer_files: + out_wandrer = os.path.join( + USER_OUTPUT_DIR, f'{tile["x"]}', f'{tile["y"]}', f'split-{os.path.basename(wandrer_map)}') + if not os.path.isfile(out_wandrer): + cmd = [self.osmconvert_path, '--hash-memory=2500'] + cmd.append('-b='+f'{tile["left"]}' + ',' + f'{tile["bottom"]}' + + ',' + f'{tile["right"]}' + ',' + f'{tile["top"]}') + cmd.extend( + ['--complete-ways', '--complete-multipolygons', '--complete-boundaries']) + cmd.append(wandrer_map) + cmd.append('-o='+out_wandrer) + #print(cmd) + run_subprocess_and_log_output( + cmd, '! Error in osmconvert while processing Wandrer file: {wandrer_map}.') + # Non-Windows else: cmd = ['osmium', 'extract'] @@ -434,13 +592,28 @@ def split_filtered_country_files_to_tiles(self): run_subprocess_and_log_output( cmd, '! Error in Osmium with country: {country}. macOS/out_file_names') + if process_wandrer: + in_wandrer_files = [] + in_wandrer_files = glob.glob(os.path.join(USER_MAPS_DIR, 'wandrer*.osm.pbf')) + for wandrer_map in in_wandrer_files: + out_wandrer = os.path.join( + USER_OUTPUT_DIR, f'{tile["x"]}', f'{tile["y"]}', f'split-{os.path.basename(wandrer_map)}') + if not os.path.isfile(out_wandrer): + cmd = ['osmium', 'extract'] + cmd.extend( + ['-b', f'{tile["left"]},{tile["bottom"]},{tile["right"]},{tile["top"]}']) + cmd.append(wandrer_map) + cmd.append('-o'+out_wandrer) + run_subprocess_and_log_output( + cmd, '! Error in osmconvert while processing Wandrer file: {wandrer_map}.') + self.log_tile_debug(tile["x"], tile["y"], tile_count, f'{country} {timings_tile.stop_and_return()}') tile_count += 1 log.info('+ Split filtered country files to tiles: OK, %s', timings.stop_and_return()) - def merge_splitted_tiles_with_land_and_sea(self, process_border_countries, contour): # pylint: disable=too-many-locals + def merge_splitted_tiles_with_land_and_sea(self, process_border_countries, contour, process_wandrer): # pylint: disable=too-many-locals """ Merge splitted tiles with land elevation and sea - elevation data only if requested @@ -463,6 +636,9 @@ def merge_splitted_tiles_with_land_and_sea(self, process_border_countries, conto elevation_files = glob.glob( os.path.join(out_tile_dir, 'elevation*.osm')) + wandrer_files = glob.glob( + os.path.join(out_tile_dir, 'split-wandrer*.osm.pbf')) + # merge splitted tiles with land and sea every time because the result is different per constants (user input) # sort land* osm files self.sort_osm_files(tile) @@ -503,6 +679,14 @@ def merge_splitted_tiles_with_land_and_sea(self, process_border_countries, conto cmd.extend( ['--rx', 'file='+elevation, '--s', '--m']) + if process_wandrer: + for wandrer in wandrer_files: + cmd.append('--rbf') + cmd.append(os.path.join( + out_tile_dir, f'{tile["x"]}', f'{tile["y"]}', f'{wandrer}')) + cmd.append('workers=' + self.workers) + cmd.append('--merge') + cmd.extend( ['--rx', 'file='+os.path.join(out_tile_dir, 'sea.osm'), '--s', '--m']) cmd.extend(['--tag-transform', 'file=' + os.path.join(RESOURCES_DIR, diff --git a/wahoomc/resources/tag_wahoo_adjusted/tag-wahoo-poi.xml b/wahoomc/resources/tag_wahoo_adjusted/tag-wahoo-poi.xml index 6f43434f..20eb1f3b 100644 --- a/wahoomc/resources/tag_wahoo_adjusted/tag-wahoo-poi.xml +++ b/wahoomc/resources/tag_wahoo_adjusted/tag-wahoo-poi.xml @@ -85,6 +85,10 @@ + + + + diff --git a/wahoomc/resources/tags-to-keep.json b/wahoomc/resources/tags-to-keep.json index b306b27c..dcf86bc1 100644 --- a/wahoomc/resources/tags-to-keep.json +++ b/wahoomc/resources/tags-to-keep.json @@ -85,6 +85,7 @@ "riverbank", "stream" ], + "wandrer": "", "wood": "deciduous", "tourism": "alpine_hut" },