[scripts] Add online routing files generation mode for generate_planet script.

This commit is contained in:
Lev Dragunov 2015-06-04 16:11:54 +03:00 committed by Alex Zolotarev
parent 143a3b24a9
commit 45af664cf6
2 changed files with 44 additions and 1 deletions

View file

@ -12,6 +12,7 @@ usage() {
echo -e "-U\tDownload planet when it is missing"
echo -e "-w\tGenerate World and WorldCoasts"
echo -e "-r\tGenerate routing files"
echo -e "-o\tGenerate online routing files"
echo -e "-a\tEquivalent to -uwr"
echo -e "-c\tClean last pass results if there was an error, and start anew"
echo -e "-v\tPrint all commands executed"
@ -65,7 +66,7 @@ OPT_WORLD=
OPT_UPDATE=
OPT_DOWNLOAD=
OPT_ROUTING=
while getopts ":cuUwravh" opt; do
while getopts ":couUwravh" opt; do
case $opt in
c)
OPT_CLEAN=1
@ -83,6 +84,9 @@ while getopts ":cuUwravh" opt; do
r)
OPT_ROUTING=1
;;
o)
OPT_ONLINE_ROUTING=1
;;
a)
OPT_WORLD=1
OPT_UPDATE=1
@ -269,6 +273,11 @@ if [ -n "$OPT_ROUTING" ]; then
fi
fi
if [ -n "$OPT_ONLINE_ROUTING" ]; then
putmode "start_online_routing(): Generating OSRM files for osrm-routed server."
bash "$ROUTING_SCRIPT" online >> "$ROUTING_LOG" 2>&1
fi
if [ "$MODE" == "inter" ]; then
putmode "Step 3: Generating intermediate data for all MWMs"
# 1st pass, run in parallel - preprocess whole planet to speed up generation if all coastlines are correct

View file

@ -115,6 +115,40 @@ elif [ "$1" == "mwm" ]; then
rmdir "$POLY_DIR"
fi
fi
elif [ "$1" == "online" ]; then
PLANET="${PLANET:-$HOME/planet/planet-latest.o5m}"
OSMCTOOLS="${OSMCTOOLS:-$HOME/osmctools}"
[ ! -d "$OSMCTOOLS" ] && OSMCTOOLS="$INTDIR"
# The patch increases number of nodes for osmconvert to avoid overflow crash
[ ! -x "$OSMCTOOLS/osmconvert" ] && wget -q -O - http://m.m.i24.cc/osmconvert.c | sed 's/60004/600004/' | cc -x c - -lz -O3 -o "$OSMCTOOLS/osmconvert"
export OSMCTOOLS
export PLANET
export INTDIR
"$OSMCTOOLS/osmconvert" "$PLANET" --hash-memory=2000 --out-pbf -o="$INTDIR/planet.pbf"
OSRM_PATH="${OSRM_PATH:-$OMIM_PATH/3party/osrm/osrm-backend}"
OSRM_BUILD_PATH="${OSRM_BUILD_PATH:-$OSRM_PATH/build}"
[ ! -x "$OSRM_BUILD_PATH/osrm-extract" ] && fail "Please compile OSRM binaries to $OSRM_BUILD_PATH"
OSRM_THREADS=${OSRM_THREADS:-15}
OSRM_MEMORY=${OSRM_MEMORY:-50}
EXTRACT_CFG="$INTDIR/extractor.ini"
PREPARE_CFG="$INTDIR/contractor.ini"
echo "threads = $OSRM_THREADS" > "$EXTRACT_CFG"
echo "memory = $OSRM_MEMORY" > "$PREPARE_CFG"
echo "threads = $OSRM_THREADS" >> "$PREPARE_CFG"
PROFILE="${PROFILE:-$OSRM_PATH/profiles/car.lua}"
[ $# -gt 1 ] && PROFILE="$2"
[ ! -r "$PROFILE" ] && fail "Lua profile $PROFILE is not found"
export STXXLCFG="$HOME/.stxxl"
PBF="$INTDIR/planet.pbf"
OSRM_FILE="$INTDIR/planet.osrm"
rm -f "$OSRM_FILE"
"$OSRM_BUILD_PATH/osrm-extract" --config "$EXTRACT_CFG" --profile "$PROFILE" "$PBF"
rm -f "$PBF"
"$OSRM_BUILD_PATH/osrm-prepare" --config "$PREPARE_CFG" --profile "$PROFILE" "$OSRM_FILE"
else
fail "Incorrect parameter: $1"
fi