Repository navigation
Conversation
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.
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| Security | 1 medium |
🟢 Metrics 343 complexity · 4 duplication
Metric Results Complexity 343 Duplication 4
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.
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.
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
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.
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/hubson 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 (journeyswithout 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'smax_durationis a window from the time asked, the wait included).scripts/itinevert/update_school_holidays.py, to run once a year).end_production_dateof the coverage, about 3 months ahead).The plain modules (
c2corg_api/itinevert/: reachability, day_classes, hubs) have no database nor Navitia calls;searchbinds them.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
/navitia/journeys.🤖 Generated with Claude Code