forked from organicmaps/organicmaps
Shell variables, more fixes and less dependencies
This commit is contained in:
parent
daa14192b1
commit
46eabf4048
1 changed files with 52 additions and 39 deletions
|
@ -5,10 +5,12 @@
|
|||
|
||||
# Prerequisites:
|
||||
#
|
||||
# - The script should be placed in omim/tools/unix
|
||||
# - Compiled generator_tool somewhere in omim/../build/out/whatever
|
||||
# - For routing, compiled OSRM binaries in omim/3party/osrm/osrm-backend/build
|
||||
# - Data path with classificators etc. should be present in omim/data
|
||||
# - The script should be placed in omim/tools/unix, or supply OMIM_PATH with path to omim repo
|
||||
# - Data path with classificators etc. should be present in $OMIM_PATH/data
|
||||
# Inside it should be at least: categories.txt, classificator.txt, types.txt, drules_proto.bin
|
||||
# - Compiled generator_tool somewhere in omim/../build/out/whatever, or supply BUILD_PATH
|
||||
# - For routing, compiled OSRM binaries in omim/3party/osrm/osrm-backend/build, or supply OSRM_BUILD_PATH
|
||||
# - Target path for mwm is the same as o5m path, or supply TARGET
|
||||
|
||||
# Cross-borders routing index is not created, since we don't assume
|
||||
# the source file to be one of the pre-defined countries.
|
||||
|
@ -22,7 +24,9 @@ if [ $# -lt 1 ]; then
|
|||
fi
|
||||
SOURCE_FILE="$1"
|
||||
BASE_NAME="${SOURCE_FILE%%.*}"
|
||||
MY_PATH=$(cd $(dirname $0); pwd)
|
||||
[ ! -d "$TARGET" ] && TARGET="$(dirname "$SOURCE_FILE")"
|
||||
[ ! -d "$OMIM_PATH/data" ] && OMIM_PATH="$(cd "$(dirname "$0")/../.."; pwd)"
|
||||
DATA_PATH="$OMIM_PATH/data/"
|
||||
|
||||
if [ $# -gt 1 ]; then
|
||||
MODE=routing
|
||||
|
@ -30,27 +34,28 @@ else
|
|||
MODE=mwm
|
||||
fi
|
||||
|
||||
# find generator_tool. Supply your own priority dir if needed
|
||||
PRIORITY_PATH="$MY_PATH/../../build_omim-zv-desktop-Debug"
|
||||
IT_PATHS_ARRAY=()
|
||||
for i in $PRIORITY_PATH $MY_PATH/../.. $MY_PATH/../../../*omim*elease* $MY_PATH/../../../*omim*ebug; do
|
||||
if [ -d "$i/out" ]; then
|
||||
IT_PATHS_ARRAY+=("$i/out/release/generator_tool" "$i/out/debug/generator_tool")
|
||||
fi
|
||||
done
|
||||
if [ -z "$GENERATOR_TOOL" ]; then
|
||||
# find generator_tool. Supply your own priority dir if needed
|
||||
IT_PATHS_ARRAY=()
|
||||
for i in $BUILD_PATH $OMIM_PATH $OMIM_PATH/../*omim*elease* $OMIM_PATH/../*omim*ebug; do
|
||||
if [ -d "$i/out" ]; then
|
||||
IT_PATHS_ARRAY+=("$i/out/release/generator_tool" "$i/out/debug/generator_tool")
|
||||
fi
|
||||
done
|
||||
|
||||
for i in ${IT_PATHS_ARRAY[@]}; do
|
||||
if [ -x "$i" ]; then
|
||||
GENERATOR_TOOL="$i"
|
||||
echo TOOL: $GENERATOR_TOOL
|
||||
break
|
||||
fi
|
||||
done
|
||||
for i in "$BUILD_PATH/generator_tool" ${IT_PATHS_ARRAY[@]}; do
|
||||
if [ -x "$i" ]; then
|
||||
GENERATOR_TOOL="$i"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ ! -n $GENERATOR_TOOL ]]; then
|
||||
if [[ ! -x "$GENERATOR_TOOL" ]]; then
|
||||
echo "No generator_tool found in ${IT_PATHS_ARRAY[*]}"
|
||||
exit 1
|
||||
fi
|
||||
echo TOOL: $GENERATOR_TOOL
|
||||
|
||||
if [[ "`uname`" == 'Darwin' ]]; then
|
||||
INTDIR=$(mktemp -d -t mwmgen)
|
||||
|
@ -63,15 +68,14 @@ if [ "$MODE" == "mwm" ]; then
|
|||
INTDIR_FLAG="--intermediate_data_path=$INTDIR/ --osm_file_type=o5m --osm_file_name=$SOURCE_FILE --node_storage=map"
|
||||
$GENERATOR_TOOL $INTDIR_FLAG --preprocess=true
|
||||
|
||||
DATA_PATH="$MY_PATH/../../data/"
|
||||
$GENERATOR_TOOL --data_path=$MY_PATH --user_resource_path=$DATA_PATH $INTDIR_FLAG --generate_features=true --generate_geometry=true --generate_index=true --generate_search_index=true --output=$BASE_NAME
|
||||
$GENERATOR_TOOL --data_path=$TARGET --user_resource_path=$DATA_PATH $INTDIR_FLAG --generate_features=true --generate_geometry=true --generate_index=true --generate_search_index=true --output=$BASE_NAME
|
||||
|
||||
elif [ "$MODE" == "routing" ]; then
|
||||
|
||||
OSRM_PATH="$MY_PATH/../../3party/osrm/osrm-backend"
|
||||
BIN_PATH="$OSRM_PATH/build"
|
||||
if [ ! -x "$BIN_PATH/osrm-extract" ]; then
|
||||
echo "Please compile OSRM binaries to $BIN_PATH"
|
||||
[ ! -d "$OSRM_PATH" ] && OSRM_PATH="$OMIM_PATH/3party/osrm/osrm-backend"
|
||||
[ ! -d "$OSRM_BUILD_PATH" ] && OSRM_BUILD_PATH="$OSRM_PATH/build"
|
||||
if [ ! -x "$OSRM_BUILD_PATH/osrm-extract" ]; then
|
||||
echo "Please compile OSRM binaries to $OSRM_BUILD_PATH"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -r "$BASE_NAME.mwm" ]; then
|
||||
|
@ -79,14 +83,23 @@ elif [ "$MODE" == "routing" ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
EXTRACT_CFG="$OSRM_PATH/../extractor.ini"
|
||||
PREPARE_CFG="$OSRM_PATH/../contractor.ini"
|
||||
[ -z "$OSRM_THREADS" ] && OSRM_THREADS=15
|
||||
[ -z "$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"
|
||||
if [ -r "$2" ]; then
|
||||
PROFILE="$2"
|
||||
else
|
||||
echo "$2 is not a profile, using standard car.lua"
|
||||
PROFILE="$OSRM_PATH/profiles/car.lua"
|
||||
fi
|
||||
if [ ! -r "$PROFILE" ]; then
|
||||
echo "Lua profile $PROFILE is not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PBF="$INTDIR/$BASENAME.pbf"
|
||||
OSRM="$INTDIR/$BASENAME.osrm"
|
||||
|
@ -98,12 +111,12 @@ elif [ "$MODE" == "routing" ]; then
|
|||
wget -O - http://m.m.i24.cc/osmconvert.c | cc -x c - -lz -O3 -o $OSMCONVERT
|
||||
fi
|
||||
$OSMCONVERT $SOURCE_FILE -o=$PBF
|
||||
"$BIN_PATH/osrm-extract" --config "$EXTRACT_CFG" --profile "$PROFILE" "$PBF"
|
||||
"$OSRM_BUILD_PATH/osrm-extract" --config "$EXTRACT_CFG" --profile "$PROFILE" "$PBF"
|
||||
rm "$PBF"
|
||||
"$BIN_PATH/osrm-prepare" --config "$PREPARE_CFG" --profile "$PROFILE" "$OSRM"
|
||||
"$BIN_PATH/osrm-mapsme" -i "$OSRM"
|
||||
"$OSRM_BUILD_PATH/osrm-prepare" --config "$PREPARE_CFG" --profile "$PROFILE" "$OSRM"
|
||||
"$OSRM_BUILD_PATH/osrm-mapsme" -i "$OSRM"
|
||||
# create fake poly file
|
||||
POLY="$MY_PATH/borders/$BASE_NAME.poly"
|
||||
POLY="$TARGET/borders/$BASE_NAME.poly"
|
||||
if [ ! -r "$POLY" ]; then
|
||||
POLY_DIR="$(dirname "$POLY")"
|
||||
mkdir -p "$POLY_DIR"
|
||||
|
@ -118,18 +131,18 @@ fake
|
|||
END
|
||||
END
|
||||
EOPOLY
|
||||
if [ -r "$MY_PATH/polygons.lst" ]; then
|
||||
mv "$MY_PATH/polygons.lst" "$POLY_DIR"
|
||||
if [ -r "$TARGET/polygons.lst" ]; then
|
||||
mv "$TARGET/polygons.lst" "$POLY_DIR"
|
||||
fi
|
||||
echo "$BASE_NAME" > "$MY_PATH/polygons.lst"
|
||||
echo "$BASE_NAME" > "$TARGET/polygons.lst"
|
||||
fi
|
||||
$GENERATOR_TOOL --osrm_file_name=$OSRM --data_path=$MY_PATH --output=$BASE_NAME
|
||||
$GENERATOR_TOOL --osrm_file_name=$OSRM --data_path=$TARGET --user_resource_path=$DATA_PATH --output=$BASE_NAME
|
||||
if [ -n "$POLY_DIR" ]; then
|
||||
# remove fake poly
|
||||
rm "$POLY"
|
||||
rm "$MY_PATH/polygons.lst"
|
||||
rm "$TARGET/polygons.lst"
|
||||
if [ -r "$POLY_DIR/polygons.lst" ]; then
|
||||
mv "$POLY_DIR/polygons.lst" "$MY_PATH"
|
||||
mv "$POLY_DIR/polygons.lst" "$TARGET"
|
||||
fi
|
||||
if [ -z "$(ls -A "$POLY_DIR")" ]; then
|
||||
rm -r "$POLY_DIR"
|
||||
|
|
Loading…
Add table
Reference in a new issue