Skip to content

Commit c3e755e

Browse files
Merge pull request #357 from rustprooflabs/track-input-file
Track `--input-file` when used
2 parents b5a70e9 + 4601d37 commit c3e755e

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

db/deploy/osm_pgosm_flex.sql

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ CREATE TABLE IF NOT EXISTS {schema_name}.pgosm_flex (
1414
"language" text NOT NULL,
1515
import_mode JSONB NULL,
1616
import_status TEXT NOT NULL DEFAULT 'Initializing',
17+
input_file TEXT NULL,
1718
CONSTRAINT pk_osm_pgosm_flex PRIMARY KEY (id)
1819
);
1920

@@ -36,6 +37,9 @@ ALTER TABLE {schema_name}.pgosm_flex
3637
ALTER TABLE {schema_name}.pgosm_flex
3738
ADD COLUMN IF NOT EXISTS layerset TEXT NULL;
3839

40+
ALTER TABLE {schema_name}.pgosm_flex
41+
ADD COLUMN IF NOT EXISTS input_file TEXT NULL;
42+
3943
ALTER TABLE {schema_name}.pgosm_flex DROP COLUMN IF EXISTS project_url;
4044
ALTER TABLE {schema_name}.pgosm_flex DROP COLUMN IF EXISTS default_date;
4145

@@ -46,10 +50,12 @@ COMMENT ON COLUMN {schema_name}.pgosm_flex.osm_date IS 'Indicates the date of th
4650
COMMENT ON COLUMN {schema_name}.pgosm_flex.srid IS 'SRID of imported data.';
4751
COMMENT ON COLUMN {schema_name}.pgosm_flex.pgosm_flex_version IS 'Version of PgOSM-Flex used to generate schema.';
4852
COMMENT ON COLUMN {schema_name}.pgosm_flex.osm2pgsql_version IS 'Version of osm2pgsql used to load data.';
49-
COMMENT ON COLUMN {schema_name}.pgosm_flex.region IS 'Region specified at run time via env var PGOSM_REGION.';
53+
COMMENT ON COLUMN {schema_name}.pgosm_flex.region IS 'Region specified at run time via --region and --subregion values. When using --input-file without region/subregion, this defaults to the input filename.';
5054
COMMENT ON COLUMN {schema_name}.pgosm_flex.language IS 'Preferred language specified at run time via env var PGOSM_LANGUAGE. Empty string when not defined.';
5155
COMMENT ON COLUMN {schema_name}.pgosm_flex.layerset IS 'PgOSM Flex layerset used for the import style.';
5256
COMMENT ON COLUMN {schema_name}.pgosm_flex.import_status IS 'Status of the import. Starts as initialized, tracks status during imports and final success/failure.';
57+
COMMENT ON COLUMN {schema_name}.pgosm_flex.input_file IS 'Tracks explicit file defined when --input-file is used. NULL when --input-file not used.';
58+
5359

5460

5561
COMMIT;

docker/db.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def prepare_pgosm_db(skip_qgis_style, db_path, import_mode, schema_name):
237237

238238

239239
def start_import(pgosm_region, pgosm_date, srid, language, layerset, git_info,
240-
osm2pgsql_version, import_mode, schema_name):
240+
osm2pgsql_version, import_mode, schema_name, input_file):
241241
"""Creates record in osm.pgosm_flex table.
242242
243243
Parameters
@@ -251,6 +251,7 @@ def start_import(pgosm_region, pgosm_date, srid, language, layerset, git_info,
251251
osm2pgsql_version : str
252252
import_mode : import_mode.ImportMode
253253
schema_name : str
254+
input_file : str
254255
255256
Returns
256257
----------------------------
@@ -260,16 +261,18 @@ def start_import(pgosm_region, pgosm_date, srid, language, layerset, git_info,
260261
params = {'pgosm_region': pgosm_region, 'pgosm_date': pgosm_date,
261262
'srid': srid, 'language': language, 'layerset': layerset,
262263
'git_info': git_info, 'osm2pgsql_version': osm2pgsql_version,
263-
'import_mode': import_mode.as_json()}
264+
'import_mode': import_mode.as_json(),
265+
'input_file': input_file}
264266

265267
sql_raw = """
266268
INSERT INTO {schema_name}.pgosm_flex
267269
(osm_date, region, pgosm_flex_version, srid,
268270
osm2pgsql_version, "language", import_mode,
269-
layerset)
271+
layerset, input_file)
270272
VALUES(%(pgosm_date)s, %(pgosm_region)s, %(git_info)s, %(srid)s,
271273
%(osm2pgsql_version)s,
272-
COALESCE(%(language)s, ''), %(import_mode)s, %(layerset)s
274+
COALESCE(%(language)s, ''), %(import_mode)s, %(layerset)s,
275+
%(input_file)s
273276
)
274277
RETURNING id
275278
;

docker/pgosm_flex.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ def run_pgosm_flex(ram, region, subregion, debug, force,
151151
git_info=helpers.get_git_info(),
152152
osm2pgsql_version=vers_lines,
153153
import_mode=import_mode,
154-
schema_name=schema_name)
154+
schema_name=schema_name,
155+
input_file=input_file)
155156

156157
logger.info(f'Started import id {import_id}')
157158

0 commit comments

Comments
 (0)