main
Motiejus Jakštys 2021-05-19 22:57:45 +03:00 committed by Motiejus Jakštys
parent cea1c6eb29
commit 4c6adcc71e
1 changed files with 11 additions and 11 deletions

22
wm.sql
View File

@ -21,22 +21,22 @@ begin
-- --
-- Given 3 vertices p1, p2, p3: -- Given 3 vertices p1, p2, p3:
-- --
-- p1___ ... -- p1___ ...
-- / -- /
-- ..._____/ -- ... _____/
-- p3 p2 -- p3 p2
-- --
-- This loop will use p1 as the head vertex, p2 will be the measured angle, -- When looping over the line, p1 will be head (lead) vertex, p2 will be the
-- and p3 will be trailing. The line that will be added to the bend will -- measured angle, and p3 will be trailing. The line that will be added to
-- always be [p3,p2]. -- the bend will always be [p3,p2].
-- So once the p1 becomes the last vertex, the loop terminates, and the -- So once the p1 becomes the last vertex, the loop terminates, and the
-- [p2,p1] line will not have a chance to be added. So the loop adds the last -- [p2,p1] line will not have a chance to be added. So the loop adds the last
-- vertex twice, so it has a chance to become p2, and be added to the bend. -- vertex twice, so it has a chance to become p2, and be added to the bend.
-- --
for p in ( for p in (
(select (dp).geom from st_dumppoints(line) as dp order by (dp).path[1] asc) (select geom from st_dumppoints(line) order by path[1] asc)
union all union all
(select (dp).geom from st_dumppoints(line) as dp order by (dp).path[1] desc limit 1) (select geom from st_dumppoints(line) order by path[1] desc limit 1)
) loop ) loop
p3 = p2; p3 = p2;
p2 = p1; p2 = p1;
@ -61,8 +61,8 @@ begin
prev_sign = cur_sign; prev_sign = cur_sign;
end loop; end loop;
-- the last bend may be lost if there is no "final" inflection angle. Add it. -- the last line may be lost if there is no "final" inflection angle. Add it.
if (select count(1) from ((select st_dumppoints(bend) as a)) b) >= 2 then if (select count(1) >= 2 from st_dumppoints(bend)) then
bends = bends || bend; bends = bends || bend;
end if; end if;
end end