working-stage-2 export to kml
This commit is contained in:
@@ -183,6 +183,7 @@ def coord_distance_m(a: Landmark, b: Landmark) -> float:
|
|||||||
|
|
||||||
def load_landmarks(paths: Iterable[Path]) -> list[Landmark]:
|
def load_landmarks(paths: Iterable[Path]) -> list[Landmark]:
|
||||||
items: list[Landmark] = []
|
items: list[Landmark] = []
|
||||||
|
print(f"Loading detected CSVs - {len(paths)} total CSVs")
|
||||||
for path in paths:
|
for path in paths:
|
||||||
with open_text(path, "r") as f:
|
with open_text(path, "r") as f:
|
||||||
reader = csv.DictReader(f)
|
reader = csv.DictReader(f)
|
||||||
@@ -213,6 +214,7 @@ def load_landmarks(paths: Iterable[Path]) -> list[Landmark]:
|
|||||||
garmin_image_file=sanitize_text((row.get("garmin_image_file") or "").strip()),
|
garmin_image_file=sanitize_text((row.get("garmin_image_file") or "").strip()),
|
||||||
source_files=[path.name],
|
source_files=[path.name],
|
||||||
))
|
))
|
||||||
|
print("Done reading CSVs")
|
||||||
return items
|
return items
|
||||||
|
|
||||||
def dedupe_signature(it: Landmark, mode: str) -> tuple:
|
def dedupe_signature(it: Landmark, mode: str) -> tuple:
|
||||||
@@ -845,6 +847,7 @@ def apply_postprocess(props: dict[str, str], group: dict[str, Any], config: dict
|
|||||||
def build_records(items: list[Landmark], config: dict[str, Any]) -> tuple[list[dict[str, Any]], list[Landmark]]:
|
def build_records(items: list[Landmark], config: dict[str, Any]) -> tuple[list[dict[str, Any]], list[Landmark]]:
|
||||||
out = []
|
out = []
|
||||||
unmatched: list[Landmark] = []
|
unmatched: list[Landmark] = []
|
||||||
|
print("Building records - ", len(items))
|
||||||
for it in items:
|
for it in items:
|
||||||
group = assign_group(it, config)
|
group = assign_group(it, config)
|
||||||
if group is None:
|
if group is None:
|
||||||
@@ -885,6 +888,7 @@ def build_records(items: list[Landmark], config: dict[str, Any]) -> tuple[list[d
|
|||||||
"source_files": list(it.source_files),
|
"source_files": list(it.source_files),
|
||||||
"duplicate_count": it.duplicate_count,
|
"duplicate_count": it.duplicate_count,
|
||||||
})
|
})
|
||||||
|
print("Finished constructing the records")
|
||||||
return out, unmatched
|
return out, unmatched
|
||||||
|
|
||||||
def write_unmatched_csv(items: list[Landmark], path: Path):
|
def write_unmatched_csv(items: list[Landmark], path: Path):
|
||||||
|
|||||||
@@ -120,22 +120,13 @@ Each KML/KMZ contains:
|
|||||||
Example build:
|
Example build:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
python landmarks_csv_to_osmand_google_earth.py build parsed-landmarks/csv/*.csv ^
|
python landmarks_csv_to_osmand_google_earth.py build parsed-landmarks/csv/*.csv --config stage2_config.json --kml bgmountains_landmarks.kml --kmz bgmountains_landmarks.kmz --resolved-csv resolved.csv --summary-json build_summary.json
|
||||||
--config stage2_config.json ^
|
|
||||||
--kml bgmountains_landmarks.kml ^
|
|
||||||
--kmz bgmountains_landmarks.kmz ^
|
|
||||||
--resolved-csv resolved.csv ^
|
|
||||||
--summary-json build_summary.json
|
|
||||||
```
|
```
|
||||||
|
|
||||||
For large datasets, use this instead:
|
For large datasets, use this instead:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
python landmarks_csv_to_osmand_google_earth.py build parsed-landmarks/csv/*.csv ^
|
python landmarks_csv_to_osmand_google_earth.py build parsed-landmarks/csv/*.csv --config stage2_config.json --kmz-split-dir google-earth-groups --kml-folder-visibility 0 --kml-label-scale 0
|
||||||
--config stage2_config.json ^
|
|
||||||
--kmz-split-dir google-earth-groups ^
|
|
||||||
--kml-folder-visibility 0 ^
|
|
||||||
--kml-label-scale 0
|
|
||||||
```
|
```
|
||||||
|
|
||||||
That creates one `.kmz` per group plus:
|
That creates one `.kmz` per group plus:
|
||||||
|
|||||||
Reference in New Issue
Block a user