Skip to content

Fix public transport waypoint distance#2200

Open
Nayor wants to merge 1 commit into
c2corg:masterfrom
Nayor:fix-public-transport-waypoint-distance
Open

Fix public transport waypoint distance#2200
Nayor wants to merge 1 commit into
c2corg:masterfrom
Nayor:fix-public-transport-waypoint-distance

Conversation

@Nayor

@Nayor Nayor commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@codacy-production

codacy-production Bot commented Jul 1, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

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 Nayor force-pushed the fix-public-transport-waypoint-distance branch from f4127d6 to 39e94d3 Compare July 1, 2026 16:25

@lgourdin lgourdin left a comment

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.

le seul point important est le fait d'enlever max_duration_to_pt, le non respect de la limite des 5km c'est un bug de l'API, le paramètre était bien le bon (et fonctionnait dans le passé).
Sinon j'ai pas testé, mais si tu as testé et que ça donne des bons résultats alors ça me va ! Ok pour la fusion des deux passes de sélection.
PS: si tu veux tester en env de dev, je te conseille de tester sur rhone, ça consomme peu de requêtes.

# Get walking travel time
journey_response=$(curl -s -H "Authorization: $NAVITIA_API_KEY" \
"https://api.navitia.io/v1/journeys?to=$lon%3B$lat&walking_speed=$WALKING_SPEED&max_walking_direct_path_duration=$DURATION&direct_path_mode%5B%5D=walking&from=$stop_id&direct_path=only_with_alternatives")
"https://api.navitia.io/v1/journeys?to=$lon%3B$lat&walking_speed=$WALKING_SPEED&max_duration_to_pt=$DURATION&direct_path_mode%5B%5D=walking&from=$stop_id&direct_path=only_with_alternatives")

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.

Suite à la discussion du ticket 2208 sur notre plateforme: ça c'est pas bon. C'est bien max_walking_direct_path_duration qu'il faut utiliser, seulement ça marche plus depuis les dernières versions de Navitia a priori à cause d'un bug de leur côté. En attendant, la solution est de laisser ce paramètre et de faire la vérif dans le code, comme proposé dans ce commit : 4c357f0
Le paramètre max_duration_to_pt est censé être utilisé quand le trajet inclut des transports en commun seulement a priori.
Un autre fix temporairement possible est de supprimer direct_path, mais on évite de faire ça car on perdrait la garantie que le trajet arrêt -> waypoint ne contient pas de partie en TC.

walk_duration=$(echo "$journey_response" | jq -r '.journeys[0].duration // 0')
distance_km=$(awk "BEGIN {printf \"%.2f\", ($walk_duration * $WALKING_SPEED) / 1000}")

over_distance_limit=$(awk "BEGIN {print (($distance_km > $MAX_DISTANCE_KM) ? 1 : 0)}")

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.

ha ben voilà on a fait plus ou moins la même chose, ça je pense qu'on peut le garder tant qu'on est pas sur de la fiabilité des résultats retournés par l'API.

DURATION=$(echo "scale=0; $MAX_DISTANCE_WAYPOINT_TO_STOPAREA / $WALKING_SPEED" | bc)
MAX_STOP_AREA_FETCHED=$((MAX_STOP_AREA_FOR_1_WAYPOINT * 3))
MAX_DISTANCE_KM=$(awk "BEGIN {printf \"%.6f\", $MAX_DISTANCE_WAYPOINT_TO_STOPAREA / 1000}")
# Augmenter le nombre d'arrêts récupérés pour avoir plus de choix

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.

pour MAX_STOP_AREA_FETCHED: 6 fois ?
pour MAX_DISTANCE_KM: %.6f peut être pas nécessaire mais ok

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.

mêmes commentaires que sur le 1er fichier

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.

2 participants