Keep clipped features within their true map coordinates - #24
Open
paulstothard wants to merge 1 commit into
Open
paulstothard wants to merge 1 commit into
paulstothard wants to merge 1 commit into
Conversation
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.
Proposed PR: Keep clipped features within their true map coordinates
Target:
sciguy/cgview-js:mainSource:
paulstothard/cgview-js:fix/wrapped-feature-clippingSummary
Intersect feature ranges with an expanded visible range before drawing them. This prevents a feature from being extended past its biological coordinates when the visible range wraps the map origin, and prevents a directional arrowhead from being placed at an artificial clipping boundary.
Why
Feature.drawRange()currently replaces a feature endpoint that is outside the visible range withvisibleRange.start - 100orvisibleRange.stop + 100. That shortcut works for many ordinary views, but a wrapped visible range has two disjoint linear coordinate intervals. Treating it as one interval can extend a feature beyond its actual start or stop.The visible symptom is most obvious after panning an off-center circular map across the origin: a preceding feature can be painted past its true endpoint and overpaint an adjacent feature. The adjacent feature has not changed its legend category or color; it is being covered by incorrect geometry from the earlier feature.
Reproduction on
main:Implementation
Scope and non-goals
Compatibility and Proksee integration
Tests
Automated:
npx jest test/Feature.test.js --runInBand— 19/19 passed.npx jest --runInBand— 77/77 passed across 10 suites.npm run gh-pages— production/test-page build succeeded (existing Rollup warnings only).Regression coverage includes:
Manual browser verification:
Prepared evidence files:
user-reproduction-before-pan-correct.pnguser-reproduction-after-pan-overpaint.pngcircular-panned-upstream.pngcircular-panned-fixed.pngcanvas-circular-linear-fixed.pngsvg-circular-linear-fixed.pngindex.html(standalone comparison/verification harness)Browser evidence
main, after wrapped/off-center panPerformance considerations
The common non-wrapping case uses a direct constant-time intersection and does not run the wrapped-range splitting/merging logic. Wrapped ranges contain at most two feature segments and two visible segments, so the fallback has a fixed upper bound of four intersections. The change does not scan sequence bases or materialize feature data.
Risk assessment
Moderate but bounded. This replaces complicated clipping logic in a hot drawing method, so the main risks are origin wrapping, arrow placement, and linear/circular parity. Those cases have focused unit coverage and were verified in both Canvas and SVG output. No serialized or public API surface changes.
Suggested reviewer checklist
mainusing a wrapped visible range.