16 |
17 | # wahooMapsCreator
18 | wahooMapsCreator is a tool to create up-to-date maps for your Wahoo device. It supports BOLTv1, BOLTv2, ROAM, ROAMv2 and ELEMNT!
19 |
20 | You can generate maps for the countries you like with latest OSM data and you can control which OSM-tags are included.
21 |
22 | > why? The maps of your device may be old because Wahoo did not release a newer version in the last years.
23 |
24 | ## Get it running
25 | The instructions are intended to be suitable for beginners.
26 |
27 | If anything is unclear or seams wrong, write an [:pencil2: issue](https://github.com/treee111/wahooMapsCreator/issues)
28 |
29 | ## To start with...
30 | 1. [:rocket: Quick Start Guide to download and install required programs](docs/QUICKSTART_ANACONDA.md#download-and-install-required-programs)
31 |
32 | 2. [:computer: Run wahooMapsCreator - detailled usage description](docs/USAGE.md#usage-of-wahoomapscreator)
33 |
34 | > In short: activate Anaconda environment, run wahooMapsCreator via CLI or via GUI.
35 | ```
36 | conda activate gdal-user
37 | python -m wahoomc cli -co malta
38 | python -m wahoomc gui
39 | ```
40 |
41 | 3. [:floppy_disk: Copy the map-files to your device after generation](docs/COPY_TO_WAHOO.md#copy-maps-files-to-wahoo-device-)
42 |
43 | ## To further adjust...
44 | * [:cookie: Get POIs displayed on your Wahoo](docs/USAGE.md#pois---points-of-interest)
45 |
46 | * [:mount_fuji: Integrate contour lines into the generated maps](docs/USAGE.md#pois---points-of-interest)
47 |
48 | * [:wrench: Control OSM tags to be included in your maps ](docs/USAGE.md#user-specific-configuration)
49 |
50 | * [:computer: Preview your generated maps with cruiser ](docs/USAGE_CRUISER.md#usage-of-cruiser)
51 |
52 |
53 | * [:mag: Use a custom theme on your Wahoo to control what and in which zoom-level certain elements are rendered](docs/TAGS_ON_MAP_AND_DEVICE.md#osm-tags-during-map-creation-and-on-your-device-)
54 |
55 | ## Contribution / Questions
56 | You are welcome to provide input via Pull Requests, Issues or in any other way!
57 | If you have trouble using wahooMapsCreator, look into the FAQ, write an issue or join the telegram channel
58 | - [FAQ](docs/FAQ.md#frequently-asked-questions)
59 | - [:pencil2: issue](https://github.com/treee111/wahooMapsCreator/issues)
60 | - telegram channel: https://t.me/joinchat/TaMhjouxlsAzNWZk
61 |
62 | More details can be found here: [CONTRIBUTING](docs/CONTRIBUTING.md#contributing-to-wahoomapscreator-)
63 |
64 | ## Thanks to
65 | [@Intyre](https://github.com/Intyre)/Hank for the initial version of the script
66 |
67 | [@Ebe66](https://github.com/Ebe66)/ebo for the Windows- port
68 |
69 | [@mweirauch](https://github.com/mweirauch) for bringing in new ideas, testing and using the tool
70 |
71 | [@zenziwerken](https://github.com/zenziwerken) for the work done for [POIs](https://github.com/zenziwerken/Bolt2-Mapsforge-Rendertheme)!
72 |
73 | [@macdet](https://github.com/macdet) for bringing in new thoughts, testing and making this a little more public
74 |
75 | [@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!
--------------------------------------------------------------------------------
/conda_env/gdal-dev.yml:
--------------------------------------------------------------------------------
1 | name: gdal-dev
2 | channels:
3 | - conda-forge
4 | dependencies:
5 | - python=3.10
6 | - gdal=3.6.*
7 | - requests=2.28.*
8 | - pylint=2.15.*
9 | - geojson=2.5.*
10 | - shapely=1.8.*
11 | - osmium-tool=1.16.*
12 | - bs4=4.11.*
13 | - lxml=4.9.*
14 | - matplotlib=3.4.3
15 | - autopep8=2.0.*
16 | - mock
17 | - twine
18 | - pip
19 | - vulture
20 | - pydeps
21 | - pip:
22 | - build
23 |
--------------------------------------------------------------------------------
/conda_env/gdal-user.yml:
--------------------------------------------------------------------------------
1 | name: gdal-user
2 | channels:
3 | - conda-forge
4 | dependencies:
5 | - python=3.10
6 | - geojson=2.5.*
7 | - gdal=3.6.*
8 | - bs4=4.11.*
9 | - lxml=4.9.*
10 | - matplotlib=3.4.3
11 | - pip
12 | - pip:
13 | - wahoomc==4.3.0
14 |
--------------------------------------------------------------------------------
/copyFilesToDist.sh:
--------------------------------------------------------------------------------
1 | FOLDER_NAME_DEVICE_THEMES="wahooMapsCreator-device_themes-"${GITHUB_REF_VARIABLE}
2 |
3 | echo "Github-Ref: ${GITHUB_REF_VARIABLE}"
4 |
5 | # delete folder with content and create top-level folder
6 | rm -rf dist
7 | mkdir -p dist
8 |
9 | # zip device themes
10 | cd device_themes
11 | zip -r -q ../dist/${FOLDER_NAME_DEVICE_THEMES}.zip *
12 | cd ..
--------------------------------------------------------------------------------
/device_themes/vtm_theme_poi/COLORS.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/device_themes/vtm_theme_poi/icons/bakery.svg:
--------------------------------------------------------------------------------
1 |
2 |
7 |
--------------------------------------------------------------------------------
/device_themes/vtm_theme_poi/icons/cafe.svg:
--------------------------------------------------------------------------------
1 |
2 |
7 |
--------------------------------------------------------------------------------
/device_themes/vtm_theme_poi/icons/drinking_water.svg:
--------------------------------------------------------------------------------
1 |
2 |
10 |
--------------------------------------------------------------------------------
/device_themes/vtm_theme_poi/icons/fuel.svg:
--------------------------------------------------------------------------------
1 |
2 |
7 |
--------------------------------------------------------------------------------
/device_themes/vtm_theme_poi/icons/shop_bicycle.svg:
--------------------------------------------------------------------------------
1 |
2 |
16 |
--------------------------------------------------------------------------------
/device_themes/vtm_theme_poi/icons/train_station.svg:
--------------------------------------------------------------------------------
1 |
2 |
8 |
--------------------------------------------------------------------------------
/docs/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to wahooMapsCreator
2 |
3 | #### Table of contents
4 | - [How to Contribute](#how-to-contribute)
5 | - [Developer Anaconda environment](#developer-anaconda-environment)
6 | - [Pylint](#pylint)
7 | - [Unittests](#unittests)
8 | - [Structure of the repository](#structure-of-the-repository)
9 | - [User directory](#user-directory)
10 | - [Git Guidelines](#git-guidelines)
11 | - [No Merge Commits](#no-merge-commits)
12 | - [Pull Requests](#pull-requests)
13 | - [Pull Request Title](#pull-request-title)
14 | - [Types](#types)
15 | - [Squash Commit Summary](#squash-commit-summary)
16 | - [Example](#example)
17 | - [Release](#release)
18 | - [Automatic CHANGELOG creation](#automatic-changelog-creation)
19 | - [PyPI commands](#pypi-commands)
20 |
21 | ## How to Contribute
22 | 1. Create a Anaconda environment for developers
23 | - 👉 [Developer Anaconda environment](#developer-anaconda-environment)
24 | 2. Create a branch by forking the repository and apply your change.
25 | 3. Commit and push your change on that branch.
26 | 4. Run Pylint with 10.00/10
27 | 5. Run unittests successfully
28 | 6. Create a pull request.
29 | - 👉 **Please follow the [Git Guidlines](#Git-Guidelines).**
30 | 7. Wait for our code review and approval, possibly enhancing your change on request.
31 | - Note that the wahooMapsCreator maintainers have many duties. So, depending on the required effort for reviewing, testing, and clarification, this may take a while.
32 | 8. Once the change has been approved and merged, we will inform you in a comment.
33 | 9. Celebrate! 🎉
34 |
35 | ### Developer Anaconda environment
36 | - /conda_env/gdal-user.yml is for creating Anaconda environment for users
37 | - /conda_env/gdal-dev.yml is for creating Anaconda environment for developers
38 |
39 | The Anaconda environment for development can be installed via
40 |
41 | - macOS/ Linux
42 | ```
43 | conda env create -f ./conda_env/gdal-dev.yml
44 | ```
45 | - Windows
46 | ```
47 | conda env create -f .\conda_env\gdal-dev.yml
48 | ```
49 |
50 | more information on [documentation for sharing Anaconda environments](https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#exporting-an-environment-file-across-platforms)
51 |
52 | The .yml files with only the installed packages were created via
53 | ```
54 | conda env export > environment.yml --from-history
55 | ```
56 |
57 | ### Pylint
58 | Run pylint for all relevant directories/files
59 | ```
60 | pylint -j 0 ./wahoomc ./tests
61 | ```
62 |
63 | ### Unittests
64 | Python unittests are defined in the directory `tests`.
65 | They can be started via "Testing" pane from VSCode or via terminal in the root of the repo with
66 | ```
67 | python -m unittest
68 | ```
69 |
70 | For the `test_generated_files.py` unittests to run successful, static land-poligons-file and static country files are needed to ensure equal results. The country files are included in the repo in `tests/resources`, the land-poligons-file needs to be downloaded from https://1drv.ms/u/s!AnpNcYd7Zz7TnXorg_zZuvsbMGsJ?e=fL6zvM and extracted to `~/wahooMapsCreatorData/_unittest/` like this:
71 |
72 |
73 | More information about Python unittest can be read here: https://docs.python.org/3/library/unittest.html.
74 |
75 | ## Structure of the repository
76 | There is one python coding base for both Windows and for macOS.
77 | Differences between the different OS are the used programs.
78 | The folders in the repo have the following purposes:
79 | - `wahoo_mc` - custom python files
80 | - `wahoo_mc/resources` - config, json files
81 | - `wahoo_mc/tooling_win` - programs, scripts for Windows
82 | - `tooling` - programs, scripts used by Windows and macOS to test and check the generated maps
83 |
84 | ## User directory
85 | Files which are processed through the tool are stored in the user directory to be release-independent. The name of the directory is: `$user_directory/wahooMapsCreatorData` and has the follwing folders:
86 | - root - generated files are saved here
87 | - `_download` - all downloaded files are saved and extracted here
88 | - `_tiles` - intermediate files per tile are stored here
89 |
90 | ## Git Guidelines
91 | ### No Merge Commits
92 | Please use [rebase instead of merge](https://www.atlassian.com/git/tutorials/merging-vs-rebasing) to update a branch to the latest master. This helps keeping a clean commit history in the project.
93 |
94 | ### Pull Requests
95 | #### Pull Request Title
96 | The pull request title is a short description of the change to be introduced in the repository.
97 | The pull request tilte will later on be used for the squash commit summary and then appear in the CHANGELOG.
98 | - The title should be 50-70 characters long.
99 | - The commit summary must be **prefixed** by one of the following types.
100 |
101 | ##### Types
102 | - The commit summary must be **prefixed** by one of the following types.
103 | + Use `[FEATURE]` for new features / enhancements.
104 | + Use `[FIX]` for bugfixes.
105 | + Use `[DEV]` for development, infrastructure, test or CI topics.
106 | + Use `[BREAKING]` for breaking / incompatible changes.
107 | _**Note:** The commit body of a breaking change should also include a paragraph starting with `BREAKING CHANGE:`.
108 | This paragraph will be highlighted in the changelog._
109 | + Exceptions are changes created by automated processes like releases or dependency updates
110 |
111 | #### Squash Commit Summary
112 | The commit summary is the first line of the commit message.
113 | For a squash commit to appear in the CHANGELOG.md later on, it has to follow a certain naming pattern:
114 | - [type] ... (#PR-number)
115 | - The commit summary must be **prefixed** by one of the [types](#Types).
116 | - In the end there must be the `#pull request number` to be automatically linked in Github
117 |
118 | ##### Example
119 | ```
120 | [FEATURE] Add check for required input parameter for CLI and GUI (#41)
121 | ```
122 | ```
123 | [FIX] Storing and interpretation of CLI arguments (#48)
124 | ```
125 | ## Release
126 | Coding is updated in the develop-branch mainly via pull requests.
127 | After testing carefully, a Release will be created based on branch develop or a hotfix branch.
128 |
129 | ### Automatic CHANGELOG creation
130 | After installing [git-chglog](https://github.com/git-chglog/git-chglog) locally, the CHANGELOG.md can be generated with this command:
131 | ```
132 | git-chglog -o CHANGELOG.md
133 | ```
134 |
135 | To generate the CHANGELOG.md for a upcoming release (no tag exists yet), the following command can be used:
136 | ```
137 | git-chglog -o CHANGELOG.md --next-tag v0.10.0
138 | ```
139 |
140 | ### PyPI commands
141 | 1. Change the version in `setup.cfg`, `constants.py` and `gdal-user.yml`
142 | 2. Build a new release to publish to PyPI:
143 | ```
144 | python -m build
145 | ```
146 | 3. Publish these files to PyPI:
147 | ```
148 | twine upload dist\*
149 | ```
150 |
--------------------------------------------------------------------------------
/docs/COPY_TO_WAHOO.md:
--------------------------------------------------------------------------------
1 | # Copy Maps files to Wahoo Device
2 |
3 | #### Table of contents
4 | - [Steps to carry out](#steps-to-carry-out)
5 | - [Location of the generated maps](#location-of-the-generated-maps)
6 | - [Tools to copy maps onto your Wahoo](#tools-to-copy-maps-onto-your-wahoo)
7 | - [Install ADB](#install-adb)
8 | - [Authorize Wahoo device](#authorize-wahoo-device)
9 | - [BOLT v1, ROAMv1, ELEMNT, BOLT v2, ROAMv2](#bolt-v1-roamv1-elemnt-bolt-v2-roamv2)
10 | - [ACE](#ace)
11 | - [Copy map files](#copy-map-files)
12 | - [Copy device theme](#copy-device-theme)
13 | - [POIs](#pois)
14 | - [Copy relevant files for POIs](#copy-relevant-files-for-pois)
15 | - [Activate VTM rendering](#activate-vtm-rendering)
16 | - [Delete temp-files and Clear Cache](#delete-temp-files-and-clear-cache)
17 |
18 | # Steps to carry out
19 | ## Location of the generated maps
20 | The generated maps are saved in the user directory in folder: `$user_directory/wahooMapsCreatorData`.
21 |
22 | There is a folder per country or for the X/Y combination with the relevant tiles.
23 |
24 | ## Tools to copy maps onto your Wahoo
25 | There are some different tools you can use to copy the created files onto your device.
26 | You always have to first [authorize to your Wahoo device](#authorize-wahoo-device).
27 |
28 | - The most easy to use toll with a GUI would be the Elemntary app: https://github.com/vti/elemntary
29 | - Windows
30 | - Copy via Windows built in MTP protocol . On windows you can navigate to the maps folder and drag new map files onto the folder called `maps/8` ([the Wahoo documentation](https://support.wahoofitness.com/hc/en-us/articles/115000127910-Connecting-ELEMNT-BOLT-ROAM-to-Desktop-or-Laptop-Computers))
31 | - GIU tool: https://github.com/hexadezi/adbGUI
32 | - macOS
33 | - GUI tool: https://www.android.com/filetransfer/
34 |
35 | ## Install ADB
36 | You can download the lates ADB-tools (included in the SDK Platform Tools) for your OS here:
37 | https://developer.android.com/studio/releases/platform-tools
38 |
39 | ## Authorize Wahoo device
40 | The Wahoo device must be authorized for ADB to be reachable from Windows and macOS. ADB authorization works different per Wahoo device and is decribed now.
41 |
42 | ### BOLT v1, ROAMv1, ELEMNT, BOLT v2, ROAMv2
43 | 1. disconnect device from your computer
44 | 2. turn the device on
45 | 3. press keys on device
46 | * **BOLT v1, ROAMv1, ELEMNT**
47 | * press the power button (you enter the settings menu)
48 | * press the power button again (you return to the normal screen)
49 | * **BOLT v2, ROAMv2**
50 | * press the power, up and down buttons at the same time
51 | 4. connect the device to your pc
52 |
53 | ### ACE
54 | 1. connect device to your computer with usb cable
55 | 2. press keys on device
56 | * press and hold the zoom out (lower) button and repeatedly shortly press the power button
57 | * release both buttons
58 | 3. Do 2. a couple of times for a greater chance of success
59 | 4. unplug the usb cable from your computer
60 | 5. connect the usb cable to your computer again
61 |
62 | Successful authorization can be tested via terminal / cmd:
63 | ```
64 | adb devices
65 | ```
66 |
67 | ## Copy map files
68 | The generated maps are stored in a folder per country or processed X/Y coordinates in this folder in your user account: `wahooMapsCreatorData`.
69 |
70 | Copy the the whole content of the country- or X/Y folder or just the content of the containing X-folders (if the X-folder exists already) to `/ELEMNT-BOLT/maps/tiles/8` with a tool of your [choice](#tools-to-copy-maps-onto-your-wahoo).
71 |
72 | After copying, it should look like that:
73 |
74 |
75 |
76 | For another way of explanation, see [here](FAQ.md#where-on-my-wahoo-do-i-have-to-copy-the-maps)
77 |
78 | ## Copy device theme
79 | In this repo, device themes are stored in folder `device_themes`. There are initial versions and adjusted versions. Both can be further changed to your requirements!
80 |
81 | The following table shows the file per device and the location where the device theme needs to be copied to.
82 |
83 | | device | rendering | file | location |
84 | | ------ | --------- | -------------------- | ---------------------------------------- |
85 | | all | VTM | `vtm-elemnt.xml` | `maps/vtm-elemnt/vtm-elemnt.xml` |
86 | | ROAM | non-VTM | `mapsforge-roam.xml` | `maps/mapsforge-roam/mapsforge-roam.xml` |
87 | | BOLTv1 | non-VTM | `mapsforge-bolt.xml` | `maps/mapsforge-bolt/mapsforge-bolt.xml` |
88 | | ELEMNT | non-VTM | ? | ? |
89 |
90 | Device themes are described [here](TAGS_ON_MAP_AND_DEVICE.md#Device-Theme)
91 |
92 | # POIs
93 | ## Copy relevant files for POIs
94 | For having POIs displayed on your device, you need to copy the icons and a corresponding device theme on your device.
95 | These are the steps to follow:
96 | - create folder `maps/vtm-elemnt`
97 | - copy the content of `device_themes/vtm_theme_poi` into `maps/vtm-elemnt`.
98 |
99 | ## Activate VTM rendering
100 | If you have a ROAM or BOLTv2, VTM is already the default rendering theme.
101 | For e.g. a BOLTv1, you need to activete VTM rendering first.
102 |
103 | - Create a empty file with this name `cfg_BHomeActivity_VtmMaps`
104 | - Copy that file to the root-folder. It should be on the same level as the `maps` and `factory` folder.
105 |
106 | # Delete temp-files and Clear Cache
107 | - delete all files from \ELEMNT-BOLT\USB storage\maps\temp\
108 | - to clear the cache and load the new maps on your Wahooo device:
109 | 1. `adb shell am broadcast -a com.wahoofitness.bolt.service.BMapManager.PURGE`
110 | 2. `adb shell am broadcast -a com.wahoofitness.bolt.service.BMapManager.RELOAD_MAP`
111 |
--------------------------------------------------------------------------------
/docs/FAQ.md:
--------------------------------------------------------------------------------
1 | # Frequently asked questions
2 |
3 | - [Usage of wahooMapsCreator](#usage-of-wahoomapscreator)
4 | - [The tool stops but does not output an error](#the-tool-stops-but-does-not-output-an-error)
5 | - [I have a Java error. "Java heap space - out of memory"](#i-have-a-java-error-java-heap-space---out-of-memory)
6 | - [I have a Osmosis error. "Task type mw doesn't exist"](#i-have-a-osmosis-error-task-type-mw-doesnt-exist)
7 | - [How can I migrate from v3.x.x to v4.x.x?](#how-can-i-migrate-from-v3xx-to-v4xx)
8 | - [Is there a way to use wahooMapsCreator without installing Anaconda and the other software directly on OS level?](#is-there-a-way-to-use-wahoomapscreator-without-installing-anaconda-and-the-other-software-directly-on-os-level)
9 | - [Generated maps](#generated-maps)
10 | - [Where on my Wahoo device do I have to copy the maps?](#where-on-my-wahoo-device-do-i-have-to-copy-the-maps)
11 | - [How can I restore original maps?](#how-can-i-restore-original-maps)
12 | - [Can I preview my generated maps before putting them onto the Wahoo device?](#can-i-preview-my-generated-maps-before-putting-them-onto-the-wahoo-device)
13 | - [Does device/offline routing functionality use the new roads?](#does-deviceoffline-routing-functionality-use-the-new-roads)
14 | - [Are there already generated maps available for download?](#are-there-already-generated-maps-available-for-download)
15 | - [Are there already generated routing tiles available for download?](#are-there-already-generated-routing-tiles-available-for-download)
16 | - [Device theme](#device-theme)
17 | - [How can I restore original rendering layout?](#how-can-i-restore-original-rendering-layout)
18 | - [Connection from Wahoo device to computer](#connection-from-wahoo-device-to-computer)
19 | - [I can't see my Wahoo device on my computer](#i-cant-see-my-wahoo-device-on-my-computer)
20 |
21 |
22 | ## Usage of wahooMapsCreator
23 | ### The tool stops but does not output an error
24 | Run the tool and output debug logging messages.
25 | Add the `-v` argument if running via CLI or set the checkbox on `Advanced settings` via GUI.
26 |
27 | ### I have a Java error. "Java heap space - out of memory"
28 | If you are on Windows and running out of memory, it can be that you just don't have enough memory OR that the memory limit of java 32 is the cause.
29 |
30 | You identify a Java error when the console outputs `java.lang.OutOfMemoryError`.
31 |
32 | There are some possible workarounds:
33 | 1. You can try to deinstall Java 32 and install the 64 bit version
34 | 2. Launch this command before running wahooMapsCreator helped here: https://github.com/treee111/wahooMapsCreator/issues/198
35 | ```
36 | set JAVACMD_OPTIONS=-server -Xmx3G
37 | ```
38 | 3. A permanent workaround (in opposite to 2.) is making changes from this PR https://github.com/treee111/wahooMapsCreator/pull/171/files in the osmosis.bat file on your computer. This file located here: `wahooMapsCreatorData\_download\tooling_win\Osmosis\bin\osmosis.bat`.
39 |
40 | ### I have a Osmosis error. "Task type mw doesn't exist"
41 | You might have osmosis installed in version 0.49.0 or 0.49.1 and might be using macOS or Linux. If yes, this error occurs during creation of the .map files:
42 | ```
43 | org.openstreetmap.osmosis.core.OsmosisRuntimeException: Task type mw doesn't exist.
44 | ```
45 |
46 | In these two versions 0.49.0 and 0.49.1, the feature we use for loading the mapwriter plugin was removed and just brought back in version 0.49.2.
47 |
48 | You can list your version of osmosis on macOS/Linux with:
49 | ```
50 | brew list osmosis
51 | ```
52 |
53 | You can upgrade osmosis on macOS/Linux with:
54 | ```
55 | brew upgrade osmosis
56 | ```
57 |
58 | ### How can I migrate from v3.x.x to v4.x.x?
59 | You have to remove your existing environment:
60 | ```
61 | conda env remove -n gdal-user
62 | ```
63 | followed by creating a new environment and install wahoomc into:
64 | ```
65 | conda create -n gdal-user python=3.10 geojson=2.5 gdal=3.6 requests=2.28 shapely=1.8 bs4=4.11 lxml=4.9 matplotlib=3.4.3 pip --channel conda-forge --override-channels
66 | conda activate gdal-user
67 | pip install wahoomc
68 | ```
69 |
70 | ### Is there a way to use wahooMapsCreator without installing Anaconda and the other software directly on OS level?
71 | The process of setting up the environment for creating your individual maps with wahooMapsCreator is way easier as it was before. Before, many manual steps have been involved, taking care of certain versions of tools to be OK with each other and configs around the OS.
72 |
73 | You can give the docker version of wahooMapsCreator a try: https://github.com/vti/wahooMapsCreator-docker, it is kind of a A standalone package without having to install stuff on OS level.
74 |
75 | ## Generated maps
76 | ### Where on my Wahoo device do I have to copy the maps?
77 | There is a directory named like the country or X/Y coordinates you processed in the `wahooMapsCreatorData` directory (see [docs](https://github.com/treee111/wahooMapsCreator/blob/develop/docs/COPY_TO_WAHOO.md#location-of-the-generated-maps)).
78 | The content of this folder is relevant.
79 |
80 | As an example, lets assume, we want to copy the maps of american_samoa
81 |
82 |
83 |
84 | We need to copy the folders under the `american_samoa` directory into the `maps/tiles/8` directory on the Wahoo device (see [docs](https://github.com/treee111/wahooMapsCreator/blob/develop/docs/COPY_TO_WAHOO.md#copy-map-files)).
85 |
86 | It should look like that after copying the files
87 |
88 |
89 |
90 | If the folder, i.e. `maps/tiles/8/6` does already exist on your Wahoo device, copy the .map.lzma and .map.lzma.17 files into the existing folder.
91 |
92 | ### How can I restore original maps?
93 | Delete all content from `maps/tiles/8` on your Wahoo device. After that, you can download original Wahoo maps from the ELEMNT mobile phone app again.
94 |
95 | ### Can I preview my generated maps before putting them onto the Wahoo device?
96 | Read [usage of cruiser](USAGE_CRUISER.md#usage-of-cruiser)
97 |
98 | ### Does device/offline routing functionality use the new roads?
99 | The device routing (synonym: offline routing) functionality is provided through routing tiles and available on newer models e.g. BOLTv2/ROAMv2. The routing tiles are stored in the directory `maps/routing` and contain all know roads which can be used to route over. This is something different then routes synced from Komoot, Stava, ... or planned via the ELEMNT Companion mobile app. In this case you follow a track, but on device routing will be used when you wonder off that track.
100 |
101 | Without updating the routing tiles in addition to updating the generated map files, device routing of your device will not route you over the newly added roads in the maps. The reason is: The old routing tiles simply do not know about there existence.
102 |
103 | Generating Routing tiles are not covered in this repo.
104 |
105 | ### Are there already generated maps available for download?
106 | On this OneDrive, you'll find already generated maps for download: http://wahoomaps.higli.de/ .
107 |
108 | The content of these maps are slightly different from what you create with the default settings of wahooMapsCreator. Other than that this might be a good starting point to tryout and get them on your device and see what can be achieved.
109 |
110 | By customizing the wahooMapsCreator settings and configuration you can than create your individual maps with wahooMapsCreator.
111 |
112 | Base map tiles could also be downloaded from Wahoo update server (url: https://cdn.wahooligan.com/wahoo-maps/{version}/tiles/{zoom}/{x}/{y}.map.lzma; latest map version = 12, zoom level =8, x, y = map tile index/coordinates) but these are relatively old.
113 |
114 | ### Are there already generated routing tiles available for download?
115 | Current routing tiles can be downloaded from http://wahoomaps.higli.de/. Download the -routing.zip file for the countries of your choice and copy the content under the `maps/routing` directory on your wahoo device.
116 |
117 | Routing tiles could also be downloaded from Wahoo update server, see [documentation](./HOWTO_ADD_ROUTING_TILES_MANUALLY.MD#option-c-download-from-wahoo-update-server) but these are relatively old.
118 |
119 | Examplary the germany routing tiles would be stored in `maps/routing/2/000/...`. More details can be accessed [here](./HOWTO_ADD_ROUTING_TILES_MANUALLY.MD#directory-hierarchy-in-wahoo-elelmnt-roam-device)
120 |
121 | ## Device theme
122 | ### How can I restore original rendering layout?
123 | If you render using VTM, delete this folder on your Wahoo device: `maps/vtm-elemnt/vtm-elemnt.xml`.
124 |
125 | If you do not render using VTM, delete this file `maps/mapsforge-roam/mapsforge-roam.xml` or `maps/mapsforge-bolt/mapsforge-bolt.xml`. Depending on which exists.
126 |
127 | In addition, delete the empty file `cfg_BHomeActivity_VtmMaps` in the root directory of the Wahoo device if it exists.
128 |
129 | ## Connection from Wahoo device to computer
130 | ### I can't see my Wahoo device on my computer
131 | If ADB does not seam to work with your PC and Wahoo:
132 | - try to do the [Authorization](COPY_TO_WAHOO.md#authorize-wahoo-device) multiple times
133 | - try another USB cable. Some cables do not support adb / file transfer
134 |
135 |
--------------------------------------------------------------------------------
/docs/HOWTO_ADD_ROUTING_TILES_MANUALLY.MD:
--------------------------------------------------------------------------------
1 | # How to add routing tiles manually for Wahoo Elemnt ROAM
2 | In addition to the base map tiles, routing tiles are also required to support routing/navigation features (i.e. turn by turn support for Strava route). And it seems Valhalla (https://valhalla.readthedocs.io/en/latest/api/turn-by-turn/overview/) is used by Wahoo Elemnt ROAM as routing services. Following are the detailed instructions for getting routing tiles.
3 |
4 | ## How to get routing tiles?
5 |
6 | Different options exist to get routing tiles. Read the following information in combination with the chapter further down to get a full view on the topic.
7 |
8 | ### Option a: download pre-generated routing tiles made by the community
9 |
10 | This might be the easiest option to get up-to-date routing tiles. Read [here](./FAQ.md#are-there-already-generated-routing-tiles-available-for-download) where to download pre-generated routing tiles and where to put it onto your Wahoo device.
11 |
12 | ### Option b: generate by using henks repo
13 |
14 | This is a very technical option where not everything is predefined and digging into is needed.
15 | This repository https://github.com/Intyre/valhalla-wahoo has most of whats needed to generate routing tiles on your own. Keep the [telegram channel](../README.md#contribution--questions) in mind for technical questions.
16 |
17 | ### Option c: download from wahoo update server
18 | This is option gets the "standard" routing tiles from Wahoo which might be relatively old.
19 |
20 | First of all, index numbers for the routing tiles of target country are required before trying to download them from wahoo update server. Since wahoo use the routing tiles ID ("routing_coordinates") instead of index in mappack-gzip.json, the python script from valhalla are required to decode the ID into six digital index (first three are the folder name and last three are filename).
21 |
22 | Following are the python code for the decode function. More details and full python script can be found from: https://valhalla.github.io/valhalla/tiles
23 |
24 | ```
25 | #!/usr/bin/env python
26 |
27 | LEVEL_BITS = 3
28 | TILE_INDEX_BITS = 22
29 | TILE_INDEX_MASK = (2**TILE_INDEX_BITS) - 1
30 | def get_tile_index(id):
31 | return (id >> LEVEL_BITS) & TILE_INDEX_MASK
32 | ```
33 |
34 | After decoding the routing tile IDs into index, it is fairly easy to download all routing tiles from wahoo update server. Following are the URL:
35 | https://cdn.wahooligan.com/wahoo-maps/{version}/routing/tiles/{level}/000/{x}/{y}.gph.lzma
36 | And the latest map version is 12; level is 2; x, y are both 3 digitals map tile index.
37 |
38 | Note:
39 | - Please use 3 digitals for x and y, and add "0" if x or y is less than 100. e.g. use "003" instead "3" when trying to download them
40 | - Some tiles may be missing, the reason and impact are unclear. But it still can work.
41 |
42 | ## Directory hierarchy in Wahoo Elelmnt ROAM device
43 | ```
44 | maps
45 | | - routing
46 | | | - routing-config.json
47 | | | - 2
48 | | |- 000
49 | | | - xxx
50 | | | |- yyy.gph.lzma
51 | | | | - ……
52 | | | | - yyy.gph.lzma
53 | | | - ……
54 | | | - ……
55 | | | - ……
56 | | | - xxx
57 | | | | - yyy.gph.lzma
58 | | | | - ……
59 | | | | - yyy.gph.lzma
60 | | - tiles
61 | | - 8
62 | | - xxx
63 | | | - yyy.map.lzma
64 | | | - ……
65 | | | - yyy.map.lzma
66 | | - ……
67 | | - ……
68 | | - ……
69 | | - xxx
70 | | | - yyy.map.lzma
71 | | | - ……
72 | | | - yyy.map.lzma
73 | ```
74 |
--------------------------------------------------------------------------------
/docs/QUICKSTART_ANACONDA.md:
--------------------------------------------------------------------------------
1 | # Quickstart Guide for Anaconda on Windows and macOS
2 |
3 | #### Table of contents
4 | - [Download and Install required programs](#download-and-install-required-programs)
5 | - [Anaconda](#anaconda)
6 | - [Java](#java)
7 | - [Oracle Java:](#oracle-java)
8 | - [OpenJDK:](#openjdk)
9 | - [macOS, Linux only](#macos-linux-only)
10 | - [homebrew](#homebrew)
11 | - [OSM-tools](#osm-tools)
12 | - [wahooMapsCreator](#wahoomapscreator)
13 | - [Create Anaconda environment](#create-anaconda-environment)
14 | - [Install wahooMapsCreator into Anaconda environment](#install-wahoomapscreator-into-anaconda-environment)
15 | - [Update wahooMapsCreator](#update-wahoomapscreator)
16 | - [Additional programs for generating contour lines](#additional-programs-for-generating-contour-lines)
17 | - [Install phyghtmap](#install-phyghtmap)
18 | - [Verify phyghtmap](#verify-phyghtmap)
19 | - [Free account for USGS](#free-account-for-usgs)
20 | - [Run wahooMapsCreator](#run-wahoomapscreator)
21 | - [Additional information](#additional-information)
22 |
23 | # Download and Install required programs
24 | Using Anaconda to setup a virtual Python environment is the fastest way to get wahooMapsCreator running!
25 |
26 | ## Anaconda
27 | 1. Download `Anaconda Individual Edition` for your OS
28 |
29 | Click *Download* on top right to download `Anaconda Distribution` for your OS:
30 |
31 | https://www.anaconda.com/products/individual
32 |
33 |
34 | 2. Install `Anaconda Individual Edition` with default settings
35 |
36 | ## Java
37 | Java needs to be installed for every OS (Windows, macOS, Linux). You can use Oracle Java or OpenJDK.
38 |
39 | ### Oracle Java:
40 | 1. Download `Java Runtime Environment` for your OS from:
41 |
42 | https://www.java.com/de/download/
43 |
44 | 2. Install `Java Runtime Environment` with default settings
45 |
46 | ### OpenJDK:
47 | 1. Download latest `OpenJDK` build file for your OS and unzip
48 |
49 | https://jdk.java.net
50 |
51 | 2. Move the folder to the appropriate directory
52 | * macOS: `/Library/Java/JavaVirtualMachines/`
53 | * Windows: `C:\Program Files\Java\`
54 | * Linux: `/usr/java`
55 |
56 | 3. Set environment variable
57 | * macOS: nothing to do
58 | * Windows: https://javatutorial.net/set-java-home-windows-10/
59 | * Linux: https://www.cyberciti.biz/faq/linux-unix-set-java_home-path-variable/
60 |
61 | ## macOS, Linux only
62 | The following programs are needed for macOS and Linux
63 |
64 | ### homebrew
65 | Install using terminal
66 | https://brew.sh/
67 |
68 | ### OSM-tools
69 | 1. Install **osmium-tool** using homebrew in terminal:
70 | ```
71 | brew install osmium-tool
72 | ```
73 | 2. Install **Osmosis** using homebrew in terminal:
74 | ```
75 | brew install osmosis
76 | ```
77 |
78 | # wahooMapsCreator
79 | ## Create Anaconda environment
80 | 1. Open terminal (macOS/Linux) or **Anaconda Prompt** (Windows, via Startmenu)
81 | 2. Create a new Anaconda environment with needed packages
82 | ```
83 | conda create -n gdal-user python=3.10 geojson=2.5 gdal=3.6 requests=2.28 shapely=1.8 bs4=4.11 lxml=4.9 matplotlib=3.4.3 pip --channel conda-forge --override-channels
84 | ```
85 | 3. activate Anaconda environment with the command printed out (this needs to be done each time you want to use wahooMapsCreator maps)
86 | ```
87 | conda activate gdal-user
88 | ```
89 |
90 | ## Install wahooMapsCreator into Anaconda environment
91 | ```
92 | pip install wahoomc
93 | ```
94 |
95 | ### Update wahooMapsCreator
96 | If you have wahooMapsCreator already installed via pip and you want to install a newer version this can be done via:
97 | ```
98 | pip install wahoomc --upgrade
99 | ```
100 |
101 | If you want to upgrade to a version other than the release actual one, use this command:
102 | ```
103 | pip install wahoomc==2.0.0a5 --upgrade
104 | ```
105 |
106 | ## Additional programs for generating contour lines
107 | For integrating contour lines into the generated maps, some additional steps need to be taken.
108 | An additional Python packages has to be installed and you need an free account for USGS to query contour lines from.
109 |
110 | ### Install phyghtmap
111 | 1. Download and unpack http://katze.tfiu.de/projects/phyghtmap/phyghtmap_2.23.orig.tar.gz
112 | 2. Enter your Anaconda environment and go to the unpacked folder
113 | 3. Install phyghtmap into your Anaconda environment
114 |
115 | macOS / Linux
116 | ```
117 | sudo python setup.py install
118 | ```
119 |
120 | Windows
121 | ```
122 | python setup.py install
123 | ```
124 |
125 | ### Verify phyghtmap
126 | You can verify the installation of phyghtmap and dependant python packages if you enter the following into your Anaconda shell.
127 | ```
128 | phyghtmap
129 | ```
130 |
131 | If there is a output, phyghtmap was installed and recognized successfully
132 |
133 | ### Free account for USGS
134 | 1. Enter https://ers.cr.usgs.gov/ and create a free account. It's straight forward.
135 | 2. Remember your username and password.
136 |
137 | # Run wahooMapsCreator
138 | Run wahooMapsCreater as described in the [README](../README.md/#Run-wahooMapsCreator)
139 |
140 | # Additional information
141 | Additional information: https://opensourceoptions.com/blog/how-to-install-gdal-with-anaconda/
142 |
--------------------------------------------------------------------------------
/docs/TAGS_ON_MAP_AND_DEVICE.md:
--------------------------------------------------------------------------------
1 | # OSM-tags during map creation and on your device
2 |
3 | #### Table of contents
4 | - [Order of generating maps](#order-of-generating-maps)
5 | - [Zoom levels and scale](#zoom-levels-and-scale)
6 | - [Files used in map processing](#files-used-in-map-processing)
7 | - [File tags-to-keep.json](#file-tags-to-keepjson)
8 | - [File tag-wahoo.xml](#file-tag-wahooxml)
9 | - [Attribute "zoom-appear"](#attribute-zoom-appear)
10 | - [Combination of tags-to-keep.json and tag-wahoo.xml](#combination-of-tags-to-keepjson-and-tag-wahooxml)
11 | - [Device-Theme](#device-theme)
12 | - [Activate VTM Rendering](#activate-vtm-rendering)
13 | - [Preview maps and device themes using cruiser](#preview-maps-and-device-themes-using-cruiser)
14 | - [Attribute "zoom-min"](#attribute-zoom-min)
15 | - [Copy the theme to the device](#copy-the-theme-to-the-device)
16 | - [Use the theme in cruiser](#use-the-theme-in-cruiser)
17 | - [Combination of tag-wahoo.xml and device-theme](#combination-of-tag-wahooxml-and-device-theme)
18 | - [Adjustments of the device themes](#adjustments-of-the-device-themes)
19 | - [mapsforge-bolt.xml](#mapsforge-boltxml)
20 |
21 |
22 | # Order of generating maps
23 | 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.
24 |
25 | 1. Filter relevant OSM tags from raw OSM country files - [tags-to-keep.json](#file-tags-to-keepjson)
26 | 2. Create different map increments per tile: OSM map, land and sea
27 | 3. Merge these map increments into a merged .osm.pbf file
28 | 4. Create .map file while applying tag-wahoo.xml to the merged .osm.pbf file - [tag-wahoo.xml](#file-tag-wahooxml)
29 |
30 | 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).
31 |
32 | # Zoom levels and scale
33 | | Zoom level | Scale |
34 | | ---------- | :---: |
35 | | 10 | 10km |
36 | | 11 | 5km |
37 | | 12 | 2km |
38 | | 13 | 1km |
39 | | 14 | 500m |
40 | | 15 | 200m |
41 | | 16 | 100m |
42 |
43 | That information was derived from Wahoo BOLTv1. It might be different on different Wahoo devices.
44 |
45 | # Files used in map processing
46 | ## File tags-to-keep.json
47 | 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.
48 |
49 | ## File tag-wahoo.xml
50 | The `tag-wahoo.xml` files defines how to proceed wit OSM-elements during map generation.
51 | The OSM-tags defined in the tag-wahoo.xml are stored in the map file.
52 |
53 | E.g. roads, locations, ...
54 |
55 | ### Attribute "zoom-appear"
56 | 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.
57 |
58 | ### Combination of tags-to-keep.json and tag-wahoo.xml
59 | 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
60 | 1. `tags-to-keep.json` to not be filtered out
61 | 2. `tag-wahoo.xml` to be included in the generated maps
62 |
63 | # Device-Theme
64 | 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.
65 |
66 | There are two types of rendering methods: VTM and non-VTM rendering. This table shows the default rendering per device:
67 | | device | default rendering |
68 | | ------ | :---------------: |
69 | | ROAMv2 | VTM |
70 | | BOLTv2 | VTM |
71 | | ROAMv1 | non-VTM |
72 | | BOLTv1 | non-VTM |
73 | | ELEMNT | non-VTM |
74 |
75 | The VTM rendering device theme is called `vtm-elemnt.xml` and for the non-VTM devices the themes are named like the device, e.g. `mapsforge-bolt.xml` or `mapsforge-roam.xml`. Content wise it is more or less equal to the `tag-wahoo.xml` files.
76 |
77 | ## Activate VTM Rendering
78 | You can enable the VTM rendering method on Wahoo devices which do not have VTM rendering as default by creating a empty file on the device with the name "cfg_BHomeActivity_VtmMaps" in the root folder.
79 |
80 | ## Preview maps and device themes using cruiser
81 | cruiser is named throughout this file. See the documentation of using cruiser [here](USAGE_CRUISER.md#usage-of-cruiser) to know how to use it.
82 |
83 | ## Attribute "zoom-min"
84 | Each entry in the theme has a "zoom-min" attribute, which defines from which zoom level onwards the element will be shown. If zoom-min is set to 13, the OSM-tag will be displayed in zoom level 500m, 200m and 100m.
85 |
86 | ## Copy the theme to the device
87 | See [here](COPY_TO_WAHOO.md#Copy-device-theme)
88 |
89 | ## Use the theme in cruiser
90 | You should always use the corresponding theme in cruiser if you preview generated maps on your computer.
91 | Because the theme kind of determines what you're gonna see, you want to preview what later on will be visible on the device.
92 |
93 | ## Combination of tag-wahoo.xml and device-theme
94 | 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 your Wahoo device etc (zoom-min).
95 |
96 | 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.
97 |
98 | # Adjustments of the device themes
99 | This chapter documents, which changes are done to the files in `device_themes/adjusted` in comparision to the initial device themes.
100 |
101 | ## mapsforge-bolt.xml
102 | - render highway-secondary when zoomed out
103 | - from zoom 10 / 5km on (was zoom 13 / 500m before)
104 | - to have a overview when zoomed "out"
105 |
106 | - render highway-road only when zoomed in
107 | - from zoom 14 / 200m on (was zoom 13 / 500m before)
108 | - to make it clearly arranged when zoomed "out" by zoom 500m
109 |
--------------------------------------------------------------------------------
/docs/USAGE.md:
--------------------------------------------------------------------------------
1 | # Usage of wahooMapsCreator
2 | - [Usage of wahooMapsCreator](#usage-of-wahoomapscreator)
3 | - [Always activate environment first](#always-activate-environment-first)
4 | - [Run wahooMapsCreator for your country](#run-wahoomapscreator-for-your-country)
5 | - [GUI (Graphical User Interface)](#gui-graphical-user-interface)
6 | - [CLI (Command Line Interface)](#cli-command-line-interface)
7 | - [Advanced CLI-Usage](#advanced-cli-usage)
8 | - [Mandatory CLI arguments](#mandatory-cli-arguments)
9 | - [Optional arguments](#optional-arguments)
10 | - [Main arguments](#main-arguments)
11 | - [Examples](#examples)
12 | - [POIs - Points of Interest](#pois---points-of-interest)
13 | - [Contour lines](#contour-lines)
14 | - [User specific configuration](#user-specific-configuration)
15 |
16 | # Usage of wahooMapsCreator
17 | wahooMapsCreator can be used in two different ways:
18 | - as [graphical window](#gui-graphical-user-interface) programm
19 | - as [command line](#cli-command-line-interface) programm
20 |
21 | 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).
22 |
23 | ## Always activate environment first
24 | ```
25 | conda activate gdal-user
26 | ```
27 |
28 | ## Run wahooMapsCreator for your country
29 | It might be a good idea to run wahooMapsCreator first for a small country e.g. Malta to check if everything is running fine.
30 | In a next step you can run it for your own country.
31 |
32 | ## GUI (Graphical User Interface)
33 |
34 | From the `root` folder of wahooMapsCreator, run:
35 | - `python -m wahoomc gui`
36 |
37 | Set your arguments as required via the window:
38 |
39 |
40 |
41 | ## CLI (Command Line Interface)
42 |
43 | From the `root` folder of wahooMapsCreator, run:
44 | - `python -m wahoomc cli -co `
45 |
46 | Examples:
47 | - for Malta: `python -m wahoomc cli -co malta`
48 | - for Ireland: `python -m wahoomc cli -co ireland`
49 |
50 | ## Advanced CLI-Usage
51 | wahooMapsCreator supports many arguments via command line.
52 | For a list of all supported arguments, run:
53 | - `python -m wahoomc cli -h`
54 |
55 |
56 | wahooMapsCreator provides following arguments, later on, there are some example calls
57 |
58 | ### Mandatory CLI arguments
59 | One of them is mandatory for running in CLI mode.
60 |
61 | | Option | Description | Default Value |
62 | | :----- | :------------------------------------------------------------------------------------ | :------------ |
63 | | -co | One or more Country to create maps or to create maps for. `malta` or `malta,germany`. | - |
64 | | -xy | One or more X/Y coordinates to create maps for. `133/35` or `133/35,133/66`. | - |
65 |
66 |
67 | ### Optional arguments
68 | If you like to run wahooMapsCreator with another value than the default, use the following arguments.
69 |
70 | | Option | Description | Default Value |
71 | | :----- | :--------------------------------------------------------------------------------------------------------------- | :------------------ |
72 | | -md | Maximum age of source maps and other files in days. | 24 |
73 | | -nbc | Do not process border countries of tiles involving more than one country. Only useful when processing a country. | false |
74 | | -con | Calculate contour lines (elevation) and integrate into generated maps (using view1 as data source). | false |
75 | | -srtm1 | Use SRTM1 data as source for calculating contour lines (elevation) maps. Has only affect togester with -con. | false |
76 | | -fd | Force download of files. Download all files new. | false |
77 | | -fp | Force processing of files. Create all files new. | false |
78 | | -c | Save uncompressed maps for Cruiser. | false |
79 | | -tag | File with tags to keep in the output. | `tag-wahoo-poi.xml` |
80 | | -z | Zip the country (and country-maps) folder. | false |
81 | | -v | Output debug logger messages. | false |
82 | | -hdd | Use mapwriters hdd mode, 'type=hd' parameter. Slower processing, but good for low memory systems. | false |
83 |
84 | ### Main arguments
85 | **Create maps for a country**
86 | - `python -m wahoomc cli -co `
87 |
88 | **Create maps for X/Y coordinates**
89 |
90 | In particular for testing adjustments in configuration-files or coding it is helpful to create maps for only one tile or a handful of tiles!
91 |
92 | To create maps for only one tile and not a whole country, one can use the X/Y coordinates of that tile. X/Y coordinates can be retrieved from this in zoom-level 8: [link](http://tools.geofabrik.de/map/#8/50.3079/8.8026&type=Geofabrik_Standard&grid=1).
93 | - `python -m wahoomc cli -xy `
94 |
95 | ### Examples
96 | - for Malta, download new maps if existing maps are older than 100 days and process files even if files exist
97 | - `python -m wahoomc cli -co malta -md 100 -fp`
98 | - for Germany, download and process whole tiles which involves other countries than the given
99 | - `python -m wahoomc cli -co germany -bc`
100 | - to create maps for only one tile
101 | - `python -m wahoomc cli -xy 134/88`
102 | - for multiple tiles
103 | - `python -m wahoomc cli -xy 134/88,133/88`
104 |
105 | ## POIs - Points of Interest
106 | For creating maps which include POIs and have them displayed on your Wahoo device, these steps need to be done:
107 | 1. Create custom maps including POIs like [normally](#run-wahoomapscreator-for-your-country), POI's are included per default.
108 |
109 | Actually, wahooMapsCreator includes fuel stations, backeries, cafes and railway stations POI's into the generated maps.
110 |
111 | 2. Copy POIs relevant files to your device
112 | - [:floppy_disk: docu](COPY_TO_WAHOO.md#copy-relevant-files-for-pois)
113 |
114 | 3. Activate VTM rendering if needed
115 | - [see here](COPY_TO_WAHOO.md#activate-vtm-rendering)
116 | - see also: https://github.com/treee111/wahooMapsCreator/wiki/Enable-hidden-features
117 |
118 | ## Contour lines
119 | For creating maps which include contour lines and have them displayed on your Wahoo device, these steps need to be done:
120 | 1. Enhance your Anaconda environment using [these steps](./QUICKSTART_ANACONDA.md#additions-for--generating-contour-lines)
121 | 2. Create custom maps with the argument `-con` like [normally](#run-wahoomapscreator-for-your-country). You will be asked for username/password on first run generating contour lines.
122 | 3. Use a theme that renders contour lines
123 |
124 | ## User specific configuration
125 | You can control popular configuration with your own files in the home directory `wahooMapsCreatorData/_config`.
126 |
127 | 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.
128 |
129 | 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.
130 |
131 | 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.
132 |
133 | The structure of `~/wahooMapsCreatorData/_config/tag_wahoo_adjusted/` is analogue to the one in the repo: `wahooMapsCreatorwahoomc/resources`.
134 |
--------------------------------------------------------------------------------
/docs/USAGE_CRUISER.md:
--------------------------------------------------------------------------------
1 | # Usage of cruiser
2 | - [Usage of cruiser](#usage-of-cruiser)
3 | - [Setting things up](#setting-things-up)
4 | - [Run cruiser](#run-cruiser)
5 | - [UI Elements](#ui-elements)
6 | - [Select rendering engine](#select-rendering-engine)
7 | - [Select map and device theme](#select-map-and-device-theme)
8 |
9 | # Usage of cruiser
10 | cruiser can be used to view the generated maps on your computer before copying them onto your Wahoo device. You'll select two things in cruiser: the generated .map file and the device theme.
11 |
12 | By doing so, you can check if the wanted OSM elements are in your generated map files and if and how and the device theme will display them (and later on your Wahoo device).
13 |
14 | ## Setting things up
15 | 1. Download the latest cruiser version from: https://github.com/devemux86/cruiser/releases/latest and extract.
16 |
17 | 2. Create uncompressed maps for usage in cruiser. The map files you use for the Wahoo device are compressed and cannot be used in cruiser.
18 |
19 | Either use `-c` CLI argument or set the checkbox in the Advanced settings when running the GUI.
20 |
21 | ## Run cruiser
22 | Running cruiser is most simly by running `cruiser.jar`. Running the other files via command line is also possible
23 |
24 | ## UI Elements
25 | You select maps and device themes with the Map menuitem `(1)`. Selecting the rendering engine can be established with Settings->Rendering engine `(2)`.
26 |
27 |
28 |
29 | ### Select rendering engine
30 | Depending if you like to render VTM or non-VTM later on on your Wahoo device you need to choose either VTM rendering or Mapsforge.
31 |
32 | Most probably you want to view POIs and therefore use VTM rendering.
33 |
34 | ### Select map and device theme
35 | While creating the maps for cruiser, for e.g. `malta`, a folder called `malta-maps` was created. Choose a .map file of this folder for viewing in cruiser.
36 |
37 |
38 |
39 | Choose a device theme of your choice.
40 | - from within the repo in the directory `device_themes`
41 | - from the downloaded device_themes.zip file
42 | - on your computer adjusted to your needs
43 |
44 | Depending of which rendering engine you use you need the vtm-element.xml or a non-VTM device theme.
45 |
46 | This screenshot is for a non-VTM theme.
47 |
48 |
--------------------------------------------------------------------------------
/docs/pictures/cruiser-map-selection.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/docs/pictures/cruiser-map-selection.png
--------------------------------------------------------------------------------
/docs/pictures/cruiser-theme-selection.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/docs/pictures/cruiser-theme-selection.png
--------------------------------------------------------------------------------
/docs/pictures/cruiser-ui-elements.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/docs/pictures/cruiser-ui-elements.png
--------------------------------------------------------------------------------
/docs/pictures/gui.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/docs/pictures/gui.png
--------------------------------------------------------------------------------
/docs/pictures/maps-american_samoa-generated.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/docs/pictures/maps-american_samoa-generated.png
--------------------------------------------------------------------------------
/docs/pictures/maps-american_samoa-wahoo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/docs/pictures/maps-american_samoa-wahoo.png
--------------------------------------------------------------------------------
/docs/pictures/maps-file-structure.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/docs/pictures/maps-file-structure.png
--------------------------------------------------------------------------------
/docs/pictures/unittest-land-poligons.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/docs/pictures/unittest-land-poligons.png
--------------------------------------------------------------------------------
/docs/pictures/wahoo_elemnt_bolt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/docs/pictures/wahoo_elemnt_bolt.png
--------------------------------------------------------------------------------
/docs/pictures/wahoo_elemnt_bolt_poi1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/docs/pictures/wahoo_elemnt_bolt_poi1.png
--------------------------------------------------------------------------------
/docs/pictures/wahoo_elemnt_bolt_poi2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/docs/pictures/wahoo_elemnt_bolt_poi2.png
--------------------------------------------------------------------------------
/pyproject.toml:
--------------------------------------------------------------------------------
1 | [build-system]
2 | requires = [
3 | "setuptools>=42",
4 | "wheel"
5 | ]
6 | build-backend = "setuptools.build_meta"
--------------------------------------------------------------------------------
/setup.cfg:
--------------------------------------------------------------------------------
1 | [metadata]
2 | name = wahoomc
3 | version = 4.3.0
4 | author = Benjamin Kreuscher
5 | author_email = benni.kreuscher@gmail.com
6 | description = Create maps for your Wahoo bike computer based on latest OSM maps
7 | long_description = file: README.md
8 | long_description_content_type = text/markdown
9 | url = https://github.com/treee111/wahooMapsCreator
10 | project_urls =
11 | Bug Tracker = https://github.com/treee111/wahooMapsCreator/issues
12 | classifiers =
13 | Programming Language :: Python :: 3
14 | License :: OSI Approved :: MIT License
15 | Operating System :: OS Independent
16 |
17 | [options]
18 | packages = wahoomc, wahoomc.init
19 | python_requires = >=3.10
20 |
21 | [options.package_data]
22 | wahoomc = resources/*.*, resources/*/*.*, resources/*/*/*.*, resources/*/*/*/*.*, tooling_win/*.*, tooling_win/*/*.*, tooling_win/*/*/*.*, tooling_win/*/*/*/*.*
--------------------------------------------------------------------------------
/tests/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/__init__.py
--------------------------------------------------------------------------------
/tests/resources/liechtenstein-latest_2021-10-31.osm.pbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/liechtenstein-latest_2021-10-31.osm.pbf
--------------------------------------------------------------------------------
/tests/resources/macos/134/89.map:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/macos/134/89.map
--------------------------------------------------------------------------------
/tests/resources/macos/134/89.map.lzma:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/macos/134/89.map.lzma
--------------------------------------------------------------------------------
/tests/resources/macos/134/89.map.lzma.17:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/macos/134/89.map.lzma.17
--------------------------------------------------------------------------------
/tests/resources/macos/134/89/land.prj:
--------------------------------------------------------------------------------
1 | GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]
--------------------------------------------------------------------------------
/tests/resources/macos/134/89/land.shp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/macos/134/89/land.shp
--------------------------------------------------------------------------------
/tests/resources/macos/134/89/land.shx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/macos/134/89/land.shx
--------------------------------------------------------------------------------
/tests/resources/macos/134/89/land1.osm:
--------------------------------------------------------------------------------
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 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
--------------------------------------------------------------------------------
/tests/resources/macos/134/89/merged.osm.pbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/macos/134/89/merged.osm.pbf
--------------------------------------------------------------------------------
/tests/resources/macos/134/89/sea.osm:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/tests/resources/macos/134/89/split-liechtenstein-names.osm.pbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/macos/134/89/split-liechtenstein-names.osm.pbf
--------------------------------------------------------------------------------
/tests/resources/macos/134/89/split-liechtenstein.osm.pbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/macos/134/89/split-liechtenstein.osm.pbf
--------------------------------------------------------------------------------
/tests/resources/macos/137/100.map:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/macos/137/100.map
--------------------------------------------------------------------------------
/tests/resources/macos/137/100.map.lzma:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/macos/137/100.map.lzma
--------------------------------------------------------------------------------
/tests/resources/macos/137/100.map.lzma.17:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/macos/137/100.map.lzma.17
--------------------------------------------------------------------------------
/tests/resources/macos/137/100/land.prj:
--------------------------------------------------------------------------------
1 | GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]
--------------------------------------------------------------------------------
/tests/resources/macos/137/100/land.shp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/macos/137/100/land.shp
--------------------------------------------------------------------------------
/tests/resources/macos/137/100/land.shx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/macos/137/100/land.shx
--------------------------------------------------------------------------------
/tests/resources/macos/137/100/merged.osm.pbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/macos/137/100/merged.osm.pbf
--------------------------------------------------------------------------------
/tests/resources/macos/137/100/sea.osm:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/tests/resources/macos/137/100/split-malta-names.osm.pbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/macos/137/100/split-malta-names.osm.pbf
--------------------------------------------------------------------------------
/tests/resources/macos/137/100/split-malta.osm.pbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/macos/137/100/split-malta.osm.pbf
--------------------------------------------------------------------------------
/tests/resources/macos/138/100.map:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/macos/138/100.map
--------------------------------------------------------------------------------
/tests/resources/macos/138/100.map.lzma:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/macos/138/100.map.lzma
--------------------------------------------------------------------------------
/tests/resources/macos/138/100.map.lzma.17:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/macos/138/100.map.lzma.17
--------------------------------------------------------------------------------
/tests/resources/macos/138/100/land.prj:
--------------------------------------------------------------------------------
1 | GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]
--------------------------------------------------------------------------------
/tests/resources/macos/138/100/land.shp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/macos/138/100/land.shp
--------------------------------------------------------------------------------
/tests/resources/macos/138/100/land.shx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/macos/138/100/land.shx
--------------------------------------------------------------------------------
/tests/resources/macos/138/100/merged.osm.pbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/macos/138/100/merged.osm.pbf
--------------------------------------------------------------------------------
/tests/resources/macos/138/100/sea.osm:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/tests/resources/macos/138/100/split-malta-names.osm.pbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/macos/138/100/split-malta-names.osm.pbf
--------------------------------------------------------------------------------
/tests/resources/macos/138/100/split-malta.osm.pbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/macos/138/100/split-malta.osm.pbf
--------------------------------------------------------------------------------
/tests/resources/macos/liechtenstein/filtered.o5m.pbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/macos/liechtenstein/filtered.o5m.pbf
--------------------------------------------------------------------------------
/tests/resources/macos/liechtenstein/filtered_names.o5m.pbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/macos/liechtenstein/filtered_names.o5m.pbf
--------------------------------------------------------------------------------
/tests/resources/macos/malta/filtered.o5m.pbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/macos/malta/filtered.o5m.pbf
--------------------------------------------------------------------------------
/tests/resources/macos/malta/filtered_names.o5m.pbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/macos/malta/filtered_names.o5m.pbf
--------------------------------------------------------------------------------
/tests/resources/malta-latest_2021-10-31.osm.pbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/malta-latest_2021-10-31.osm.pbf
--------------------------------------------------------------------------------
/tests/resources/windows/134/89.map:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/windows/134/89.map
--------------------------------------------------------------------------------
/tests/resources/windows/134/89.map.lzma:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/windows/134/89.map.lzma
--------------------------------------------------------------------------------
/tests/resources/windows/134/89.map.lzma.17:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/windows/134/89.map.lzma.17
--------------------------------------------------------------------------------
/tests/resources/windows/134/89/land.prj:
--------------------------------------------------------------------------------
1 | GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]
--------------------------------------------------------------------------------
/tests/resources/windows/134/89/land.shp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/windows/134/89/land.shp
--------------------------------------------------------------------------------
/tests/resources/windows/134/89/land.shx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/windows/134/89/land.shx
--------------------------------------------------------------------------------
/tests/resources/windows/134/89/land1.osm:
--------------------------------------------------------------------------------
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 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
--------------------------------------------------------------------------------
/tests/resources/windows/134/89/merged.osm.pbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/windows/134/89/merged.osm.pbf
--------------------------------------------------------------------------------
/tests/resources/windows/134/89/sea.osm:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/tests/resources/windows/134/89/split-liechtenstein-names.osm.pbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/windows/134/89/split-liechtenstein-names.osm.pbf
--------------------------------------------------------------------------------
/tests/resources/windows/134/89/split-liechtenstein.osm.pbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/windows/134/89/split-liechtenstein.osm.pbf
--------------------------------------------------------------------------------
/tests/resources/windows/137/100.map:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/windows/137/100.map
--------------------------------------------------------------------------------
/tests/resources/windows/137/100.map.lzma:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/windows/137/100.map.lzma
--------------------------------------------------------------------------------
/tests/resources/windows/137/100.map.lzma.17:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/windows/137/100.map.lzma.17
--------------------------------------------------------------------------------
/tests/resources/windows/137/100/land.prj:
--------------------------------------------------------------------------------
1 | GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]
--------------------------------------------------------------------------------
/tests/resources/windows/137/100/land.shp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/windows/137/100/land.shp
--------------------------------------------------------------------------------
/tests/resources/windows/137/100/land.shx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/windows/137/100/land.shx
--------------------------------------------------------------------------------
/tests/resources/windows/137/100/merged.osm.pbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/windows/137/100/merged.osm.pbf
--------------------------------------------------------------------------------
/tests/resources/windows/137/100/sea.osm:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/tests/resources/windows/137/100/split-malta-names.osm.pbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/windows/137/100/split-malta-names.osm.pbf
--------------------------------------------------------------------------------
/tests/resources/windows/137/100/split-malta.osm.pbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/windows/137/100/split-malta.osm.pbf
--------------------------------------------------------------------------------
/tests/resources/windows/138/100.map:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/windows/138/100.map
--------------------------------------------------------------------------------
/tests/resources/windows/138/100.map.lzma:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/windows/138/100.map.lzma
--------------------------------------------------------------------------------
/tests/resources/windows/138/100.map.lzma.17:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/windows/138/100.map.lzma.17
--------------------------------------------------------------------------------
/tests/resources/windows/138/100/land.prj:
--------------------------------------------------------------------------------
1 | GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]
--------------------------------------------------------------------------------
/tests/resources/windows/138/100/land.shp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/windows/138/100/land.shp
--------------------------------------------------------------------------------
/tests/resources/windows/138/100/land.shx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/windows/138/100/land.shx
--------------------------------------------------------------------------------
/tests/resources/windows/138/100/merged.osm.pbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/windows/138/100/merged.osm.pbf
--------------------------------------------------------------------------------
/tests/resources/windows/138/100/sea.osm:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/tests/resources/windows/138/100/split-malta-names.osm.pbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/windows/138/100/split-malta-names.osm.pbf
--------------------------------------------------------------------------------
/tests/resources/windows/138/100/split-malta.osm.pbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/windows/138/100/split-malta.osm.pbf
--------------------------------------------------------------------------------
/tests/resources/windows/liechtenstein/filtered.o5m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/windows/liechtenstein/filtered.o5m
--------------------------------------------------------------------------------
/tests/resources/windows/liechtenstein/filtered_names.o5m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/windows/liechtenstein/filtered_names.o5m
--------------------------------------------------------------------------------
/tests/resources/windows/liechtenstein/outFile.o5m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/windows/liechtenstein/outFile.o5m
--------------------------------------------------------------------------------
/tests/resources/windows/malta/filtered.o5m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/windows/malta/filtered.o5m
--------------------------------------------------------------------------------
/tests/resources/windows/malta/filtered_names.o5m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/windows/malta/filtered_names.o5m
--------------------------------------------------------------------------------
/tests/resources/windows/malta/outFile.o5m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/tests/resources/windows/malta/outFile.o5m
--------------------------------------------------------------------------------
/tests/test_cli.py:
--------------------------------------------------------------------------------
1 | """
2 | tests for the python file
3 | """
4 | import os
5 | import unittest
6 |
7 | # import custom python packages
8 |
9 |
10 | class TestCli(unittest.TestCase):
11 | """
12 | tests for the CLI of the python file
13 | """
14 |
15 | def test_top_parser_help(self):
16 | """
17 | tests, if help of top parser can be called
18 | """
19 |
20 | result = os.system("python -m wahoomc -h")
21 |
22 | self.assertEqual(result, 0)
23 |
24 | def test_cli_help(self):
25 | """
26 | tests, if CLI help can be called
27 | """
28 |
29 | result = os.system("python -m wahoomc cli -h")
30 |
31 | self.assertEqual(result, 0)
32 |
33 | def test_gui_help(self):
34 | """
35 | tests, if GUI help can be called
36 | """
37 |
38 | result = os.system("python -m wahoomc gui -h")
39 |
40 | self.assertEqual(result, 0)
41 |
42 |
43 | if __name__ == '__main__':
44 | unittest.main()
45 |
--------------------------------------------------------------------------------
/tests/test_constants.py:
--------------------------------------------------------------------------------
1 | """
2 | tests for the downloader file
3 | """
4 | import os
5 | import unittest
6 | import mock
7 |
8 |
9 | from wahoomc.constants_functions import translate_tags_to_keep, \
10 | get_tag_wahoo_xml_path, TagWahooXmlNotFoundError
11 | from wahoomc.constants import RESOURCES_DIR
12 |
13 |
14 | tags_universal_simple = {"TAGS_TO_KEEP_UNIVERSAL": {
15 | 'access': '',
16 | 'area': 'yes'
17 | }}
18 |
19 | tags_universal_adv = {"TAGS_TO_KEEP_UNIVERSAL": {
20 | 'access': '',
21 | 'area': 'yes',
22 | 'bicycle': '',
23 | 'bridge': '',
24 | 'foot': ['ft_yes', 'foot_designated']
25 | }}
26 |
27 |
28 | class TestTranslateTags(unittest.TestCase):
29 | """
30 | tests for translating tags-constants between the universal format and OS-specific formats
31 | """
32 |
33 | @ mock.patch("wahoomc.file_directory_functions.json.load")
34 | @ mock.patch("wahoomc.open")
35 | def test_translate_tags_to_keep_simple_macos(self, mock_open, mock_json_load): # pylint: disable=unused-argument
36 | """
37 | Test translating tags to keep from universal format to macOS
38 | """
39 | tags = ['access', 'area=yes']
40 | mock_json_load.return_value = tags_universal_simple
41 |
42 | transl_tags = translate_tags_to_keep()
43 | self.assertEqual(tags, transl_tags)
44 |
45 | @ mock.patch("wahoomc.file_directory_functions.json.load")
46 | @ mock.patch("wahoomc.open")
47 | def test_translate_tags_to_keep_simple_win(self, mock_open, mock_json_load): # pylint: disable=unused-argument
48 | """
49 | Test translating tags to keep from universal format to Windows
50 | """
51 | tags_win = 'access= area=yes'
52 | mock_json_load.return_value = tags_universal_simple
53 |
54 | transl_tags = translate_tags_to_keep(sys_platform='Windows')
55 | self.assertEqual(tags_win, transl_tags)
56 |
57 | @ mock.patch("wahoomc.file_directory_functions.json.load")
58 | @ mock.patch("wahoomc.open")
59 | def test_translate_tags_to_keep_adv_macos(self, mock_open, mock_json_load): # pylint: disable=unused-argument
60 | """
61 | Test translating tags to keep from universal format to macOS
62 | """
63 | tags = ['access', 'area=yes', 'bicycle',
64 | 'bridge', 'foot=ft_yes, foot_designated']
65 | mock_json_load.return_value = tags_universal_adv
66 |
67 | transl_tags = translate_tags_to_keep()
68 | self.assertEqual(tags, transl_tags)
69 |
70 | @ mock.patch("wahoomc.file_directory_functions.json.load")
71 | @ mock.patch("wahoomc.open")
72 | def test_translate_tags_to_keep_adv_win(self, mock_open, mock_json_load): # pylint: disable=unused-argument
73 | """
74 | Test translating tags to keep from universal format to Windows
75 | """
76 | tags_win = 'access= area=yes bicycle= bridge= foot=ft_yes =foot_designated'
77 | mock_json_load.return_value = tags_universal_adv
78 |
79 | transl_tags = translate_tags_to_keep(sys_platform='Windows')
80 | self.assertEqual(tags_win, transl_tags)
81 |
82 | def test_translate_tags_to_keep_full_macos(self):
83 | """
84 | Test translating tags to keep from universal format to macOS // all "tags to keep"
85 | """
86 | tags = ['access', 'area=yes', 'bicycle', 'bridge', 'foot=ft_yes, foot_designated',
87 | 'amenity=fuel, cafe, drinking_water, shelter', 'shop=bakery, bicycle',
88 | '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',
89 | 'natural=coastline, nosea, sea, beach, land, scrub, water, wetland, wood',
90 | 'landuse=forest, commercial, industrial, residential, retail',
91 | 'leisure=park, nature_reserve', 'railway=rail, tram, station, stop',
92 | 'surface', 'tracktype', 'tunnel', 'waterway=canal, drain, river, riverbank, stream', 'wood=deciduous', 'tourism=alpine_hut']
93 |
94 | transl_tags = translate_tags_to_keep(use_repo=True)
95 | self.assertEqual(tags, transl_tags)
96 |
97 | def test_translate_tags_to_keep_full_win(self):
98 | """
99 | Test translating tags to keep from universal format to Windows // all "tags to keep"
100 | """
101 | tags_win = 'access= area=yes bicycle= bridge= foot=ft_yes =foot_designated amenity=fuel =cafe =drinking_water =shelter 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 =stream wood=deciduous tourism=alpine_hut'
102 |
103 | transl_tags = translate_tags_to_keep(
104 | sys_platform='Windows', use_repo=True)
105 | self.assertEqual(tags_win, transl_tags)
106 |
107 | def test_translate_name_tags_to_keep_full_macos(self):
108 | """
109 | Test translating name tags to keep from universal format to Windows // all "name tags to keep"
110 | """
111 | names_tags = ['admin_level=2', 'area=yes', 'mountain_pass', 'natural',
112 | 'place=city, hamlet, island, isolated_dwelling, islet, locality, suburb, town, village, country']
113 |
114 | transl_tags = translate_tags_to_keep(name_tags=True, use_repo=True)
115 | self.assertEqual(names_tags, transl_tags)
116 |
117 | def test_translate_name_tags_to_keep_full_win(self):
118 | """
119 | Test translating name tags to keep from universal format to macOS // all "name tags to keep"
120 | """
121 |
122 | names_tags_win = 'admin_level=2 area=yes mountain_pass= natural= place=city =hamlet =island =isolated_dwelling =islet =locality =suburb =town =village =country'
123 |
124 | transl_tags = translate_tags_to_keep(
125 | name_tags=True, sys_platform='Windows', use_repo=True)
126 | self.assertEqual(names_tags_win, transl_tags)
127 |
128 |
129 | class TestTagWahooXML(unittest.TestCase):
130 | """
131 | tests for tag-wahoo xml file
132 | """
133 |
134 | def test_not_existing_tag_wahoo_xml(self):
135 | """
136 | check if a non-existing tag-wahoo xml file issues an exception
137 | """
138 | with self.assertRaises(TagWahooXmlNotFoundError):
139 | get_tag_wahoo_xml_path("not_existing.xml")
140 |
141 | def test_existing_tag_wahoo_xml(self):
142 | """
143 | check if the correct path of an existing tag-wahoo xml file is returned
144 | """
145 |
146 | expected_path = os.path.join(
147 | RESOURCES_DIR, "tag_wahoo_adjusted", "tag-wahoo-poi.xml")
148 | self.assertEqual(get_tag_wahoo_xml_path(
149 | "tag-wahoo-poi.xml"), expected_path)
150 |
151 |
152 | if __name__ == '__main__':
153 | unittest.main()
154 |
--------------------------------------------------------------------------------
/tests/test_constants_geofabrik.py:
--------------------------------------------------------------------------------
1 | """
2 | tests for the constants geofabrik & geofabrik file
3 | """
4 | import os
5 | import unittest
6 |
7 | import geojson # pylint: disable=import-error
8 |
9 | # import custom python packages
10 | from wahoomc.downloader import Downloader
11 | from wahoomc import constants
12 | from wahoomc.geofabrik_json import GeofabrikJson
13 | from wahoomc.geofabrik_json import CountyIsNoGeofabrikCountry
14 |
15 |
16 | class TestConstantsGeofabrik(unittest.TestCase):
17 | """
18 | tests for constants in geofabrik context
19 | """
20 |
21 | def setUp(self):
22 | if not os.path.isfile(constants.GEOFABRIK_PATH):
23 | o_downloader = Downloader(24, False)
24 | o_downloader.download_geofabrik_file()
25 |
26 | self.o_geofabrik_json = GeofabrikJson()
27 |
28 | self.relevant_countries = []
29 |
30 | # calc relevant countries in constructor. these should be valid for the whole class
31 | with open(constants.GEOFABRIK_PATH, encoding='utf8') as file_handle:
32 | raw_json = geojson.load(file_handle)
33 | file_handle.close()
34 |
35 | for entry in raw_json.features:
36 | id_no = entry.properties['id']
37 | self.relevant_countries.append(id_no)
38 |
39 | def test_if_json_countries_exist_in_geofabrik(self):
40 | """
41 | go through all files in the wahoo_mc/resources/json directory
42 | - check if each country does also exist in geofabrik
43 | - some countries are skipped because they do not exist in geofabrik
44 | """
45 | for country in self.relevant_countries:
46 | child = self.o_geofabrik_json.translate_id_no_to_geofabrik(country)
47 |
48 | self.assertIn(child, {country.replace(
49 | '_', '-'), 'us/'+country.replace('_', '-')})
50 |
51 | def test_regions_of_geofabrik(self):
52 | """
53 | go through all files in the wahoo_mc/resources/json directory
54 | - check if each country does also exist in geofabrik
55 | - some countries are skipped because they do not exist in geofabrik
56 | """
57 |
58 | id_with_no_parent_geofabrik = []
59 | regions_geofabrik = []
60 |
61 | geofabrik_regions = ['africa', 'antarctica', 'asia', 'australia-oceania',
62 | 'central-america', 'europe', 'north-america', 'south-america', 'russia']
63 |
64 | # check against (new) raw representation of geofabrik json
65 | for feature in self.o_geofabrik_json.raw_json.features:
66 | try:
67 | feature.properties['parent']
68 | except KeyError:
69 | id_with_no_parent_geofabrik.append(feature.properties['id'])
70 |
71 | self.assertCountEqual(geofabrik_regions,
72 | id_with_no_parent_geofabrik)
73 |
74 | # also check against (new) created dict
75 | for region in self.o_geofabrik_json.geofabrik_region_overview:
76 | regions_geofabrik.append(region)
77 | self.assertCountEqual(geofabrik_regions,
78 | regions_geofabrik)
79 |
80 | def test_reading_geofabrik_parent(self):
81 | """
82 | go through all files in the wahoo_mc/resources/json directory
83 | - compare the built URL via existing coding with the url out of the geofabrik json file
84 | - some countries are skipped because they do not exist in geofabrik
85 | - in addition
86 | - skip countries if there is a geofabrik URL (because this URL is different to the built one)
87 | - skip countries which do not have a direct geofabrik json entry, mostly they are in another country/region
88 | """
89 | parent, child = self.o_geofabrik_json.get_geofabrik_parent_country(
90 | 'germany')
91 | self.assertTrue(parent == 'europe' and child == 'germany')
92 |
93 | parent, child = self.o_geofabrik_json.get_geofabrik_parent_country(
94 | 'baden-wuerttemberg')
95 | self.assertTrue(parent == 'germany' and child == 'baden-wuerttemberg')
96 |
97 | parent, child = self.o_geofabrik_json.get_geofabrik_parent_country(
98 | 'malta')
99 | self.assertTrue(parent == 'europe' and child == 'malta')
100 |
101 | parent, child = self.o_geofabrik_json.get_geofabrik_parent_country(
102 | 'asia')
103 | self.assertTrue(parent == '' and child == 'asia')
104 |
105 | with self.assertRaises(CountyIsNoGeofabrikCountry):
106 | parent, child = self.o_geofabrik_json.get_geofabrik_parent_country(
107 | 'xy')
108 |
109 | def test_if_input_is_geofabrik_id(self):
110 | """
111 | check if the input is a id of the geofabrik file
112 | """
113 | self.assertTrue(
114 | self.o_geofabrik_json.is_input_a_geofabrik_id_no('germany'))
115 |
116 | self.assertTrue(
117 | self.o_geofabrik_json.is_input_a_geofabrik_id_no('baden-wuerttemberg'))
118 |
119 | self.assertTrue(
120 | self.o_geofabrik_json.is_input_a_geofabrik_id_no('asia'))
121 | self.assertFalse(
122 | self.o_geofabrik_json.is_input_a_geofabrik_id_no('xy'))
123 |
124 | self.assertFalse(self.o_geofabrik_json.is_input_a_geofabrik_id_no('*'))
125 |
126 | def test_tranlation_id_to_geofabrik_id(self):
127 | """
128 | get geofabrik id by country .json filename
129 | """
130 | transl_country = self.o_geofabrik_json.translate_id_no_to_geofabrik(
131 | 'malta')
132 | self.assertEqual('malta', transl_country)
133 |
134 | transl_country = self.o_geofabrik_json.translate_id_no_to_geofabrik(
135 | 'solomon_islands')
136 | self.assertEqual('solomon-islands', transl_country)
137 |
138 | transl_country = self.o_geofabrik_json.translate_id_no_to_geofabrik(
139 | 'nebraska')
140 | self.assertEqual('us/nebraska', transl_country)
141 |
142 |
143 | if __name__ == '__main__':
144 | unittest.main()
145 |
--------------------------------------------------------------------------------
/tests/test_downloader.py:
--------------------------------------------------------------------------------
1 | """
2 | tests for the downloader file
3 | """
4 | import os
5 | # import sys
6 | import posixpath
7 | import unittest
8 | import time
9 | import shutil
10 | import platform
11 |
12 | # import custom python packages
13 | # sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
14 |
15 | from wahoomc.downloader import older_than_x_days
16 | from wahoomc.downloader import download_file
17 | from wahoomc.downloader import build_osm_pbf_filepath
18 | from wahoomc.downloader import download_tooling
19 | from wahoomc.downloader import Downloader
20 | from wahoomc import constants
21 | from wahoomc.constants_functions import get_tooling_win_path
22 | from wahoomc.geofabrik_json import GeofabrikJson
23 |
24 |
25 | class TestDownloader(unittest.TestCase):
26 | """
27 | tests for the downloader file
28 | """
29 |
30 | def setUp(self):
31 | self.max_days_old = 14
32 |
33 | self.o_downloader = Downloader(24, False)
34 |
35 | def test_outdated_timestamp(self):
36 | """
37 | Test a outdated timestamp against 14 days ago
38 | """
39 |
40 | past = time.time() - (60 * 60 * 24 * 20)
41 |
42 | result = older_than_x_days(past, self.max_days_old)
43 | self.assertTrue(result)
44 |
45 | def test_outdated_timestamp_2(self):
46 | """
47 | Test a outdated timestamp against 14 days ago
48 | """
49 |
50 | result = older_than_x_days(1601097377.792748, self.max_days_old)
51 | self.assertTrue(result)
52 |
53 | def test_today_timestamp(self):
54 | """
55 | Test today timestamp against 14 days ago
56 | """
57 |
58 | today = time.time()
59 |
60 | result = older_than_x_days(today, self.max_days_old)
61 | self.assertFalse(result)
62 |
63 | def test_future_timestamp(self):
64 | """
65 | Test a timestamp in the future against 14 days ago
66 | """
67 |
68 | future = time.time() + (60 * 60 * 24 * 20)
69 |
70 | result = older_than_x_days(future, self.max_days_old)
71 | self.assertFalse(result)
72 |
73 | def test_download_geofabrik_file(self):
74 | """
75 | Test the download of geofabrik file via URL
76 | """
77 | path = os.path.join(constants.USER_DL_DIR, 'geofabrik.json')
78 | download_file(
79 | path, 'https://download.geofabrik.de/index-v1.json', False)
80 |
81 | self.assertTrue(os.path.exists(path))
82 |
83 | def test_download_geofabrik_file_2(self):
84 | """
85 | Test the download of geofabrik file via URL.
86 | check & download via built functions of downloader class
87 | """
88 | path = os.path.join(constants.USER_DL_DIR, 'geofabrik.json')
89 |
90 | if os.path.exists(path):
91 | os.remove(path)
92 |
93 | self.assertTrue(
94 | self.o_downloader.should_geofabrik_file_be_downloaded())
95 |
96 | self.o_downloader.download_geofabrik_file()
97 |
98 | self.assertTrue(os.path.exists(path))
99 | self.assertFalse(
100 | self.o_downloader.should_geofabrik_file_be_downloaded())
101 |
102 | def test_building_osm_pbf_filepaths(self):
103 | """
104 | Test if composing map file path on the device is correct
105 | "/" to "_" is done for "us/" countries
106 | """
107 | self.check_exp_agains_composed_map_file_path(
108 | 'us/nebraska', 'us_nebraska')
109 |
110 | self.check_exp_agains_composed_map_file_path(
111 | 'us/georgia', 'us_georgia')
112 |
113 | self.check_exp_agains_composed_map_file_path(
114 | 'malta', 'malta')
115 |
116 | self.check_exp_agains_composed_map_file_path(
117 | 'asia', 'asia')
118 |
119 | self.check_exp_agains_composed_map_file_path(
120 | 'georgia', 'georgia')
121 |
122 | def test_download_osm_pbf_file(self):
123 | """
124 | Test the download of geofabrik file via URL
125 | """
126 | self.check_download_osm_pbf_file('malta', os.path.join(constants.USER_DL_DIR, 'maps',
127 | 'malta' + '-latest.osm.pbf'))
128 |
129 | self.check_download_osm_pbf_file('us/hawaii', os.path.join(constants.USER_DL_DIR, 'maps',
130 | 'us_hawaii' + '-latest.osm.pbf'))
131 |
132 | self.check_download_osm_pbf_file('solomon-islands', os.path.join(constants.USER_DL_DIR, 'maps',
133 | 'solomon-islands' + '-latest.osm.pbf'))
134 |
135 | def test_delete_not_existing_file(self):
136 | """
137 | Test if the removal of a not existing file raises a exception
138 | """
139 |
140 | path = os.path.join(constants.USER_DL_DIR, 'maps',
141 | 'malta' + '-latest.osm.pbf')
142 |
143 | if os.path.exists(path):
144 | os.remove(path)
145 |
146 | with self.assertRaises(FileNotFoundError):
147 | os.remove(path)
148 |
149 | def test_check_dl_needed_geofabrik(self):
150 | """
151 | Test if geofabrik file needs to be downloaded
152 | """
153 | path = os.path.join(constants.USER_DL_DIR, 'geofabrik.json')
154 |
155 | if os.path.exists(path):
156 | os.remove(path)
157 |
158 | self.o_downloader.max_days_old = 24
159 | # self.o_downloader.check_geofabrik_file()
160 |
161 | self.assertTrue(
162 | self.o_downloader.should_geofabrik_file_be_downloaded())
163 |
164 | def test_download_windows_files(self):
165 | """
166 | Test if Windows tooling files download is successful
167 | """
168 | if platform.system() == "Windows":
169 | path = constants.USER_TOOLING_WIN_DIR
170 |
171 | if os.path.exists(path):
172 | shutil.rmtree(path)
173 |
174 | self.assertFalse(os.path.exists(path))
175 |
176 | download_tooling()
177 |
178 | self.assertTrue(os.path.exists(path))
179 |
180 | self.assertTrue(
181 | os.path.exists(get_tooling_win_path('osmfilter.exe', in_user_dir=True)))
182 |
183 | def test_download_macos_files(self):
184 | """
185 | Test if macOS tooling files download is successful
186 | """
187 | if platform.system() != "Windows":
188 | path = os.path.join(str(constants.USER_DIR), '.openstreetmap', 'osmosis',
189 | 'plugins', 'mapsforge-map-writer-0.21.0-jar-with-dependencies.jar')
190 |
191 | if os.path.exists(path):
192 | os.remove(path)
193 |
194 | self.assertFalse(os.path.exists(path))
195 |
196 | download_tooling()
197 |
198 | self.assertTrue(os.path.exists(path))
199 |
200 | def test_map_writer_url_calculation(self):
201 | """
202 | Test if joining mapwriter filename to base path is the same as the full path
203 | """
204 | map_writer_filename = 'mapsforge-map-writer-0.18.0-jar-with-dependencies.jar'
205 | mapwriter_plugin_url = 'https://search.maven.org/remotecontent?filepath=org/mapsforge/mapsforge-map-writer/0.18.0/mapsforge-map-writer-0.18.0-jar-with-dependencies.jar'
206 |
207 | mapwriter_plugin_url_base = 'https://search.maven.org/remotecontent?filepath=org/mapsforge/mapsforge-map-writer/0.18.0'
208 | mapwriter_plugin_url_join = posixpath.join(mapwriter_plugin_url_base, map_writer_filename)
209 |
210 | self.assertEqual(mapwriter_plugin_url_join, mapwriter_plugin_url)
211 |
212 |
213 | def check_exp_agains_composed_map_file_path(self, country, country_map_file_path):
214 | """
215 | helper function to check a given to-be-path against the composed on based on country
216 | """
217 | exp_path = os.path.join(constants.USER_DL_DIR, 'maps',
218 | f'{country_map_file_path}' + '-latest.osm.pbf')
219 |
220 | composed_path = build_osm_pbf_filepath(country)
221 |
222 | self.assertEqual(exp_path, composed_path)
223 |
224 | def check_download_osm_pbf_file(self, country, path):
225 | """
226 | Test if the download of a input country created the wanted map file
227 | """
228 | o_geofabrik_json = GeofabrikJson()
229 |
230 | if os.path.exists(path):
231 | os.remove(path)
232 |
233 | map_file_path = build_osm_pbf_filepath(country)
234 | url = o_geofabrik_json.get_geofabrik_url(country)
235 | download_file(map_file_path, url, False)
236 |
237 | self.assertTrue(os.path.exists(path))
238 |
239 |
240 | if __name__ == '__main__':
241 | unittest.main()
242 |
--------------------------------------------------------------------------------
/tests/test_setup.py:
--------------------------------------------------------------------------------
1 | """
2 | tests for setup functions
3 | """
4 | import unittest
5 | import platform
6 | import os
7 | import pkg_resources
8 |
9 | # import custom python packages
10 | from wahoomc.setup_functions import is_program_installed, is_map_writer_plugin_installed, \
11 | read_version_last_run
12 | from wahoomc.constants_functions import get_tooling_win_path
13 | from wahoomc.constants import USER_WAHOO_MC, VERSION
14 | from wahoomc.file_directory_functions import write_json_file_generic
15 | from wahoomc.downloader import get_latest_pypi_version
16 |
17 |
18 | class TestSetup(unittest.TestCase):
19 | """
20 | tests for the required non-python programs of the python module
21 | """
22 |
23 | def test_installed_programs_mac(self):
24 | """
25 | tests, if the mac-relevant programs are installed
26 | """
27 | if platform.system() != "Windows":
28 | self.check_installation_of_program("java")
29 |
30 | self.check_installation_of_program("osmium")
31 | self.check_installation_of_program("osmosis")
32 |
33 | result = is_map_writer_plugin_installed()
34 | self.assertTrue(result)
35 |
36 | def test_installed_programs_windows(self):
37 | """
38 | tests, if the windows-relevant programs are installed
39 | """
40 | if platform.system() == "Windows":
41 | self.check_installation_of_program("java")
42 |
43 | self.assertTrue(os.path.exists(get_tooling_win_path(
44 | os.path.join('Osmosis', 'bin', 'osmosis.bat'), in_user_dir=True)))
45 | self.assertTrue(os.path.exists(
46 | get_tooling_win_path('osmconvert.exe')))
47 | self.assertTrue(os.path.exists(
48 | get_tooling_win_path('osmfilter.exe', in_user_dir=True)))
49 | self.assertTrue(os.path.exists(get_tooling_win_path('7za.exe')))
50 |
51 | def check_installation_of_program(self, program):
52 | """
53 | tests, if a given program is installed
54 | """
55 | result = is_program_installed(program)
56 |
57 | self.assertTrue(result)
58 |
59 |
60 | class TestConfigFile(unittest.TestCase):
61 | """
62 | tests for the config .json file in the "wahooMapsCreatorData" directory
63 | """
64 |
65 | config_file_path = os.path.join(USER_WAHOO_MC, ".config.json")
66 |
67 | def test_version_if_no_config_file_exists(self):
68 | """
69 | tests, if the return value is None if the config file is deleted
70 | """
71 | if os.path.exists(self.config_file_path):
72 | os.remove(self.config_file_path)
73 |
74 | self.assertEqual(None, read_version_last_run())
75 |
76 | def test_version_if_written_eq(self):
77 | """
78 | tests, if return version is the one saved
79 | """
80 | # write dictionary to config file
81 | write_json_file_generic(self.config_file_path, {
82 | "version_last_run": '2.0.2'})
83 |
84 | self.assertEqual('2.0.2', read_version_last_run())
85 |
86 | def test_version_if_written_neq(self):
87 | """
88 | tests, if the comparison of the returned version_last_run is OK
89 | """
90 | # write dictionary to config file
91 | write_json_file_generic(self.config_file_path, {
92 | "version_last_run": '2.0.3'})
93 |
94 | self.assertNotEqual('2.0.2', read_version_last_run())
95 |
96 | def test_version_constants_against_pypi(self):
97 | """
98 | tests, if the version of constants.py is equal to the latest available version on PyPI
99 | """
100 | latest_version = pkg_resources.parse_version(
101 | get_latest_pypi_version()).public
102 |
103 | self.assertEqual(
104 | VERSION, latest_version)
105 |
106 |
107 | if __name__ == '__main__':
108 | unittest.main()
109 |
--------------------------------------------------------------------------------
/tooling/map-info.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 |
3 | import argparse
4 | import sys
5 | import time
6 |
7 |
8 | class MapFileReader:
9 | def __init__(self, filename) -> None:
10 | self.mapFile = open(filename, "rb")
11 |
12 | def close(self):
13 | self.mapFile.close()
14 |
15 | def readMagic(self):
16 | return self.mapFile.read(20).decode('utf-8')
17 |
18 | def readByte(self):
19 | return self.mapFile.read(1)[0]
20 |
21 | def readShort(self):
22 | b = self.mapFile.read(2)
23 | return b[0] << 8 | b[1]
24 |
25 | def readInt(self):
26 | b = self.mapFile.read(4)
27 | return b[0] << 24 | b[1] << 16 | b[2] << 8 | b[3]
28 |
29 | def readDegrees(self):
30 | return float(self.readInt())/1000000
31 |
32 | def readLong(self):
33 | b = self.mapFile.read(8)
34 | return b[0] << 56 | b[1] << 48 | b[2] << 40 | b[3] << 32 | b[4] << 24 | b[5] << 16 | b[6] << 8 | b[7]
35 |
36 | def readVBEU(self):
37 | res, shift, buf = 0, 0, 0
38 | while True:
39 | buf = int.from_bytes(self.mapFile.read(1), byteorder="big")
40 | if (buf & 0x80) == 0:
41 | break
42 |
43 | res |= (buf & 0x7f) << shift
44 | shift += 7
45 |
46 | return res | (buf << shift)
47 |
48 | def readString(self):
49 | return self.mapFile.read(self.readVBEU()).decode('utf-8')
50 |
51 | def readTags(self):
52 | amount = self.readShort()
53 | tags = []
54 | for _ in range(amount):
55 | tags.append(self.readString())
56 |
57 | return tags
58 |
59 | def readZoomIntervals(self):
60 | amount = self.readByte()
61 | intervals = []
62 | for _ in range(amount):
63 | values = (
64 | self.readByte(),
65 | self.readByte(),
66 | self.readByte(),
67 | self.readLong(),
68 | self.readLong(),
69 | )
70 | intervals.append(values)
71 | return intervals
72 |
73 |
74 | def main(args):
75 | r = MapFileReader(args.mapfile)
76 |
77 | magic = r.readMagic()
78 | print("Magic:", magic)
79 | if magic != "mapsforge binary OSM":
80 | print("invalid magic bytes")
81 | sys.exit(1)
82 |
83 | print("Header size:", r.readInt())
84 | print("File version:", r.readInt())
85 | print("File size:", r.readLong())
86 | print("Date of creation:", time.ctime(r.readLong()/1000))
87 | print("Bounding box:")
88 | print(
89 | " - minLat: {:f} minLon: {:f}".format(r.readDegrees(), r.readDegrees()))
90 | print(
91 | " - maxLat: {:f} maxLon: {:f}".format(r.readDegrees(), r.readDegrees()))
92 | print("Tile size:", r.readShort())
93 | print("Projection:", r.readString())
94 |
95 | flags = r.readByte()
96 | print("Flags: {:08b}".format(flags))
97 | if (flags & 0x80) != 0:
98 | print(" - Debug file")
99 | if (flags & 0x40) != 0:
100 | print(
101 | " - Map start position: lat: {:f} lon: {:f}", r.readDegrees(), r.readDegrees())
102 | if (flags & 0x20) != 0:
103 | print(" - Start zoom level", r.readByte())
104 | if (flags & 0x10) != 0:
105 | print(" - Languages", r.readString())
106 | if (flags & 0x08) != 0:
107 | print(" - Comment", r.readString())
108 | if (flags & 0x04) != 0:
109 | print(" - Created by", r.readString())
110 |
111 | poiTags = r.readTags()
112 | print("Poi tags:", len(poiTags))
113 | if args.pois:
114 | for tag in poiTags:
115 | print(" -", tag)
116 |
117 | wayTags = r.readTags()
118 | print("Way tags:", len(wayTags))
119 | if args.ways:
120 | for tag in wayTags:
121 | print(" -", tag)
122 |
123 | zoomIntervals = r.readZoomIntervals()
124 | print("Zoom intervals:", len(zoomIntervals))
125 | if args.zoom_intervals:
126 | for zi in zoomIntervals:
127 | print(
128 | " - Base: {} Min: {} Max: {} Pos: {} Size: {}".format(zi[0], zi[1], zi[2], zi[3], zi[4]))
129 |
130 | r.close()
131 |
132 |
133 | if __name__ == "__main__":
134 | parser = argparse.ArgumentParser()
135 | parser.add_argument(
136 | '-p', "--pois", help="show poi tags", action="store_true")
137 | parser.add_argument(
138 | '-w', "--ways", help="show way tags", action="store_true")
139 | parser.add_argument('-z', "--zoom-intervals",
140 | help="show zoom intervals", action="store_true")
141 | parser.add_argument('mapfile', help='map file')
142 | main(parser.parse_args())
143 |
--------------------------------------------------------------------------------
/wahoomc/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/wahoomc/__init__.py
--------------------------------------------------------------------------------
/wahoomc/__main__.py:
--------------------------------------------------------------------------------
1 | """
2 | can be directly called via `python -m wahoomc -h`
3 | """
4 | from wahoomc import main
5 |
6 | if __name__ == '__main__':
7 | main.run("run")
8 |
--------------------------------------------------------------------------------
/wahoomc/constants.py:
--------------------------------------------------------------------------------
1 | """
2 | constants
3 | """
4 | #!/usr/bin/python
5 |
6 | import os
7 | from pathlib import Path
8 |
9 | # User
10 | USER_DIR = str(Path.home())
11 | USER_WAHOO_MC = os.path.join(str(Path.home()), 'wahooMapsCreatorData')
12 | USER_DL_DIR = os.path.join(USER_WAHOO_MC, '_download')
13 | USER_MAPS_DIR = os.path.join(USER_DL_DIR, 'maps')
14 | LAND_POLYGONS_PATH = os.path.join(
15 | USER_DL_DIR, 'land-polygons-split-4326', 'land_polygons.shp')
16 | GEOFABRIK_PATH = os.path.join(USER_DL_DIR, 'geofabrik.json')
17 | USER_OUTPUT_DIR = os.path.join(USER_WAHOO_MC, '_tiles')
18 | USER_CONFIG_DIR = os.path.join(USER_WAHOO_MC, '_config')
19 | USER_TOOLING_WIN_DIR = os.path.join(USER_DL_DIR, 'tooling_win')
20 | OSMOSIS_WIN_FILE_PATH = os.path.join(
21 | USER_TOOLING_WIN_DIR, 'Osmosis', 'bin', 'osmosis.bat')
22 |
23 | # Python Package - wahooMapsCreator directory
24 | WAHOO_MC_DIR = os.path.dirname(__file__)
25 | RESOURCES_DIR = os.path.join(WAHOO_MC_DIR, 'resources')
26 | TOOLING_WIN_DIR = os.path.join(WAHOO_MC_DIR, 'tooling_win')
27 | # location of repo / python installation - not used
28 | ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
29 | VERSION = '4.3.0'
30 |
31 |
32 | block_download = ['africa', 'alps', 'asia', 'australia-oceania', 'britain-and-ireland',
33 | 'canada', 'dach', 'europe', 'great-britain' , 'norcal' ,'north-america',
34 | 'russia','socal', 'south-africa-and-lesotho', 'south-america', 'us',
35 | 'us-midwest', 'us-northeast', 'us-pacific', 'us-south', 'us-west']
36 |
37 | # Special_regions like (former) colonies where the map of the wanted region is not present in the map of the parent country.
38 | # example Guadeloupe, it's Geofabrik parent country is France but Guadeloupe is not located within the region covered by the map of France.
39 | special_regions = ['guadeloupe', 'guyane', 'martinique', 'mayotte', 'reunion']
40 |
--------------------------------------------------------------------------------
/wahoomc/constants_functions.py:
--------------------------------------------------------------------------------
1 | """
2 | functions and object for constants
3 | """
4 | #!/usr/bin/python
5 |
6 | # import official python packages
7 | import logging
8 | import os
9 | import struct
10 |
11 | # import custom python packages
12 | from wahoomc.constants import RESOURCES_DIR
13 | from wahoomc.constants import TOOLING_WIN_DIR
14 | from wahoomc.constants import USER_CONFIG_DIR
15 | from wahoomc.constants import USER_TOOLING_WIN_DIR
16 | from wahoomc.file_directory_functions import read_json_file_generic
17 |
18 | log = logging.getLogger('main-logger')
19 |
20 |
21 | class TagWahooXmlNotFoundError(Exception):
22 | """Raised when the specified tag-wahoo xml file does not exist"""
23 |
24 |
25 | class TagsToKeepNotFoundError(Exception):
26 | """Raised when the specified tags to keep .json file does not exist"""
27 |
28 |
29 | def translate_tags_to_keep(name_tags=False, sys_platform='', use_repo=False):
30 | """
31 | translates the given tags to format of the operating system.
32 | """
33 |
34 | if sys_platform == "Windows":
35 | separator = ' ='
36 | else:
37 | separator = ', '
38 |
39 | tags_modif = []
40 |
41 | # read tags-to-keep .json from user-dir in favor of python installation
42 | # evaluate path first: user-dir in favor of PyPI installation
43 | if not use_repo:
44 | for path in get_absolute_dir_user_or_repo('', file='tags-to-keep.json'):
45 | if os.path.exists(path):
46 | break
47 | # force using file from repo - used in unittests for equal output
48 | else:
49 | path = get_absolute_dir_user_or_repo(
50 | '', file='tags-to-keep.json')[1]
51 |
52 | # read the tags from the evaluated path above
53 | tags_from_json = read_json_file_generic(path)
54 |
55 | if not tags_from_json:
56 | raise TagsToKeepNotFoundError
57 |
58 | if not name_tags:
59 | universal_tags = tags_from_json['TAGS_TO_KEEP_UNIVERSAL']
60 | else:
61 | universal_tags = tags_from_json['NAME_TAGS_TO_KEEP_UNIVERSAL']
62 |
63 | for tag, value in universal_tags.items():
64 | to_append = transl_tag_value(sys_platform, separator, tag, value)
65 |
66 | tags_modif.append(to_append)
67 |
68 | if sys_platform == "Windows":
69 | tags_modif = ' '.join(tags_modif)
70 |
71 | return tags_modif
72 |
73 |
74 | def transl_tag_value(sys_platform, separator, tag, value):
75 | """
76 | translates one tag with value(s) to a "common" format
77 | """
78 | if isinstance(value, list):
79 | for iteration, sing_val in enumerate(value):
80 | if iteration == 0:
81 | to_append = f'{tag}={sing_val}'
82 | else:
83 | to_append = f'{to_append}{separator}{sing_val}'
84 | elif value:
85 | to_append = f'{tag}={value}'
86 | else:
87 | if sys_platform == "Windows":
88 | to_append = f'{tag}='
89 | else:
90 | to_append = tag
91 |
92 | return to_append
93 |
94 |
95 | def get_tooling_win_path(path_in_tooling_win, in_user_dir=False):
96 | """
97 | return path to a tooling in the tooling_win directory and the given path
98 | OR from the user tooling_win directory
99 | """
100 | if in_user_dir:
101 | tooling_dir = USER_TOOLING_WIN_DIR
102 | else:
103 | tooling_dir = TOOLING_WIN_DIR
104 |
105 | # special for osmconvert: handle 32 and 64 bit here
106 | if path_in_tooling_win in ('osmconvert', 'osmconvert.exe'):
107 | if 8 * struct.calcsize("P") == 32:
108 | return os.path.join(tooling_dir, path_in_tooling_win)
109 | # 64 bit: replace with 64 in the end
110 | return os.path.join(tooling_dir, path_in_tooling_win.replace("osmconvert", "osmconvert64-0.8.8p"))
111 |
112 | # all other "toolings": concatenate with win tooling dir
113 | return os.path.join(tooling_dir, path_in_tooling_win)
114 |
115 |
116 | def get_tag_wahoo_xml_path(tag_wahoo_xml):
117 | """
118 | return path to tag-wahoo xml file if the file exists
119 | - from the user directory "USER_WAHOO_MC/_config/tag_wahoo_adjusted/tag_wahoo_xml"
120 | - 2ndly from the PyPI installation: "RESOURCES_DIR/tag_wahoo_adjusted/tag_wahoo_xml"
121 | """
122 |
123 | for path in get_absolute_dir_user_or_repo("tag_wahoo_adjusted", tag_wahoo_xml):
124 | if os.path.exists(path):
125 | return path
126 |
127 | raise TagWahooXmlNotFoundError
128 |
129 |
130 | def get_absolute_dir_user_or_repo(folder, file=''):
131 | """
132 | return the absolute path to the folder (and file) in this priorization
133 | 1. user dir
134 | 2. wahoomc package dir
135 |
136 | Priorization is important later on because user- should always be used in favor of repo-dir!
137 | """
138 | absolute_paths = []
139 | if file:
140 | absolute_paths.append(os.path.join(
141 | USER_CONFIG_DIR, folder, file))
142 | absolute_paths.append(os.path.join(
143 | RESOURCES_DIR, folder, file))
144 | else:
145 | absolute_paths.append(os.path.join(USER_CONFIG_DIR, folder))
146 | absolute_paths.append(os.path.join(
147 | RESOURCES_DIR, folder))
148 |
149 | return absolute_paths
150 |
--------------------------------------------------------------------------------
/wahoomc/file_directory_functions.py:
--------------------------------------------------------------------------------
1 | """
2 | constants, functions and object for file-system operations
3 | """
4 | #!/usr/bin/python
5 |
6 | # import official python packages
7 | import json
8 | import os
9 | from os.path import isfile, join
10 | import sys
11 | import logging
12 | import shutil
13 |
14 | # import custom python packages
15 |
16 | log = logging.getLogger('main-logger')
17 |
18 |
19 | def move_content(src_folder_name, dst_path):
20 | """
21 | copy files from source directory of to destination directory
22 | delete source directory afterwards
23 |
24 | similar function to copy_or_move_files_and_folder but without user-request when overwriting
25 | and only support for directories
26 | """
27 | # build path to old folder on the same level as wahooMapsCreator
28 | par_dir = os.path.abspath(os.path.join(os.path.join(
29 | os.path.dirname(__file__), os.pardir), os.pardir))
30 | source_dir = os.path.join(par_dir, src_folder_name)
31 |
32 | if os.path.exists(source_dir):
33 | # copy & delete directory
34 | for item in os.listdir(source_dir):
35 | src = os.path.join(source_dir, item)
36 | dst = os.path.join(dst_path, item)
37 | # next, if destination directory exists
38 | if os.path.isdir(dst):
39 | continue
40 |
41 | if os.path.isdir(src):
42 | shutil.copytree(src, dst)
43 | else:
44 | shutil.copy2(src, dst)
45 |
46 | shutil.rmtree(source_dir)
47 |
48 |
49 | def create_empty_directories(parent_dir, tiles_from_json, border_countries):
50 | """
51 | create empty directories for each tile and each country
52 | """
53 | for tile in tiles_from_json:
54 | outdir = os.path.join(parent_dir,
55 | f'{tile["x"]}', f'{tile["y"]}')
56 | os.makedirs(outdir, exist_ok=True)
57 |
58 | for country in border_countries:
59 | outdir = os.path.join(parent_dir, country)
60 | os.makedirs(outdir, exist_ok=True)
61 |
62 |
63 | def read_json_file_country_config(json_file_path):
64 | """
65 | read the country config (of last run) from the given json file
66 | """
67 |
68 | log.debug('-' * 80)
69 | log.debug('# Read country config json file')
70 |
71 | country_config = read_json_file_generic(json_file_path)
72 | if country_config == '':
73 | log.error('! Json file could not be opened.')
74 | sys.exit()
75 |
76 | log.debug(
77 | '+ Use country config file %s', json_file_path)
78 | log.debug('+ Read country config json file: OK')
79 |
80 | return country_config
81 |
82 |
83 | def read_json_file_generic(json_file_path):
84 | """
85 | reads content of given .json file
86 | """
87 | try:
88 | with open(json_file_path, encoding="utf-8") as json_file:
89 | json_content = json.load(json_file)
90 | json_file.close()
91 |
92 | return json_content
93 |
94 | except FileNotFoundError:
95 | return {}
96 |
97 |
98 | def write_json_file_generic(json_file_path, json_content):
99 | """
100 | writes content to .json file
101 | """
102 | # Serializing json
103 | json_content = json.dumps(json_content, indent=4)
104 |
105 | # Writing to file
106 | with open(json_file_path, "w", encoding="utf-8") as json_file:
107 | json_file.write(json_content)
108 | json_file.close()
109 |
110 |
111 | def get_files_in_folder(folder):
112 | """
113 | return filenames of given folder without path as list
114 | """
115 | onlyfiles = [f for f in os.listdir(folder) if isfile(join(folder, f))]
116 |
117 | return onlyfiles
118 |
119 |
120 | def delete_o5m_pbf_files_in_folder(folder):
121 | """
122 | delete .o5m and .pbf files of given folder
123 | """
124 | onlyfiles = [f for f in os.listdir(folder) if isfile(join(folder, f))]
125 |
126 | for file in onlyfiles:
127 | if file.endswith('.o5m') or file.endswith('.pbf'):
128 | try:
129 | os.remove(os.path.join(folder, file))
130 | except OSError:
131 | pass
132 |
133 |
134 | def delete_everything_in_folder(folder):
135 | """
136 | delete all files and directories of given folder
137 | """
138 | files_and_folders = list(os.listdir(folder)) # [f for f in os.listdir(folder)]
139 |
140 | for file in files_and_folders:
141 | try:
142 | file_or_dir = os.path.join(folder, file)
143 | # file or dir?
144 | if os.path.isfile(file_or_dir):
145 | # delete file
146 | os.remove(file_or_dir)
147 | else:
148 | # delete directory if exists. copytree fails if dir exists already
149 | shutil.rmtree(file_or_dir)
150 | except OSError:
151 | pass
152 |
153 |
154 | def copy_or_move_files_and_folder(from_path, to_path, delete_from_dir=False):
155 | """
156 | copy content from source directory to destination directory
157 | optionally delete source directory afterwards
158 |
159 | similar function to move_content but with user-request when overwriting and support for files
160 | """
161 | # check if from path/file exists at all
162 | if os.path.exists(from_path):
163 |
164 | # given path is a directory
165 | if os.path.isdir(from_path):
166 | # first create the to-directory if not already there
167 | os.makedirs(to_path, exist_ok=True)
168 |
169 | for item in os.listdir(from_path):
170 | from_item = os.path.join(from_path, item)
171 | to_item = os.path.join(to_path, item)
172 |
173 | # copy directory
174 | if os.path.isdir(from_item):
175 | copy_directory_w_user_input(from_item, to_item)
176 |
177 | # copy file
178 | else:
179 | copy_file_w_user_input(from_item, to_item)
180 |
181 | # given path is a file
182 | else:
183 | copy_file_w_user_input(from_path, to_path)
184 |
185 | # directory
186 | if delete_from_dir:
187 | shutil.rmtree(from_path)
188 |
189 |
190 | def copy_directory_w_user_input(from_item, to_item):
191 | """
192 | copy content from source directory to destination directory
193 | """
194 | if not os.path.isdir(to_item):
195 | shutil.copytree(from_item, to_item)
196 | else:
197 | val = input(f"{to_item} exists already. Overwrite? (y/n):")
198 | if val == 'y':
199 | shutil.copytree(from_item, to_item)
200 | log.info('! %s overwritten', to_item)
201 | else:
202 | log.debug('! %s not copied, exists already.', to_item)
203 |
204 |
205 | def copy_file_w_user_input(from_item, to_item):
206 | """
207 | copy source file to destination file
208 | """
209 | if not os.path.isfile(to_item):
210 | shutil.copy2(from_item, to_item)
211 | else:
212 | val = input(f"{to_item} exists already. Overwrite? (y/n):")
213 | if val == 'y':
214 | shutil.copy2(from_item, to_item)
215 | log.info('! %s overwritten', to_item)
216 | else:
217 | log.debug('! %s not copied, exists already.', to_item)
218 |
--------------------------------------------------------------------------------
/wahoomc/geofabrik_json.py:
--------------------------------------------------------------------------------
1 | """
2 | Object for accessing Geofabrik .json file
3 | """
4 | #!/usr/bin/python
5 |
6 | # import official python packages
7 | import geojson # pylint: disable=import-error
8 |
9 | # import custom python packages
10 | from wahoomc.constants import GEOFABRIK_PATH
11 |
12 |
13 | class CountyIsNoGeofabrikCountry(Exception):
14 | """Raised when actual country is not a geofabrik country"""
15 |
16 | def __init__(self, country):
17 | message = f"Entered country '{country}' is not a geofabrik country. \
18 | \nPlease check this URL for possible countries: https://download.geofabrik.de/index.html"
19 | super().__init__(message)
20 |
21 |
22 | class GeofabrikJson:
23 | """
24 | This is a Geofabrik .json processing class for constants in the Geofabrik .json file
25 | """
26 | raw_json = None
27 | geofabrik_overview = {}
28 | geofabrik_region_overview = {}
29 | geofabrik_regions = []
30 |
31 | def __init__(self):
32 | # read geofabrik .json file and fill class-attributes // access is only once
33 | if GeofabrikJson.raw_json is None and not GeofabrikJson.geofabrik_overview \
34 | and not GeofabrikJson.geofabrik_region_overview and not GeofabrikJson.geofabrik_regions:
35 | GeofabrikJson.raw_json, GeofabrikJson.geofabrik_overview, GeofabrikJson.geofabrik_region_overview, GeofabrikJson.geofabrik_regions = self.read_geofabrik_json_file()
36 |
37 | def read_geofabrik_json_file(self):
38 | """
39 | read geofabrik .json file and fill class-attributes
40 |
41 | geofabrik_regions as i defined them are the ones without parent
42 | geofabrik_overview contain all entries, with and without parent
43 | """
44 | raw_json = []
45 | geofabrik_overview = {}
46 | geofabrik_region_overview = {}
47 | geofabrik_regions = set()
48 |
49 | with open(GEOFABRIK_PATH, encoding='utf8') as file_handle:
50 | raw_json = geojson.load(file_handle)
51 | file_handle.close()
52 |
53 | # create a dict with information easy to access because they are often needed
54 | for feature in raw_json.features:
55 | props = feature.properties
56 | id_no = props['id']
57 | pbf_url = props['urls']['pbf']
58 |
59 | try:
60 | parent = props['parent']
61 |
62 | geofabrik_overview[id_no] = {
63 | 'parent': parent,
64 | 'pbf_url': pbf_url,
65 | 'geometry': feature.geometry}
66 | # Add the parent region of every map/region to the list of regions
67 | geofabrik_regions.add(parent)
68 | except KeyError:
69 | geofabrik_overview[id_no] = {
70 | 'pbf_url': pbf_url,
71 | 'geometry': feature.geometry}
72 | geofabrik_region_overview[id_no] = {
73 | 'pbf_url': pbf_url}
74 | geofabrik_regions.add(id_no)
75 |
76 | # Remove 'us/california' if it exists, as it is not needed in the regions list
77 | if 'us/california' in geofabrik_regions:
78 | geofabrik_regions.remove('us/california')
79 | geofabrik_regions = sorted(geofabrik_regions)
80 |
81 | return raw_json, geofabrik_overview, geofabrik_region_overview, geofabrik_regions
82 |
83 | def get_geofabrik_parent_country(self, id_no):
84 | """
85 | Get the parent map/region of a country from the already loaded json data
86 | """
87 | try:
88 | entry = self.geofabrik_overview[id_no]
89 | if 'parent' in entry:
90 | return (entry['parent'], id_no)
91 |
92 | return ('', id_no)
93 | except KeyError as exception:
94 | raise CountyIsNoGeofabrikCountry(id_no) from exception
95 |
96 | def get_geofabrik_url(self, id_no):
97 | """
98 | Get the map download url from a country/region with the already loaded json data
99 | if no URL found, try with / instead of _
100 | """
101 | try:
102 | entry = self.geofabrik_overview[id_no]
103 | except KeyError:
104 | id_with_slash = id_no.replace('_', '/')
105 | entry = self.geofabrik_overview[id_with_slash]
106 | if 'pbf_url' in entry:
107 | return entry['pbf_url']
108 |
109 | return None
110 |
111 | def get_geofabrik_geometry(self, id_no):
112 | """
113 | Get the geometry from a country/region with the already loaded json data
114 | """
115 | try:
116 | entry = self.geofabrik_overview[id_no]
117 | if 'geometry' in entry:
118 | return entry['geometry']
119 | except KeyError:
120 | pass
121 |
122 | return None
123 |
124 | def is_input_a_geofabrik_id_no(self, id_no):
125 | """
126 | check if the given input is a geofabrik id number
127 | """
128 | if id_no in self.geofabrik_overview:
129 | return True
130 |
131 | return False
132 |
133 | def translate_id_no_to_geofabrik(self, country):
134 | """
135 | get geofabrik id by country .json filename
136 | """
137 |
138 | if country in self.geofabrik_overview:
139 | return country
140 |
141 | if country.replace('_', '-') in self.geofabrik_overview:
142 | return country.replace('_', '-')
143 |
144 | if 'us/'+country.replace('_', '-') in self.geofabrik_overview:
145 | return 'us/'+country.replace('_', '-')
146 |
147 | # if none of them got triggert --> exception
148 | raise CountyIsNoGeofabrikCountry(country)
149 |
--------------------------------------------------------------------------------
/wahoomc/init/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/wahoomc/init/__init__.py
--------------------------------------------------------------------------------
/wahoomc/init/__main__.py:
--------------------------------------------------------------------------------
1 | """
2 | can be directly called via `python -m wahoomc.init -h`
3 | """
4 | from wahoomc import main
5 |
6 | if __name__ == '__main__':
7 | main.run("init")
8 |
--------------------------------------------------------------------------------
/wahoomc/main.py:
--------------------------------------------------------------------------------
1 | """
2 | executable file to create up-to-date map-files for the Wahoo ELEMNT and Wahoo ELEMNT BOLT
3 | """
4 | #!/usr/bin/python
5 |
6 | # import official python packages
7 | import logging
8 |
9 | # import custom python packages
10 | from wahoomc.input import process_call_of_the_tool, cli_init
11 | from wahoomc.setup_functions import initialize_work_directories, \
12 | check_installation_of_required_programs, write_config_file, \
13 | adjustments_due_to_breaking_changes, copy_jsons_from_repo_to_user, \
14 | check_installed_version_against_latest_pypi, check_installation_of_programs_credentials_for_contour_lines
15 | from wahoomc.downloader import download_tooling
16 | from wahoomc.timings import Timings
17 |
18 | from wahoomc.osm_maps_functions import OsmMaps
19 | from wahoomc.osm_data import CountryOsmData, XYOsmData
20 |
21 | # logging used in the terminal output:
22 | # # means top-level command
23 | # ! means error
24 | # + means additional comment in a working-unit
25 |
26 |
27 | def run(run_level):
28 | """
29 | main program run
30 | """
31 | # create logger
32 | logging.basicConfig(format='%(levelname)s:%(message)s',
33 | level=logging.INFO)
34 |
35 | # initializing work directories needs to be the first call,
36 | # because other setup stuff relies on that (breaking changes)
37 | check_installed_version_against_latest_pypi()
38 | initialize_work_directories()
39 | adjustments_due_to_breaking_changes()
40 | download_tooling()
41 | check_installation_of_required_programs()
42 |
43 | if run_level == 'init':
44 | o_input_data = cli_init()
45 | else:
46 | # handle GUI and CLI processing via one function and different cli-calls
47 | o_input_data = process_call_of_the_tool()
48 |
49 | if o_input_data.verbose:
50 | logging.getLogger().setLevel(logging.DEBUG)
51 |
52 | if run_level == 'init':
53 | copy_jsons_from_repo_to_user('tag_wahoo_adjusted')
54 | copy_jsons_from_repo_to_user('.', 'tags-to-keep.json')
55 | else:
56 | # Is there something to do?
57 | o_input_data.is_required_input_given_or_exit(issue_message=True)
58 |
59 | if o_input_data.contour:
60 | check_installation_of_programs_credentials_for_contour_lines()
61 |
62 | if o_input_data.country:
63 | o_osm_data = CountryOsmData(o_input_data)
64 | elif o_input_data.xy_coordinates:
65 | o_osm_data = XYOsmData(o_input_data)
66 |
67 | timings = Timings()
68 | # Check for not existing or expired files. Mark for download, if dl is needed
69 | o_osm_data.process_input_of_the_tool()
70 | o_downloader = o_osm_data.get_downloader()
71 |
72 | # Download files marked for download
73 | o_downloader.download_files_if_needed()
74 |
75 | o_osm_maps = OsmMaps(o_osm_data)
76 |
77 | # Filter tags from country osm.pbf files'
78 | o_osm_maps.filter_tags_from_country_osm_pbf_files()
79 |
80 | # Generate land
81 | o_osm_maps.generate_land()
82 |
83 | # Generate sea
84 | o_osm_maps.generate_sea()
85 |
86 | # Generate elevation
87 | if o_input_data.contour:
88 | o_osm_maps.generate_elevation(o_input_data.use_srtm1)
89 |
90 | # Split filtered country files to tiles
91 | o_osm_maps.split_filtered_country_files_to_tiles()
92 |
93 | # Merge splitted tiles with land and sea
94 | o_osm_maps.merge_splitted_tiles_with_land_and_sea(
95 | o_input_data.process_border_countries, o_input_data.contour)
96 |
97 | # Creating .map files
98 | o_osm_maps.create_map_files(o_input_data.save_cruiser,
99 | o_input_data.tag_wahoo_xml,
100 | o_input_data.hdd_mode)
101 |
102 | # Zip .map.lzma files
103 | o_osm_maps.make_and_zip_files('.map.lzma', o_input_data.zip_folder)
104 |
105 | # Make Cruiser map files zip file
106 | if o_input_data.save_cruiser is True:
107 | o_osm_maps.make_and_zip_files('.map', o_input_data.zip_folder)
108 |
109 | timings.stop_and_log('# Total time')
110 |
111 | # run was successful --> write config file
112 | write_config_file()
113 |
--------------------------------------------------------------------------------
/wahoomc/osm_data.py:
--------------------------------------------------------------------------------
1 | """
2 | functions and object for managing OSM maps
3 | """
4 | #!/usr/bin/python
5 |
6 | # import official python packages
7 | import sys
8 | import logging
9 |
10 | # import custom python packages
11 | from wahoomc.downloader import Downloader
12 | from wahoomc.geofabrik import CountryGeofabrik, XYCombinationHasNoCountries, XYGeofabrik
13 |
14 | log = logging.getLogger('main-logger')
15 |
16 | class InformalOsmDataInterface:
17 | """
18 | object with all internal parameters to process maps
19 | """
20 |
21 | def __init__(self, o_input_data):
22 | """
23 | steps in constructor:
24 | 1. take over input paramters (force_processing is changed in the function further down)
25 | 2. check + download geofabrik file (always)
26 | """
27 | self.force_processing = False
28 | self.tiles = []
29 | self.border_countries = {}
30 | self.country_name = ''
31 |
32 | self.o_downloader = Downloader(
33 | o_input_data.max_days_old, o_input_data.force_download, self.border_countries)
34 | # takeover what is given by user first for force_processing
35 | self.force_processing = o_input_data.force_processing
36 | self.process_border_countries = o_input_data.process_border_countries
37 |
38 | log.info('-' * 80)
39 |
40 | # geofabrik file
41 | if self.o_downloader.should_geofabrik_file_be_downloaded():
42 | self.force_processing = True
43 | self.o_downloader.download_geofabrik_file()
44 |
45 | def process_input_of_the_tool(self):
46 | """
47 | Process input: get relevant tiles and if border countries should be calculated
48 | The three primary inputs are giving by a separate value each and have separate processing:
49 | 1. country name
50 | 2. x/y combinations
51 | """
52 |
53 | def calc_tiles(self):
54 | """
55 | calculate relevant tiles for input country or xy coordinate
56 | """
57 |
58 | def calc_border_countries(self):
59 | """
60 | calculate the border countries for the given tiles. i.e.
61 | - if CLI/GUI input by user
62 | - if processing x/y coordinates
63 | """
64 | log.info('# Determine involved/border countries')
65 |
66 | # Build list of countries needed
67 | for tile in self.tiles:
68 | for country in tile['countries']:
69 | if country not in self.border_countries:
70 | self.border_countries[country] = {}
71 |
72 | def log_border_countries(self):
73 | """
74 | write calculated border countries/involved countries to log
75 | """
76 | for country in self.border_countries:
77 | log.info('+ Involved country: %s', country)
78 |
79 | # border countries should be processed. Log it.
80 | if self.process_border_countries:
81 | log.info('+ Border countries will be processed')
82 |
83 | def get_downloader(self):
84 | """
85 | steps in this function:
86 | 1. Check for not existing or expired files. Mark for download, if dl is needed
87 | - land polygons file
88 | - .osm.pbf files
89 | 2. Calculate if force_processing should be set to true
90 | """
91 | # calc force processing
92 | # Check for not existing or expired files. Mark for download, if dl is needed
93 | self.o_downloader.check_land_polygons_file()
94 | self.o_downloader.check_osm_pbf_file()
95 |
96 | # If one of the files needs to be downloaded, reprocess all files
97 | if self.o_downloader.need_to_dl:
98 | self.force_processing = True
99 |
100 | return self.o_downloader
101 |
102 |
103 | class CountryOsmData(InformalOsmDataInterface):
104 | """
105 | object with all internal parameters to process maps for countries
106 | """
107 |
108 | def __init__(self, o_input_data):
109 | super().__init__(o_input_data)
110 | self.input_country = o_input_data.country
111 |
112 | self.o_geofabrik = CountryGeofabrik(self.input_country)
113 |
114 | def process_input_of_the_tool(self):
115 | """
116 | steps in this function:
117 | 1. calculate relevant tiles for map creation
118 | 2. calculate border countries for map creation
119 | 3. evaluate the country-name for folder cration during processing
120 | """
121 |
122 | # calc tiles
123 | self.calc_tiles()
124 |
125 | # calc border countries
126 | log.info('-' * 80)
127 | self.calc_border_countries()
128 | # log border countries when and when not calculated to output the processed country(s)
129 | self.log_border_countries()
130 |
131 | # calc country name
132 | self.calc_country_name()
133 |
134 | def calc_tiles(self):
135 | """
136 | option 1: input a country as parameter, e.g. germany
137 | """
138 | log.info('# Input country: %s.', self.input_country)
139 |
140 | # use Geofabrik-URL to calculate the relevant tiles
141 | self.tiles = self.o_geofabrik.get_tiles_of_wanted_map()
142 |
143 | def calc_border_countries(self):
144 | """
145 | calculate the border countries for the given tiles when input is a country
146 | - if CLI/GUI input by user
147 | """
148 | if self.process_border_countries:
149 | super().calc_border_countries()
150 | # set the to-be-processed country as border country
151 | else:
152 | for country in self.o_geofabrik.wanted_maps:
153 | self.border_countries[country] = {}
154 |
155 | def calc_country_name(self):
156 | """
157 | country name is the country
158 | >1 countries are separated by underscore
159 | """
160 | for country in self.o_geofabrik.wanted_maps:
161 | if not self.country_name:
162 | self.country_name = country
163 | else:
164 | self.country_name = f'{self.country_name}_{country}'
165 |
166 |
167 | class XYOsmData(InformalOsmDataInterface):
168 | """
169 | object with all internal parameters to process maps for XY coordinates
170 | """
171 |
172 | def __init__(self, o_input_data):
173 | super().__init__(o_input_data)
174 | self.input_xy_coordinates = o_input_data.xy_coordinates
175 |
176 | def process_input_of_the_tool(self):
177 | """
178 | Process input: get relevant tiles and if border countries should be calculated
179 | The three primary inputs are giving by a separate value each and have separate processing:
180 | 1. country name
181 | 2. x/y combinations
182 |
183 | # Check for not existing or expired files. Mark for download, if dl is needed
184 | # - land polygons file
185 | # - .osm.pbf files
186 |
187 | steps in this function:
188 | 1. calculate relevant tiles for map creation
189 | 2. calculate border countries for map creation
190 | 3. evaluate the country-name for folder cration during processing
191 | """
192 |
193 | # calc tiles
194 | self.calc_tiles()
195 |
196 | # calc border countries
197 | log.info('-' * 80)
198 | self.calc_border_countries()
199 | # log border countries when and when not calculated to output the processed country(s)
200 | self.log_border_countries()
201 |
202 | # calc country name
203 | self.calc_country_name()
204 |
205 | def calc_tiles(self):
206 | """
207 | option 2: input a x/y combinations as parameter, e.g. 134/88 or 133/88,130/100
208 | """
209 | log.info(
210 | '# Input X/Y coordinates: %s.', self.input_xy_coordinates)
211 |
212 | o_geofabrik = XYGeofabrik(self.input_xy_coordinates)
213 | # find the tiles for x/y combinations in the geofabrik json files
214 | try:
215 | self.tiles = o_geofabrik.get_tiles_of_wanted_map()
216 | except XYCombinationHasNoCountries as exception:
217 | # this exception is actually only raised in class XYGeofabrik
218 | sys.exit(exception)
219 |
220 | def calc_country_name(self):
221 | """
222 | country name is the X/Y combinations separated by minus
223 | >1 x/y combinations are separated by underscore
224 | """
225 | for tile in self.tiles:
226 | if not self.country_name:
227 | self.country_name = f'{tile["x"]}-{tile["y"]}'
228 | else:
229 | self.country_name = f'{self.country_name}_{tile["x"]}-{tile["y"]}'
230 |
--------------------------------------------------------------------------------
/wahoomc/resources/sea.osm:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/wahoomc/resources/tag_wahoo_initial/tag-wahoo_original.xml:
--------------------------------------------------------------------------------
1 |
2 |
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 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
--------------------------------------------------------------------------------
/wahoomc/resources/tags-to-keep.json:
--------------------------------------------------------------------------------
1 | {
2 | "TAGS_TO_KEEP_UNIVERSAL": {
3 | "access": "",
4 | "area": "yes",
5 | "bicycle": "",
6 | "bridge": "",
7 | "foot": [
8 | "ft_yes",
9 | "foot_designated"
10 | ],
11 | "amenity": [
12 | "fuel",
13 | "cafe",
14 | "drinking_water",
15 | "shelter"
16 | ],
17 | "shop": [
18 | "bakery",
19 | "bicycle"
20 | ],
21 | "highway": [
22 | "abandoned",
23 | "bus_guideway",
24 | "disused",
25 | "bridleway",
26 | "byway",
27 | "construction",
28 | "cycleway",
29 | "footway",
30 | "living_street",
31 | "motorway",
32 | "motorway_link",
33 | "path",
34 | "pedestrian",
35 | "primary",
36 | "primary_link",
37 | "residential",
38 | "road",
39 | "secondary",
40 | "secondary_link",
41 | "service",
42 | "steps",
43 | "tertiary",
44 | "tertiary_link",
45 | "track",
46 | "trunk",
47 | "trunk_link",
48 | "unclassified"
49 | ],
50 | "natural": [
51 | "coastline",
52 | "nosea",
53 | "sea",
54 | "beach",
55 | "land",
56 | "scrub",
57 | "water",
58 | "wetland",
59 | "wood"
60 | ],
61 | "landuse": [
62 | "forest",
63 | "commercial",
64 | "industrial",
65 | "residential",
66 | "retail"
67 | ],
68 | "leisure": [
69 | "park",
70 | "nature_reserve"
71 | ],
72 | "railway": [
73 | "rail",
74 | "tram",
75 | "station",
76 | "stop"
77 | ],
78 | "surface": "",
79 | "tracktype": "",
80 | "tunnel": "",
81 | "waterway": [
82 | "canal",
83 | "drain",
84 | "river",
85 | "riverbank",
86 | "stream"
87 | ],
88 | "wood": "deciduous",
89 | "tourism": "alpine_hut"
90 | },
91 | "NAME_TAGS_TO_KEEP_UNIVERSAL": {
92 | "admin_level": "2",
93 | "area": "yes",
94 | "mountain_pass": "",
95 | "natural": "",
96 | "place": [
97 | "city",
98 | "hamlet",
99 | "island",
100 | "isolated_dwelling",
101 | "islet",
102 | "locality",
103 | "suburb",
104 | "town",
105 | "village",
106 | "country"
107 | ]
108 | }
109 | }
--------------------------------------------------------------------------------
/wahoomc/resources/tunnel-transform.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Adjust tunnel Layers
5 | Adjust tunnel Layers
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
20 |
21 |
--------------------------------------------------------------------------------
/wahoomc/timings.py:
--------------------------------------------------------------------------------
1 | """
2 | functions for timing sections of code, and output results in log lines
3 | """
4 | #!/usr/bin/python
5 |
6 | # import official python packages
7 | import time
8 | import logging
9 |
10 | log = logging.getLogger('main-logger')
11 |
12 |
13 | class Timings:
14 | """Class for starting the wall time, and logging when done"""
15 | wall_time_start = None
16 | wall_time_end = None
17 |
18 | def __init__(self):
19 | """Start the wall time"""
20 | self.wall_time_start = time.perf_counter()
21 |
22 | def stop_wall_time(self):
23 | """Stop the wall time"""
24 | self.wall_time_end = time.perf_counter()
25 |
26 | def stop_and_return(self, additional_info='') -> str:
27 | """Stop and return text"""
28 | self.stop_wall_time()
29 | return self.get_text_summary(additional_info)
30 |
31 | def stop_and_log(self, additional_info=''):
32 | """Log the time taken"""
33 | self.stop_wall_time()
34 | log.info('-' * 80)
35 | log.info(self.get_text_summary(additional_info))
36 |
37 | def get_text_summary(self, additional_info='') -> str:
38 | """Get text summarizing the timings"""
39 | time_taken_msg = f'{self.wall_time_end - self.wall_time_start:.3f} s'
40 | if additional_info:
41 | return f'{additional_info} {time_taken_msg}'
42 | return f'took {time_taken_msg}'
43 |
--------------------------------------------------------------------------------
/wahoomc/tooling_win/7za.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/wahoomc/tooling_win/7za.dll
--------------------------------------------------------------------------------
/wahoomc/tooling_win/7za.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/wahoomc/tooling_win/7za.exe
--------------------------------------------------------------------------------
/wahoomc/tooling_win/7zxa.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/wahoomc/tooling_win/7zxa.dll
--------------------------------------------------------------------------------
/wahoomc/tooling_win/lzma.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/wahoomc/tooling_win/lzma.exe
--------------------------------------------------------------------------------
/wahoomc/tooling_win/osmconvert.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/wahoomc/tooling_win/osmconvert.exe
--------------------------------------------------------------------------------
/wahoomc/tooling_win/osmconvert64-0.8.8p.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treee111/wahooMapsCreator/a798a5e9d3d28b03a5eaf9efa1d33fdc0b63a708/wahoomc/tooling_win/osmconvert64-0.8.8p.exe
--------------------------------------------------------------------------------