Add KML support to conform pipeline - #111
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #17
Adds
"kml"as a recognizedconform.formatvalue, reusing the existing OGR-based extraction path (ogr_source_to_csv) already used for shapefile/gdb/gpkg/xml(gml) sources. GDAL's built-in LIBKML/KML drivers handle the actual parsing, same as for the other OGR-backed formats.Changes in
openaddr/conform.py:find_source_path(): newkmlbranch that locates a.kmlfile among the downloaded source paths (mirrors the existinggpkgbranch, including the "multiple candidates +fileattribute" disambiguation logic).extract_to_source_csv(): routeskmlthrough the sameogr_source_to_csv()call used forshapefile/xml/gdb/gpkg.conform_cli(): addedkmlto the list of recognized format strings.What's supported
Placemarkelements withPointgeometry and simple attribute data in<ExtendedData><Data name="...">elements, read via GDAL's LIBKML/KML OGR driver.Verified end-to-end with a new test (
test_lake_man_kmlinopenaddr/tests/conform.py) using a hand-written KML fixture (openaddr/tests/conforms/lake-man.kml) containing the same 6 addresses as the existinglake-man.shp/lake-man.gpkgfixtures, with a matching conform JSON (lake-man-kml.json).Explicitly out of scope for this first pass
<coordinates>(lon,lat,alt). The test fixture intentionally uses 2D coordinates (lon,lat) so OGR reads plainPOINTgeometry, matching the 2D output of the other formats. Placemarks with an altitude component will come through asPOINT Zgeometry and produce a 3-elementcoordinatesarray in the output GeoJSON — this isn't tested or specifically handled.ogr_source_to_csvpath should handle them the same way it does for shapefile/gdb/gpkg polygon/line sources (used today for buildings/parcels layers).Schema/SimpleField-typedExtendedData(the more structured alternative to plain<Data name="...">elements) — not tested, though OGR's KML/LIBKML drivers generally support both.Verified locally with GDAL 3.11 (matching the project's Docker image): both the
KMLandLIBKMLOGR drivers are present in the build, and the full test suite (python3 test.py, 121 tests) passes.