Fix getShapesAsGeoJSON returning reversed shape coordinates#203
Merged
brendannee merged 1 commit intoJul 7, 2026
Merged
Conversation
consolidateShapes reversed each segment in place while building its dedupe key, so the line was then built from the reversed points. Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
Member
|
Great catch - thanks for documenting this and the pull request! |
Member
|
The latest version https://github.com/BlinkTagInc/node-gtfs/releases/tag/4.19.3 has this fix included. |
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.
While using
getShapesAsGeoJSON()I noticed the returned line geometry was off — the coordinates come back reordered, with a point duplicated and the last one dropped, so the line doesn't trace the actual shape.It's in
consolidateShapes(src/lib/geojson-utils.ts). When it builds the direction-agnostic dedupe key it callssegment.reverse(), which reversessegmentin place. That samesegmentis then used just below (segment[0],segment[1]) to append points to the line, so every segment ends up added in reverse.For a shape
[P0, P1, P2, P3]you get[P1, P0, P1, P2]instead of[P0, P1, P2, P3]. The existing tests only asserted the coordinate array length, which the bug preserves, so it wasn't caught.The fix copies the segment before reversing it for the key. I added an ordering assertion to the
cal_sf_tamshape test (fails before, passes after); the full suite still passes.