gpx-to-map 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+ .coverage
9
+ .pytest_cache/
10
+
11
+ # Virtual environments
12
+ .venv
13
+
14
+ /exports/
15
+ /data/
16
+
17
+ .env
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mario Angst
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,115 @@
1
+ Metadata-Version: 2.5
2
+ Name: gpx-to-map
3
+ Version: 0.1.0
4
+ Summary: Convert a folder of GPX files into an interactive HTML map or a static PNG.
5
+ Project-URL: Homepage, https://codeberg.org/marioangst/winti-zh-gpx
6
+ Project-URL: Repository, https://codeberg.org/marioangst/winti-zh-gpx
7
+ Author-email: Mario Angst <mario.angst@gmail.com>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: geospatial,gps,gpx,map,visualization
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: End Users/Desktop
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Scientific/Engineering :: GIS
17
+ Requires-Python: >=3.12
18
+ Requires-Dist: contextily>=1.6.0
19
+ Requires-Dist: duckdb>=1.4.1
20
+ Requires-Dist: geojson-transformer>=0.0.7
21
+ Requires-Dist: gpxpy>=1.6.0
22
+ Requires-Dist: loguru>=0.7.3
23
+ Requires-Dist: lonboard>=0.13.0
24
+ Requires-Dist: matplotlib>=3.10.0
25
+ Requires-Dist: pyarrow>=22.0.0
26
+ Requires-Dist: tqdm>=4.67.1
27
+ Requires-Dist: typer>=0.12.0
28
+ Description-Content-Type: text/markdown
29
+
30
+ # gpx-to-map
31
+
32
+ Convert a folder of GPX tracks into an **interactive HTML map** (lonboard / deck.gl) or a **static PNG image** (matplotlib + contextily) with a single command.
33
+
34
+ ![example output](https://codeberg.org/marioangst/winti-zh-gpx/raw/branch/main/img/winti_zh.png)
35
+
36
+ ## Installation
37
+
38
+ ```bash
39
+ pip install gpx-to-map
40
+ ```
41
+
42
+ ## Usage
43
+
44
+ ```
45
+ gpx-to-map <gpx-folder> <output-file> [OPTIONS]
46
+ ```
47
+
48
+ | Argument | Description |
49
+ |---|---|
50
+ | `gpx-folder` | Directory containing `.gpx` files |
51
+ | `output-file` | Destination path — `.html` for interactive, `.png` for static |
52
+
53
+ ### Options
54
+
55
+ | Option | Default | Description |
56
+ |---|---|---|
57
+ | `--style` / `-s` | `dark` | Background map style: `dark`, `light`, `voyager` |
58
+ | `--color` / `-c` | `red` | Track color — any matplotlib name, hex (`#1f77b4`), or CSS color |
59
+ | `--highlight-latest` / `--no-highlight-latest` | disabled | Highlight the most recent track with a contrasting accent color. Recency is determined by the first trackpoint timestamp in each GPX file, falling back to file modification time |
60
+ | `--geojson-folder` | *(discard)* | Keep intermediate GeoJSON files in this folder (created if absent) |
61
+ | `--dpi` | `200` | Resolution for PNG output in dots per inch; ignored for HTML |
62
+
63
+ ### Examples
64
+
65
+ ```bash
66
+ # Interactive map with default dark style
67
+ gpx-to-map ./rides output.html
68
+
69
+ # Light basemap, steelblue tracks, highlight the latest ride
70
+ gpx-to-map ./rides output.html --style light --color steelblue
71
+
72
+ # Export a static PNG instead
73
+ gpx-to-map ./rides output.png --style voyager --color "#e07b39"
74
+
75
+ # Don't highlight the latest track
76
+ gpx-to-map ./rides output.html --no-highlight-latest
77
+ ```
78
+
79
+ ## How it works
80
+
81
+ 1. Every `.gpx` file in the folder is converted to GeoJSON via [`geojson-transformer`](https://pypi.org/project/geojson-transformer/).
82
+ 2. All tracks are loaded into an in-memory [DuckDB](https://duckdb.org/) database using the `spatial` extension.
83
+ 3. **HTML output** — renders an interactive [lonboard](https://developmentseed.org/lonboard/) / deck.gl `PathLayer` map and saves it as a self-contained HTML file.
84
+ 4. **PNG output** — plots the tracks with matplotlib and overlays map tiles via [contextily](https://contextily.readthedocs.io/), then saves a high-resolution raster image.
85
+
86
+ The latest GPX file is always loaded into a separate layer so it can be highlighted. "Latest" is determined by the timestamp of the first trackpoint (`<trkpt><time>`) recorded in the file; files without trackpoint timestamps (e.g. manually-planned routes) fall back to their filesystem modification time.
87
+
88
+ ## Python API
89
+
90
+ `create_map` can be called directly from Python without the CLI:
91
+
92
+ ```python
93
+ from pathlib import Path
94
+ from gpx_to_map.core import create_map
95
+
96
+ create_map(
97
+ gpx_folder=Path("./rides"),
98
+ output_file=Path("output.html"), # or "output.png" for a static image
99
+ style="dark", # "dark" | "light" | "voyager"
100
+ color="steelblue",
101
+ highlight_latest=True,
102
+ geojson_folder=Path("./geojson"), # optional: keep intermediate GeoJSON files
103
+ )
104
+ ```
105
+
106
+ All parameters correspond directly to the CLI options. `style` accepts the same string values as `--style`.
107
+
108
+ ## Development
109
+
110
+ ```bash
111
+ git clone https://codeberg.org/marioangst/winti-zh-gpx
112
+ cd gpx-to-map
113
+ uv sync
114
+ uv run gpx-to-map --help
115
+ ```
@@ -0,0 +1,86 @@
1
+ # gpx-to-map
2
+
3
+ Convert a folder of GPX tracks into an **interactive HTML map** (lonboard / deck.gl) or a **static PNG image** (matplotlib + contextily) with a single command.
4
+
5
+ ![example output](https://codeberg.org/marioangst/winti-zh-gpx/raw/branch/main/img/winti_zh.png)
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pip install gpx-to-map
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```
16
+ gpx-to-map <gpx-folder> <output-file> [OPTIONS]
17
+ ```
18
+
19
+ | Argument | Description |
20
+ |---|---|
21
+ | `gpx-folder` | Directory containing `.gpx` files |
22
+ | `output-file` | Destination path — `.html` for interactive, `.png` for static |
23
+
24
+ ### Options
25
+
26
+ | Option | Default | Description |
27
+ |---|---|---|
28
+ | `--style` / `-s` | `dark` | Background map style: `dark`, `light`, `voyager` |
29
+ | `--color` / `-c` | `red` | Track color — any matplotlib name, hex (`#1f77b4`), or CSS color |
30
+ | `--highlight-latest` / `--no-highlight-latest` | disabled | Highlight the most recent track with a contrasting accent color. Recency is determined by the first trackpoint timestamp in each GPX file, falling back to file modification time |
31
+ | `--geojson-folder` | *(discard)* | Keep intermediate GeoJSON files in this folder (created if absent) |
32
+ | `--dpi` | `200` | Resolution for PNG output in dots per inch; ignored for HTML |
33
+
34
+ ### Examples
35
+
36
+ ```bash
37
+ # Interactive map with default dark style
38
+ gpx-to-map ./rides output.html
39
+
40
+ # Light basemap, steelblue tracks, highlight the latest ride
41
+ gpx-to-map ./rides output.html --style light --color steelblue
42
+
43
+ # Export a static PNG instead
44
+ gpx-to-map ./rides output.png --style voyager --color "#e07b39"
45
+
46
+ # Don't highlight the latest track
47
+ gpx-to-map ./rides output.html --no-highlight-latest
48
+ ```
49
+
50
+ ## How it works
51
+
52
+ 1. Every `.gpx` file in the folder is converted to GeoJSON via [`geojson-transformer`](https://pypi.org/project/geojson-transformer/).
53
+ 2. All tracks are loaded into an in-memory [DuckDB](https://duckdb.org/) database using the `spatial` extension.
54
+ 3. **HTML output** — renders an interactive [lonboard](https://developmentseed.org/lonboard/) / deck.gl `PathLayer` map and saves it as a self-contained HTML file.
55
+ 4. **PNG output** — plots the tracks with matplotlib and overlays map tiles via [contextily](https://contextily.readthedocs.io/), then saves a high-resolution raster image.
56
+
57
+ The latest GPX file is always loaded into a separate layer so it can be highlighted. "Latest" is determined by the timestamp of the first trackpoint (`<trkpt><time>`) recorded in the file; files without trackpoint timestamps (e.g. manually-planned routes) fall back to their filesystem modification time.
58
+
59
+ ## Python API
60
+
61
+ `create_map` can be called directly from Python without the CLI:
62
+
63
+ ```python
64
+ from pathlib import Path
65
+ from gpx_to_map.core import create_map
66
+
67
+ create_map(
68
+ gpx_folder=Path("./rides"),
69
+ output_file=Path("output.html"), # or "output.png" for a static image
70
+ style="dark", # "dark" | "light" | "voyager"
71
+ color="steelblue",
72
+ highlight_latest=True,
73
+ geojson_folder=Path("./geojson"), # optional: keep intermediate GeoJSON files
74
+ )
75
+ ```
76
+
77
+ All parameters correspond directly to the CLI options. `style` accepts the same string values as `--style`.
78
+
79
+ ## Development
80
+
81
+ ```bash
82
+ git clone https://codeberg.org/marioangst/winti-zh-gpx
83
+ cd gpx-to-map
84
+ uv sync
85
+ uv run gpx-to-map --help
86
+ ```
@@ -0,0 +1,3 @@
1
+ """gpx-to-map: Convert a folder of GPX files into an interactive HTML map or a static PNG."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,117 @@
1
+ """Typer-based CLI for gpx-to-map."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+ from typing import Annotated
7
+
8
+ import typer
9
+ from loguru import logger
10
+
11
+ from .core import create_map
12
+ from .styles import Style
13
+
14
+ app = typer.Typer(
15
+ name="gpx-to-map",
16
+ help=(
17
+ "Convert a folder of GPX tracks into an interactive HTML map "
18
+ "or a static PNG image."
19
+ ),
20
+ add_completion=False,
21
+ )
22
+
23
+
24
+ @app.command()
25
+ def main(
26
+ gpx_folder: Annotated[
27
+ Path,
28
+ typer.Argument(
29
+ exists=True,
30
+ file_okay=False,
31
+ dir_okay=True,
32
+ readable=True,
33
+ help="Folder containing the .gpx files.",
34
+ ),
35
+ ],
36
+ output_file: Annotated[
37
+ Path,
38
+ typer.Argument(
39
+ help="Destination file. Use .html for an interactive map or .png for a static image.",
40
+ ),
41
+ ],
42
+ style: Annotated[
43
+ Style,
44
+ typer.Option(
45
+ "--style",
46
+ "-s",
47
+ help="Background map style.",
48
+ case_sensitive=False,
49
+ ),
50
+ ] = Style.dark,
51
+ color: Annotated[
52
+ str,
53
+ typer.Option(
54
+ "--color",
55
+ "-c",
56
+ help=(
57
+ "Track color. Accepts any matplotlib color name (e.g. 'steelblue'), "
58
+ "a hex string (e.g. '#1f77b4'), or an RGB tuple (e.g. '31,119,180')."
59
+ ),
60
+ ),
61
+ ] = "red",
62
+ highlight_latest: Annotated[
63
+ bool,
64
+ typer.Option(
65
+ "--highlight-latest/--no-highlight-latest",
66
+ help=(
67
+ "Highlight the most recent track with a contrasting accent color. "
68
+ "Recency is determined by the first trackpoint timestamp recorded "
69
+ "in each GPX file (<trkpt><time>). "
70
+ "File modification time is used as a fallback for files that "
71
+ "contain no trackpoint timestamps (e.g. manually-planned routes)."
72
+ ),
73
+ ),
74
+ ] = False,
75
+ geojson_folder: Annotated[
76
+ Path | None,
77
+ typer.Option(
78
+ "--geojson-folder",
79
+ help=(
80
+ "Keep the intermediate GeoJSON files in this folder. "
81
+ "The folder is created if it does not exist. "
82
+ "Omit this option (the default) to discard the files after the run."
83
+ ),
84
+ file_okay=False,
85
+ dir_okay=True,
86
+ writable=True,
87
+ ),
88
+ ] = None,
89
+ dpi: Annotated[
90
+ int,
91
+ typer.Option(
92
+ "--dpi",
93
+ help="Resolution for PNG output in dots per inch. Has no effect on HTML output.",
94
+ min=50,
95
+ ),
96
+ ] = 200,
97
+ ) -> None:
98
+ suffix = output_file.suffix.lower()
99
+ if suffix not in {".html", ".png"}:
100
+ logger.error(
101
+ f"Output file must end in .html or .png — got '{output_file.name}'."
102
+ )
103
+ raise typer.Exit(code=1)
104
+
105
+ try:
106
+ create_map(
107
+ gpx_folder=gpx_folder,
108
+ output_file=output_file,
109
+ style=style,
110
+ color=color,
111
+ highlight_latest=highlight_latest,
112
+ geojson_folder=geojson_folder,
113
+ dpi=dpi,
114
+ )
115
+ except (ValueError, FileNotFoundError, NotADirectoryError) as exc:
116
+ logger.error(str(exc))
117
+ raise typer.Exit(code=1) from exc