From 76086150b8a85fc6b8c59c65a64ff8a93d09fab7 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Fri, 8 Apr 2022 15:51:52 +0100 Subject: [PATCH] testing way to record new geometries --- etl/update_building_records.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/etl/update_building_records.sh b/etl/update_building_records.sh index fac45fd4..cf729ae3 100644 --- a/etl/update_building_records.sh +++ b/etl/update_building_records.sh @@ -13,12 +13,21 @@ # if geometry.TOID not in builings # Add TOID to temp table called new_geometries - # psql -c "INSERT INTO buildings ( geometry_id, ref_toid ) SELECT geometry_id, source_id from geometries;" + +psql -c "CREATE TABLE new_geometries ( + geometry_id serial PRIMARY KEY, + source_id varchar(30) +);" +psql -c "INSERT INTO buildings ( geometry_id, ref_toid ) + SELECT geometry_id, source_id + FROM geometries + ON CONFLICT ( ref_toid ) + DO UPDATE SET new_geometries.source_id=EXCLUDED.ref_toid +;" # for building in buildings - # if building.TOID not in new - # (need a table with all TOIDs in the new release, but not the old ones too, which geometires has) + # if building.TOID not in new release_geometries # buildings.dynamics_has_demolished_buildings = TRUE # secondarily, if building.coordinates <10m away from any new_geometry.coordinates