-
Notifications
You must be signed in to change notification settings - Fork 1
/
01_get_osm_data.sh
executable file
·42 lines (33 loc) · 1.13 KB
/
01_get_osm_data.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
#!/bin/bash
# Extract highways from OSM data that are within the boundary of the
# city of Karlsruhe. The data is stored in `highways.osm`.
#
# Requires the `osmosis` tool.
#
# Download data if necessary
#
DIR=http://download.geofabrik.de/europe/germany
OUTPUT_DIR=output
BASE=sachsen-anhalt-latest.osm.pbf
if [ -f "${OUTPUT_DIR}/${BASE}" ]; then
# Download MD5 file to see if file is up-to-date
echo "${OUTPUT_DIR}/${BASE} exists, downloading MD5 to check whether it's up to date."
wget -q -N ${DIR}/${BASE}.md5 -O ${OUTPUT_DIR}/${BASE}.md5
LATEST_MD5=$(<${OUTPUT_DIR}/${BASE}.md5)
FILE_MD5=`md5sum ${OUTPUT_DIR}/${BASE}`
if [ "$LATEST_MD5" == "$FILE_MD5" ]; then
echo "File is up to date."
else
echo "File is outdated, downloading latest version."
wget ${DIR}/${BASE} -O ${OUTPUT_DIR}/${BASE}
fi
else
echo "${BASE} doesn't exist, downloading it."
wget ${DIR}/${BASE} -O ${OUTPUT_DIR}/${BASE}
fi
#
# Extract coordinates for things
#
osmosis --read-pbf file=${OUTPUT_DIR}/${BASE} \
--bounding-polygon file=magdeburg.poly \
--write-xml ${OUTPUT_DIR}/highways-magdeburg.osm