Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request adds schema enhancements to the segment patterns feature, enabling reconstruction of map-matched shape data by adding direction, sequence, and denormalized way information.
Changes:
- Adds
direction_id,sequence_idx,way_id, andshapefields toSegmentPatterntype - Updates database schema with migration to add new columns and indexes to
tl_segment_patternstable - Deprecates
Segment.way_idfield in favor ofSegmentPattern.way_idfor improved data access patterns
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| schema/postgres/migrations/20260115170510_segments_sequence_idx.up.pgsql | Adds direction_id, sequence_idx, and way_id columns to tl_segment_patterns table with appropriate indexes |
| testdata/server/test_supplement.pgsql | Updates test data INSERT statements to include new columns for segment patterns |
| server/model/models_gen.go | Adds DirectionID, SequenceIdx, ShapeID, WayID, and Shape fields to SegmentPattern model |
| schema/graphql/schema.graphqls | Adds new fields to SegmentPattern type and deprecates Segment.way_id |
| server/gql/segment_resolver.go | Adds Shape resolver for SegmentPattern to load shape data via dataloader |
| server/gql/route_resolver.go | Updates segment query limits to use RESOLVER_SEGMENT_MAXLIMIT |
| server/gql/resolver.go | Adds RESOLVER_SEGMENT_MAXLIMIT constant for query limiting |
| server/finders/dbfinder/segment.go | Reformats SELECT query for improved readability |
| internal/generated/gqlout/generated.go | Generated GraphQL resolver code for new fields |
| gqlgen.yml | Configures shape field as a resolver for SegmentPattern |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| (select id from gtfs_shapes where shape_id = '41698'), | ||
| 42 | ||
| 42, | ||
| 645693994, |
There was a problem hiding this comment.
The way_id value for segment 1418711 is inconsistent with the tl_segments table. In the tl_segments INSERT, segment 1418711 has way_id 90865590, but in this tl_segment_patterns INSERT it uses way_id 645693994. This should be 90865590 to match the segment's actual way_id.
Suggested change
| 645693994, | |
| 90865590, |
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.
This PR enhances the segment patterns feature to enable reconstruction of map-matched shape data by adding direction, sequence, and denormalized way information to the
SegmentPatterntype.Changes
Schema Updates
SegmentPattern:direction_id: Direction ID of the tripsequence_idx: Sequence order of this segment within the patternshape_id: Shape ID for this segment patternway_id: OSM Way ID associated with this segment patternshape: Shape resolver for direct access to shape dataSegment.way_idin favor ofSegmentPattern.way_idfor improved data access patternsDatabase Migration
tl_segment_patternstable:direction_id(integer, NOT NULL, default 0)sequence_idx(integer, NOT NULL, default 0)way_id(bigint, NOT NULL, populated from existing segment data)Resolvers & Model Updates
Shaperesolver forSegmentPatternto load shape data via dataloaderRESOLVER_SEGMENT_MAXLIMITconstant (100,000)SegmentPatternmodel structTest Data
Why
These changes allow clients to reconstruct the original map-matched output for each shape by providing:
sequence_idx)direction_id)way_id)