From 4b7f544e286ca41b861835ed88d1ab7cbe16d373 Mon Sep 17 00:00:00 2001 From: "D. Berge" Date: Tue, 6 Oct 2020 16:39:07 +0200 Subject: [PATCH] Order preplot points according to `incr` flag. Fixes #58. --- lib/www/server/lib/db/line/list.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/www/server/lib/db/line/list.js b/lib/www/server/lib/db/line/list.js index 10635d0..fdf21b4 100644 --- a/lib/www/server/lib/db/line/list.js +++ b/lib/www/server/lib/db/line/list.js @@ -17,13 +17,16 @@ async function list (projectId, opts = {}) { last_value(point) OVER w lsp, count(point) OVER w num_points, -- ST_MakeLine(first_value(geometry) OVER w, last_value(geometry) over w) geometry, - ST_Distance(first_value(geometry) OVER w, last_value(geometry) over w) length, - ST_Azimuth(first_value(geometry) OVER w, last_value(geometry) over w)*180/pi() azimuth + ST_Distance(first_value(pp.geometry) OVER w, last_value(pp.geometry) over w) length, + ST_Azimuth(first_value(pp.geometry) OVER w, last_value(pp.geometry) over w)*180/pi() azimuth FROM preplot_points pp - WHERE class = 'V' + INNER JOIN preplot_lines pl USING (line) + WHERE pp.class = 'V' WINDOW w AS ( PARTITION BY line - ORDER BY point + ORDER BY + CASE WHEN pl.incr THEN point END ASC, + CASE WHEN pl.incr THEN point END DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING