Created
January 17, 2013 19:08
-
-
Save jones139/4558645 to your computer and use it in GitHub Desktop.
Keep an OSM Database up to date over a particular bounding box. There are probably lots of different versions of this around.
This file contains hidden or 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 | |
#This scripts updates the area and inserts the changes into the database | |
SLEEP_TIME=30s | |
BBOX="-6.5,49.5,2.1,59.0" # United Kingdom | |
DBUSER=graham | |
DBNAME=osm_gb | |
WORKDIR_OSM=/home/osmdb | |
OSMOSIS_CHANGE_FILE=changes.osc.gz | |
OSMOSIS=/usr/local/bin/osmosis | |
OSM2PGSQL=/usr/bin/osm2pgsql | |
PID_FILE="/var/run/osmosis.pid" | |
SLEEP=/bin/sleep | |
#Update-Intervall is parameter 1 | |
if [ "$1" != "" ]; then | |
SLEEP_TIME=$1; | |
fi | |
if [ -e $PID_FILE ]; then | |
echo "Is already running"; | |
exit 1 | |
fi | |
echo $$ > $PID_FILE | |
echo "Change file is "$WORKDIR_OSM/$OSMOSIS_CHANGE_FILE | |
while [ 0 ]; do | |
date | |
time $OSMOSIS --read-replication-interval workingDirectory=$WORKDIR_OSM --simplify-change --write-xml-change $WORKDIR_OSM/$OSMOSIS_CHANGE_FILE | |
time $OSM2PGSQL --append -S default.style --slim --bbox $BBOX -U $DBUSER -d $DBNAME -C 8192 $WORKDIR_OSM/$OSMOSIS_CHANGE_FILE | |
echo "Sleeping for "$SLEEP_TIME | |
$SLEEP $SLEEP_TIME | |
echo "***********************************************" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment