feat(db): add :schema.vw_gtfs_stops_lt_0 view and corresponding table

This commit is contained in:
dancingCycle 2023-08-28 08:00:43 +02:00
parent c9e3a17f55
commit aabed958be
2 changed files with 23 additions and 19 deletions

View File

@ -23,4 +23,3 @@ SET
1
)
;

View File

@ -2,48 +2,53 @@
DROP SCHEMA IF EXISTS :schema CASCADE;
CREATE SCHEMA IF NOT EXISTS :schema;
SET search_path to :schema, public;
SET search_path to :schema, :schema_gtfs, public;
---get subset of stops in Germany and its states
---create views
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_lt_0 AS
SELECT * FROM :schema_gtfs.stops WHERE location_type=0;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de AS
SELECT * FROM :schema_gtfs.stops AS stops JOIN public.de_al2_w_ntags_smplcty10_20230818 AS de ON ST_Intersects(stops.the_geom, de.wkb_geometry) order by stop_id;
SELECT * FROM :schema.vw_gtfs_stops_lt_0 AS stops JOIN public.de_al2_w_ntags_smplcty10_20230818 AS de ON ST_Intersects(stops.the_geom, de.wkb_geometry) order by stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_hb AS
SELECT * FROM :schema_gtfs.stops AS stops JOIN public.de_hb_al4_w_ntags_smplcty10_20230818 AS de_hb ON ST_Intersects(stops.the_geom, de_hb.wkb_geometry) order by stop_id;
SELECT * FROM :schema.vw_gtfs_stops_lt_0 AS stops JOIN public.de_hb_al4_w_ntags_smplcty10_20230818 AS de_hb ON ST_Intersects(stops.the_geom, de_hb.wkb_geometry) order by stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_hh AS
SELECT * FROM :schema_gtfs.stops AS stops JOIN public.de_hh_al4_w_ntags_smplcty10_20230818 AS de_hh ON ST_Intersects(stops.the_geom, de_hh.wkb_geometry) order by stop_id;
SELECT * FROM :schema.vw_gtfs_stops_lt_0 AS stops JOIN public.de_hh_al4_w_ntags_smplcty10_20230818 AS de_hh ON ST_Intersects(stops.the_geom, de_hh.wkb_geometry) order by stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_ni AS
SELECT * FROM :schema_gtfs.stops AS stops JOIN public.de_ni_al4_w_ntags_smplcty10_20230818 AS de_ni ON ST_Intersects(stops.the_geom, de_ni.wkb_geometry) order by stop_id;
SELECT * FROM :schema.vw_gtfs_stops_lt_0 AS stops JOIN public.de_ni_al4_w_ntags_smplcty10_20230818 AS de_ni ON ST_Intersects(stops.the_geom, de_ni.wkb_geometry) order by stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_sh AS
SELECT * FROM :schema_gtfs.stops AS stops JOIN public.de_sh_al4_w_ntags_smplcty10_20230818 AS de_sh ON ST_Intersects(stops.the_geom, de_sh.wkb_geometry) order by stop_id;
SELECT * FROM :schema.vw_gtfs_stops_lt_0 AS stops JOIN public.de_sh_al4_w_ntags_smplcty10_20230818 AS de_sh ON ST_Intersects(stops.the_geom, de_sh.wkb_geometry) order by stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_mv AS
SELECT * FROM :schema_gtfs.stops AS stops JOIN public.de_mv_al4_w_ntags_smplcty10_20230818 AS de_mv ON ST_Intersects(stops.the_geom, de_mv.wkb_geometry) order by stop_id;
SELECT * FROM :schema.vw_gtfs_stops_lt_0 AS stops JOIN public.de_mv_al4_w_ntags_smplcty10_20230818 AS de_mv ON ST_Intersects(stops.the_geom, de_mv.wkb_geometry) order by stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_bb AS
SELECT * FROM :schema_gtfs.stops AS stops JOIN public.de_bb_al4_w_ntags_smplcty10_20230818 AS de_bb ON ST_Intersects(stops.the_geom, de_bb.wkb_geometry) order by stop_id;
SELECT * FROM :schema.vw_gtfs_stops_lt_0 AS stops JOIN public.de_bb_al4_w_ntags_smplcty10_20230818 AS de_bb ON ST_Intersects(stops.the_geom, de_bb.wkb_geometry) order by stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_st AS
SELECT * FROM :schema_gtfs.stops AS stops JOIN public.de_st_al4_w_ntags_smplcty10_20230818 AS de_st ON ST_Intersects(stops.the_geom, de_st.wkb_geometry) order by stop_id;
SELECT * FROM :schema.vw_gtfs_stops_lt_0 AS stops JOIN public.de_st_al4_w_ntags_smplcty10_20230818 AS de_st ON ST_Intersects(stops.the_geom, de_st.wkb_geometry) order by stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_be AS
SELECT * FROM :schema_gtfs.stops AS stops JOIN public.de_be_al4_w_ntags_smplcty10_20230818 AS de_be ON ST_Intersects(stops.the_geom, de_be.wkb_geometry) order by stop_id;
SELECT * FROM :schema.vw_gtfs_stops_lt_0 AS stops JOIN public.de_be_al4_w_ntags_smplcty10_20230818 AS de_be ON ST_Intersects(stops.the_geom, de_be.wkb_geometry) order by stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_nw AS
SELECT * FROM :schema_gtfs.stops AS stops JOIN public.de_nw_al4_w_ntags_smplcty10_20230818 AS de_nw ON ST_Intersects(stops.the_geom, de_nw.wkb_geometry) order by stop_id;
SELECT * FROM :schema.vw_gtfs_stops_lt_0 AS stops JOIN public.de_nw_al4_w_ntags_smplcty10_20230818 AS de_nw ON ST_Intersects(stops.the_geom, de_nw.wkb_geometry) order by stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_he AS
SELECT * FROM :schema_gtfs.stops AS stops JOIN public.de_he_al4_w_ntags_smplcty10_20230818 AS de_he ON ST_Intersects(stops.the_geom, de_he.wkb_geometry) order by stop_id;
SELECT * FROM :schema.vw_gtfs_stops_lt_0 AS stops JOIN public.de_he_al4_w_ntags_smplcty10_20230818 AS de_he ON ST_Intersects(stops.the_geom, de_he.wkb_geometry) order by stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_sn AS
SELECT * FROM :schema_gtfs.stops AS stops JOIN public.de_sn_al4_w_ntags_smplcty10_20230818 AS de_sn ON ST_Intersects(stops.the_geom, de_sn.wkb_geometry) order by stop_id;
SELECT * FROM :schema.vw_gtfs_stops_lt_0 AS stops JOIN public.de_sn_al4_w_ntags_smplcty10_20230818 AS de_sn ON ST_Intersects(stops.the_geom, de_sn.wkb_geometry) order by stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_th AS
SELECT * FROM :schema_gtfs.stops AS stops JOIN public.de_th_al4_w_ntags_smplcty10_20230818 AS de_th ON ST_Intersects(stops.the_geom, de_th.wkb_geometry) order by stop_id;
SELECT * FROM :schema.vw_gtfs_stops_lt_0 AS stops JOIN public.de_th_al4_w_ntags_smplcty10_20230818 AS de_th ON ST_Intersects(stops.the_geom, de_th.wkb_geometry) order by stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_rp AS
SELECT * FROM :schema_gtfs.stops AS stops JOIN public.de_rp_al4_w_ntags_smplcty10_20230818 AS de_rp ON ST_Intersects(stops.the_geom, de_rp.wkb_geometry) order by stop_id;
SELECT * FROM :schema.vw_gtfs_stops_lt_0 AS stops JOIN public.de_rp_al4_w_ntags_smplcty10_20230818 AS de_rp ON ST_Intersects(stops.the_geom, de_rp.wkb_geometry) order by stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_sl AS
SELECT * FROM :schema_gtfs.stops AS stops JOIN public.de_sl_al4_w_ntags_smplcty10_20230818 AS de_sl ON ST_Intersects(stops.the_geom, de_sl.wkb_geometry) order by stop_id;
SELECT * FROM :schema.vw_gtfs_stops_lt_0 AS stops JOIN public.de_sl_al4_w_ntags_smplcty10_20230818 AS de_sl ON ST_Intersects(stops.the_geom, de_sl.wkb_geometry) order by stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_by AS
SELECT * FROM :schema_gtfs.stops AS stops JOIN public.de_by_al4_w_ntags_smplcty10_20230818 AS de_by ON ST_Intersects(stops.the_geom, de_by.wkb_geometry) order by stop_id;
SELECT * FROM :schema.vw_gtfs_stops_lt_0 AS stops JOIN public.de_by_al4_w_ntags_smplcty10_20230818 AS de_by ON ST_Intersects(stops.the_geom, de_by.wkb_geometry) order by stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_bw AS
SELECT * FROM :schema_gtfs.stops AS stops JOIN public.de_bw_al4_w_ntags_smplcty10_20230818 AS de_bw ON ST_Intersects(stops.the_geom, de_bw.wkb_geometry) order by stop_id;
SELECT * FROM :schema.vw_gtfs_stops_lt_0 AS stops JOIN public.de_bw_al4_w_ntags_smplcty10_20230818 AS de_bw ON ST_Intersects(stops.the_geom, de_bw.wkb_geometry) order by stop_id;
---create tables
CREATE TABLE IF NOT EXISTS :schema.tbl_gtfs_stops_lt_0 AS SELECT stop_id,stop_name,stop_lat,stop_lon,the_geom FROM :schema.vw_gtfs_stops_lt_0;
CREATE TABLE IF NOT EXISTS :schema.tbl_gtfs_stops_de AS SELECT stop_id,stop_name,stop_lat,stop_lon,the_geom FROM :schema.vw_gtfs_stops_de;
CREATE TABLE IF NOT EXISTS :schema.tbl_gtfs_stops_de_hb AS SELECT stop_id,stop_name,stop_lat,stop_lon,the_geom FROM :schema.vw_gtfs_stops_de_hb;