Fix previous fix to preplot azimuth calculation.

Closes #58.
This commit is contained in:
D. Berge
2020-10-06 18:29:59 +02:00
parent 4b7f544e28
commit efc1711158

View File

@@ -13,20 +13,33 @@ async function list (projectId, opts = {}) {
WITH summary AS (
SELECT DISTINCT
line,
first_value(point) OVER w fsp,
last_value(point) OVER w lsp,
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,
ST_Azimuth(first_value(pp.geometry) OVER w, last_value(pp.geometry) over w)*180/pi() azimuth
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
CASE WHEN pl.incr THEN point END ASC,
CASE WHEN pl.incr THEN point END DESC
ORDER BY point ASC
ROWS BETWEEN
UNBOUNDED PRECEDING
AND UNBOUNDED FOLLOWING