From 20c509994f712a378cd7d60f0582ced784388b01 Mon Sep 17 00:00:00 2001 From: Ananda Date: Tue, 10 Dec 2024 13:44:41 +0100 Subject: [PATCH] chore: update isochrone script --- tools/isochrones/docker-compose.yml | 1 - tools/isochrones/graphhopper/config.yml | 1 + tools/isochrones/graphhopper/gtfs.sh | 2 ++ tools/isochrones/isochrones/Dockerfile | 2 ++ tools/isochrones/isochrones/entrypoint.sh | 11 ++++++----- tools/isochrones/isochrones/isochrone.sh | 18 ++++++++++++++++++ 6 files changed, 29 insertions(+), 6 deletions(-) create mode 100755 tools/isochrones/isochrones/isochrone.sh diff --git a/tools/isochrones/docker-compose.yml b/tools/isochrones/docker-compose.yml index d68655c..1370d55 100644 --- a/tools/isochrones/docker-compose.yml +++ b/tools/isochrones/docker-compose.yml @@ -28,7 +28,6 @@ services: - ISOCHRONE_DATE=${ISOCHRONE_DATE:-2024-12-16T05%3A00%3A00.000Z} - CQLP_API=${CQLP_API:-http://host.docker.internal:5000} - COMPUTE_POSTGRES_URI=${POSTGRES_URI} - - ISOCHRONES_MEMORY_LIMIT=${ISOCHRONES_MEMORY_LIMIT:-4g} - GRAPHHOPPER_URL=${GRAPHHOPPER_URL:-http://graphhopper:8989} container_name: isochrones build: diff --git a/tools/isochrones/graphhopper/config.yml b/tools/isochrones/graphhopper/config.yml index 3fa696d..6454f29 100644 --- a/tools/isochrones/graphhopper/config.yml +++ b/tools/isochrones/graphhopper/config.yml @@ -11,6 +11,7 @@ graphhopper: - bike.json profiles_ch: - profile: foot + - profile: bike graph.encoded_values: foot_access, foot_average_speed, hike_rating, foot_priority, bike_priority, bike_access, roundabout, bike_average_speed,average_slope, hike_rating, country, road_class import.osm.ignored_highways: motorway,trunk # ,primary diff --git a/tools/isochrones/graphhopper/gtfs.sh b/tools/isochrones/graphhopper/gtfs.sh index 753bcf6..bd859ba 100644 --- a/tools/isochrones/graphhopper/gtfs.sh +++ b/tools/isochrones/graphhopper/gtfs.sh @@ -8,6 +8,8 @@ function download_and_clean() { cd gtfs-out zip -0 $filename * mv $filename .. + cd .. + rm -Rf gtfs-out } download_and_clean https://eu.ftp.opendatasoft.com/stif/GTFS/IDFM-gtfs.zip diff --git a/tools/isochrones/isochrones/Dockerfile b/tools/isochrones/isochrones/Dockerfile index bf54224..c876b2b 100644 --- a/tools/isochrones/isochrones/Dockerfile +++ b/tools/isochrones/isochrones/Dockerfile @@ -3,6 +3,8 @@ FROM debian:bookworm-slim RUN apt-get update RUN apt-get -y install jq parallel curl +WORKDIR /data + COPY entrypoint.sh entrypoint.sh ENTRYPOINT ["bash", "entrypoint.sh"] \ No newline at end of file diff --git a/tools/isochrones/isochrones/entrypoint.sh b/tools/isochrones/isochrones/entrypoint.sh index 3bc61c0..8fecd32 100644 --- a/tools/isochrones/isochrones/entrypoint.sh +++ b/tools/isochrones/isochrones/entrypoint.sh @@ -1,25 +1,26 @@ #!/bin/bash set -e -cd /data - curl ${CQLP_API}/api/etablissements >etablissements.json mkdir -p isochrones # Create isochrones scripts readonly GRAPHHOPPER_URL=$GRAPHHOPPER_URL +readonly ISOCHRONE_DATE=$ISOCHRONE_DATE +readonly ISOCHRONE_PARALLEL=$ISOCHRONE_PARALLEL readonly GRAPHHOPPER_PROFILE=${1:?"Merci de préciser un profil (ex: pt ou bike)"} + shift TIMES=(5400 3600 2700 1800 900) for TIME in ${TIMES[@]}; do mkdir -p isochrones/${GRAPHHOPPER_PROFILE}/${TIME} - jq --raw-output '.[] | select(.latitude!=null)| "\(.uai),\(.latitude),\(.longitude)"' etablissements.json | - awk -F, -v GRAPHHOPPER_PROFILE="$GRAPHHOPPER_PROFILE" -v GRAPHHOPPER_URL="$GRAPHHOPPER_URL" -v DATE="$ISOCHRONE_DATE" -v TIME="$TIME" '{print "curl \""GRAPHHOPPER_URL"/isochrone?point="$2","$3"&profile="GRAPHHOPPER_PROFILE"&pt.earliest_departure_time="DATE"&time_limit="TIME"&buckets=1&result=multipolygon&reverse_flow=true\" > isochrones/"GRAPHHOPPER_PROFILE"/"TIME"/"$1".json"}' >liste_${GRAPHHOPPER_PROFILE}_${TIME} + jq --raw-output '.[] | select(.latitude!=null)| "\(.uai) \(.latitude) \(.longitude)"' etablissements.json | + awk -F, -v GRAPHHOPPER_PROFILE="$GRAPHHOPPER_PROFILE" -v DATE="$ISOCHRONE_DATE" -v TIME="$TIME" '{print GRAPHHOPPER_PROFILE" "DATE" "TIME" "$1" "$2" "$3}' >liste_${GRAPHHOPPER_PROFILE}_${TIME} done # Get isochrones for TIME in ${TIMES[@]}; do - parallel -j $ISOCHRONE_PARALLEL bash -c "{}" isochrones/${GRAPHHOPPER_PROFILE}/${TIME}/${UAI}.json +echo "done: ${UAI}" >>${RESULT_FILE}