2018-10-02 16:12:46 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
#
|
2018-10-21 15:47:31 -04:00
|
|
|
# Extract, transform and load building outlines and property records
|
2018-10-02 16:12:46 -04:00
|
|
|
#
|
2022-03-18 07:07:15 -04:00
|
|
|
: ${1?"Usage: $0 ./path/to/mastermap/dir ./path/to/boundary"}
|
|
|
|
: ${2?"Usage: $0 ./path/to/mastermap/dir ./path/to/boundary"}
|
2018-10-02 16:12:46 -04:00
|
|
|
|
2022-03-18 07:07:15 -04:00
|
|
|
mastermap_dir=$1
|
|
|
|
boundary_file=$2
|
2018-10-02 16:12:46 -04:00
|
|
|
script_dir=${0%/*}
|
|
|
|
|
2018-10-21 15:47:31 -04:00
|
|
|
#
|
|
|
|
# Process
|
|
|
|
#
|
|
|
|
|
2018-10-02 16:12:46 -04:00
|
|
|
# extract both datasets
|
2018-10-04 14:01:40 -04:00
|
|
|
$script_dir/extract_mastermap.sh $mastermap_dir
|
2018-10-02 16:12:46 -04:00
|
|
|
# filter mastermap ('building' polygons and any others referenced by addressbase)
|
2022-03-18 07:07:15 -04:00
|
|
|
$script_dir/filter_transform_mastermap_for_loading.sh $mastermap_dir
|
2018-10-04 14:01:40 -04:00
|
|
|
|
2018-10-21 15:47:31 -04:00
|
|
|
#
|
|
|
|
# Load
|
|
|
|
#
|
|
|
|
|
2018-10-02 16:12:46 -04:00
|
|
|
# load all building outlines
|
|
|
|
$script_dir/load_geometries.sh $mastermap_dir
|
|
|
|
# index geometries (should be faster after loading)
|
|
|
|
psql < $script_dir/../migrations/002.index-geometries.up.sql
|
2018-10-04 14:01:40 -04:00
|
|
|
$script_dir/drop_outside_limit.sh $boundary_file
|
2018-10-02 16:12:46 -04:00
|
|
|
# create a building record per outline
|
|
|
|
$script_dir/create_building_records.sh
|
2022-03-18 07:07:15 -04:00
|
|
|
# Run remaining migrations
|
|
|
|
ls $script_dir/../migrations/*.up.sql 2>/dev/null | while read -r migration; do psql < $migration; done;
|