mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 11:57:08 +00:00
Add planner elements to DB schema
This commit is contained in:
@@ -1150,6 +1150,56 @@ refer to that view for more details. Note that the set of missing shots may not
|
||||
coincide betwen raw and final data, due to edits on the final dataset.';
|
||||
|
||||
|
||||
--
|
||||
-- Name: planned_lines; Type: TABLE; Schema: _SURVEY__TEMPLATE_; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE _SURVEY__TEMPLATE_.planned_lines (
|
||||
sequence integer NOT NULL,
|
||||
line integer NOT NULL,
|
||||
fsp integer NOT NULL,
|
||||
lsp integer NOT NULL,
|
||||
ts0 timestamp with time zone NOT NULL,
|
||||
ts1 timestamp with time zone NOT NULL,
|
||||
name text NOT NULL,
|
||||
remarks text DEFAULT ''::text NOT NULL,
|
||||
meta jsonb DEFAULT '{}'::jsonb NOT NULL,
|
||||
class character(1) DEFAULT 'V'::bpchar NOT NULL
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE _SURVEY__TEMPLATE_.planned_lines OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- Name: planned_lines_summary; Type: VIEW; Schema: _SURVEY__TEMPLATE_; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE VIEW _SURVEY__TEMPLATE_.planned_lines_summary AS
|
||||
SELECT pl.sequence,
|
||||
pl.line,
|
||||
pl.fsp,
|
||||
pl.lsp,
|
||||
pl.ts0,
|
||||
pl.ts1,
|
||||
pl.name,
|
||||
pl.remarks,
|
||||
pl.meta,
|
||||
pl.class,
|
||||
( SELECT count(*) AS count
|
||||
FROM _SURVEY__TEMPLATE_.preplot_points pp_1
|
||||
WHERE ((pp_1.line = pl.line) AND (pp_1.class = pl.class) AND (((pp_1.point >= pl.fsp) AND (pp_1.point <= pl.lsp)) OR ((pp_1.point >= pl.lsp) AND (pp_1.point <= pl.fsp))))) AS num_points,
|
||||
(pl.ts1 - pl.ts0) AS duration,
|
||||
public.st_distance(pp0.geometry, pp1.geometry) AS length,
|
||||
((public.st_azimuth(pp0.geometry, pp1.geometry) * (180.0)::double precision) / pi()) AS azimuth,
|
||||
(public.st_transform(public.st_makeline(pp0.geometry, pp1.geometry), 4326))::jsonb AS geometry
|
||||
FROM (((_SURVEY__TEMPLATE_.planned_lines pl
|
||||
JOIN _SURVEY__TEMPLATE_.preplot_points pp0 ON (((pl.line = pp0.line) AND (pl.fsp = pp0.point) AND (pl.class = pp0.class))))
|
||||
JOIN _SURVEY__TEMPLATE_.preplot_points pp1 ON (((pl.line = pp1.line) AND (pl.lsp = pp1.point) AND (pl.class = pp1.class))))
|
||||
JOIN _SURVEY__TEMPLATE_.preplot_points pp ON (((pl.line = pp.line) AND (((pp.point >= pl.fsp) AND (pp.point <= pl.fsp)) OR ((pp.point >= pl.fsp) AND (pp.point <= pl.fsp))) AND (pl.class = pp.class))));
|
||||
|
||||
|
||||
ALTER TABLE _SURVEY__TEMPLATE_.planned_lines_summary OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- Name: preplot_lines_summary; Type: VIEW; Schema: _SURVEY__TEMPLATE_; Owner: postgres
|
||||
--
|
||||
@@ -1593,6 +1643,22 @@ ALTER TABLE ONLY _SURVEY__TEMPLATE_.labels
|
||||
ADD CONSTRAINT labels_pkey PRIMARY KEY (name);
|
||||
|
||||
|
||||
--
|
||||
-- Name: planned_lines planned_lines_name_key; Type: CONSTRAINT; Schema: _SURVEY__TEMPLATE_; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY _SURVEY__TEMPLATE_.planned_lines
|
||||
ADD CONSTRAINT planned_lines_name_key UNIQUE (name);
|
||||
|
||||
|
||||
--
|
||||
-- Name: planned_lines planned_lines_pkey; Type: CONSTRAINT; Schema: _SURVEY__TEMPLATE_; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY _SURVEY__TEMPLATE_.planned_lines
|
||||
ADD CONSTRAINT planned_lines_pkey PRIMARY KEY (sequence);
|
||||
|
||||
|
||||
--
|
||||
-- Name: preplot_lines preplot_lines_pkey; Type: CONSTRAINT; Schema: _SURVEY__TEMPLATE_; Owner: postgres
|
||||
--
|
||||
@@ -1696,6 +1762,13 @@ CREATE TRIGGER final_shots_qc_tg AFTER INSERT OR DELETE OR UPDATE ON _SURVEY__TE
|
||||
CREATE TRIGGER final_shots_tg AFTER INSERT OR DELETE OR UPDATE ON _SURVEY__TEMPLATE_.final_shots FOR EACH STATEMENT EXECUTE FUNCTION public.notify('final_shots');
|
||||
|
||||
|
||||
--
|
||||
-- Name: planned_lines planned_lines_tg; Type: TRIGGER; Schema: _SURVEY__TEMPLATE_; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TRIGGER planned_lines_tg AFTER INSERT OR DELETE OR UPDATE ON _SURVEY__TEMPLATE_.planned_lines FOR EACH STATEMENT EXECUTE FUNCTION public.notify('planned_lines');
|
||||
|
||||
|
||||
--
|
||||
-- Name: preplot_lines preplot_lines_tg; Type: TRIGGER; Schema: _SURVEY__TEMPLATE_; Owner: postgres
|
||||
--
|
||||
@@ -1812,6 +1885,30 @@ ALTER TABLE ONLY _SURVEY__TEMPLATE_.final_shots
|
||||
ADD CONSTRAINT final_shots_hash_fkey FOREIGN KEY (hash, sequence) REFERENCES _SURVEY__TEMPLATE_.final_lines_files(hash, sequence) ON UPDATE CASCADE ON DELETE CASCADE;
|
||||
|
||||
|
||||
--
|
||||
-- Name: planned_lines planned_lines_line_class_fkey; Type: FK CONSTRAINT; Schema: _SURVEY__TEMPLATE_; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY _SURVEY__TEMPLATE_.planned_lines
|
||||
ADD CONSTRAINT planned_lines_line_class_fkey FOREIGN KEY (line, class) REFERENCES _SURVEY__TEMPLATE_.preplot_lines(line, class) ON UPDATE CASCADE ON DELETE CASCADE;
|
||||
|
||||
|
||||
--
|
||||
-- Name: planned_lines planned_lines_line_fsp_class_fkey; Type: FK CONSTRAINT; Schema: _SURVEY__TEMPLATE_; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY _SURVEY__TEMPLATE_.planned_lines
|
||||
ADD CONSTRAINT planned_lines_line_fsp_class_fkey FOREIGN KEY (line, fsp, class) REFERENCES _SURVEY__TEMPLATE_.preplot_points(line, point, class) ON UPDATE CASCADE ON DELETE CASCADE;
|
||||
|
||||
|
||||
--
|
||||
-- Name: planned_lines planned_lines_line_lsp_class_fkey; Type: FK CONSTRAINT; Schema: _SURVEY__TEMPLATE_; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY _SURVEY__TEMPLATE_.planned_lines
|
||||
ADD CONSTRAINT planned_lines_line_lsp_class_fkey FOREIGN KEY (line, lsp, class) REFERENCES _SURVEY__TEMPLATE_.preplot_points(line, point, class) ON UPDATE CASCADE ON DELETE CASCADE;
|
||||
|
||||
|
||||
--
|
||||
-- Name: preplot_lines preplot_lines_hash_fkey; Type: FK CONSTRAINT; Schema: _SURVEY__TEMPLATE_; Owner: postgres
|
||||
--
|
||||
|
||||
Reference in New Issue
Block a user