Skip to content

Latest commit

 

History

History
131 lines (79 loc) · 4.48 KB

File metadata and controls

131 lines (79 loc) · 4.48 KB

Documentation for "Mobilité douce" made by Smart/Origin

This documentation concerns the "Public Transport Access" box code, which appears on the camp to camp routes

⚠️ S/O added a .env to the backend.

v6_api/.env.template #rename it into .env

If you haven't already, update the database with Alembic (this will create the missing tables and fields) :

docker-compose exec api .build/venv/bin/alembic upgrade head

"Show Nearby Stops" section

This section is used to search for public transport stops around 'access' waypoints. The public transport data comes from an external API called Navitia, which is stored in the CamptoCamp database.

IF YOU DON'T HAVE ANY RESULT ON THE "Public Transports Access" section : this means that your imported database does not contain Navitia data. To have visible results, you must launch the script "get_public_transports_from_France.sh" in the backend (see backend documentation)

Warning ⚠️ : it takes a while (~3h, see other option below)

(on api_v6/ )
sh get_public_transports_from_France.sh

If you just want to work with the Isère department for local dev, you can run this script instead (~18 minutes):

(on api_v6/ )
sh get_public_transports_from_Isere.sh

Files created / used for this section :

FRONT-END :

c2c_ui/src/views/document/utils/boxes/TransportsBox.vue => Parent view of the section

c2c_ui/src/views/document/RouteView.vue=> View that call TransportsBox and IsReachableByPublicTransportsBox

c2c_ui/src/views/document/utils/boxes/NearbyStopsSection.vue => Features for nearby stops

c2c_ui/src/views/document/utils/boxes/IsReachableByPublicTransportsBox.vue=> Displays the small card on the left to indicate if there is at least one transport uploaded by the database for this route

c2c_ui/src/components/map/OlMap.vue => Map-related features

c2c_ui/src/components/map/map-utils.vue => Map Objects Style

c2c_ui/src/js/apis/transport-service.js => Calls the backend to get results from the database

c2c_ui/src/assets/img/boxes/... => Images


BACK-END :

v6_api/c2corg_api/models/waypoint_stoparea.py => waypoint_stoparea class

v6_api/c2corg_api/models/stoparea.py => stoparea class

v6_api/c2corg_api/views/waypoint_stoparea.py => waypoint_stoparea endpoints

v6_api/c2corg_api/views/stoparea.py => stoparea waypoints

v6_api/c2corg_api/__init__.py => add a event : after each access waypoint created on C2C, the nearby stops are requested

v6_api/alembic_migration/versions/bb61456d557f_create_stops_and_waypoints_stops.py=> Creates the stops and waypoints_stops tables

v6_api/c2corg_api/__init__.py=> sqlalchemy event (it's like db trigger) : after each access waypoint insert, we request Navitia

"Plan a trip" section

This section is used to plan a trip by calling the Navitia API. Unlike the previous section, we don't store the results in the database; we query Navitia directly by launching a query from the backend. This section uses the calculated_duration attribute, which is calculated with the calcul_duration_for_routes.sh script in the backend (see backend documentation)

If you need to update the calculated duration of itineraries, you can run this :

  1. Go on v6_api/c2corg_api/views/document.py and put the LIMIT_MAX to 100000 :
# the maximum number of documents that can be returned in a request
LIMIT_MAX = 100000
  1. Run the script
(on api_v6/ )
sh calcul_duration_for_routes.sh
  1. Put the limit back to 100
# the maximum number of documents that can be returned in a request
LIMIT_MAX = 100

Files created / used :

FRONT-END :

c2c_ui/src/views/document/utils/boxes/TransportsBox.vue => Parent view of the section

c2c_ui/src/views/document/utils/boxes/PlanATripSection.vue => Features for planning a trip

c2c_ui/src/js/apis/navitia-service.js => Navitia's call on the back

c2c_ui/src/components/map/OlMap.vue => Map-related features

c2c_ui/src/components/map/map-utils.vue => Map Objects Style

c2c_ui/src/assets/img/boxes/... (images) => Images


BACK-END :

v6_api/c2corg_api/views/navitia.py => Call Navitia API

v6_api/c2corg_api/__init__.py => add a event : after each route created on C2C, the calculated_duration is calculed

v6_api/alembic_migration/versions/6b40cb9c7c3d_add_calculated_duration_to_routes.py => Add calculated_duration in DB, on routes objects

v6_api/c2corg_api/__init__.py=> sqlalchemy event (it's like db trigger) : after each route insert, we calculate the duration

Lot 3