kopia lustrzana https://github.com/kartoza/docker-osm
add SQL script and QGIS styling
rodzic
0e82a6188b
commit
c27a7e066f
|
@ -12,6 +12,7 @@ storage:
|
||||||
#- ./cache:/home/cache
|
#- ./cache:/home/cache
|
||||||
|
|
||||||
db:
|
db:
|
||||||
|
# About the postgresql version, it should match in the dockerfile of docker-imposm3
|
||||||
image: kartoza/postgis:9.4-2.1
|
image: kartoza/postgis:9.4-2.1
|
||||||
hostname: db
|
hostname: db
|
||||||
environment:
|
environment:
|
||||||
|
@ -30,7 +31,7 @@ imposm:
|
||||||
- PASSWORD=docker
|
- PASSWORD=docker
|
||||||
- PORT=5432
|
- PORT=5432
|
||||||
- HOST=db
|
- HOST=db
|
||||||
- DATEBASE=gis
|
- DATABASE=gis
|
||||||
# seconds between 2 executions of the script
|
# seconds between 2 executions of the script
|
||||||
- TIME=120
|
- TIME=120
|
||||||
# folder for settings (with *.json and *.sql)
|
# folder for settings (with *.json and *.sql)
|
||||||
|
@ -51,6 +52,8 @@ imposm:
|
||||||
- DBSCHEMA_IMPORT=import
|
- DBSCHEMA_IMPORT=import
|
||||||
# http://imposm.org/docs/imposm3/latest/tutorial.html#deploy-production-tables
|
# http://imposm.org/docs/imposm3/latest/tutorial.html#deploy-production-tables
|
||||||
- DBSCHEMA_BACKUP=backup
|
- DBSCHEMA_BACKUP=backup
|
||||||
|
# Install some styles if you are using the default mapping. It can be 'yes' or 'no'
|
||||||
|
- QGIS_STYLE=yes
|
||||||
|
|
||||||
|
|
||||||
osmupdate:
|
osmupdate:
|
||||||
|
|
|
@ -3,7 +3,7 @@ MAINTAINER Etienne Trimaille <etienne@kartoza.com>
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y python-pip \
|
RUN apt-get update && apt-get install -y python-pip \
|
||||||
libprotobuf-dev libleveldb-dev libgeos-dev \
|
libprotobuf-dev libleveldb-dev libgeos-dev \
|
||||||
libpq-dev python-dev \
|
libpq-dev python-dev postgresql-client-9.4 \
|
||||||
--no-install-recommends
|
--no-install-recommends
|
||||||
|
|
||||||
RUN ln -s /usr/lib/libgeos_c.so /usr/lib/libgeos.so
|
RUN ln -s /usr/lib/libgeos_c.so /usr/lib/libgeos.so
|
||||||
|
|
|
@ -44,7 +44,8 @@ default = {
|
||||||
'OPTIMIZE': 'false',
|
'OPTIMIZE': 'false',
|
||||||
'DBSCHEMA_PRODUCTION': 'public',
|
'DBSCHEMA_PRODUCTION': 'public',
|
||||||
'DBSCHEMA_IMPORT': 'import',
|
'DBSCHEMA_IMPORT': 'import',
|
||||||
'DBSCHEMA_BACKUP': 'backup'
|
'DBSCHEMA_BACKUP': 'backup',
|
||||||
|
'QGIS_STYLE': 'yes'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if we overwrite default values.
|
# Check if we overwrite default values.
|
||||||
|
@ -54,7 +55,12 @@ for key in environ.keys():
|
||||||
|
|
||||||
# Check valid SRID.
|
# Check valid SRID.
|
||||||
if default['SRID'] not in ['4326', '3857']:
|
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()
|
exit()
|
||||||
|
|
||||||
# Check folders.
|
# Check folders.
|
||||||
|
@ -73,6 +79,7 @@ for folder in folders:
|
||||||
osm_file = None
|
osm_file = None
|
||||||
mapping_file = None
|
mapping_file = None
|
||||||
post_import_file = None
|
post_import_file = None
|
||||||
|
qgis_style = None
|
||||||
for f in listdir(default['SETTINGS']):
|
for f in listdir(default['SETTINGS']):
|
||||||
|
|
||||||
if f.endswith('.pbf'):
|
if f.endswith('.pbf'):
|
||||||
|
@ -81,9 +88,12 @@ for f in listdir(default['SETTINGS']):
|
||||||
if f.endswith('.json'):
|
if f.endswith('.json'):
|
||||||
mapping_file = join(default['SETTINGS'], f)
|
mapping_file = join(default['SETTINGS'], f)
|
||||||
|
|
||||||
if f.endswith('.sql'):
|
if f == 'post-pbf-import.sql':
|
||||||
post_import_file = join(default['SETTINGS'], f)
|
post_import_file = join(default['SETTINGS'], f)
|
||||||
|
|
||||||
|
if f == 'qgis_style.sql':
|
||||||
|
qgis_style = join(default['SETTINGS'], f)
|
||||||
|
|
||||||
if not osm_file:
|
if not osm_file:
|
||||||
print >> stderr, 'OSM file *.pbf is missing in %s' % default['SETTINGS']
|
print >> stderr, 'OSM file *.pbf is missing in %s' % default['SETTINGS']
|
||||||
exit()
|
exit()
|
||||||
|
@ -97,6 +107,14 @@ if not post_import_file:
|
||||||
else:
|
else:
|
||||||
print '%s detected for post import.' % post_import_file
|
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.
|
# In docker-compose, we should wait for the DB is ready.
|
||||||
print 'The checkup is OK. The container will continue soon, after the database.'
|
print 'The checkup is OK. The container will continue soon, after the database.'
|
||||||
sleep(45)
|
sleep(45)
|
||||||
|
@ -150,9 +168,27 @@ if osm_tables < 1:
|
||||||
else:
|
else:
|
||||||
print 'Import PBF successful : %s' % osm_file
|
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:
|
if post_import_file:
|
||||||
for sql in open(post_import_file):
|
print 'Running the post import SQL file.'
|
||||||
cursor.execute(sql)
|
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:
|
else:
|
||||||
print 'The database is not empty. Let\'s import only diff files.'
|
print 'The database is not empty. Let\'s import only diff files.'
|
||||||
|
|
||||||
|
|
Plik diff jest za duży
Load Diff
Ładowanie…
Reference in New Issue