mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 12:17:08 +00:00
Add views related to missing shots and outstanding production
This commit is contained in:
@@ -965,6 +965,40 @@ CREATE TABLE _SURVEY__TEMPLATE_.info (
|
||||
|
||||
ALTER TABLE _SURVEY__TEMPLATE_.info OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- Name: missing_final_points; Type: VIEW; Schema: _SURVEY__TEMPLATE_; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE VIEW _SURVEY__TEMPLATE_.missing_final_points AS
|
||||
SELECT DISTINCT psp.sailline,
|
||||
psp.sailline_ntba,
|
||||
psp.line,
|
||||
psp.point,
|
||||
psp.class,
|
||||
psp.ntba,
|
||||
psp.geometry,
|
||||
psp.meta
|
||||
FROM (survey_3.preplot_saillines_points psp
|
||||
LEFT JOIN ((survey_3.final_lines fl
|
||||
JOIN survey_3.raw_lines rl ON (((fl.sequence = rl.sequence) AND (NOT rl.ntbp))))
|
||||
JOIN survey_3.final_shots fs ON ((fl.sequence = fs.sequence))) ON (((psp.sailline = fl.line) AND (psp.point = fs.point))))
|
||||
WHERE (fl.sequence IS NULL);
|
||||
|
||||
|
||||
ALTER TABLE _SURVEY__TEMPLATE_.missing_final_points OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- Name: VIEW missing_final_points; Type: COMMENT; Schema: _SURVEY__TEMPLATE_; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON VIEW _SURVEY__TEMPLATE_.missing_final_points IS 'Return the set of points which have not yet been shot, or which have
|
||||
been shot only in sequences which have subsequently been marked as
|
||||
NTBP. Note that this includes lines and points which may have been
|
||||
marked as NTBA; we also return those but we report both the line
|
||||
and point NTBA attributes (via preplot_saillines_points.sailline_ntba
|
||||
and preplot_saillines_points.ntba, respectively).';
|
||||
|
||||
|
||||
--
|
||||
-- Name: preplot_lines; Type: TABLE; Schema: _SURVEY__TEMPLATE_; Owner: postgres
|
||||
--
|
||||
@@ -1009,6 +1043,136 @@ indicating the preplot type.
|
||||
COMMENT ON COLUMN _SURVEY__TEMPLATE_.preplot_lines.ntba IS 'Not to be acquired. A value of True causes this preplot not to be reported as a missed shot and not to be taken into account in completion stats.';
|
||||
|
||||
|
||||
--
|
||||
-- Name: preplot_saillines_points; Type: VIEW; Schema: _SURVEY__TEMPLATE_; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE VIEW _SURVEY__TEMPLATE_.preplot_saillines_points AS
|
||||
WITH fdd AS (
|
||||
SELECT pl.hash,
|
||||
pl.line,
|
||||
((pl.line)::numeric - ((fd.data -> 'saillineOffset'::text))::numeric) AS l0,
|
||||
((pl.line)::numeric + ((fd.data -> 'saillineOffset'::text))::numeric) AS l1
|
||||
FROM (_SURVEY__TEMPLATE_.preplot_lines pl
|
||||
JOIN _SURVEY__TEMPLATE_.file_data fd USING (hash))
|
||||
WHERE (fd.data ? 'saillineOffset'::text)
|
||||
)
|
||||
SELECT plv.line AS sailline,
|
||||
plv.ntba AS sailline_ntba,
|
||||
pps.line,
|
||||
pps.point,
|
||||
pps.class,
|
||||
pps.ntba,
|
||||
pps.geometry,
|
||||
pps.meta
|
||||
FROM ((fdd
|
||||
JOIN _SURVEY__TEMPLATE_.preplot_lines plv ON (((plv.class = 'V'::bpchar) AND (((plv.line)::numeric = fdd.l0) OR ((plv.line)::numeric = fdd.l1)))))
|
||||
JOIN _SURVEY__TEMPLATE_.preplot_points pps ON ((pps.line = fdd.line)));
|
||||
|
||||
|
||||
ALTER TABLE _SURVEY__TEMPLATE_.preplot_saillines_points OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- Name: VIEW preplot_saillines_points; Type: COMMENT; Schema: _SURVEY__TEMPLATE_; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON VIEW _SURVEY__TEMPLATE_.preplot_saillines_points IS 'Associate source preplot lines with their corresponding sail lines.
|
||||
This relies on the user having specified a "saillineOffset" value in
|
||||
the import configuration for the associated preplot file. We then try
|
||||
to match vessel lines by adding / subtracting this offset from our
|
||||
source line numbers. It is substandard but it will do for the time
|
||||
being. A better approach would be to explicitly import the sail lines,
|
||||
e.g., by adding a column to the source preplots file.';
|
||||
|
||||
|
||||
--
|
||||
-- Name: missing_sequence_final_points; Type: VIEW; Schema: _SURVEY__TEMPLATE_; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE VIEW _SURVEY__TEMPLATE_.missing_sequence_final_points AS
|
||||
WITH seqs AS (
|
||||
SELECT fl.sequence,
|
||||
fl.line AS sailline,
|
||||
min(fs_1.point) AS sp0,
|
||||
max(fs_1.point) AS sp1
|
||||
FROM (_SURVEY__TEMPLATE_.final_lines fl
|
||||
JOIN _SURVEY__TEMPLATE_.final_shots fs_1 USING (sequence))
|
||||
GROUP BY fl.sequence, fl.line
|
||||
)
|
||||
SELECT seqs.sequence,
|
||||
psp.sailline,
|
||||
psp.sailline_ntba,
|
||||
psp.line,
|
||||
psp.point,
|
||||
psp.class,
|
||||
psp.ntba,
|
||||
psp.geometry,
|
||||
psp.meta
|
||||
FROM ((_SURVEY__TEMPLATE_.preplot_saillines_points psp
|
||||
JOIN seqs USING (sailline))
|
||||
LEFT JOIN _SURVEY__TEMPLATE_.final_shots fs USING (sequence, point))
|
||||
WHERE ((((psp.point >= seqs.sp0) AND (psp.point <= seqs.sp1)) OR ((psp.point >= seqs.sp1) AND (psp.point <= seqs.sp0))) AND (fs.* IS NULL));
|
||||
|
||||
|
||||
ALTER TABLE _SURVEY__TEMPLATE_.missing_sequence_final_points OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- Name: VIEW missing_sequence_final_points; Type: COMMENT; Schema: _SURVEY__TEMPLATE_; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON VIEW _SURVEY__TEMPLATE_.missing_sequence_final_points IS 'Return sequence missing shots. These are the shots that would typically
|
||||
need to be reported as missing for a sequence. A point is missing from
|
||||
a sequence if it is between the first and last shot for that sequence
|
||||
but no final_shots point exists with that point number within that
|
||||
sequence.
|
||||
|
||||
Note that the shot may not be missing from the overall production as it
|
||||
might have been acquired in a later sequence.
|
||||
|
||||
Missing points are reported regardless of the underlying preplot NTBA
|
||||
status.';
|
||||
|
||||
|
||||
--
|
||||
-- Name: missing_sequence_raw_points; Type: VIEW; Schema: _SURVEY__TEMPLATE_; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE VIEW _SURVEY__TEMPLATE_.missing_sequence_raw_points AS
|
||||
WITH seqs AS (
|
||||
SELECT fl.sequence,
|
||||
fl.line AS sailline,
|
||||
min(fs_1.point) AS sp0,
|
||||
max(fs_1.point) AS sp1
|
||||
FROM (_SURVEY__TEMPLATE_.raw_lines fl
|
||||
JOIN _SURVEY__TEMPLATE_.raw_shots fs_1 USING (sequence))
|
||||
GROUP BY fl.sequence, fl.line
|
||||
)
|
||||
SELECT seqs.sequence,
|
||||
psp.sailline,
|
||||
psp.sailline_ntba,
|
||||
psp.line,
|
||||
psp.point,
|
||||
psp.class,
|
||||
psp.ntba,
|
||||
psp.geometry,
|
||||
psp.meta
|
||||
FROM ((_SURVEY__TEMPLATE_.preplot_saillines_points psp
|
||||
JOIN seqs USING (sailline))
|
||||
LEFT JOIN _SURVEY__TEMPLATE_.raw_shots fs USING (sequence, point))
|
||||
WHERE ((((psp.point >= seqs.sp0) AND (psp.point <= seqs.sp1)) OR ((psp.point >= seqs.sp1) AND (psp.point <= seqs.sp0))) AND (fs.* IS NULL));
|
||||
|
||||
|
||||
ALTER TABLE _SURVEY__TEMPLATE_.missing_sequence_raw_points OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- Name: VIEW missing_sequence_raw_points; Type: COMMENT; Schema: _SURVEY__TEMPLATE_; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON VIEW _SURVEY__TEMPLATE_.missing_sequence_raw_points IS 'Return sequence missing raw shots. Analogous to missing_sequence_final_points,
|
||||
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: preplot_lines_summary; Type: VIEW; Schema: _SURVEY__TEMPLATE_; Owner: postgres
|
||||
--
|
||||
|
||||
Reference in New Issue
Block a user