Skip to content

feat(itinevert): search from the transport hubs, by class of days - #2829

Draft
Nayor wants to merge 8 commits into
masterfrom
feat/itinevert-transport-search-rework
Draft

Nayor wants to merge 8 commits into
masterfrom
feat/itinevert-transport-search-rework

Conversation

@Nayor

@Nayor Nayor commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

The rework of the Itinevert search ("parcours 3": the routes reachable by public transport from home, with the topoguide filters), following the design recorded on #2343: stop-level journeys from the transport hubs of a town, by class of days, instead of isochrones. Draft: the API prototype, the UI comes next.

What it does

  • GET /itinevert/hubs?lon=&lat=[&insee=][&date=]: the transport hubs of the town at a position. The stop areas around the centre served by train, metro, tramway, coach or funicular (the bus stops for a small town without any), kept when in the town, grouped within 200 m, ranked by number of lines of all modes: more than 10 lines, at most 6, at least the best one. One light Navitia call (two for a small town), cached a year. With a date, each hub says whether its search is already cached (an immediate answer). The hubs proposed are the only origins a search accepts.
  • GET /itinevert/reachable?origin=&date=: from a hub proposed by /itinevert/hubs on a date, the earliest arrival at and the latest departure from each access waypoint (the walk from the stop included), and per route its best access and time on site (a traverse arrives by one access waypoint and leaves from another one), the longest first. Two heavy Navitia calls (journeys without destination / without origin, from the position of the hub) on the first search of a class of days, cached 90 days; a concurrent search of the same class waits for it. The day is explored in two windows: leaving the hub 06:00–11:00, leaving the stops 16:00–21:00 (Navitia's max_duration is a window from the time asked, the wait included).
  • Classes of days: weekday / Saturday / Sunday or bank holiday × school holiday period of the zone of the origin, or season out of holidays, cut at the yearly timetable change (2nd Sunday of December). The school holidays come from the open data of the ministry of education (scripts/itinevert/update_school_holidays.py, to run once a year).
  • The dates are limited to the timetables known by Navitia (end_production_date of the coverage, about 3 months ahead).
  • Every call goes through the daily Navitia budget (feat(navitia): daily budget of the Navitia calls, with a kill switch #2821) and the limits per client.

The plain modules (c2corg_api/itinevert/: reachability, day_classes, hubs) have no database nor Navitia calls; search binds them.

  • The route listings take itv=origin,date: the reachable routes of a search in cache (never a Navitia call), with the filters and the sort of the topoguide, the ones whose time on site covers their duration first, then the ones of an unknown duration.

Checked on real data

On the answers of Navitia from Grenoble station (Saturday 2026-12-05, saved during the design) and 40 hiking routes around Grenoble: 25 with a time on site (e.g. Le Sappey → Col de Porte 08:42 → 17:08, Chamrousse → Vizille 07:41 → 17:53), the others really not served that day (school lines, the closest stop reached over 800 m away). The answers reduced to the stop times: about 1 MB each, 2 s.

The requests of this PR, run on Navitia (Grenoble station, Saturday): 21,350 stop points reached outbound (48 MB, 7 s) and 29,816 for the return (68 MB, 12.5 s), more than the first test; one more route reached. From the stop area id rather than its position, Navitia repeats the stop area with its lines in each journey (266 MB); with a return window of 10 hours, it timed out.

Settings

ITINEVERT_SEARCH_CACHE_DAYS (90), ITINEVERT_HUBS_CACHE_DAYS (365), ITINEVERT_OUTBOUND_WINDOW (06:00-11:00), ITINEVERT_RETURN_WINDOW (16:00-21:00).

Remaining

  • The first real searches (above).
  • The listing of the topoguide filtered by the reachable routes.
  • The stops whose last departure is before 16:00 are not reached by the return: a second return window would find them, for one more heavy call.
  • UI: the town / hub field, the date, the loader, the time on site on the cards, the check of a chosen route with /navitia/journeys.
  • Remove the isochrone routes and the journey jobs once the UI uses this.

🤖 Generated with Claude Code

Nayor added 3 commits December 2, 2026 19:37
The core of the search of the routes reachable by public transport from a
transport hub of a town, without database nor Navitia calls:
- reachability: the answers of Navitia journeys without destination / origin
  reduced to the stop times, joined with the stop areas of the access
  waypoints, give the time on site of each waypoint and route (traverses
  included);
- day_classes: the class of days of a date (kind of day x school holiday
  period of the zone of the origin, or season), cut at the yearly timetable
  change; the school holidays come from the open data of the ministry of
  education (scripts/itinevert/update_school_holidays.py);
- hubs: the stop areas of a town where the most lines stop, grouped within
  200 m, more than 10 lines, at most 6, at least the best one.
Two routes for the new search of the routes reachable by public transport:
- GET /itinevert/hubs: the transport hubs of the town at a position (one or
  two light Navitia calls, cached ITINEVERT_HUBS_CACHE_DAYS, 365 by
  default); with a date, whether each hub has its search in cache;
- GET /itinevert/reachable: from a hub on a date, the earliest arrival at and
  latest departure from each access waypoint, and per route its best access
  and time on site. Two heavy Navitia calls on the first search of a class
  of days, cached ITINEVERT_SEARCH_CACHE_DAYS (90 by default); a concurrent
  search of the same class waits for it. The dates are limited to the
  timetables known by Navitia.

Both go through the daily Navitia budget and the limits per client.
The parameter itv=origin,date[,insee] of the route listings keeps the routes
reachable of a search of /itinevert/reachable in cache, with the other
filters and the sort of the topoguide: the routes whose time on site covers
their duration first, then the routes of an unknown duration. A listing never
calls Navitia: without the search in cache, it answers 400.

The cache of a search no longer depends on the coverage: a Navitia stop area
is in one coverage.
@codacy-production

codacy-production Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 1 medium

Alerts:
⚠ 1 issue (≤ 0 issues of at least minor severity)

Results:
1 new issue

Category Results
Security 1 medium

View in Codacy

🟢 Metrics 343 complexity · 4 duplication

Metric Results
Complexity 343
Duplication 4

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Nayor added 3 commits December 2, 2026 20:39
Checked on Navitia: its max_duration is a window from the time asked, the
wait included (from 06:00 in 4 hours, no stop reached after 10:00; a return
by 22:00 in 4 hours keeps the departures after 18:00 only). The day is
explored in two windows of 5 hours, settings ITINEVERT_OUTBOUND_WINDOW
(06:00-11:00) and ITINEVERT_RETURN_WINDOW (16:00-21:00): from Grenoble
station, 21,000 stop points reached outbound and 30,000 for the return, in 7
and 12 s (a return window of 10 hours timed out at Navitia).

The journeys start from the position of the hub rather than its stop area:
Navitia repeats the stop area of the origin with all its lines in each
journey (266 MB instead of 37 MB).

A search starts from a hub proposed by /itinevert/hubs only, whose position
and town are kept: /itinevert/reachable takes the hub and the date, and the
listing parameter itv the hub and the date.
… the transfers

The journeys requests without destination answer tens of megabytes: they are
parsed journey by journey with ijson instead of being decoded at once. The
journeys are limited to 3 transfers (ITINEVERT_MAX_TRANSFERS) and the default
windows are narrower (06:00-10:00 outbound, 16:00-20:30 return), to bound the
computation of Navitia and the weight of its answers.
The interface shows it from a link or after a reload, without the hubs of the
town.
Nayor added 2 commits December 3, 2026 08:08
Navitia gives every journey of the return the requested time as arrival, so
the stops a narrower return window would lose cannot be measured.
Until 10:00 only, the search would lose the valleys whose morning coach
arrives after 10:00.

This branch has not been deployed

No deployments
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.

1 participant