add SQL script and QGIS styling

pull/24/head
Etienne Trimaille 2015-12-22 13:45:54 +01:00
rodzic 0e82a6188b
commit c27a7e066f
4 zmienionych plików z 1465 dodań i 7 usunięć

Wyświetl plik

@ -12,6 +12,7 @@ storage:
#- ./cache:/home/cache
db:
# About the postgresql version, it should match in the dockerfile of docker-imposm3
image: kartoza/postgis:9.4-2.1
hostname: db
environment:
@ -30,7 +31,7 @@ imposm:
- PASSWORD=docker
- PORT=5432
- HOST=db
- DATEBASE=gis
- DATABASE=gis
# seconds between 2 executions of the script
- TIME=120
# folder for settings (with *.json and *.sql)
@ -51,6 +52,8 @@ imposm:
- DBSCHEMA_IMPORT=import
# http://imposm.org/docs/imposm3/latest/tutorial.html#deploy-production-tables
- DBSCHEMA_BACKUP=backup
# Install some styles if you are using the default mapping. It can be 'yes' or 'no'
- QGIS_STYLE=yes
osmupdate:

Wyświetl plik

@ -3,7 +3,7 @@ MAINTAINER Etienne Trimaille <etienne@kartoza.com>
RUN apt-get update && apt-get install -y python-pip \
libprotobuf-dev libleveldb-dev libgeos-dev \
libpq-dev python-dev \
libpq-dev python-dev postgresql-client-9.4 \
--no-install-recommends
RUN ln -s /usr/lib/libgeos_c.so /usr/lib/libgeos.so

Wyświetl plik

@ -44,7 +44,8 @@ default = {
'OPTIMIZE': 'false',
'DBSCHEMA_PRODUCTION': 'public',
'DBSCHEMA_IMPORT': 'import',
'DBSCHEMA_BACKUP': 'backup'
'DBSCHEMA_BACKUP': 'backup',
'QGIS_STYLE': 'yes'
}
# Check if we overwrite default values.
@ -54,7 +55,12 @@ for key in environ.keys():
# Check valid SRID.
if default['SRID'] not in ['4326', '3857']:
print >> stderr, 'SRID not supported : %s' % default['srid']
print >> stderr, 'SRID not supported : %s' % default['SRID']
exit()
# Check valid QGIS_STYLE.
if default['QGIS_STYLE'] not in ['yes', 'no']:
print >> stderr, 'QGIS_STYLE not supported : %s' % default['QGIS_STYLE']
exit()
# Check folders.
@ -73,6 +79,7 @@ for folder in folders:
osm_file = None
mapping_file = None
post_import_file = None
qgis_style = None
for f in listdir(default['SETTINGS']):
if f.endswith('.pbf'):
@ -81,9 +88,12 @@ for f in listdir(default['SETTINGS']):
if f.endswith('.json'):
mapping_file = join(default['SETTINGS'], f)
if f.endswith('.sql'):
if f == 'post-pbf-import.sql':
post_import_file = join(default['SETTINGS'], f)
if f == 'qgis_style.sql':
qgis_style = join(default['SETTINGS'], f)
if not osm_file:
print >> stderr, 'OSM file *.pbf is missing in %s' % default['SETTINGS']
exit()
@ -97,6 +107,14 @@ if not post_import_file:
else:
print '%s detected for post import.' % post_import_file
if not qgis_style and default['QGIS_STYLE'] == 'yes':
print >> stderr, 'qgis_style.sql is missing in %s and QGIS_STYLE = yes.' % default['SETTINGS']
exit()
elif qgis_style and default['QGIS_STYLE']:
print '%s detected for QGIS styling.' % qgis_style
else:
print 'Not using QGIS default styles.'
# In docker-compose, we should wait for the DB is ready.
print 'The checkup is OK. The container will continue soon, after the database.'
sleep(45)
@ -150,9 +168,27 @@ if osm_tables < 1:
else:
print 'Import PBF successful : %s' % osm_file
if post_import_file or qgis_style:
# Set the password for psql
environ['PGPASSWORD'] = default['PASSWORD']
if post_import_file:
for sql in open(post_import_file):
cursor.execute(sql)
print 'Running the post import SQL file.'
command = ['psql']
command += ['-h', default['HOST']]
command += ['-U', default['USER']]
command += ['-d', default['DATABASE']]
command += ['-f', post_import_file]
call(command)
if qgis_style:
'Installing QGIS styles.'
command = ['psql']
command += ['-h', default['HOST']]
command += ['-U', default['USER']]
command += ['-d', default['DATABASE']]
command += ['-f', qgis_style]
call(command)
else:
print 'The database is not empty. Let\'s import only diff files.'

Plik diff jest za duży Load Diff