-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: script de créations des isochrones
- Loading branch information
Showing
7 changed files
with
180 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
version: "3" | ||
services: | ||
graphhopper: | ||
image: graphhopper | ||
environment: | ||
- GRAPHHOPPER_MEMORY_LIMIT=${GRAPHHOPPER_MEMORY_LIMIT:-4g} | ||
container_name: graphhopper | ||
build: | ||
context: graphhopper | ||
args: | ||
GRAPHHOPPER_MEMORY_LIMIT: ${GRAPHHOPPER_MEMORY_LIMIT:-4g} | ||
mem_limit: ${GRAPHHOPPER_MEMORY_LIMIT:-4g} | ||
restart: unless-stopped | ||
networks: | ||
- isochrones_network | ||
volumes: | ||
- ./graphhopper/data:/data:z | ||
healthcheck: | ||
test: ["CMD", "curl", "-f", "http://localhost:8989/health"] | ||
interval: 30s | ||
timeout: 10s | ||
retries: 5 | ||
|
||
isochrones: | ||
image: isochrones | ||
environment: | ||
- ISOCHRONE_PARALLEL=${ISOCHRONE_PARALLEL:-16} | ||
- 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} | ||
container_name: isochrones | ||
build: | ||
context: isochrones | ||
args: | ||
ISOCHRONES_MEMORY_LIMIT: ${ISOCHRONES_MEMORY_LIMIT:-4g} | ||
mem_limit: ${ISOCHRONES_MEMORY_LIMIT:-4g} | ||
networks: | ||
- isochrones_network | ||
extra_hosts: | ||
- "host.docker.internal:host-gateway" | ||
volumes: | ||
- ./isochrones/data:/data:z | ||
depends_on: | ||
graphhopper: | ||
condition: service_healthy | ||
links: | ||
- graphhopper | ||
|
||
networks: | ||
isochrones_network: | ||
name: isochrones_network |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
FROM debian:bookworm-slim AS build | ||
|
||
ARG GRAPHHOPPER_MEMORY_LIMIT | ||
|
||
# Install package | ||
RUN apt-get update | ||
RUN apt-get -y install osmium-tool wget zip | ||
|
||
# Install go | ||
RUN wget https://go.dev/dl/go1.23.4.linux-amd64.tar.gz | ||
RUN tar -C /usr/local -xzf go1.23.4.linux-amd64.tar.gz | ||
ENV PATH="$PATH:/usr/local/go/bin" | ||
RUN go install github.com/public-transport/gtfsclean@latest | ||
|
||
WORKDIR /data/pbf | ||
|
||
# Download pbf | ||
RUN wget https://download.geofabrik.de/europe/france-latest.osm.pbf | ||
RUN wget https://download.geofabrik.de/europe/france/martinique-latest.osm.pbf | ||
RUN wget https://download.geofabrik.de/europe/france/guadeloupe-latest.osm.pbf | ||
RUN wget https://download.geofabrik.de/europe/france/mayotte-latest.osm.pbf | ||
RUN wget https://download.geofabrik.de/europe/france/guyane-latest.osm.pbf | ||
RUN wget https://download.geofabrik.de/europe/france/reunion-latest.osm.pbf | ||
|
||
# Merge pbf | ||
RUN osmium merge france-latest.osm.pbf martinique-latest.osm.pbf guadeloupe-latest.osm.pbf mayotte-latest.osm.pbf guyane-latest.osm.pbf reunion-latest.osm.pbf -o full.osm.pbf | ||
|
||
WORKDIR /data/gtfs | ||
# Download and clean gtfs | ||
COPY gtfs.sh gtfs.sh | ||
RUN bash gtfs.sh | ||
|
||
FROM amazoncorretto:21-alpine | ||
|
||
ARG GRAPHHOPPER_MEMORY_LIMIT | ||
|
||
WORKDIR /data/graphhopper | ||
|
||
# Get graphhopper | ||
RUN wget https://repo1.maven.org/maven2/com/graphhopper/graphhopper-web/9.1/graphhopper-web-9.1.jar | ||
|
||
COPY --from=build /data/pbf /data/graphhopper/pbf | ||
COPY --from=build /data/gtfs /data/graphhopper/gtfs | ||
|
||
COPY entrypoint.sh entrypoint.sh | ||
COPY config.yml config.yml | ||
|
||
|
||
RUN java -Xmx${GRAPHHOPPER_MEMORY_LIMIT} -Xms${GRAPHHOPPER_MEMORY_LIMIT} -jar graphhopper-web-9.1.jar import config.yml | ||
|
||
ENTRYPOINT ["entrypoint.sh"] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
graphhopper: | ||
datareader.file: pbf/full.osm.pbf | ||
gtfs.file: gtfs/IDFM-gtfs.zip,gtfs/export-ter-gtfs-last.zip,gtfs/KORRIGOBRET.gtfs.zip | ||
graph.location: graphs | ||
profiles: | ||
- name: foot | ||
custom_model_files: | ||
- foot.json | ||
- name: bike | ||
custom_model_files: | ||
- bike.json | ||
profiles_ch: | ||
- profile: foot | ||
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 | ||
|
||
datareader.preferred_language: fr | ||
|
||
server: | ||
application_connectors: | ||
- type: http | ||
port: 8989 | ||
bind_host: 0.0.0.0 | ||
admin_connectors: | ||
- type: http | ||
port: 8990 | ||
bind_host: localhost |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
java -Xmx$GRAPHHOPPER_MEMORY_LIMIT -Xms$GRAPHHOPPER_MEMORY_LIMIT -jar graphhopper-web-9.1.jar server config.yml |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
function download_and_clean() { | ||
wget $* | ||
filename=$(basename "$*") | ||
$(go env GOPATH)/bin/gtfsclean -SCRmTcdsOeD $filename | ||
cd gtfs-out | ||
zip -0 $filename * | ||
mv $filename .. | ||
} | ||
|
||
download_and_clean https://eu.ftp.opendatasoft.com/stif/GTFS/IDFM-gtfs.zip | ||
download_and_clean https://www.korrigo.bzh/ftp/OPENDATA/KORRIGOBRET.gtfs.zip | ||
download_and_clean https://eu.ftp.opendatasoft.com/sncf/plandata/export-ter-gtfs-last.zip |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM debian:bookworm-slim | ||
|
||
RUN apt-get update | ||
RUN apt-get -y install jq parallel curl | ||
|
||
COPY entrypoint.sh entrypoint.sh | ||
|
||
ENTRYPOINT ["bash", "entrypoint.sh"] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
cd /data | ||
|
||
curl ${CQLP_API}/api/etablissements >etablissements.json | ||
|
||
mkdir -p isochrones | ||
|
||
# Create isochrones scripts | ||
GRAPHHOPPER_URL=http://graphhopper:8989 | ||
|
||
TIMES=(5400 3600 2700 1800 900) | ||
for TIME in ${TIMES[@]}; do | ||
mkdir -p isochrones/${TIME} | ||
jq --raw-output '.[] | select(.latitude!=null)| "\(.uai),\(.latitude),\(.longitude)"' etablissements.json | | ||
awk -F, -v GRAPHHOPPER_URL="$GRAPHHOPPER_URL" -v DATE="$ISOCHRONE_DATE" -v TIME="$TIME" '{print "curl \""GRAPHHOPPER_URL"/isochrone?point="$2","$3"&profile=pt&pt.earliest_departure_time="DATE"&time_limit="TIME"&buckets=1&result=multipolygon&reverse_flow=true\" > isochrones/"TIME"/"$1".json"}' >liste_${TIME} | ||
done | ||
|
||
# Get isochrones | ||
for TIME in ${TIMES[@]}; do | ||
parallel -j $ISOCHRONE_PARALLEL bash -c "{}" <liste_${TIME} | ||
done |