Files
garmin-img-format-parsing/stage-1-read-garmin-img/readme.md
T

112 lines
3.9 KiB
Markdown
Raw Normal View History

2026-04-15 04:33:06 -07:00
I reworked the extractor around the weak spots you pointed out and validated it against the uploaded `gmapsupp.img`, using GPXSee’s Garmin IMG support and source tree as the reference model for the label and local-field paths. GPXSee officially supports Garmin IMG/GMAP maps, and its public source is the right place to mirror parsing behavior from. ([gpxsee.org][1])
2026-04-14 16:37:10 -07:00
2026-04-15 04:33:06 -07:00
Updated script:
[garmin_img_to_osmand_v5.py](sandbox:/mnt/data/garmin_img_to_osmand_v5.py)
2026-04-14 16:37:10 -07:00
2026-04-15 04:33:06 -07:00
What changed:
2026-04-14 16:37:10 -07:00
2026-04-15 04:33:06 -07:00
* **better name extraction**
2026-04-14 16:37:10 -07:00
2026-04-15 04:33:06 -07:00
* fixed the big one: standard point labels now respect the Garmin **POI indirection bit**, instead of always treating the label offset as a direct string pointer
* codepage handling is kept for your map’s Cyrillic labels
* uppercase labels are normalized more cleanly
* control-character cleanup added
* **all mapsets / segments**
2026-04-14 16:37:10 -07:00
2026-04-15 04:33:06 -07:00
* still traverses all mapsets
* now records **segment stats** and **segment error previews** into metadata so you can see where parsing is still rough
* **image/icon grouping**
2026-04-14 16:37:10 -07:00
2026-04-15 04:33:06 -07:00
* extended points can now expose `garmin_image_id` when present in local fields
* landmark CSV/GeoJSON now includes:
2026-04-14 16:37:10 -07:00
2026-04-15 04:33:06 -07:00
* `mapset`
* `garmin_image_id`
* `garmin_image_file`
* best-effort embedded image dumping is supported with `--extract-images-dir`
* image grouping can be listed/exported with:
2026-04-14 16:37:10 -07:00
2026-04-15 04:33:06 -07:00
* `--list-image-groups`
* `--image-groups-csv`
* **validation against your upload**
* the broken/truncated names improved a lot on the tested mapset
* examples that now decode sensibly include:
* `Полски ясен`
* `Андзова чешма`
* `Дубрава (310)`
* `Св. Димитър`
* `Паметник на Мико Нинов`
A concrete test I ran on your uploaded mapset `02234010`:
* parsed `52686` features
* water-source landmark export produced `1404` point rows
* segment stats reported parsed points/polylines/polygons instead of only points
2026-04-14 16:37:10 -07:00
Use it like this.
2026-04-15 04:33:06 -07:00
Better landmark CSV with mapset + image fields:
2026-04-14 16:37:10 -07:00
2026-04-15 04:33:06 -07:00
```bash
python garmin_img_to_osmand_v5.py gmapsupp.img ^
--mapset 02234010 ^
--category water_sources ^
--landmarks-csv water_sources.csv ^
--meta-json water_sources.meta.json
```
List landmark types with better names:
```bash
python garmin_img_to_osmand_v5.py gmapsupp.img ^
--mapset 02234010 ^
2026-04-14 16:37:10 -07:00
--list-landmark-types
```
2026-04-15 04:33:06 -07:00
List image/icon groups:
2026-04-14 16:37:10 -07:00
2026-04-15 04:33:06 -07:00
```bash
python garmin_img_to_osmand_v5.py gmapsupp.img ^
--mapset 02234010 ^
--list-image-groups
2026-04-14 16:37:10 -07:00
```
2026-04-15 04:33:06 -07:00
Export image/icon group summary:
2026-04-14 16:37:10 -07:00
2026-04-15 04:33:06 -07:00
```bash
python garmin_img_to_osmand_v5.py gmapsupp.img ^
--mapset 02234010 ^
--image-groups-csv image_groups.csv
2026-04-14 16:37:10 -07:00
```
2026-04-15 04:33:06 -07:00
Best-effort dump embedded Garmin image blobs:
2026-04-14 16:37:10 -07:00
2026-04-15 04:33:06 -07:00
```bash
python garmin_img_to_osmand_v5.py gmapsupp.img ^
--mapset 02234010 ^
--extract-images-dir dumped_images ^
--landmarks-csv landmarks.csv
2026-04-14 16:37:10 -07:00
```
2026-04-15 04:33:06 -07:00
The landmark CSV now has these extra columns:
2026-04-14 16:37:10 -07:00
2026-04-15 04:33:06 -07:00
* `mapset`
* `garmin_image_id`
* `garmin_image_file`
2026-04-14 16:37:10 -07:00
2026-04-15 04:33:06 -07:00
So even if a real image blob is not recoverable for a given point, you can still group by image id or by dumped image file when present.
2026-04-14 16:37:10 -07:00
2026-04-15 04:33:06 -07:00
One important note: on the tested mapset, I did **not** see a rich population of extracted image-backed point icons yet. The support is there now, but this particular IMG seems to benefit much more from the **fixed label path** than from embedded-image extraction. So the image grouping path is now available, but the biggest win on your sample was clearly the label repair.
2026-04-14 16:37:10 -07:00
2026-04-15 04:33:06 -07:00
What is still not fully okay:
2026-04-14 16:37:10 -07:00
2026-04-15 04:33:06 -07:00
* some segment errors remain, and the script now reports them in metadata instead of silently hiding them
* extended/local/class Garmin fields are still only partially decoded
* raw embedded icon extraction is best-effort, not guaranteed for every IMG flavor
2026-04-14 16:37:10 -07:00
2026-04-15 04:33:06 -07:00
The next best refinement is to push one more level into GPXSee-style local/class field parsing so more special POIs get richer metadata instead of only names and coordinates.
2026-04-14 16:37:10 -07:00
[1]: https://www.gpxsee.org/doc "https://www.gpxsee.org/doc"