alt way to load geometries (untested)

This commit is contained in:
Ed Chalstrey 2022-04-08 11:33:30 +01:00
parent c42f5423b8
commit e83419cc3b

View File

@ -12,11 +12,21 @@ mastermap_dir=$1
# source_id: <toid>,
# geom: <geom>
echo "Creating temporary geometries table for input data..."
psql -c "CREATE TABLE IF NOT EXISTS release_geometries (
geometry_id serial PRIMARY KEY,
source_id varchar(30),
geometry_geom geometry(GEOMETRY, 3857)
);"
echo "Copy geometries to db..."
find $mastermap_dir -type f -name '*.3857.csv' \
-printf "$mastermap_dir/%f\n" | \
parallel \
cat {} '|' psql -c "\"COPY geometries ( geometry_geom, source_id ) FROM stdin WITH CSV HEADER;\""
cat {} '|' psql -c "\"COPY release_geometries ( geometry_geom, source_id ) FROM stdin WITH CSV HEADER;\""
# Copy release_geometries into existing geometries table
psql -c "INSERT INTO geometries SELECT * FROM release_geometries;"
# Delete any duplicated geometries (by TOID)
echo "Delete duplicate geometries..."