add conversion to latlon step

This commit is contained in:
Ed Chalstrey 2022-04-01 16:50:15 +01:00
parent c1e51531f7
commit 5e89bc9dac

View File

@ -7,7 +7,10 @@
opentoid_dir=$1
echo "Create a temporary table for coordinates..."
echo "Converting OSGB36 Eastings and Northings to WGS84 longitude and latitude coordinates..."
python convert_opentoid_bng_latlon.py $opentoid_dir
echo "Creating a temporary table for coordinates..."
psql -c "CREATE TABLE open_toid (
toid varchar,
version_number smallint,
@ -15,20 +18,20 @@ psql -c "CREATE TABLE open_toid (
source_product varchar,
easting float,
northing float,
latitute float,
longitude float
longitude float,
latitute float
);"
echo "Loading Open TOID CSV(s) to temporary table..."
find $opentoid_dir -type f -name '*.csv' \
-printf "$opentoid_dir/%f\n" | \
parallel \
cat {} '|' psql -c "\"COPY open_toid ( toid, version_number, version_date, source_product, easting, northing ) FROM stdin WITH CSV HEADER;\""
cat {} '|' psql -c "\"COPY open_toid ( toid, version_number, version_date, source_product, easting, northing, longitude, latitute ) FROM stdin WITH CSV HEADER;\""
# Convert the northing/easting coordinates to latitude/longitute with PostGIS
psql -c "select AddGeometryColumn( 'public', 'open_toid', 'the_geom', 27700, 'POINT', 2);"
psql -c "update open_toid set the_geom=GeomFromText('POINT('||easting||' '||northing||')',27700);"
psql -c "update open_toid set longitude=st_x(st_transform(the_geom,4326)), latitude=st_y(st_transform(the_geom,4326));"
# psql -c "select AddGeometryColumn( 'public', 'open_toid', 'the_geom', 27700, 'POINT', 2);"
# psql -c "update open_toid set the_geom=GeomFromText('POINT('||easting||' '||northing||')',27700);"
# psql -c "update open_toid set longitude=st_x(st_transform(the_geom,4326)), latitude=st_y(st_transform(the_geom,4326));"
# Update the buildings table with coordinates
# psql -c ""