From 88f88fb5ed9468be45e520f9a64d31bf6f315d05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Sat, 26 Oct 2019 15:24:58 +0300 Subject: [PATCH] convert units, drop unneeded columns --- MTM/task4-straipsnis/init.sql | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/MTM/task4-straipsnis/init.sql b/MTM/task4-straipsnis/init.sql index a9211a6..f5734fd 100644 --- 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;