2026-04-15 04:33:06 -07:00
Found the two real problems.
First, your crash:
* `minidom.parseString(...)` was reparsing the entire generated XML in memory
* one of the landmark names or tag values contains an XML-illegal control character
* on a huge file, that blows up exactly like your `ExpatError: not well-formed (invalid token)`
Second, the sampling:
* the previous script was taking the first few examples in a group
* now it samples **spread out across the group** , so the examples are taken from different positions in the dataset instead of only the front
2026-04-14 16:37:10 -07:00
2026-04-14 16:48:13 -07:00
Updated script:
2026-04-15 04:33:06 -07:00
[landmarks_csv_to_osmand_v3.py ](sandbox:/mnt/data/landmarks_csv_to_osmand_v3.py )
2026-04-14 16:37:10 -07:00
2026-04-14 16:48:13 -07:00
What changed:
2026-04-14 16:37:10 -07:00
2026-04-15 04:33:06 -07:00
* removed the fragile `minidom.parseString()` round-trip
* writes XML directly with `ElementTree`
* sanitizes text and tag values to strip XML-invalid control characters
* supports `.gz` outputs correctly
* group examples are now **spread-out samples**
* interactive group renaming still works, but now the shown examples are better distributed
* loader still accepts both raw landmark CSVs and slimmer derived CSVs
2026-04-14 16:37:10 -07:00
2026-04-15 04:33:06 -07:00
Use it instead of the old one:
2026-04-14 16:37:10 -07:00
2026-04-14 16:48:13 -07:00
```bash
2026-04-15 04:33:06 -07:00
python landmarks_csv_to_osmand_v3.py *.csv --osm bgmountains_poi.osm.gz
2026-04-14 16:37:10 -07:00
```
2026-04-15 04:33:06 -07:00
If you want to inspect grouping before writing:
2026-04-14 16:37:10 -07:00
2026-04-14 16:48:13 -07:00
```bash
2026-04-15 04:33:06 -07:00
python landmarks_csv_to_osmand_v3.py *.csv --show-groups --group-examples 5
2026-04-14 16:37:10 -07:00
```
2026-04-15 04:33:06 -07:00
If you want interactive naming with spread-out examples:
2026-04-14 16:37:10 -07:00
2026-04-14 16:48:13 -07:00
```bash
2026-04-15 04:33:06 -07:00
python landmarks_csv_to_osmand_v3.py *.csv --show-groups --interactive-group-names --group-examples 5 --gpx landmarks.gpx
2026-04-14 16:37:10 -07:00
```
2026-04-15 04:33:06 -07:00
If you want POI-only OSM for OsmAndMapCreator:
2026-04-14 16:37:10 -07:00
2026-04-14 16:48:13 -07:00
```bash
2026-04-15 04:33:06 -07:00
python landmarks_csv_to_osmand_v3.py *.csv --osm landmarks.osm.gz
2026-04-14 16:37:10 -07:00
```
2026-04-15 04:33:06 -07:00
Then:
2026-04-14 16:37:10 -07:00
2026-04-14 16:48:13 -07:00
```bash
2026-04-15 04:33:06 -07:00
java.exe -Xms256M -Xmx4096M -cp "OsmAndMapCreator.jar;lib/*" net.osmand.MainUtilities generate-poi C:\p ath\t o\l andmarks.osm.gz
2026-04-14 16:37:10 -07:00
```
2026-04-15 04:33:06 -07:00
The main fix is this: the script now treats dirty text safely instead of trusting all names/tags to already be valid XML.
2026-04-14 16:37:10 -07:00
2026-04-15 04:33:06 -07:00
If you want, the next refinement should be a `--debug-bad-rows` mode that writes out the original rows whose text had to be sanitized, so you can see exactly which source landmarks were malformed.