stud

study spacejunk
Log | Files | Refs | LICENSE

commit 733c7f409a2bd3db5733b50820b7c83977fef900 (tree)
parent 5cb3f6aea61bb80c63fc6a1d5241e0f897673036
Author: Motiejus Jakštys <motiejus@uber.com>
Date:   Fri, 26 Feb 2021 10:41:38 +0200

debugging inflections

Diffstat:
MIV/tests.sql | 2+-
MIV/wm.sql | 4+++-
2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/IV/tests.sql b/IV/tests.sql @@ -48,6 +48,6 @@ begin drop table if exists inflections; create table inflections (way geometry); --insert into inflections select unnest(fix_gentle_inflections(vbends)); - select fix_gentle_inflections(vbends); + insert into inflections select unnest(fix_gentle_inflections(vbends)); end $$ language plpgsql; diff --git a/IV/wm.sql b/IV/wm.sql @@ -76,11 +76,13 @@ $$ language plpgsql; -- commulative inflection angle small (see variable below). create or replace function fix_gentle_inflections(INOUT bends geometry[]) as $$ declare + pi real; small_angle real; phead geometry; -- head point of head bend ptail geometry[]; -- 3 head points of tail bend i int4; -- bends[i] is the current head begin + pi = radians(180); -- the threshold when the angle is still "small", so gentle inflections can -- be joined small_angle := radians(30); @@ -116,7 +118,7 @@ begin select geom from st_dumppoints(bends[i]) order by path[1] desc limit 1 into phead; while true loop -- copy last 3 points of bends[i-1] (tail) to ptail - select array_agg(geom) from st_dumppoints(bends[i-1]) order by path[1] desc limit 3 into ptail; + select array(select geom from st_dumppoints(bends[i-1]) order by path[1] desc limit 3) into ptail; -- if inflection angle between ptail[1:3] "large", stop processing this bend if abs(st_angle(ptail[1], ptail[2], ptail[2], ptail[3]) - pi) > small_angle then