2022-04-08 04:49:39 -04:00
|
|
|
|
#!/usr/bin/env bash
|
2022-04-08 07:17:53 -04:00
|
|
|
|
|
2022-04-08 10:15:39 -04:00
|
|
|
|
## Comments:
|
|
|
|
|
## Is dynamics_has_demolished_buildings = TRUE sufficient to prevent buildings being loaded? - No
|
|
|
|
|
## Lets mark them, then see if there even are any
|
|
|
|
|
## Describe these changes in PR and ask for comment if the bool is sufficient
|
|
|
|
|
|
2022-04-08 07:17:53 -04:00
|
|
|
|
## Prerequisites:
|
|
|
|
|
## - Make geometries table have coordinates (load_coordinates.sh) - DONE
|
|
|
|
|
## - <mastermap download>= release_geometries
|
2022-04-08 04:49:39 -04:00
|
|
|
|
|
2022-04-08 06:13:03 -04:00
|
|
|
|
# for geometry in geometries
|
|
|
|
|
|
2022-04-08 04:49:39 -04:00
|
|
|
|
# if geometry.TOID not in builings
|
2022-04-08 06:13:03 -04:00
|
|
|
|
# Add TOID to temp table called new_geometries
|
2022-04-08 10:51:52 -04:00
|
|
|
|
|
2022-04-11 05:18:54 -04:00
|
|
|
|
psql -c "CREATE TABLE new_geometries (
|
|
|
|
|
geometry_id serial PRIMARY KEY,
|
|
|
|
|
source_id varchar(30),
|
|
|
|
|
geometry_geom geometry(GEOMETRY, 3857),
|
|
|
|
|
longitude float,
|
|
|
|
|
latitude float
|
|
|
|
|
);"
|
|
|
|
|
psql -c "INSERT INTO new_geometries *
|
|
|
|
|
SELECT *
|
2022-04-11 05:11:13 -04:00
|
|
|
|
FROM geometries
|
|
|
|
|
WHERE source_id NOT IN ( SELECT ref_toid FROM buildings);"
|
2022-04-08 06:13:03 -04:00
|
|
|
|
|
|
|
|
|
# for building in buildings
|
2022-04-08 04:49:39 -04:00
|
|
|
|
|
2022-04-08 10:51:52 -04:00
|
|
|
|
# if building.TOID not in new release_geometries
|
2022-04-08 06:13:03 -04:00
|
|
|
|
# buildings.dynamics_has_demolished_buildings = TRUE
|
|
|
|
|
|
|
|
|
|
# secondarily, if building.coordinates <10m away from any new_geometry.coordinates
|
|
|
|
|
# older_building.dynamics_has_demolished_buildings = TRUE
|
2022-04-08 10:15:39 -04:00
|
|
|
|
# link new_geometry TOID in the geometries table to old building and delete duplicate building we just created for new_geometry
|