Skip to content

Handle empty coordinate arrays when calculating GeoJSON bounds - #1401

Open
LucioLiu wants to merge 1 commit into
wireservice:masterfrom
LucioLiu:fix/empty-geojson-bounds
Open

LucioLiu wants to merge 1 commit into
wireservice:masterfrom
LucioLiu:fix/empty-geojson-bounds

Conversation

@LucioLiu

Copy link
Copy Markdown

A CSV containing a LineString with an empty coordinate array makes csvjson stop before it writes the FeatureCollection. The bounding-box walk indexes the first coordinate even when there are none.

To reproduce with the fixture in this PR:

csvjson --lat lat --lon lon --geometry shape examples/test_geo_empty_coordinates.csv

On master (43d09bf), this raises IndexError: list index out of range. With the change, both features are retained and the point at [12, 34] supplies the collection bounds. The empty geometry contributes no extent.

The regression test failed on master and passed with the fix. Full local suite on Python 3.12: 368 passed, 4 skipped.

Prepared and tested with Codex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant