A fast, user-friendly CLI tool to download Garmin OpenTopoMap files in bulk based on YAML configuration.
- π¦ Bulk downloads of multiple countries in one command
- π― Per-country selection of Garmin, contour, and Basecamp maps
- π Update checking using the latest timestamp from
garmin.opentopomap.org - π¨ Structured, colored logging with optional debug output
- π‘οΈ Resilient behavior: invalid countries or failed downloads do not stop others
- π Debug mode for verbose troubleshooting
git clone https://github.com/joanbono/otm-dl.git
cd otm-dl
go mod tidy
go build -o otm-dlDefault location: ~/.otp-dl/config.yaml
Example:
- country:
andorra:
garmin: true
contour: true
basecamp: false
spain:
garmin: false
contour: false
basecamp: trueThis will:
- Download Garmin and Contours maps for Andorra
- Download only Basecamp maps for Spain
# Use default config and current directory
$ otm-dl download
# Specify config file and output directory
$ otm-dl download -c ~/.otp-dl/config.yaml -o ~/Downloads/Maps
# Enable debug logging
$ otm-dl download -dotm-dl update
otm-dl update -d # with debug loggingThe update command compares the date stored in $HOME/.otp-dl/last-download.txt with the current date parsed from the OpenTopoMap HTML and informs you if a newer version is available.
$ otm-dl [command] [flags]| Command | Alias | Description |
|---|---|---|
download |
dl |
Download map files according to the YAML config |
update |
β | Check if a newer map version is available |
| Flag | Short | Default | Description |
|---|---|---|---|
--debug |
-d |
false | Enable verbose debug logging |
| Flag | Short | Default | Description |
|---|---|---|---|
--config |
-c |
~/.otp-dl/config.yaml |
Path to configuration YAML file |
--out |
-o |
current working directory | Directory where files are downloaded |
# Basic usage with defaults
otm-dl download
# Use custom config and output directory with debug
otm-dl download -c /path/to/config.yaml -o /path/to/output -dThe configuration file is a YAML list where each item contains a country block. Inside country, keys are country names (case-insensitive), and values are the map types to download.
- country:
<country-name>:
garmin: <true|false>
contour: <true|false>
basecamp: <true|false>Example:
- country:
andorra:
garmin: true
contour: true
basecamp: false
spain:
garmin: true
contour: false
basecamp: true
bosnia_herzegovina:
garmin: true
contour: true
basecamp: trueCountry names in YAML are normalized as follows:
- Case-insensitive:
Andorra,andorra,ANDORRAare equivalent - Spaces are converted to underscores for URL slugs:
czech republicβczech_republic - Some special mappings are handled explicitly, for example:
bosnia and herzegovinaβbosnia_herzegovinaczech republicβczech_republicunited kingdomβgreat_britain
If a country name cannot be mapped to a known slug or a download URL returns 404, the tool logs a warning but continues with other countries.
For each country and map type enabled in the config, the tool constructs URLs like:
- Garmin:
https://garmin.opentopomap.org/europe/<slug>/otm-<slug>.zip - Contours:
https://garmin.opentopomap.org/europe/<slug>/otm-<slug>-contours.zip - Basecamp:
https://garmin.opentopomap.org/europe/<slug>/otm-<slug>-basecamp.zip
Professional, user-friendly messages are printed, e.g.:
Downloaded OpenTopoMap for AndorraDownloaded Contours for AndorraDownloaded Basecamp for Andorra
- Invalid country names: A warning is logged and processing continues
- HTTP errors / missing files: A warning is logged for that file; other downloads continue
- At the end, a summary indicates whether there were warnings
Each successful download run:
- Scrapes the OpenTopoMap HTML for the Andorra row
- Extracts the last update timestamp (e.g.
2026-01-23 03:18:44) - Stores the date part (
2026-01-23) into$HOME/.otp-dl/last-download.txt
The update command:
- Reads
last-download.txt - Fetches the current update date from the server
- Informs you whether a newer version is available
- Go 1.21 or newer
From the project root:
go mod tidy(If needed, explicitly:)
go get github.com/spf13/cobra@latest
go get github.com/sirupsen/logrus@latest
go get github.com/PuerkitoBio/goquery@latest
go get gopkg.in/yaml.v3@latest
go get github.com/briandowns/spinner@latest
go get github.com/fatih/color@latestgo build -o otm-dl.
βββ main.go
βββ internal/
β βββ downloader.go # download command & logic
β βββ update.go # update command & logic
βββ go.mod
βββ go.sum
βββ README.md
- Ensure
~/.otp-dl/config.yamlexists, or use-cto point to a config:otm-dl download -c /path/to/config.yaml
- Check the spelling of the country in your config
- For complex names, verify how the country is named in OpenTopoMap or adjust to one of the supported patterns
- The specific map type may not exist for that country
- The tool logs a warning and continues with the rest
Run with debug for more context:
otm-dl download -dThis project is licensed under the MIT License.
See the LICENSE file for details.
Contributions are welcome:
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Commit your changes:
git commit -m "Add my feature" - Push the branch:
git push origin feature/my-feature - Open a Pull Request
- OpenTopoMap for the map data and Garmin exports
- Go ecosystem: Cobra, Logrus, GoQuery and others that make this CLI ergonomic
If this project is useful to you, please consider starring the repository on GitHub.
It helps others discover it and motivates further improvements!