summaryrefslogtreecommitdiff
path: root/convert
blob: ca60c2439729c9534333ccf8f5e06a58ed544643 (plain)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/bash

set -e

if [ "$(basename "$(pwd)")" != "work" ]
then
  >&2 echo 'You should call this script within a directory called "work".'
  exit 1
fi

mainUrl='https://download.geofabrik.de/europe/'
countries=(
  austria
  croatia
  czech-republic
  germany
  italy
  poland
  slovakia
  slovenia
)
numJobs="$[$(/usr/bin/getconf _NPROCESSORS_ONLN)-2]"
if [ ${numJobs} -lt 1 ]
then
  numJobs=1
fi

[ -f "sea.zip" ] || \
  wget -nd 'http://osm2.pleiades.uni-wuppertal.de/sea/latest/sea.zip'
[ -f "bounds.zip" ] || \
  wget -nd 'http://osm2.pleiades.uni-wuppertal.de/bounds/latest/bounds.zip'

needsRecompilation=false

nextId="63240001"

for country in "${countries[@]}"
do
  baseName="${country}-latest.osm.pbf"
  baseNameDir="${country}-latest_dir"
  dlItem="${mainUrl}${baseName}"
  if [ ! -e "${baseName}" ] || ! wget -O - "${dlItem}.md5" 2> /dev/null | md5sum -c
  then
    rm -f "${baseName}"
    wget -nd "${dlItem}"
    needsRecompilation=true
  fi

  if [ ! -d "${baseNameDir}" ]
  then
    needsRecompilation=true
  fi

  if ${needsRecompilation}
  then
    if [ -d "${baseNameDir}" ]
    then
      if ls "${baseNameDir}" | grep -q ''
      then
        rm "${baseNameDir}"/*
      fi
      rmdir "${baseNameDir}"
    fi

    mkdir "${baseNameDir}"
    /usr/lib/jvm/java-8-openjdk/jre/bin/java -jar /usr/share/java/splitter/splitter.jar \
      --output-dir="${baseNameDir}" \
      --mapid="${nextId}" \
      "${baseName}"
  fi

  nextId=$[
    $(
      ls -1 "${baseNameDir}" | \
        grep '^6324....\.osm\.pbf$' | \
        cut -d. -f1 | \
        sort -n | \
        tail -n1
    )
    +1
  ]
done

if ${needsRecompilation}
then
  /usr/lib/jvm/java-8-openjdk/jre/bin/java -jar /usr/share/java/mkgmap/mkgmap.jar \
    --route \
    --add-pois-to-lines \
    --add-pois-to-areas \
    --bounds=bounds.zip \
    --precomp-sea=sea.zip \
    --generate-sea \
    --index \
    --gmapsupp \
    --family-name="OpenStreetmap mkgmap" \
    --area-name="parts of europe" \
    --max-jobs="${numJobs}" \
    --remove-ovm-work-files \
    *-latest_dir/6324????.osm.pbf
  rm -f 6324????.img
fi