convert units, drop unneeded columns

This commit is contained in:
Motiejus Jakštys 2019-10-26 15:24:58 +03:00
parent 409b522f89
commit 88f88fb5ed

View File

@ -15,7 +15,7 @@ CREATE TABLE airports (
tz TEXT, tz TEXT,
type TEXT, type TEXT,
source 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_geotype_geom CHECK (geometrytype(geom) = 'POINT'::text OR geom IS NULL),
CONSTRAINT enforce_srid_geom CHECK (st_srid(geom) = 4326) CONSTRAINT enforce_srid_geom CHECK (st_srid(geom) = 4326)
); );
@ -23,6 +23,12 @@ CREATE TABLE airports (
-- import data from airports.dat -- 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; \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 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;