Add Shapes when shapes.txt is missing / no Shape assigned
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 24
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
The shapes.txt file of the GTFS specification is an optional file. To avoid special case handling in the algorithms in case of its absence, we implement artificial segments for all routes that do not provide a shape-id.
In a first step, which is the goal of this task, we should simple add a list of all stop locations (mandatory) along the line as a shape of the line. This *new* shape can then be used for visualisation in a consistent way with all shape-providing data sets.
The issue is targeting [this part](https://github.com/mapbox/directions-transit/blob/153eecada211e97834275b9aad57b85326b93041/src/gtfs/dataset.cpp#L187-L209) of the codebase. Instead of relying on the presence of `shapes` ([here](https://github.com/mapbox/directions-transit/blob/153eecada211e97834275b9aad57b85326b93041/src/gtfs/dataset.cpp#L189-L191), the code should generate shapes on demand.
A new function should be added to the gtfs dataset that traverses all trips. If no geometry exists for said trip, all its stops need to be traversed (see stop_times) and a new shape has to be generated.
This shape is added (with a new shape ID) to the set of existing shapes. Further processing can then make use of these newly created shapes and pretend that all feeds come with a shape file.
Later on, we might use OSM data / map matching from OSRM to find better connections between stop locations.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/gtfs/dataset.cpp at the shape-loading logic around lines 187-209, then trace the trips, stops, and stop_times structures used by the GTFS dataset. Implement the requested dataset operation so trips without geometry produce a new shape from their ordered stop locations and add it to the existing shapes; done means later processing can use those generated shapes consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100