From 7f5c3506ec461f4a4744ecb06705b0d1342ca01a Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Fri, 8 Apr 2022 11:56:07 +0100 Subject: [PATCH] add lat/lon coords geometries --- etl/load_coordinates.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/etl/load_coordinates.sh b/etl/load_coordinates.sh index 33a6ecfa..42634485 100644 --- a/etl/load_coordinates.sh +++ b/etl/load_coordinates.sh @@ -7,7 +7,9 @@ opentoid_dir=$1 +# Move this to 001.core.up.sql if needed, or otherwise delete as temp table echo "Creating table for open_toid coordinates..." +psql -c "DROP TABLE IF EXISTS open_toid" psql -c "CREATE TABLE open_toid ( toid varchar, version_number float, @@ -31,4 +33,17 @@ psql -c "UPDATE buildings location_longitude = open_toid.longitude FROM open_toid WHERE open_toid.toid = buildings.ref_toid +;" + +# Add these columns here rather than in 001.core.up.sql for legacy reasons +psql -c "ALTER TABLE geometries + ADD longitude float + ADD latitude float;" + +echo "Updating the geometries table with coordinates..." +psql -c "UPDATE geometries + SET latitude = open_toid.latitude, + longitude = open_toid.longitude + FROM open_toid + WHERE open_toid.toid = geometries.source_id ;" \ No newline at end of file