Skip to content

Conversation

@evetion
Copy link
Member

@evetion evetion commented Jan 1, 2026

I'm fixing driver combinations for GeoDataFrames, and I couldn't write empty Arrow geometries at all.

In tandem with JuliaGeo/GeoArrow.jl#6

edit: Specifically, this was an empty polygon, and calling npoints (in calc_extent) on that is an reducing an empty iterator.

@asinghvi17
Copy link
Member

Seems good overall but mind if I add a test?

@evetion
Copy link
Member Author

evetion commented Jan 1, 2026

Sure! To be fair, I fear more significant changes are needed for full empty support in GI.

Tests that npoint and nring return 0 for empty polygons,
verifying the init=0 fix works correctly.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@asinghvi17
Copy link
Member

Codecov only complains that + npoint(t::AbstractMultiCurveTrait, geom) is not covered but ehh I don't think that should block merging this

@evetion evetion marked this pull request as ready for review January 2, 2026 20:10
@evetion evetion requested a review from Copilot January 2, 2026 20:10
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses an issue where empty Arrow geometries could not be written properly, specifically fixing a bug in the calc_extent function that would fail when processing empty geometries (e.g., empty polygons). The fix adds proper handling for empty geometries by adding an init=0 parameter to sum operations and an early return for empty geometries in extent calculations.

Key Changes:

  • Added init=0 parameter to all sum operations counting points and rings to handle empty geometry collections
  • Added early return in calc_extent when geometry is empty to prevent reduction on empty iterators
  • Added test coverage for empty polygon geometries

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
test/test_primitives.jl Added MyEmptyPolygon test struct and test cases to verify proper handling of empty polygon geometries
src/fallbacks.jl Fixed sum operations to handle empty collections and added empty geometry check in calc_extent

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@asinghvi17 asinghvi17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@evetion evetion merged commit 5a85ddc into main Jan 3, 2026
6 of 7 checks passed
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.

3 participants