mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 12:17:08 +00:00
Report on virgin points and points to be acquired.
Virgin points are those that have not been acquired (and processed) at least once. Points to be acquired are virgin points that do not have the `ntba` flag set.
This commit is contained in:
@@ -10,44 +10,23 @@ async function list (projectId, opts = {}) {
|
||||
const limit = Math.abs(Number(opts.itemsPerPage)) || null;
|
||||
|
||||
const text = `
|
||||
WITH summary AS (
|
||||
SELECT DISTINCT
|
||||
line,
|
||||
CASE
|
||||
WHEN pl.incr THEN
|
||||
first_value(point) OVER w
|
||||
ELSE
|
||||
last_value(point) OVER w
|
||||
END fsp,
|
||||
CASE
|
||||
WHEN pl.incr THEN
|
||||
last_value(point) OVER w
|
||||
ELSE
|
||||
first_value(point) OVER w
|
||||
END lsp,
|
||||
count(point) OVER w num_points,
|
||||
-- ST_MakeLine(first_value(geometry) OVER w, last_value(geometry) over w) geometry,
|
||||
ST_Distance(first_value(pp.geometry) OVER w, last_value(pp.geometry) over w) length,
|
||||
CASE
|
||||
WHEN pl.incr THEN
|
||||
ST_Azimuth(first_value(pp.geometry) OVER w, last_value(pp.geometry) over w)*180/pi()
|
||||
ELSE
|
||||
ST_Azimuth(last_value(pp.geometry) OVER w, first_value(pp.geometry) over w)*180/pi()
|
||||
END azimuth
|
||||
FROM preplot_points pp
|
||||
INNER JOIN preplot_lines pl USING (line)
|
||||
WHERE pp.class = 'V'
|
||||
WINDOW w AS (
|
||||
PARTITION BY line
|
||||
ORDER BY point ASC
|
||||
ROWS BETWEEN
|
||||
UNBOUNDED PRECEDING
|
||||
AND UNBOUNDED FOLLOWING
|
||||
)
|
||||
WITH counts AS (
|
||||
SELECT pls.*, COALESCE(ppc.virgin, 0) na, COALESCE(ppc.tba, 0) tba
|
||||
FROM preplot_lines_summary pls
|
||||
LEFT JOIN (
|
||||
SELECT line, COUNT(*) virgin, COUNT(NULLIF(ntba,true)) tba
|
||||
FROM preplot_points_count pc
|
||||
INNER JOIN preplot_points pp
|
||||
USING (line, point)
|
||||
WHERE pc.count = 0
|
||||
GROUP BY line
|
||||
) ppc
|
||||
USING (line)
|
||||
)
|
||||
SELECT s.*, incr, remarks, pl.ntba, pl.meta
|
||||
FROM summary s
|
||||
SELECT s.*, pl.ntba, c.na, c.tba, pl.meta
|
||||
FROM preplot_lines_summary s
|
||||
INNER JOIN preplot_lines pl ON pl.class = 'V' AND s.line = pl.line
|
||||
LEFT JOIN counts c ON s.line = c.line
|
||||
ORDER BY ${sortKey} ${sortDir}
|
||||
OFFSET $1
|
||||
LIMIT $2;
|
||||
|
||||
Reference in New Issue
Block a user