-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.sh
executable file
·100 lines (85 loc) · 2.88 KB
/
run.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
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
#!/bin/sh
# Copyright (c) 2015 Cédric Bosdonnat <[email protected]>
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
grab_data ()
{
wget -O $WORKDIR/data.zip http://donnees.roulez-eco.fr/opendata/instantane
unzip $WORKDIR/data.zip -d $WORKDIR
}
create_obf ()
{
create_obf_in=$1
create_obf_out=$2
mapcreator=$PWD/OsmAndMapCreator-main
batch=$mapcreator/osm2obf.xml
# Download OsmandMapCreator if needed
if ! test -e "$mapcreator"; then
mkdir -p "$mapcreator"
wget http://download.osmand.net/latest-night-build/OsmAndMapCreator-main.zip
unzip OsmAndMapCreator-main.zip -d $mapcreator
fi
cat >$batch <<EOF
<?xml version="1.0" encoding="utf-8"?>
<batch_process>
<process_attributes
mapZooms=""
renderingTypesFile=""
zoomWaySmoothness=""
osmDbDialect="sqlite"
mapDbDialect="sqlite"/>
<process
directory_for_osm_files="$create_obf_in"
directory_for_index_files="$create_obf_out"
directory_for_generation="$create_obf_out"
skipExistingIndexesAt=""
indexPOI="true"
indexRouting="false"
indexMap="false"
indexTransport="false"
indexAddress="false">
</process>
</batch_process>
EOF
cd "$mapcreator"
java -Djava.util.logging.config.file=logging.properties -Xms256M -Xmx2560M \
-cp "./OsmAndMapCreator.jar:./lib/OsmAnd-core.jar:./lib/*.jar" \
net.osmand.util.IndexBatchCreator osm2obf.xml
cd $OLDPWD
}
WORKDIR=$PWD/tmp
if ! test -e $WORKDIR; then
mkdir $WORKDIR
fi
osmdir=$PWD/osm
obfdir=$PWD/obf
mkdir -p $osmdir
mkdir -p $obfdir
grab_data
data=$(ls -1 $WORKDIR/*.xml)
python3 create_osm.py "$data" "$osmdir/prix-carburant.osm"
create_obf "$osmdir" "$obfdir"
rm $obfdir/*.gen.log
for f in $(ls -1 $obfdir/*.obf); do
newname=$(echo "$f" | sed "s/_2//")
mv $f $newname
done
rm -rf $WORKDIR
rm -rf "$osmdir"