This repository has been archived by the owner on Jun 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgen-ghz.sh
executable file
·61 lines (48 loc) · 1.61 KB
/
gen-ghz.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
GH_LIB="lib/*:osmosis/lib/default/*"
GH_CLASS="org.fruct.oss.ghpriority.Main"
if [ "x$JAVA_HOME" = "x" ]; then
JAVA=java
else
JAVA=${JAVA_HOME}/bin/java
fi
function die {
echo ${1}
exit 1
}
if [ $# -lt 4 ]; then
echo "Usage: $0 source-dir polygon-dir regions-file target-dir"
exit 1
fi
SOURCE_DIR=$(realpath ${1})
POLYGON_DIR=$(realpath ${2})
FILE_REGIONS=$(realpath ${3})
TARGET_DIR=$(realpath ${4})
mkdir -p ${TARGET_DIR} || die "Cannot create directory ${TARGET_DIR}"
while read line; do
FILE_POLY=`echo "$line" | cut -f1`
FILE_OUTPUT=`echo "$line" | cut -f2`
DESC=`echo "$line" | cut -f3`
SOURCE_FILE="${SOURCE_DIR}/${FILE_OUTPUT}.osm.pbf"
TARGET_FILE="${TARGET_DIR}/${FILE_OUTPUT}.osm.pbf.ghz"
OUTPUT_DIR="${TARGET_DIR}/out"
${JAVA} ${JAVACMD_OPTIONS} -cp "${GH_LIB}" ${GH_CLASS} config=config.properties \
graph.location="${OUTPUT_DIR}" osmreader.osm="$SOURCE_FILE"
cp "${POLYGON_DIR}/${FILE_POLY}" "${OUTPUT_DIR}/polygon.poly"
mkdir -p "${OUTPUT_DIR}/regions6"
osmosis/bin/osmosis --rb "$SOURCE_FILE" --wrd file="${OUTPUT_DIR}/regions6"
./rdp-poly.sh "${OUTPUT_DIR}/regions6" 1000
cat << EOF > ${OUTPUT_DIR}/description.txt
<file>
<region-id>$(./create-id.sh rb "${FILE_OUTPUT}")</region-id>
<name>${FILE_OUTPUT}.osm.pbf.ghz</name>
<description lang="ru">${DESC}</description>
</file>
EOF
pushd "${OUTPUT_DIR}"
zip -r "${TARGET_FILE}" description.txt polygon.poly edges geometry location_index names nodes properties regions6
popd
pushd "${TARGET_DIR}"
rm -rv out
popd
done < "${FILE_REGIONS}"