From 733c7f409a2bd3db5733b50820b7c83977fef900 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Fri, 26 Feb 2021 10:41:38 +0200 Subject: [PATCH] debugging inflections --- IV/tests.sql | 2 +- IV/wm.sql | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/IV/tests.sql b/IV/tests.sql index 1f13350..311477b 100644 --- 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 index 1f3fe5d..c9d798e 100644 --- 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