forked from OSGeo/OSGeoLive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
load_postgis.sh
executable file
·127 lines (102 loc) · 3.91 KB
/
load_postgis.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/sh
# Copyright (c) 2009 Mark Leslie
# Copyright (c) 2009-2022 The Open Source Geospatial Foundation and others.
# Licensed under the GNU LGPL version >= 2.1.
#
# This library is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 2.1 of the License,
# or any later version. This library is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY, without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details, either
# in the "LICENSE.LGPL.txt" file distributed with this software or at
# web page "http://www.fsf.org/licenses/lgpl.html".
#
# About:
# =====
# This script will is to be run after the installation of postgresql
# and postgis. It will download, validate and load a simple dataset.
#
# Authors:
# =======
# Alex Mandel <[email protected]>
# Brian Hamlin <maplabs-at-light42-dot-com>
# Hamish Bowman <hamish_b yahoo com>
# Mark Leslie <[email protected]>
#
./diskspace_probe.sh "`basename $0`" begin
BUILD_DIR=`pwd`
####
if [ -z "$USER_NAME" ] ; then
USER_NAME="user"
fi
POSTGRES_USER="$USER_NAME"
TMP_DIR="/tmp/build_postgis"
if [ ! -d "$TMP_DIR" ] ; then
mkdir "$TMP_DIR"
fi
cd "$TMP_DIR"
### download data
## May12 - standardize data file name
## July10 - rely on a reference download of OSM data
## provided by ** install_osm.sh **, instead of getting it here
## File name will change from time to time.
#CITY=""
OSM_FILE="/usr/local/share/data/osm/feature_city.osm.bz2"
# download package is not versioned so we really shouldn't use "wget -c"
#wget -c --progress=dot:mega "$URL_BASE/$DL_FILE"
# -O used to enable auto-overwrite
#wget -nv "$URL_BASE/$DL_FILE.sha1" -O "$DL_FILE.sha1"
#sha1sum --check "$DL_FILE.sha1"
#if [ $? -ne 0 ] ; then
# echo "ERROR: checksum failed on download"
# exit 1
#fi
### create DB and populate it
### PostGIS 2.0 no longer needs a template, use the extension mechanism instead
sudo -u $POSTGRES_USER createdb osm_local
sudo -u $POSTGRES_USER psql osm_local -c 'create extension postgis;'
# Kosmo, gpsdrive, please update your API calls ....
#cp "$BUILD_DIR"/../app-conf/postgis/legacy*.sql \
# /usr/share/postgresql/9.5/contrib/postgis-2.2/
#
#sed -i -e 's/postgis-2.0/postgis-2.2/' \
# /usr/share/postgresql/9.5/contrib/postgis-2.2/legacy*.sql
#
#sudo -u $POSTGRES_USER psql osm_local \
# -f /usr/share/postgresql/9.5/contrib/postgis-2.2/legacy_minimal.sql
#sudo -u $POSTGRES_USER createdb osm_local_smerc
#sudo -u $POSTGRES_USER psql osm_local_smerc -c 'create extension postgis;'
#sudo -u $POSTGRES_USER psql osm_local_smerc \
# -f /usr/share/postgresql/9.3/contrib/postgis-2.1/legacy_minimal.sql
# v3 - simplified the script, was too hard to debug with all the commands
# attempting to be piped continuously with each other
#bzip2 -d "$DL_FILE"
#sed -i "s/mleslie/$POSTGRES_USER/g" `basename $DL_FILE .bz2`
# use the psql --quiet flag!
#sudo -u $POSTGRES_USER psql --quiet -d denver -f `basename $DL_FILE .bz2`
## July10 -
## Now importing data from already downloaded sources (osm)
if [ ! -e "$OSM_FILE" ] ; then
echo "ERROR: $OSM_FILE sample data is not available"
exit 1
fi
# lat/lon
sudo -u $POSTGRES_USER osm2pgsql -U $POSTGRES_USER \
--database osm_local --latlong \
--style /usr/share/osm2pgsql/default.style \
"$OSM_FILE"
sudo -u $POSTGRES_USER psql osm_local \
--quiet -c "vacuum analyze"
# spherical merc
#sudo -u $POSTGRES_USER osm2pgsql -U $POSTGRES_USER \
# --database osm_local_smerc --merc \
# --style /usr/share/osm2pgsql/default.style \
# /usr/local/share/osm/$CITY.osm.bz2
#
#sudo -u $POSTGRES_USER psql osm_local_smerc \
# --quiet -c "vacuum analyze"
#Add additional data sources here, be sparing to minimize duplication of data.
####
"$BUILD_DIR"/diskspace_probe.sh "`basename $0`" end