co-maps/tools/unix/maps/generate_subways.sh

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

53 lines
1.9 KiB
Bash
Raw Permalink Normal View History

2025-11-22 13:58:55 +01:00
#!/usr/bin/env bash
set -e -u -o pipefail
# Generate subways.transit.json file consumed by the maps generator.
# Inputs:
# - OSM planet in pbf format
# - csv table of subway networks
# (auto-downloaded from https://docs.google.com/spreadsheets/d/1SEW1-NiNOnA2qDwievcxYV1FOaQl1mb1fdeyqAxHu3k)
# Output:
# - subways.transit.json
source "$(dirname "$0")/helper_settings.sh"
source "$REPO_PATH/tools/unix/helper_python.sh"
# Parameters for the process_subways.sh script:
export PLANET="$PLANET_PBF"
export SKIP_PLANET_UPDATE="1"
# http(s) or "file://" URL to a CSV file with a list of subway networks.
# Auto-downloaded from https://docs.google.com/spreadsheets/d/1SEW1-NiNOnA2qDwievcxYV1FOaQl1mb1fdeyqAxHu3k
# If unavailable then replace with a local file.
# TODO: keep the downloaded csv file from the latest run.
#export CITIES_INFO_URL=""
export TMPDIR="$BUILD_PATH/subway"
# The output file, which needs post-processing by transit_graph_generator.py
export MAPSME="$SUBWAYS_PATH/subway.json"
# Produce additional files needed for https://cdn.organicmaps.app/subway/
export HTML_DIR="$SUBWAYS_VALIDATOR_PATH"
export DUMP="$SUBWAYS_VALIDATOR_PATH"
export GEOJSON="$SUBWAYS_VALIDATOR_PATH"
export DUMP_CITY_LIST="$SUBWAYS_VALIDATOR_PATH/cities.txt"
# cd to subways repo so relative paths work in the script
PREVDIR=$(pwd)
cd "$SUBWAYS_REPO_PATH"
echo "Running process_subways.sh:"
./scripts/process_subways.sh 2>&1 | tee "$SUBWAYS_LOG"
cd "$PREVDIR"
# Make render.html available for map visualization on the web
cp -r "$SUBWAYS_REPO_PATH"/render/* "$SUBWAYS_VALIDATOR_PATH/"
TRANSIT_TOOL_PATH="$REPO_PATH/tools/python/transit"
SUBWAYS_GRAPH_FILE="$SUBWAYS_PATH/subways.transit.json"
activate_venv_at_path "$TRANSIT_TOOL_PATH"
"$PYTHON" "$TRANSIT_TOOL_PATH/transit_graph_generator.py" "$MAPSME" "$SUBWAYS_GRAPH_FILE" 2>&1 | tee -a "$SUBWAYS_LOG"
deactivate
echo "Generated subways transit graph file:"
echo "$SUBWAYS_GRAPH_FILE"
echo "Finished"