Fix lineSliceAlong() dropping altitude of the line's vertices - #1637
Merged
Conversation
The flat coordinate rewrite made lineSliceAlong() rebuild every point from FlattenListOfPoints#getFlattenLngLatArray() only, ignoring the parallel altitudes array, so 3D input lines came back as 2D. Read the altitudes and rebuild the emitted vertices through them. The interpolated start and stop points remain 2D: they are computed by TurfMeasurement#destination(), which has always been 2D. With the vertices restored the output matches v7.9.0 exactly. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
jush
previously approved these changes
Jul 30, 2026
yuryybk
previously approved these changes
Jul 31, 2026
|
Successfully scanned changes introduced in a pull request into Internal scan identifier:
See all issues found during this scan in the OX Security Application. Detailed information
1 aggregation
|
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #1637 +/- ##
=========================================
Coverage 79.35% 79.36%
- Complexity 1129 1131 +2
=========================================
Files 162 162
Lines 4698 4705 +7
Branches 659 660 +1
=========================================
+ Hits 3728 3734 +6
Misses 702 702
- Partials 268 269 +1
🚀 New features to boost your workflow:
|
stanis-k
approved these changes
Jul 31, 2026
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.
Fixes MAPSAND-2853 / #1636.
Problem
TurfMisc.lineSliceAlong()returns 2D points for a 3D inputLineStringsince v7.10.0; v7.9.0 preserved altitude on the vertices.Root cause
The flat-coordinate rewrite (#1630) changed
lineSliceAlong()to readFlattenListOfPoints#getFlattenLngLatArray()and rebuild every point with the 2-argPoint.fromLngLat(lng, lat). The altitudes live in a parallel array (FlattenListOfPoints#getAltitudes()) that the rewrite never read. The previous implementation usedline.coordinates()and passed thePoints straight through, so altitude survived.Fix
Read the altitudes alongside the flat array and rebuild the emitted vertices through a small private helper that mirrors the null/
NaNhandling inFlattenListOfPoints#points().The interpolated start and stop points stay 2D: they come from
TurfMeasurement#destination(), which has always been 2D, andbearing()/distance()ignore altitude. With the vertices restored the output matches v7.9.0 exactly, which is the behaviour the report asks for.getFlattenLngLatArray()has exactly one call site outsideservices-geojson, so no other Turf method is affected.TurfMeasurement.along()/length()never use the flatten path.Verification
New
TurfMiscTest#testLineSliceAlongPreservesAltitudeslices a 3D line from 0 to its full length, so every returned point is an original vertex, and asserts altitude on each. Confirmed failing before the fix and passing after;:services-turf:testand:services-geojson:testare green.Note:
checkstyleMaincould not be run locally — it fails the same way on unmodifiedmain(SuppressionFilter - Unable to find: config/checkstyle/suppressions.xml), so CI gates it here.🤖 Generated with Claude Code