-
Notifications
You must be signed in to change notification settings - Fork 119
Description
Proposal: V2 one-to-many endpoint
This issue proposes a V2 endpoint (/api/v2/one-to-many) to improve consistency with other MOTIS endpoints and improve developer ergonomics.
Proposed Improvements
1. Align time units with one-to-all
Currently, one-to-many uses max in seconds, while one-to-all uses maxTravelTime in minutes (and all other endpoints also mostly use minutes). Also it just does not seem to make much sense to measure time in seconds for travel, and if precision is that important, using decimal minutes should work too.
Proposal: Adopt maxTravelTime (minutes) in V2. This standardizes the API surface and reduces unit-mismatch with other endpoints. Make it easier to understand what max refers to even without reading the API description.
2. Structured response object
The current response is a JSON array: [{"duration": 120}, ...].
Proposal: Wrap the response in a structured object to allow for metadata and future extensibility:
{
"durations": [ ... ],
"debugOutput": { ... }
}This proposal together with the next one are the main reason for 'v2', as the format of the response would change significantly.
3. Add optional debug statistics
For performance profiling (distinguishing network vs. routing latency), client-side measurement is insufficient.
Proposal: Add an optional debug=true parameter.
- Initial implementation: Return server-side timing statistics (e.g.,
routing: 45ms,parsing: 2ms) in thedebugOutputfield. - Future potential: The
debugOutputstructure provides a place to expose internal routing failure reasons (e.g. "unreachable" vs "disconnected graph") if the underlyingosrlibrary exposes them in the future. Because the debug data may contain more data than the useful response with durations and distances (e.g. if debug would contain info for each calculated/non-calculated route), it should be optional.
4. Improve default values
Proposal: Make the following parameters optional with sensible defaults:
arriveBy: false: The primary use case for one-to-many is computing isochrones/accessibility from a single origin to many destinations (forward search). Defaulting tofalsecreates the "path of least resistance" for the most common task. The reverse operation is probably used less often anyway.maxMatchingDistance: 25:one-to-allalready has this default, so for consistency I would use it here too. (Even though the web ui uses a much larger 250).
5. Inline mode enum
Currently, mode references the global Mode schema, which includes unsupported modes (like PT).
Proposal: Inline enum: [WALK, BIKE, CAR] for V2. This creates a strict, self-documenting contract. Expanding this list later to include more modes is a non-breaking change. Substituting it later with 'Mode' schema if the endpoint some day supports the whole schema should not be an issue.
Also, I'n not sure if this endpoint should have
Summary of V2 Changes
| Feature | V1 (Current) | V2 (Proposed) |
|---|---|---|
| Travel Time | max (seconds) |
maxTravelTime (minutes) |
| Response format | Array<Duration> |
Object { durations: ... } |
| Defaults | arriveBy required |
Default false |
| Defaults | maxMatchingDistance required |
Default 25 |
| Debug Info | Not available | debug param & output |
| Modes | Global Mode |
Inlined WALK, BIKE, CAR |
P.S. Maybe I fundamentally misunderstand something about internals of MOTIS and its components, so maybe some of these suggestions may seem absurd or even counterproductive.