Metadata-Version: 2.5
Name: gpx-poi-enricher
Version: 1.19.3
Summary: Enrich GPX tracks with Points of Interest from OpenStreetMap via configurable YAML profiles
Project-URL: Homepage, https://github.com/devmarkusb/gpx-poi-enricher
Project-URL: Repository, https://github.com/devmarkusb/gpx-poi-enricher
Project-URL: Issues, https://github.com/devmarkusb/gpx-poi-enricher/issues
Author-email: Markus Borris <devmborrs@gmail.com>
License: MIT
License-File: LICENSE
Keywords: geocoding,gpx,openstreetmap,overpass,poi,travel,waypoints
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: End Users/Desktop
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: GIS
Classifier: Topic :: Utilities
Requires-Python: >=3.13
Requires-Dist: gpxpy>=1.6
Requires-Dist: pyyaml>=6.0
Requires-Dist: requests>=2.28
Provides-Extra: dev
Requires-Dist: pre-commit>=4.0; extra == 'dev'
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: python-semantic-release<11,>=10.5.0; extra == 'dev'
Requires-Dist: responses>=0.25; extra == 'dev'
Requires-Dist: ruff>=0.4; extra == 'dev'
Provides-Extra: gui
Requires-Dist: pyqt6>=6.4; extra == 'gui'
Description-Content-Type: text/markdown

# gpx-poi-enricher

**CLI tools and apps for finding OpenStreetMap POIs along a track or around a Google Maps place.**

[![CI][badge-ci]][ci]
[![Python 3.13+](https://img.shields.io/badge/python-3.13%2B-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
[![PyPI](https://badge.fury.io/py/gpx-poi-enricher.svg)](https://pypi.org/project/gpx-poi-enricher/)

---

## Table of Contents

- [The Pipeline](#the-pipeline)
- [Features](#features)
- [Installation](#installation)
- [Quick Start](#quick-start)
- [GUI](#gui)
- [Environment variables](#environment-variables)
- [Command: maps-to-gpx](#command-maps-to-gpx)
- [Command: gpx-split-waypoints](#command-gpx-split-waypoints)
- [Command: gpx-poi-enricher](#command-gpx-poi-enricher)
- [Built-in Profiles](#built-in-profiles)
- [POI catalog](#poi-catalog)
- [Creating Custom Profiles](#creating-custom-profiles)
- [How It Works](#how-it-works)
- [Data Attribution](#data-attribution)
- [Contributing](#contributing)
- [License](#license)

---

## The Pipeline

```
Google Maps directions ── maps-to-gpx ── routed GPX ─┐
                                                     ├─ gpx-poi-enricher ── POI waypoints
Track GPX ──────────────────────────────────────────┤
Google Maps place / coordinates ────────────────────┘
      │
      ▼
 waypoints.gpx        ← Garmin / OsmAnd / Google My Maps <https://www.google.com/mymaps>
```

All three commands install together and can be run alone or chained. Split and POI output are
**waypoints-only** GPX (no `<trk>`) — import alongside the route file or merge externally. Files
>5 MB? Try <https://www.gpxtokml.com/>.

---

## Features

- **`maps-to-gpx`** — Google Maps URL (incl. `maps.app.goo.gl`) → routed GPX via Nominatim + public
  OSRM; custom base URL via `OSRM_BASE_URL` or `--osrm-base-url`. No API keys for defaults.
- **`gpx-split-waypoints`** — evenly spaced split `<wpt>` markers for waypoint-limited apps.
- **`gpx-poi-enricher`** — OSM POIs along a track or around a point; **10** curated YAML profiles
  plus a **POI catalog** (~95 common types); **`--quick`** for sparse smoke tests.
- **GUI** (`gpx-poi-enricher-gui`) — **Easy**: route or point → GPX + POIs; **Expert**: track or point search;
  **Profiles**: add POI types from the built-in catalog.
- **Android app** — Easy and POI Enricher support point/Maps link searches.
- Country-aware **`terms`** (`DE`, `FR`, `ES`, `EN`); Overpass mirrors with retries; per-profile
  defaults overridable on the CLI; custom YAML via **`GPX_POI_PROFILES_DIR`**.

---

## Installation

**Python 3.13+**. Use an isolated install — system Python is often
[externally managed](https://peps.python.org/pep-0668/) on Linux. Recommended: venv + pip:

```bash
python3 -m venv .venv && source .venv/bin/activate   # Windows: .venv\Scripts\activate
pip install gpx-poi-enricher              # CLI
pip install "gpx-poi-enricher[gui]"       # CLI + PyQt6 GUI
```

**Alternatives:** `pipx install "gpx-poi-enricher[gui]"` (no activate); or
`uv tool install "gpx-poi-enricher[gui]"` with [uv](https://docs.astral.sh/uv/).

### Development

```bash
git clone https://github.com/devmarkusb/gpx-poi-enricher.git && cd gpx-poi-enricher
uv sync --extra dev --extra gui   # .venv + editable install (matches CI)
./scripts/setup-pre-commit.sh
uv run pytest                     # uv run <cmd> works without activating .venv
```

Without uv: venv + `pip install -e ".[dev,gui]"`. See [CONTRIBUTING.md](CONTRIBUTING.md).

---

## Quick Start

Google Maps URL → campsite waypoints:

```bash
maps-to-gpx "https://www.google.com/maps/dir/Paris/Lyon/Barcelona/" route.gpx
gpx-split-waypoints route.gpx route-split.gpx 10    # optional split markers
gpx-poi-enricher route.gpx camping.gpx --profile camping
```

---

## GUI

```bash
gpx-poi-enricher-gui          # requires [gui] extra — see Installation
gpx-poi-enricher-gui --quick  # sparse enrichment ([quick] in title bar)
```

From a clone: `uv run gpx-poi-enricher-gui`.

**macOS app bundle** (Finder/Dock icon, double-click): after `uv sync --extra gui`, run
`uv run python scripts/build_macos_app.py` → `dist/GPX POI Enricher.app`. Drag to Applications or
Dock. Rebuild after upgrading the package in `.venv`.

**Easy** — choose Route for Maps directions → GPX(s) + POIs, or Point for coordinates/a Maps
place link → POI-only GPX. Point mode has its own radius field (blank/0 = the profile radius) and
names its GPX after the nearest named POI, else the nearest place from one Nominatim reverse
lookup, else `point-{hash}` as before. Route mode also supports alternates, detours, and
milestones. Progress log + file list; cancel after the current batch.

**Expert** — POI Enricher, Split Waypoints, Maps → GPX, and **Profiles** tabs (same CLIs; Maps tab
supports multiple URLs like Easy). **Profiles → Add from catalog…** adds common OSM POI types
(museums, pharmacies, viewpoints, …) as editable user profiles. POI Enricher accepts a track GPX
or a point/Maps link. Long-running work is off the UI thread.

---

## Environment variables

**`GPX_POI_PROFILES_DIR`** — existing directory of `*.yaml` / `*.yml` **replaces** both built-in
and normal user profile locations. Desktop edits, imports, catalog additions, and deletions use
this directory too. It must be writable for those operations; failures are shown instead of saving
in an invisible fallback directory. An explicit programmatic `profiles_dir` takes precedence.

**`OSRM_BASE_URL`** — OSRM root ending in `/route/v1` for `maps-to-gpx` (override with
`--osrm-base-url`).

---

## Command: maps-to-gpx

One Google Maps directions URL → routed GPX (`<trk>` + stopover `<wpt>`). Short links, path-style
(`/maps/dir/A/B/C`), and query-style (`?api=1&origin=…`) URLs. Names →
[Nominatim](https://nominatim.openstreetmap.org/); routing → public
[OSRM](http://router.project-osrm.org/) or your own stack. Multiple routes/detours: use the GUI.

Run `maps-to-gpx --help` for `--mode`, `--name`, `--osrm-base-url`.

```bash
maps-to-gpx "https://www.google.com/maps/dir/Paris/Lyon/Marseille/" route.gpx
maps-to-gpx "https://maps.app.goo.gl/ABC123" route.gpx
maps-to-gpx "https://www.google.com/maps/dir/Amsterdam/Utrecht/" route.gpx --mode cycling
maps-to-gpx "https://www.google.com/maps/dir/A/B/" route.gpx \
  --osrm-base-url "https://my-osrm.example.com/route/v1"   # must end with /route/v1
```

---

## Command: gpx-split-waypoints

Track → **`segments`** evenly spaced milestones named `1/N`, …, `N/N`, including the finish.
Descriptions include the percentage along the track. Waypoints only — companion file, not the
original track. `segments >= 2`.

```bash
gpx-split-waypoints route.gpx route-split.gpx     # 10 milestones, 1/10 through 10/10 (default)
gpx-split-waypoints route.gpx route-split.gpx 5   # 5 milestones, 1/5 through 5/5
```

---

## Command: gpx-poi-enricher

Track GPX or point in → waypoints-only POI GPX out. A point may be `LAT,LON` or a Google Maps
place link. Run `gpx-poi-enricher --help` for all flags.

- `--profile` — required unless `--list-profiles`
- `--max-km` — max distance from track, or radius around a point
- `--sample-km` — sampling step along a track (unused for a point)
- `--output` — output GPX path with `--point`
- `--batch-size` — sample points per Overpass request
- `--country-sample-km` — spacing between track country lookups (default **40**; **500** with
  `--quick`)
- `--point` — `LAT,LON` or a Google Maps place link; pair with `--output`
- `--progress-interval` — stderr progress in seconds (`0` off; default `5`)
- `--verbose` — verbose Overpass error bodies (track searches only)
- `--list-profiles` — list profiles and defaults, then exit
- `--quick` — sparse track defaults and a 1 km radius (including point searches), unless overridden

Track search is an approximation: samples are existing GPX vertices chosen after each sampling
interval, with no interpolated points. Search circles can leave gaps; for example, a 10 km interval
with a 2 km radius does not cover the whole track. Final filtering measures distance to the nearest
original track vertex, rather than the continuous line between vertices. Smaller sampling intervals
increase coverage and API requests; `--quick` deliberately uses sparse defaults.

```bash
gpx-poi-enricher route.gpx camping.gpx --profile camping
gpx-poi-enricher route.gpx playgrounds.gpx --profile playground --max-km 5
gpx-poi-enricher --point '52.038993,13.748653' --output aquariums.gpx --profile aquarium
gpx-poi-enricher --point 'https://maps.app.goo.gl/JDocHptvdByZ1WZSA' \
  --output aquariums.gpx --profile aquarium
gpx-poi-enricher --list-profiles
gpx-poi-enricher route.gpx probe.gpx --profile camping --quick
```

---

## Built-in Profiles

From `profiles/`. `gpx-poi-enricher --list-profiles` shows `sample_km`, `batch_size`, `retries`.

| Profile | Description (YAML) | Default max_km |
| :------ | :----------------- | -------------: |
| `camping` | Campsite | 10.0 |
| `playground` | Playground | 3.0 |
| `outdoor_pool` | Outdoor Pool, Adventure Pool, Thermal Bath | 10.0 |
| `beach` | Swimming Lake, Beach | 20.0 |
| `theme_park` | Theme Park | 12.0 |
| `zoo` | Zoo, Petting Zoo | 12.0 |
| `aquarium` | Aquarium | 15.0 |
| `mcdonalds` | McDonalds | 5.0 |
| `restaurant` | Restaurant | 2.0 |
| `kids_activities` | Children's Activities of All Kinds | 15.0 |

**`kids_activities`** matches mainly via **`terms`** (literal, case-insensitive text in OSM `name` /
`alt_name` / `description` / `operator`); most others use **`tags`**, optionally plus **`terms`**.

---

## POI catalog

Besides the curated built-ins above, the app ships a **catalog of ~95 common OSM POI types**
(restaurants, museums, pharmacies, viewpoints, …) in
`src/gpx_poi_enricher/data/poi_catalog.yaml`.

**Desktop GUI:** Expert → **Profiles** → **Add from catalog…** — searchable list by category.
**Android:** **Profiles** tab → **Add from catalog…**

Choosing an entry writes a **user profile** YAML with:

- OSM **`tags`** from the catalog entry
- **`defaults`** from a preset bucket (`urban_dense`, `regional_sparse`, …) — e.g. tight radius for
  shops, wider radius for zoos
- empty **`terms`** (tag-only search; edit later if you need name matching)

If the profile id already exists (e.g. built-in `aquarium`), saving from the catalog creates a
**user override** with the same id. You can edit radius, symbols, or add `terms` afterward.

Programmatic use:

```python
from gpx_poi_enricher.poi_catalog import save_catalog_entry

save_catalog_entry("museum")  # writes ~/.config/gpx-poi-enricher/profiles/museum.yaml (desktop)
```

---

## Creating Custom Profiles

**Easiest:** use **Add from catalog…** in the GUI (see [POI catalog](#poi-catalog)) for standard OSM
types, then edit the generated YAML if needed.

**Manual:** add a YAML file; **`id`** or filename (without `.yaml`) is the profile id. With PyPI
installs, set **`GPX_POI_PROFILES_DIR`** to use **only** your profiles.

```yaml
# profiles/my_profile.yaml
id: my_profile
description: "My custom POI type"
symbol: Flag, Blue          # Garmin symbol in output GPX

defaults:
  max_km: 8.0
  sample_km: 4.0
  batch_size: 5
  retries: 3

tags:                       # any tag line can match
  - key: tourism
    value: museum
  - key: amenity
    value: fast_food
    and:
      key: cuisine
      value: pizza

terms:                      # literal text (per country + EN), case-insensitive
  DE: ["Museum", "Schloss"]
  FR: ["musée", "château"]
  ES: ["museo", "castillo"]
  EN: ["museum", "castle"]
```

Need non-empty **`tags`** or **`terms`** for the current country plus **`EN`** (else query build
fails). **`defaults`** keys are overridable on the CLI.

Terms match substrings; regex characters such as `.`, `*`, and `[` are treated literally.

---

## How It Works

**maps-to-gpx:** expand short URLs → parse path/query (geocode names, keep coords) → OSRM route →
GPX `<trk>` + stopover `<wpt>`.

**POI enrichment:** sample every `sample_km` → reverse-geocode country every `country_sample_km` →
Overpass per batch (`tags` = typed selectors; `terms` = literal text in
name/alt_name/description/operator within `max_km`) → dedupe by **OSM type + ID** → `<wpt>` only.
Repeated results for the same OSM object are emitted once. Distinct objects at the same coordinates,
including a node and a way with the same numeric ID, remain separate. Each POI includes a link to its
OSM object, which also preserves its identity during checkpoint recovery. Anonymous programmatic
results without OSM identity retain the rounded-coordinate fallback. Mirrors rotate; retries on failure.

### Recovery and limitations

- Interrupted batch searches keep a partial GPX and an `.enrich-checkpoint.json` sidecar. Resume
  requires the same input, profile, settings, and country grouping. Checkpoint version 2 retains OSM
  identity; older checkpoints are refused because their skipped batches may have lost distinct POIs.
  Preserve the partial GPX and start with a new output path, or remove the sidecar when deliberately
  restarting from scratch. Previously rounded coordinates cannot be reconstructed.
- Android resume state is retained in memory; process death does not restore it automatically.
  Cancellation is cooperative and may wait for a blocking network call or retry to finish.
- POI enrichment reads GPX 1.1 tracks. The gpxpy-backed Maps and Split commands can also read GPX 1.0.
  Sampling and vertex filtering have the coverage limits described above; detour comparisons use local
  planar geometry and remain approximate for unusually long or polar segments.
- GPX files, routes, and diagnostic logs can reveal locations. Redact them before sharing, especially
  when verbose service errors are enabled.

---

## Data Attribution

Map data © [OpenStreetMap](https://www.openstreetmap.org/) contributors — [ODbL](https://opendatacommons.org/licenses/odbl/).
[Nominatim](https://nominatim.openstreetmap.org/) — OSM Foundation. Routing —
[OSRM](http://project-osrm.org/) public demo (ODbL).

**Usage policies:** Nominatim ~1 req/s + meaningful `User-Agent` (this project sends one); Overpass —
no bulk scraping; OSRM demo — personal/non-commercial; use **`OSRM_BASE_URL`** /
**`--osrm-base-url`** for heavy use.

---

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md). Issues:
[GitHub](https://github.com/devmarkusb/gpx-poi-enricher/issues).

Android device regressions run with `./gradlew connectedAuditAndroidTest` from `android/` and a
connected emulator/device (API 29+). The separate `.audit` application uses real Chaquopy, ViewModels,
and MediaStore with mocked service responses; Internet permission and billing/ads startup are disabled.
Coverage currently includes interrupted resume, work ownership, queued cancellation, and storage
overwrites on one arm64 Android 17 emulator. Actual screen rotation, SAF picker grants and provider
failures, process death, billing/consent flows, and older Android versions still need device coverage.

---

## License

MIT — [LICENSE](LICENSE).

[badge-ci]: https://github.com/devmarkusb/gpx-poi-enricher/actions/workflows/ci.yml/badge.svg
[ci]: https://github.com/devmarkusb/gpx-poi-enricher/actions
