Last active
February 21, 2022 05:32
-
-
Save mdeweerd/9bc5f60f2d6733e907f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -xv | |
### Country list | |
# CHANGE WITH YOUR COUNTRIES | |
COUNTRIES="europe/france/guadeloupe europe/france/guyane europe/france/mayotte europe/france/martinique europe/france/reunion europe/france" | |
# SMALL SUBSET FOR TESTING: | |
COUNTRIES="europe/france/guyane europe/france/mayotte" | |
NOMINATIM="/var/www/Nominatim" | |
cd $NOMINATIM/data | |
INDEX=0 # false | |
### Foreach country check if configuration exists (if not create one) and then import the diff | |
for COUNTRY in $COUNTRIES; | |
do | |
DIR="$NOMINATIM/updates/$COUNTRY" | |
FILE="$DIR/configuration.txt" | |
if [ ! -f ${FILE} ]; | |
then | |
/bin/mkdir -p ${DIR} | |
/usr/bin/osmosis --rrii workingDirectory=${DIR}/. | |
/bin/echo baseUrl=http://download.geofabrik.de/${COUNTRY}-updates > ${FILE} | |
/bin/echo maxInterval = 0 >> ${FILE} | |
cd ${DIR} | |
/usr/bin/wget http://download.geofabrik.de/${COUNTRY}-updates/state.txt | |
fi | |
FILENAME=${COUNTRY//[\/]/_} | |
/usr/bin/osmosis --rri workingDirectory=${DIR}/. --wxc ${DIR}/${FILENAME}.osc.gz | |
### Foreach diff files do the import | |
cd ${NOMINATIM}/updates | |
# NEXT LINE MAY NOT BE NEEDED - FILE SEEMS EMPTY | |
LIST=$DIR/*.osc.gz | |
LIST2=*.osc.gz | |
LIST="$LIST $LIST2" | |
for OSC in $LIST; | |
do | |
if [ -f ${OSC} ]; | |
then | |
${NOMINATIM}/utils/update.php --import-diff ${OSC} --no-npi | |
rm ${OSC} | |
INDEX=1 | |
fi | |
done | |
done | |
### Re-index if needed | |
if ((${INDEX})); | |
then | |
${NOMINATIM}/utils/update.php --index | |
fi | |
### Remove all diff files | |
#rm -f ${NOMINATIM}/updates/*.osc.gz | |
#rm -f ${NOMINATIM}/updates/*/*.osc.gz | |
#rm -f ${NOMINATIM}/updates/*/*/*.osc.gz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@casaulenbo: If you want to use this script, you need to install osmosis.