]> git.openstreetmap.org Git - nominatim.git/blob - utils/update_database.sh
don't even try heavily penalized searches
[nominatim.git] / utils / update_database.sh
1 #!/bin/bash -xv
2
3 # Derived from https://gist.github.com/RhinoDevel/8a35ebd2a08166f328eca01ab005c6de and edited to work with Pyosmium
4 # Related to https://github.com/osm-search/Nominatim/issues/1683
5
6 # Steps being followed:
7
8 #     *) Get the diff file from server
9 #         1) pyosmium-get-changes (with -f sequence.state for getting sequenceNumber)
10
11 #     *) Import diff
12 #         1) utils/update.php --import-diff
13
14 #     *) Index for all the countries at the end
15
16 # Hint:
17 #
18 # Use "bashdb ./update_database.sh" and bashdb's "next" command for step-by-step
19 # execution.
20
21 # ******************************************************************************
22
23 # REPLACE WITH LIST OF YOUR "COUNTRIES":
24 #
25 COUNTRIES="europe/monaco europe/andorra"
26
27 UPDATEBASEURL="https://download.geofabrik.de"
28 UPDATECOUNTRYPOSTFIX="-updates"
29
30 # If you do not use Photon, let Nominatim handle (re-)indexing:
31 #
32 FOLLOWUP="nominatim index"
33 #
34 # If you use Photon, update Photon and let it handle the index
35 # (Photon server must be running and must have been started with "-database",
36 # "-user" and "-password" parameters):
37 #
38 #FOLLOWUP="curl http://localhost:2322/nominatim-update"
39
40 # ******************************************************************************
41 UPDATEDIR="update"
42
43 for COUNTRY in $COUNTRIES;
44 do
45     echo "===================================================================="
46     echo "$COUNTRY"
47     echo "===================================================================="
48     DIR="$UPDATEDIR/$COUNTRY"
49     FILE="$DIR/sequence.state"
50     BASEURL="$UPDATEBASEURL/$COUNTRY$UPDATECOUNTRYPOSTFIX"
51     FILENAME=${COUNTRY//[\/]/_}
52
53     echo "Attempting to get changes"
54     rm -f ${DIR}/${FILENAME}.osc.gz
55     pyosmium-get-changes -o ${DIR}/${FILENAME}.osc.gz -f ${FILE} --server $BASEURL -v
56
57     echo "Attempting to import diffs"
58     nominatim add-data --diff ${DIR}/${FILENAME}.osc.gz
59 done
60
61 echo "===================================================================="
62 echo "Reindexing" 
63 ${FOLLOWUP}
64 echo "===================================================================="