summaryrefslogtreecommitdiff
path: root/convert
blob: 6f1c133db375a3d3603638d3dd5372da015cab19 (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/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
  belgium
  croatia
  czech-republic
  germany
  italy
  luxembourg
  netherlands
  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 [ ! -d mkgmap-style-sheets ]
then
  git clone 'https://github.com/ligfietser/mkgmap-style-sheets.git'
  needsRecompilation=true
fi

git -C mkgmap-style-sheets fetch --all -p

if [ "$(git -C mkgmap-style-sheets rev-parse origin/HEAD)" != "$(git -C mkgmap-style-sheets rev-parse HEAD)" ]
then
  git -C mkgmap-style-sheets checkout master
  git -C mkgmap-style-sheets reset --hard origin/master
  needsRecompilation=true
fi

if ${needsRecompilation}
then
  nice /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 \
    --style-file=mkgmap-style-sheets/styles \
    --style="generic new" \
    "mkgmap-style-sheets/typ/osm generic new/2000.typ" \
    *-latest_dir/6324????.osm.pbf
  rm -f 6324????.img
fi