merge osm_pbf into settings

pull/11/head
Etienne Trimaille 2015-07-31 10:43:29 +02:00
rodzic c8a4e47312
commit 5227a13a20
6 zmienionych plików z 27 dodań i 38 usunięć

6
.gitignore vendored
Wyświetl plik

@ -1,6 +1,6 @@
.idea .idea
*.*~ *.*~
osm_pbf/*.pbf settings/*.pbf
osm_pbf/*.state.txt settings/*.state.txt
osm_pbf/*.poly settings/*.poly
settings/last.state.txt settings/last.state.txt

Wyświetl plik

@ -3,7 +3,6 @@ storage:
hostname: storage hostname: storage
volumes: volumes:
# These are sharable to other containers # These are sharable to other containers
- ./osm_pbf:/home/osm_pbf
- ./settings:/home/settings - ./settings:/home/settings
- /home/import_done - /home/import_done
- /home/import_queue - /home/import_queue

Wyświetl plik

@ -41,7 +41,6 @@ default = {
'PORT': '5432', 'PORT': '5432',
'SETTINGS': 'settings', 'SETTINGS': 'settings',
'CACHE': 'cache', 'CACHE': 'cache',
'OSM_PBF': 'osm_pbf',
'IMPORT_DONE': 'import_done', 'IMPORT_DONE': 'import_done',
'IMPORT_QUEUE': 'import_queue', 'IMPORT_QUEUE': 'import_queue',
'SRID': '4326', 'SRID': '4326',
@ -52,7 +51,6 @@ default = {
} }
# Check if we overwrite default values. # Check if we overwrite default values.
# env = [var.lower() for var in environ]
for key in default.keys(): for key in default.keys():
if key in environ: if key in environ:
default[key] = environ[key] default[key] = environ[key]
@ -82,7 +80,7 @@ postgis_uri = 'postgis://%s:%s@%s/%s' % (
default['DATABASE']) default['DATABASE'])
# Check folders. # Check folders.
folders = ['IMPORT_QUEUE', 'IMPORT_DONE', 'OSM_PBF', 'SETTINGS', 'CACHE'] folders = ['IMPORT_QUEUE', 'IMPORT_DONE', 'SETTINGS', 'CACHE']
for folder in folders: for folder in folders:
if not isabs(default[folder]): if not isabs(default[folder]):
# Get the absolute path. # Get the absolute path.
@ -98,28 +96,27 @@ state_file = None
osm_file = None osm_file = None
mapping_file = None mapping_file = None
post_import_file = None post_import_file = None
for f in listdir(default['OSM_PBF']): for f in listdir(default['SETTINGS']):
if f.endswith('.state.txt'): if f.endswith('.state.txt'):
state_file = join(default['OSM_PBF'], f) state_file = join(default['SETTINGS'], f)
if f.endswith('.pbf'): if f.endswith('.pbf'):
osm_file = join(default['OSM_PBF'], f) osm_file = join(default['SETTINGS'], f)
if not osm_file:
print >> stderr, 'OSM file *.pbf is missing in %s' % default['OSM_PBF']
exit()
if not state_file:
print >> stderr, 'State file *.state.txt is missing in %s' % default['OSM_PBF']
exit()
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.endswith('.sql'):
post_import_file = join(default['SETTINGS'], f) post_import_file = join(default['SETTINGS'], f)
if not osm_file:
print >> stderr, 'OSM file *.pbf is missing in %s' % default['SETTINGS']
exit()
if not state_file:
print >> stderr, 'State file *.state.txt is missing in %s' % default['SETTINGS']
exit()
if not mapping_file: if not mapping_file:
print >> stderr, 'Mapping file *.json is missing in %s' % default['SETTINGS'] print >> stderr, 'Mapping file *.json is missing in %s' % default['SETTINGS']
exit() exit()

Wyświetl plik

@ -39,7 +39,7 @@ default = {
'BASE_URL': 'http://planet.openstreetmap.org/replication/', 'BASE_URL': 'http://planet.openstreetmap.org/replication/',
'IMPORT_QUEUE': 'import_queue', 'IMPORT_QUEUE': 'import_queue',
'IMPORT_DONE': 'import_done', 'IMPORT_DONE': 'import_done',
'OSM_PBF': 'osm_pbf', 'SETTINGS': 'settings',
'TIME': 120, 'TIME': 120,
} }
@ -48,7 +48,7 @@ for key in default.keys():
default[key] = environ[key] default[key] = environ[key]
# Folders # Folders
folders = ['IMPORT_QUEUE', 'IMPORT_DONE', 'OSM_PBF'] folders = ['IMPORT_QUEUE', 'IMPORT_DONE', 'SETTINGS']
for folder in folders: for folder in folders:
if not isabs(default[folder]): if not isabs(default[folder]):
# Get the absolute path. # Get the absolute path.
@ -63,26 +63,26 @@ for folder in folders:
state_file = None state_file = None
osm_file = None osm_file = None
poly_file = None poly_file = None
for f in listdir(default['OSM_PBF']): for f in listdir(default['SETTINGS']):
if f.endswith('.state.txt'): if f.endswith('.state.txt'):
state_file = join(default['OSM_PBF'], f) state_file = join(default['SETTINGS'], f)
if f.endswith('.pbf'): if f.endswith('.pbf'):
osm_file = join(default['OSM_PBF'], f) osm_file = join(default['SETTINGS'], f)
if f.endswith('.poly'): if f.endswith('.poly'):
poly_file = join(default['OSM_PBF'], f) poly_file = join(default['SETTINGS'], f)
if not state_file: if not state_file:
print >> stderr, 'State file *.state.txt is missing in %s' % default['OSM_PBF'] print >> stderr, 'State file *.state.txt is missing in %s' % default['SETTINGS']
exit() exit()
if not osm_file: if not osm_file:
print >> stderr, 'OSM file *.osm.pbf is missing in %s' % default['OSM_PBF'] print >> stderr, 'OSM file *.osm.pbf is missing in %s' % default['SETTINGS']
exit() exit()
if not poly_file: if not poly_file:
print 'No *.poly detected in %s' % default['OSM_PBF'] print 'No *.poly detected in %s' % default['SETTINGS']
else: else:
print '%s detected for clipping.' % poly_file print '%s detected for clipping.' % poly_file

Wyświetl plik

@ -41,15 +41,15 @@ if url:
print 'state : ' + state print 'state : ' + state
print 'Downloading PBF' print 'Downloading PBF'
commands = ['wget', '-c', '-O', 'osm_pbf/country.pbf', pbf_file] commands = ['wget', '-c', '-O', 'settings/country.pbf', pbf_file]
call(commands) call(commands)
print 'Downloading polygon' print 'Downloading polygon'
commands = ['wget', '-c', '-O', 'osm_pbf/country.poly', poly_file] commands = ['wget', '-c', '-O', 'settings/country.poly', poly_file]
call(commands) call(commands)
print 'Downloading state' print 'Downloading state'
commands = ['wget', '-c', '-O', 'osm_pbf/country.state.txt', state] commands = ['wget', '-c', '-O', 'settings/country.state.txt', state]
call(commands) call(commands)
else: else:

Wyświetl plik

@ -1,7 +0,0 @@
This folder should contain a json file for the mapping. You can also put a
SQL file, it will be executed after the PBF import.
Optionally you can include a .poly file (see http://wiki.openstreetmap.org/wiki/Osmosis/Polygon_Filter_File_Format)
in this directory, which will be used as the clip extents for diffs. The
base name of the .poly file is not important - the first .poly file encountered
in this folder will be used.