From 54633d9e0480c602a381dd8fb23356e3fee3b474 Mon Sep 17 00:00:00 2001 From: Tom Russell Date: Sun, 9 Sep 2018 11:32:27 +0100 Subject: [PATCH] Create building-per-geometry --- etl/1_load_geometries.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/etl/1_load_geometries.py b/etl/1_load_geometries.py index b5a074df..93ac196d 100644 --- a/etl/1_load_geometries.py +++ b/etl/1_load_geometries.py @@ -5,6 +5,11 @@ doc: {source_id: }, geom: } + - create corresponding 'building' record with { + id: , + doc: {}, + geom_id: + } """ import glob import json @@ -55,6 +60,7 @@ def save_feature(cur, feature): %s::jsonb, ST_SetSRID(%s::geometry, %s) ) + RETURNING geometry_id """, ( json.dumps({ 'source_id': feature['properties']['fid'] @@ -63,6 +69,23 @@ def save_feature(cur, feature): 3857 ) ) + geom_id, = cur.fetchone() + cur.execute( + """INSERT INTO buildings + ( + building_doc, + geometry_id + ) + VALUES + ( + %s::jsonb, + %s + ) + """, ( + json.dumps({}), + geom_id + ) + ) def read_config(config_path):