Run antimeridian_split through apply on the polygonal traits - #459
Draft
asinghvi17 wants to merge 1 commit into
Draft
Run antimeridian_split through apply on the polygonal traits#459asinghvi17 wants to merge 1 commit into
antimeridian_split through apply on the polygonal traits#459asinghvi17 wants to merge 1 commit into
Conversation
Replace the hand-rolled `_each_polygon` walk with `apply` on a
`TraitTarget{Union{PolygonTrait,MultiPolygonTrait}}`, so the split runs on
every polygonal geometry in any nesting `apply` understands (features,
feature collections, tables, vectors) and the structure above is rebuilt.
The target is the union rather than `PolygonTrait` alone because a
`MultiPolygon` must split into one flat piece list, not a `MultiPolygon` of
`MultiPolygon`s. The trait guard stays — `apply` never hands an unsupported
geometry to the target function — but now only rejects non-polygonal
*geometry* traits, letting arrays/features fall through to `apply`.
Adds a `threaded` keyword, and a testset covering vector, feature
collection and `MultiPolygon` inputs.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
antimeridian_splitwalked its input with a bespoke_each_polygonhelper thatonly knew how to handle a bare
PolygonorMultiPolygon. This replaces thatwith
applyon the polygonal trait target:so the split now runs on every polygonal geometry in any nesting
applyunderstands — features, feature collections, tables, (nested) vectors — and the
structure above the polygons is rebuilt around the results. A bare
Polygonstill comes back as a
MultiPolygon, as before.Notes
PolygonTraitalone. AMultiPolygonmustsplit part-by-part into one flat piece list; targeting only
PolygonTraitwould rebuild it as a
MultiPolygonofMultiPolygons. So there are twotarget methods,
_split_geom(::GI.PolygonTrait, …)and_split_geom(::GI.MultiPolygonTrait, …), both feeding the unchanged_split_polygon!.ArgumentErrorguard stays, but shrank.applynever hands aLineStringtofwhen the target is polygonal — it descends toward pointsinstead — so a bare unsupported geometry still has to be rejected up front.
_check_split_traitnow rejects only geometry traits that aren't polygonal,letting
nothing/feature traits fall through toapply's own descent.apply._rotate_to_poleisitself an
apply(PointTrait), so it already handles any nesting, and doing itonce avoids rebuilding the rotation matrix per polygon.
threadedkeyword, forwarded toapply.No change to the split algorithm itself — the arrangement, face selection,
branch fixing and pole-row emission are untouched.
Test plan
test/transformations/antimeridian_split.jlpasses in full, including theNatural Earth cases. New
nested inputstestset covers vector input (threadedand not), a feature collection with properties preserved, and
MultiPolygoninput — the last of which was previously untested.
🤖 Generated with Claude Code