Skip to content

Instantly share code, notes, and snippets.

@mdeweerd
Last active February 21, 2022 05:32
Show Gist options
  • Save mdeweerd/9bc5f60f2d6733e907f3 to your computer and use it in GitHub Desktop.
Save mdeweerd/9bc5f60f2d6733e907f3 to your computer and use it in GitHub Desktop.
#!/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
@RhinoDevel
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment