Skip to content

stop_times API: add center coordinate parameter#1288

Merged
felixguendling merged 12 commits intomotis-project:masterfrom
Kiarash-Parvizi:extend-api
Feb 16, 2026
Merged

stop_times API: add center coordinate parameter#1288
felixguendling merged 12 commits intomotis-project:masterfrom
Kiarash-Parvizi:extend-api

Conversation

@Kiarash-Parvizi
Copy link
Copy Markdown
Contributor

Center field is added to stoptimes_ep

The behavior:
check if id is set and exists in the timetable -> just use id like before
otherwise -> use center as anchor coordinate instead
in case center is also null -> panic

Note:
radius is required when using center without stopId

Comment thread src/endpoints/stop_times.cc Outdated
Comment thread src/tag_lookup.cc
@felixguendling
Copy link
Copy Markdown
Member

Our aim is to always have tests :)

Comment thread src/endpoints/stop_times.cc Outdated
Comment on lines +371 to +380
utl::verify<net::bad_request_exception>(
center.has_value(), "no coordinates: stop_found={}, center_parsed={}",
query_stop.has_value(), query_center.has_value());

utl::verify<net::bad_request_exception>(
query_stop.has_value() ||
(query_center.has_value() && query.radius_.has_value()),
"no radius: stop_found={}, center_parsed={}", query_stop.has_value(),
query_center.has_value());

Copy link
Copy Markdown
Contributor

@traines-source traines-source Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good if at least in the standard case (just a stop id is given and this stop id doesn't exist), we still return a 404 as before.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes for the itinerary use case, we said that for that reason you will just give the center anyways.

I just meant that if a client is requesting just with a stopid, no center (i.e. same request as before), and if then no stop with that stop id exists, we should return a 404, because the client hasn't created a "bad request", it's just that the stop was not found.
(Conversely, one could return 400 already when center is set without radius, even if stopid is set and exists, but that is a minor detail.)

Comment thread openapi.yaml Outdated
schema:
type: string
required: false
description: Anchor coordination (can be used instead of stopId)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be useful to describe the fallback behavior in case both are given (because my idea was that clients can actually use that if they remember the position from a previous query – currently we get a lot of 404s due to queries with old stopids).

@felixguendling felixguendling changed the title Extend api stop_times API: add center coordinate parameter Feb 13, 2026
@felixguendling felixguendling merged commit 0c65cdf into motis-project:master Feb 16, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants