kopia lustrzana https://github.com/kartoza/docker-osm
Added logic to check if the geojson should be used if it exist or not, added martin to server vector tiles from the DB
rodzic
9c04f18a1f
commit
d5991bb1e1
|
@ -6,15 +6,37 @@ version: '2.1'
|
|||
|
||||
services:
|
||||
qgisserver:
|
||||
image: kartoza/qgis-server:2.18
|
||||
image: camptocamp/qgis-server:3.6
|
||||
hostname: dockerosm_qgisserver
|
||||
container_name: dockerosm_qgisserver
|
||||
environment:
|
||||
- QGIS_PROJECT_FILE=/project/project.qgs
|
||||
- GIS_SERVER_LOG_LEVEL=DEBUG
|
||||
- MAX_REQUESTS_PER_PROCESS=100
|
||||
volumes:
|
||||
- ./logs:/var/log/apache2
|
||||
- ./web:/project
|
||||
- ./settings:/web/settings
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
links:
|
||||
- db:db
|
||||
ports:
|
||||
- 8198:80
|
||||
restart: unless-stopped
|
||||
restart: on-failure
|
||||
|
||||
# Server vector tiles from PostgreSQL DB
|
||||
martin:
|
||||
image: urbica/martin
|
||||
hostname: dockerosm_martin
|
||||
container_name: dockerosm_martin
|
||||
restart: on-failure
|
||||
ports:
|
||||
- 3000:3000
|
||||
environment:
|
||||
- WATCH_MODE=true
|
||||
- DATABASE_URL=postgres://docker:docker@db/gis
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
|
|
|
@ -48,6 +48,7 @@ class Importer(object):
|
|||
'DBSCHEMA_PRODUCTION': 'public',
|
||||
'DBSCHEMA_IMPORT': 'import',
|
||||
'DBSCHEMA_BACKUP': 'backup',
|
||||
'CLIP': 'no',
|
||||
'QGIS_STYLE': 'yes'
|
||||
}
|
||||
self.osm_file = None
|
||||
|
@ -85,7 +86,12 @@ class Importer(object):
|
|||
self.error(msg)
|
||||
else:
|
||||
self.info('Detect SRID: ' + self.default['SRID'])
|
||||
|
||||
# Check valid CLIP.
|
||||
if self.default['CLIP'] not in ['yes', 'no']:
|
||||
msg = 'CLIP not supported : %s' % self.default['CLIP']
|
||||
self.error(msg)
|
||||
else:
|
||||
self.info('Clip: ' + self.default['CLIP'])
|
||||
# Check valid QGIS_STYLE.
|
||||
if self.default['QGIS_STYLE'] not in ['yes', 'no']:
|
||||
msg = 'QGIS_STYLE not supported : %s' % self.default['QGIS_STYLE']
|
||||
|
@ -156,6 +162,14 @@ class Importer(object):
|
|||
else:
|
||||
self.info('Not using QGIS default styles.')
|
||||
|
||||
if not self.clip_json_file and self.default['CLIP'] == 'yes':
|
||||
msg = 'clip.geojson is missing and CLIP = yes.'
|
||||
self.error(msg)
|
||||
elif self.clip_json_file and self.default['QGIS_STYLE']:
|
||||
self.info('Geojson for clipping: ' + self.clip_json_file)
|
||||
else:
|
||||
self.info('No *.geojson detected, so no clipping.')
|
||||
|
||||
# In docker-compose, we should wait for the DB is ready.
|
||||
self.info('The checkup is OK.')
|
||||
|
||||
|
@ -225,17 +239,24 @@ class Importer(object):
|
|||
|
||||
if osm_tables != 1:
|
||||
# It means that the DB is empty. Let's import the PBF file.
|
||||
self._first_pbf_import()
|
||||
|
||||
if self.clip_json_file:
|
||||
self._first_pbf_import(['-limitto', self.clip_json_file])
|
||||
else:
|
||||
self._first_pbf_import([])
|
||||
else:
|
||||
self.info(
|
||||
'The database is not empty. Let\'s import only diff files.')
|
||||
|
||||
if self.default['TIME'] != '0':
|
||||
self._import_diff()
|
||||
if self.clip_json_file:
|
||||
self._import_diff(['-limitto', self.clip_json_file])
|
||||
else:
|
||||
self._import_diff([])
|
||||
else:
|
||||
self.info('No more update to the database. Leaving.')
|
||||
|
||||
def _first_pbf_import(self):
|
||||
def _first_pbf_import(self, args):
|
||||
"""Run the first PBF import into the database."""
|
||||
command = ['imposm', 'import', '-diff', '-deployproduction']
|
||||
command += ['-overwritecache', '-cachedir', self.default['CACHE']]
|
||||
|
@ -247,10 +268,10 @@ class Importer(object):
|
|||
command += ['-diffdir', self.default['SETTINGS']]
|
||||
command += ['-mapping', self.mapping_file]
|
||||
command += ['-read', self.osm_file]
|
||||
command += ['-limitto', self.clip_json_file]
|
||||
command += ['-write', '-connection', self.postgis_uri]
|
||||
self.info('The database is empty. Let\'s import the PBF : %s' % self.osm_file)
|
||||
self.info(' '.join(command))
|
||||
|
||||
self.info(command.extend(args))
|
||||
if not call(command) == 0:
|
||||
msg = 'An error occured in imposm with the original file.'
|
||||
self.error(msg)
|
||||
|
@ -267,7 +288,7 @@ class Importer(object):
|
|||
if self.qgis_style:
|
||||
self.import_qgis_styles()
|
||||
|
||||
def _import_diff(self):
|
||||
def _import_diff(self, args):
|
||||
# Finally launch the listening process.
|
||||
while True:
|
||||
import_queue = sorted(listdir(self.default['IMPORT_QUEUE']))
|
||||
|
@ -286,7 +307,7 @@ class Importer(object):
|
|||
command += ['-connection', self.postgis_uri]
|
||||
command += [join(self.default['IMPORT_QUEUE'], diff)]
|
||||
|
||||
self.info(' '.join(command))
|
||||
self.info(command.extend(args))
|
||||
|
||||
if call(command) == 0:
|
||||
move(
|
||||
|
|
Ładowanie…
Reference in New Issue