Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] Integrate contour lines (elevation) into generated maps with argument -con #188

Merged
merged 31 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f0e470b
dev environment for countour lines
treee111 Mar 11, 2023
bfd81f2
Added contour lines py code
masc4ii Feb 18, 2023
fc5475c
Fix polygon lines
masc4ii Feb 19, 2023
70e1332
elevation: refactor, fix pylint findings
treee111 Mar 11, 2023
2a8ef8a
launch config for contour lines
treee111 Mar 16, 2023
1d387fc
correctly check if elevation file is already there in X/Y directory
treee111 Mar 17, 2023
1be92ae
refactor, separat user/pw
treee111 Mar 17, 2023
91122fa
add cli argument for contour lines
treee111 Mar 17, 2023
40f8289
handle FileNotFoundError in function instead of the caller level
treee111 Mar 17, 2023
e3f4ef8
save and read earthexplorer username & password from config file
treee111 Mar 17, 2023
b5df746
set Cache directory for hgt files to user dir instead of cwd
treee111 Mar 17, 2023
36bf409
move contour packages into conda env .yml files + delete separate con…
treee111 Mar 24, 2023
622b1d9
add contour lines to documentation
treee111 Mar 24, 2023
16c6a57
mention -con in USAGE.md and cleanup/restructure
treee111 Apr 1, 2023
0a87a9c
check for phyghtmap on macOS
treee111 Apr 1, 2023
e6a71e2
ask for -con on main.py level
treee111 Apr 1, 2023
5a6a16a
Bump version to v4.0.0a3
treee111 Apr 1, 2023
71143a3
Merge branch 'release-v4.0.0' into contour-lines
treee111 Apr 1, 2023
8c2e2e1
Bump version to v4.0.0a5
treee111 Apr 1, 2023
9a96cae
Merge branch 'release-v4.0.0' into contour-lines
treee111 Apr 2, 2023
03c3c19
Bump version to v4.0.0a8
treee111 Apr 2, 2023
77e0bba
update QUICKSTART documentation
treee111 Apr 2, 2023
de7ead4
make logging identical to other processing functions
treee111 Apr 3, 2023
b229f7f
launch config & documentation
treee111 Apr 3, 2023
f8513af
setup check can be equal for both OS
treee111 Apr 3, 2023
51f2589
Merge branch 'release-v4.0.0' into contour-lines
treee111 Apr 3, 2023
cad2743
Merge branch 'release-v4.0.0' into contour-lines
treee111 Apr 3, 2023
9e3ab34
update misc stuff (leftovers)
treee111 Apr 3, 2023
9aa5492
Bump version to v4.0.0a10
treee111 Apr 3, 2023
9a64f21
move earthexplorer credentials prompt to the beginning
treee111 Apr 25, 2023
e843caa
add GUI checkbox for contour lines
treee111 Apr 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,24 @@
"100"
]
},
{
"name": "co: malta - contour",
"type": "python",
"request": "launch",
"module": "wahoomc",
"console": "integratedTerminal",
"args": [
"cli",
"-co",
"malta",
"-fp",
"-c",
"-md",
"100",
"-con",
"-nbc"
]
},
{
"name": "x/y: 135/91 (gardasee) #160",
"type": "python",
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ python -m wahoomc gui
## To further adjust...
* [:cookie: Get POIs displayed on your Wahoo](docs/USAGE.md#pois---points-of-interest)

* [:mount_fuji: Integrate contour lines into the generated maps](docs/USAGE.md#pois---points-of-interest)

* [:wrench: Control OSM tags to be included in your maps ](docs/USAGE.md#user-specific-configuration)

* [:computer: Preview your generated maps with cruiser ](docs/USAGE_CRUISER.md#usage-of-cruiser)
Expand Down
3 changes: 3 additions & 0 deletions conda_env/gdal-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ dependencies:
- geojson=2.5.*
- shapely=1.8.*
- osmium-tool=1.15.*
- bs4=4.11.*
- lxml=4.9.*
- matplotlib=3.4.3
- autopep8=2.0.*
- mock
- twine
Expand Down
3 changes: 3 additions & 0 deletions conda_env/gdal-user.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ dependencies:
- python=3.10
- geojson=2.5.*
- gdal=3.4.*
- bs4=4.11.*
- lxml=4.9.*
- matplotlib=3.4.3
- pip
- pip:
- wahoomc==3.2.0
2 changes: 1 addition & 1 deletion docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ conda env remove -n gdal-user
```
followed by creating a new environment and install wahoomc into:
```
conda create -n gdal-user python=3.10 geojson=2.5 gdal=3.4 requests=2.28 shapely=1.8 pip --channel conda-forge --override-channels
conda create -n gdal-user python=3.10 geojson=2.5 gdal=3.4 requests=2.28 shapely=1.8 bs4=4.11 lxml=4.9 matplotlib=3.4.3 pip --channel conda-forge --override-channels
conda activate gdal-user
pip install wahoomc
```
Expand Down
37 changes: 36 additions & 1 deletion docs/QUICKSTART_ANACONDA.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
- [Create Anaconda Environment](#create-anaconda-environment)
- [Install wahooMapsCreator into Anaconda environment](#install-wahoomapscreator-into-anaconda-environment)
- [Update wahooMapsCreator](#update-wahoomapscreator)
- [Additional programs for generating contour lines](#additional-programs-for-generating-contour-lines)
- [Install phyghtmap](#install-phyghtmap)
- [Verify phyghtmap](#verify-phyghtmap)
- [Free account for USGS](#free-account-for-usgs)
- [Run wahooMapsCreator](#run-wahoomapscreator)
- [Additional information](#additional-information)

Expand Down Expand Up @@ -76,7 +80,7 @@ brew install osmosis
1. Open terminal (macOS/Linux) or **Anaconda Prompt** (Windows, via Startmenu)
2. Create a new Anaconda environment with needed packages
```
conda create -n gdal-user python=3.10 geojson=2.5 gdal=3.4 requests=2.28 shapely=1.8 pip --channel conda-forge --override-channels
conda create -n gdal-user python=3.10 geojson=2.5 gdal=3.4 requests=2.28 shapely=1.8 bs4=4.11 lxml=4.9 matplotlib=3.4.3 pip --channel conda-forge --override-channels
```
3. activate Anaconda environment with the command printed out (this needs to be done each time you want to use wahooMapsCreator maps)
```
Expand All @@ -99,6 +103,37 @@ If you want to upgrade to a version other than the release actual one, use this
pip install wahoomc==2.0.0a5 --upgrade
```

## Additional programs for generating contour lines
For integrating contour lines into the generated maps, some additional steps need to be taken.
An additional Python packages has to be installed and you need an free account for USGS to query contour lines from.

### Install phyghtmap
1. Download and unpack http://katze.tfiu.de/projects/phyghtmap/phyghtmap_2.23.orig.tar.gz
2. Enter your Anaconda environment and go to the unpacked folder
3. Install phyghtmap into your Anaconda environment

macOS / Linux
```
sudo python setup.py install
```

Windows
```
python setup.py install
```

### Verify phyghtmap
You can verify the installation of phyghtmap and dependant python packages if you enter the following into your Anaconda shell.
```
phyghtmap
```

If there is a output, phyghtmap was installed and recognized successfully

### Free account for USGS
1. Enter https://ers.cr.usgs.gov/ and create a free account. It's straight forward.
2. Remember your username and password.

# Run wahooMapsCreator
Run wahooMapsCreater as described in the [README](../README.md/#Run-wahooMapsCreator)

Expand Down
47 changes: 33 additions & 14 deletions docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
- [GUI (Graphical User Interface)](#gui-graphical-user-interface)
- [CLI (Command Line Interface)](#cli-command-line-interface)
- [Advanced CLI-Usage](#advanced-cli-usage)
- [Mandatory CLI arguments](#mandatory-cli-arguments)
- [Optional arguments](#optional-arguments)
- [Main arguments](#main-arguments)
- [Examples](#examples)
- [POIs - Points of Interest](#pois---points-of-interest)
- [Contour lines](#contour-lines)
- [User specific configuration](#user-specific-configuration)

# Usage of wahooMapsCreator
Expand Down Expand Up @@ -50,21 +53,31 @@ For a list of all supported arguments, run:
- `python -m wahoomc cli -h`


wahooMapsCreator provides following arguments.
wahooMapsCreator provides following arguments, later on, there are some example calls

| Option | Description | Mandatory | Default Value |
| :-------- | :-------------------------------------------------------------------------------------------------------------- | :-------- | :------------------ |
| gui / cli | Start graphical user interface to select options or run the tool via command line interface. | X | - |
| -co / -xy | Country to create maps or X/Y coordinates to create maps for. X/Y as `133/35`. | X | - |
| -md | Maximum age of source maps and other files in days. | - | 24 |
| -nbc | Do not process border countries of tiles involving more than one country. Only useful when processing a country | - | false |
| -fd | Force download of files. Download all files new. | - | false |
| -fp | Force processing of files. Create all files new. | - | false |
| -c | Save uncompressed maps for Cruiser. | - | false |
| -tag | File with tags to keep in the output. | - | `tag-wahoo-poi.xml` |
| -gt | Calculate tiles based on geofabrik index-v1.json file. | - | false |
| -z | Zip the country (and country-maps) folder. | - | false |
| -v | Output debug logger messages. | - | false |
### Mandatory CLI arguments
One of them is mandatory for running in CLI mode.

| Option | Description | Default Value |
| :----- | :------------------------------------------------------------------------------------ | :------------ |
| -co | One or more Country to create maps or to create maps for. `malta` or `malta,germany`. | - |
| -xy | One or more X/Y coordinates to create maps for. `133/35` or `133/35,133/66`. | - |


### Optional arguments
If you like to run wahooMapsCreator with another value than the default, use the following arguments.

| Option | Description | Default Value |
| :----- | :--------------------------------------------------------------------------------------------------------------- | :------------------ |
| -md | Maximum age of source maps and other files in days. | 24 |
| -nbc | Do not process border countries of tiles involving more than one country. Only useful when processing a country. | false |
| -con | Calculate contour lines (elevation) and integrate into generated maps. | false |
| -fd | Force download of files. Download all files new. | false |
| -fp | Force processing of files. Create all files new. | false |
| -c | Save uncompressed maps for Cruiser. | false |
| -tag | File with tags to keep in the output. | `tag-wahoo-poi.xml` |
| -z | Zip the country (and country-maps) folder. | false |
| -v | Output debug logger messages. | false |

### Main arguments
**Create maps for a country**
Expand Down Expand Up @@ -100,6 +113,12 @@ Actually, wahooMapsCreator includes fuel stations, backeries, cafes and railway
- [see here](COPY_TO_WAHOO.md#activate-vtm-rendering)
- see also: https://github.com/treee111/wahooMapsCreator/wiki/Enable-hidden-features

## Contour lines
For creating maps which include contour lines and have them displayed on your Wahoo device, these steps need to be done:
1. Enhance your Anaconda environment using [these steps](./QUICKSTART_ANACONDA.md#additions-for--generating-contour-lines)
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.
3. Use a theme that renders contour lines

## User specific configuration
You can control popular configuration with your own files in the home directory `wahooMapsCreatorData/_config`.

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = wahoomc
version = 4.0.0a9
version = 4.0.0a10
author = Benjamin Kreuscher
author_email = [email protected]
description = Create maps for your Wahoo bike computer based on latest OSM maps
Expand Down
12 changes: 8 additions & 4 deletions wahoomc/file_directory_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,15 @@ def read_json_file_generic(json_file_path):
"""
reads content of given .json file
"""
with open(json_file_path, encoding="utf-8") as json_file:
json_content = json.load(json_file)
json_file.close()
try:
with open(json_file_path, encoding="utf-8") as json_file:
json_content = json.load(json_file)
json_file.close()

return json_content

return json_content
except FileNotFoundError:
return {}


def write_json_file_generic(json_file_path, json_content):
Expand Down
14 changes: 12 additions & 2 deletions wahoomc/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ def process_call_of_the_tool():
# Do not calculate border countries of input country
options_args.add_argument('-nbc', '--bordercountries', action='store_false',
help="do not process border countries of tiles involving more than one country")
# calculate contour lines
options_args.add_argument('-con', '--contour', action='store_true',
help="process contour lines (elevation data)")
# Force download of source maps and the land shape file
# If False use Max_Days_Old to check for expired maps
# If True force redownloading of maps and landshape
Expand Down Expand Up @@ -100,6 +103,8 @@ def process_call_of_the_tool():
o_input_data.max_days_old = args.maxdays

o_input_data.process_border_countries = args.bordercountries
o_input_data.contour = args.contour

o_input_data.force_download = args.forcedownload
o_input_data.force_processing = args.forceprocessing

Expand Down Expand Up @@ -179,6 +184,7 @@ def __init__(self):
self.force_download = False
self.force_processing = False
self.process_border_countries = True
self.contour = False
self.save_cruiser = False

self.tag_wahoo_xml = "tag-wahoo-poi.xml"
Expand Down Expand Up @@ -298,6 +304,7 @@ def handle_create_map(self, event): # pylint: disable=unused-argument
self.o_input_data.force_download = tab1.third.checkb_download.get()
self.o_input_data.force_processing = tab1.third.checkb_processing_val.get()
self.o_input_data.process_border_countries = tab1.third.checkb_border_countries_val.get()
self.o_input_data.contour = tab1.third.checkb_contour_val.get()

self.o_input_data.save_cruiser = tab2.first.checkb_save_cruiser_val.get()
self.o_input_data.zip_folder = tab2.first.checkb_zip_folder_val.get()
Expand Down Expand Up @@ -394,10 +401,13 @@ def __init__(self, parent, oInputData, controller):

self.checkb_border_countries_val = create_checkbox(self, oInputData.process_border_countries,
"Process border countries", 0)
self.checkb_contour_val = create_checkbox(self, oInputData.verbose,
"process contour lines (elevation data)", 1)

self.chk_force_download.grid(
column=0, row=1, sticky=tk.W, padx=15, pady=5)
column=0, row=2, sticky=tk.W, padx=15, pady=5)
self.checkb_processing_val = create_checkbox(self, oInputData.force_processing,
"Force processing", 2)
"Force processing", 3)


class Buttons(tk.Frame):
Expand Down
9 changes: 8 additions & 1 deletion wahoomc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from wahoomc.setup_functions import initialize_work_directories, \
check_installation_of_required_programs, write_config_file, \
adjustments_due_to_breaking_changes, copy_jsons_from_repo_to_user, \
check_installed_version_against_latest_pypi
check_installed_version_against_latest_pypi, check_installation_of_programs_credentials_for_contour_lines
from wahoomc.downloader import download_tooling

from wahoomc.osm_maps_functions import OsmMaps
Expand Down Expand Up @@ -55,6 +55,9 @@ def run(run_level):
# Is there something to do?
o_input_data.is_required_input_given_or_exit(issue_message=True)

if o_input_data.contour:
check_installation_of_programs_credentials_for_contour_lines()

if o_input_data.country:
o_osm_data = CountryOsmData(o_input_data)
elif o_input_data.xy_coordinates:
Expand All @@ -78,6 +81,10 @@ def run(run_level):
# Generate sea
o_osm_maps.generate_sea()

# Generate elevation
if o_input_data.contour:
o_osm_maps.generate_elevation()

# Split filtered country files to tiles
o_osm_maps.split_filtered_country_files_to_tiles()

Expand Down
Loading