Repository navigation
fix: limit TopoJson bounds to the selected object - #2311
Open
senanurcetin wants to merge 1 commit into
Open
senanurcetin wants to merge 1 commit into
senanurcetin wants to merge 1 commit into
Conversation
Author
|
Hi Folium maintainers, I've submitted a fix to ensure The PR includes regression tests covering reversed arcs, geometry collections, negative scales, and TopoJSON data without a transform. I noticed that the GitHub Actions workflows are marked as AI assistance was used in preparing this contribution. Thank you for reviewing! |
senanurcetin
added a commit
to senanurcetin/folium
that referenced
this pull request
Oct 20, 2026
Decode selected arcs (including reversed indices), geometry collections, point coordinates, and absolute coordinates without transforms. Handle negative transforms and add regression tests for map bounds.
senanurcetin
force-pushed
the
fix/topojson-selected-object-bounds
branch
from
October 20, 2026 22:25
c222a9b to
9d807fc
Compare
This branch has not been deployed
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.
Summary
This PR fixes an issue in
TopoJson.get_bounds()where the calculated bounds include unrelated geometries from the same TopoJSON dataset.The implementation now calculates bounds using only the geometries referenced by the selected
object_path.Problem
Currently,
TopoJson.get_bounds()iterates over every arc in the entire topology, even when those arcs belong to different objects.This can produce incorrect geographic bounds and cause
Map.fit_bounds()to zoom out unnecessarily.For example, a topology containing two geographically distant objects may return bounds covering both objects, even when only one is selected.
Changes
GeometryCollectionobjects.The existing public API remains unchanged.
Reproduction
Previously, the returned bounds also included the geographically distant object.
With this change, the bounds are limited to the selected geometry.
Testing
Five focused regression scenarios were verified locally:
Local validation results:
Validation was performed using an isolated Folium 0.20.0 environment with the proposed implementation applied.
The complete upstream test suite, Ruff, Black, Sphinx documentation build, and browser integration tests have not yet been executed against the submitted branch. These remain subject to project CI verification.
Compatibility
No public API changes are introduced.
The fix preserves existing usage of
TopoJson.get_bounds()while correcting the geographic extent calculation.AI Assistance Disclosure
AI assistance was used to investigate the existing implementation, identify the bounds calculation issue, prepare the code changes, and develop focused regression tests.
The changes remain subject to project CI verification and maintainer review.