70 lines
2.4 KiB
SQL
70 lines
2.4 KiB
SQL
select load_extension('mod_spatialite.so.8');
|
|
select InitSpatialMetadata(1);
|
|
|
|
begin transaction;
|
|
|
|
create table nexrad_radar (
|
|
id INTEGER PRIMARY KEY NOT NULL,
|
|
wban INTEGER,
|
|
call TEXT NOT NULL,
|
|
name TEXT NOT NULL,
|
|
site_elevation FLOAT NOT NULL,
|
|
tower_height FLOAT NOT NULL
|
|
);
|
|
|
|
select
|
|
AddGeometryColumn('nexrad_radar', 'coord', 4326, 'POINT', 'XY'),
|
|
CreateSpatialIndex('nexrad_radar', 'coord');
|
|
|
|
create table nexrad_storm_event (
|
|
id INTEGER PRIMARY KEY NOT NULL,
|
|
episode_id INTEGER,
|
|
timestamp_start TIMESTAMP NOT NULL,
|
|
timestamp_end TIMESTAMP NOT NULL,
|
|
state TEXT NOT NULL,
|
|
event_type TEXT NOT NULL,
|
|
wfo TEXT NOT NULL,
|
|
locale_start TEXT NOT NULL,
|
|
locale_end TEXT NOT NULL,
|
|
tornado_f_rating TEXT
|
|
);
|
|
|
|
create index nexrad_storm_event_episode_id_idx on nexrad_storm_event (episode_id);
|
|
create index nexrad_storm_event_event_type_idx on nexrad_storm_event (event_type);
|
|
create index nexrad_storm_event_wfo_idx on nexrad_storm_event (wfo);
|
|
create index nexrad_storm_event_timestamp_start_idx on nexrad_storm_event (timestamp_start);
|
|
create index nexrad_storm_event_timestamp_end_idx on nexrad_storm_event (timestamp_end);
|
|
|
|
select
|
|
AddGeometryColumn('nexrad_storm_event', 'coord_start', 4326, 'POINT', 'XY', 0),
|
|
CreateSpatialIndex('nexrad_storm_event', 'coord_start');
|
|
|
|
select
|
|
AddGeometryColumn('nexrad_storm_event', 'coord_end', 4326, 'POINT', 'XY', 0),
|
|
CreateSpatialIndex('nexrad_storm_event', 'coord_end');
|
|
|
|
create table nexrad_vtec_event (
|
|
id INTEGER PRIMARY KEY NOT NULL,
|
|
timestamp_issued TIMESTAMP NOT NULL,
|
|
timestamp_expired TIMESTAMP NOT NULL,
|
|
timestamp_init_iss TIMESTAMP NOT NULL,
|
|
timestamp_init_exp TIMESTAMP NOT NULL,
|
|
timestamp_updated TIMESTAMP NOT NULL,
|
|
timestamp_poly_start TIMESTAMP NOT NULL,
|
|
timestamp_poly_end TIMESTAMP NOT NULL,
|
|
event_id INTEGER,
|
|
status TEXT NOT NULL,
|
|
wfo TEXT NOT NULL,
|
|
sig TEXT NOT NULL,
|
|
phenom TEXT NOT NULL,
|
|
hail_size FLOAT,
|
|
wind_speed FLOAT,
|
|
tornado_tag TEXT,
|
|
damage_tag TEXT
|
|
);
|
|
|
|
select
|
|
AddGeometryColumn('nexrad_vtec_event', 'poly', 4326, 'POLYGON'),
|
|
CreateSpatialIndex('nexrad_vtec_event', 'poly');
|
|
|
|
commit;
|