commit 88f88fb5ed9468be45e520f9a64d31bf6f315d05 (tree)
parent 409b522f890deda24ef4ccd5347dfb72e4eb51ae
Author: Motiejus Jakštys <desired.mta@gmail.com>
Date: Sat, 26 Oct 2019 15:24:58 +0300
convert units, drop unneeded columns
Diffstat:
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/MTM/task4-straipsnis/init.sql b/MTM/task4-straipsnis/init.sql
@@ -15,7 +15,7 @@ CREATE TABLE airports (
tz TEXT,
type TEXT,
source TEXT,
- CONSTRAINT enforce_dims_geom CHECK (st_ndims(geom) = 2),
+ CONSTRAINT enforce_dims_geom CHECK (st_ndims(geom) = 3),
CONSTRAINT enforce_geotype_geom CHECK (geometrytype(geom) = 'POINT'::text OR geom IS NULL),
CONSTRAINT enforce_srid_geom CHECK (st_srid(geom) = 4326)
);
@@ -23,6 +23,12 @@ CREATE TABLE airports (
-- import data from airports.dat
\copy airports(gid, name, city, country, iata, icao, latitude, longitude, altitude, timezone, dst, tz, type, source) FROM 'airports.dat' DELIMITERS ',' CSV;
--- put lat/lon to the real GIS "geom" field
+-- put lat/lon/altitude to the "real" geom field
UPDATE airports
-SET geom = ST_SetSRID(ST_Point(longitude, latitude),4326);
+SET geom = ST_SetSRID(ST_MakePoint(longitude, latitude, altitude * 0.3048),4326);
+
+ALTER TABLE airports DROP COLUMN latitude;
+ALTER TABLE airports DROP COLUMN longitude;
+ALTER TABLE airports DROP COLUMN altitude;
+ALTER TABLE airports DROP COLUMN type;
+ALTER TABLE airports DROP COLUMN source;