Skip to content

feat(polygon): add adaptive polyline subdivision through coordinate transforms - #166

Merged
ibgreen merged 1 commit into
masterfrom
codex/projected-polyline-subdivision
Oct 3, 2026
Merged

ibgreen merged 1 commit into
masterfrom
codex/projected-polyline-subdivision

Conversation

@ibgreen

@ibgreen ibgreen commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Long source-coordinate edges can become curved after a nonlinear map projection. Rendering only the transformed endpoints draws a straight chord and loses that curvature. Add subdividePolyline to @math.gl/polygon so renderers can share the geometry preprocessing needed for custom projections.

The utility takes a flat XY/XYZ polyline, an application-supplied coordinate transform, and a tolerance in target units. It checks quarter, midpoint, and three-quarter samples and bisects edges when their parameter-matched target interpolation error exceeds the tolerance. It also accepts a source-length limit to force sampling. For example, a latitude edge transformed with math.gl's stereographic projection is subdivided to stay within a 100-meter sampled tolerance.

API and scope

  • Return Float64 source and target positions plus input-edge indices and interpolation fractions for propagating other vertex attributes.
  • Preserve explicit ring closure and caller-owned input buffers; support independently selected XY/XYZ target dimensions.
  • Validate options and coordinates; reject invalid transform samples and throw when depth or vertex limits are exhausted. Transform exceptions propagate unchanged.
  • Keep coordinate conversion pluggable with no new dependency. Document an adapter using @math.gl/proj4, ring processing before earcut, and responsibility for renderer tolerance and GPU lifecycle.
  • Document that the criterion is sampled, not a universal error guarantee. Source edges interpolate linearly; callers must choose geodesic semantics, clip invalid domains, and split projection seams separately. Boundary subdivision does not adapt polygon triangle interiors.

Validation

  • Repository yarn build passed, including package and declaration output.
  • yarn lint passed.
  • Polygon Node suite: 7 files, 119 tests passed, including eight new cases covering dense independent error checks, an S curve, stereographic CRS integration, attribution and altitude, source-length subdivision, immutability, invalid samples, and resource exhaustion.
  • Standalone strict TypeScript check for the utility and polygon project declaration build passed.
  • Browser/headless suites and website production build were not run.

Related to the custom projection work in visgl/deck.gl#10740 and visgl/deck.gl#10742. This PR supplies a reusable math primitive; deck.gl adoption can follow separately.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-02T14:26:39.445122Z 4024704 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 37019607501

Coverage increased (+0.03%) to 92.374%

Details

  • Coverage increased (+0.03%) from the base build.
  • Patch coverage: 52 of 52 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 14728
Covered Lines: 14018
Line Coverage: 95.18%
Relevant Branches: 7760
Covered Branches: 6755
Branch Coverage: 87.05%
Branches in Coverage %: Yes
Coverage Strength: 12573.57 hits per line

💛 - Coveralls

@ibgreen
ibgreen requested a review from Pessimistress October 2, 2026 14:31
@ibgreen
ibgreen merged commit e3adfd9 into master Oct 3, 2026
7 checks passed
@ibgreen
ibgreen deleted the codex/projected-polyline-subdivision branch October 3, 2026 13:43
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.

2 participants