osm-rvb/db/import-osm-into-db.sh

34 lines
913 B
Bash

#!/bin/bash
#
echo "Started..."
#Started...
#
# special variable $# is the number of arguments
if [ $# -lt 2 ] ; then
echo 'Call ./<script> <db name> <db user>'
exit 1
fi
#
DB_NAME="$1"
echo "DB_NAME: $DB_NAME"
DB_USER="$2"
echo "DB_USER: $DB_USER"
#
#delete all rows of the given table is faster with 'TRUNCATE' than with 'DELETE'
psql -c 'TRUNCATE planet_osm_line, planet_osm_point, planet_osm_polygon, planet_osm_roads;' -d $DB_NAME -U $DB_USER
#
#
#-d: database
#-C: size in MB for caching nodes
#-s: store temporary data in the database //TODO Why?
#-x: include attributes //TODO Why?
#-a: update existing osm2pgsql database with data from file //TODO Why? The db is cleaned in advance!
#-S: location of the style file
~/git/osm2pgsql/build/osm2pgsql -d $DB_NAME -U $DB_USER /tmp/niedersachsen-latest.osm.pbf -S ./osm-rvb.style
#
#-d: database
reindexdb -d $DB_NAME -U $DB_USER
#
echo "Done."
#done.