Skip to content

Fix bounds for multi-member and wrapped GeometryCollections - #2281

Open
jokrasno wants to merge 1 commit into
python-visualization:mainfrom
jokrasno:fix/geometrycollection-bounds-jokrasno-20260907
Open

Fix bounds for multi-member and wrapped GeometryCollections#2281
jokrasno wants to merge 1 commit into
python-visualization:mainfrom
jokrasno:fix/geometrycollection-bounds-jokrasno-20260907

Conversation

@jokrasno

@jokrasno jokrasno commented Sep 8, 2026

Copy link
Copy Markdown

GeoJson.get_bounds() currently considers only the first member of a GeometryCollection. For example, a collection containing points [2, 1] and [40, 30] returns [[1, 2], [1, 2]], excluding the second point. Wrapping a collection in a Feature raises KeyError, and an empty collection raises IndexError.

Recursively traverse Features, FeatureCollections, and all GeometryCollection members in iter_coords. This handles nested and empty collections while preserving null-geometry handling. Follow-up to #1599 and #1633, whose regression covers a single member.

Validation:

  • Nine new regression cases assert both layer and map bounds for multiple, nested, and empty collections, directly and inside Features/FeatureCollections. All nine fail before the fix and pass afterward.
  • python -B -m pytest tests/test_features.py tests/test_utilities.py tests/test_vector_layers.py -q --tb=short — 116 passed (one existing pytest deprecation warning).
  • Changed-file Ruff, Black (Python 3.9 target), and git diff --check pass.
  • Tested on Windows in an isolated virtual environment. Browser and notebook suites were not run.

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