From 84d77a61023ac69169416f3f97da848eed532074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Wed, 19 May 2021 22:57:46 +0300 Subject: [PATCH] less reliance on test tables --- tests.sql | 5 +++-- wm.sql | 8 +++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/tests.sql b/tests.sql index 15739b7..b02c8ab 100644 --- a/tests.sql +++ b/tests.sql @@ -104,7 +104,7 @@ declare vcrossings geometry[]; mutated boolean; begin - select (self_crossing((select ways from inflections where name='fig6'))).* into vcrossings, mutated; + select (self_crossing(array((select way from debug_wm where stage='cinflections' and dbgname='fig6')))).* into vcrossings, mutated; perform assert_equals(true, mutated); perform assert_equals( 'LINESTRING(84 47,91 59,114 64,120 45,125 39,141 39,147 32)', @@ -113,7 +113,7 @@ begin ) from (select unnest(vcrossings) way) a) ); - select (self_crossing((select ways from inflections where name='fig6-rev'))).* into vcrossings, mutated; + select (self_crossing(array((select way from debug_wm where stage='cinflections' and dbgname='fig6-rev')))).* into vcrossings, mutated; perform assert_equals(true, mutated); perform assert_equals( 'LINESTRING(84 47,91 59,114 64,120 45,125 39,141 39,147 32)', @@ -123,6 +123,7 @@ begin ); select (self_crossing((select ways from inflections where name='fig6-combi'))).* into vcrossings, mutated; + --select (self_crossing(array((select way from debug_wm where stage='cinflections' and dbgname='fig6-combi')))).* into vcrossings, mutated; perform assert_equals(true, mutated); perform assert_equals( 'LINESTRING(84 137,91 149,114 154,120 135,125 129,141 129,147 122,164 137,171 149,194 154,200 135,205 129,221 129,227 122)', diff --git a/wm.sql b/wm.sql index ec8b0c7..9a2fb56 100644 --- a/wm.sql +++ b/wm.sql @@ -98,15 +98,13 @@ drop function if exists fix_gentle_inflections1; create function fix_gentle_inflections1(INOUT bends geometry[]) as $$ declare pi constant real default radians(180); - small_angle real; + -- the threshold when the angle is still "small", so gentle inflections can + -- be joined + small_angle constant real default radians(30); ptail geometry; -- tail point of tail bend phead geometry[]; -- 3 tail points of head bend i int4; -- bends[i] is the current head begin - -- the threshold when the angle is still "small", so gentle inflections can - -- be joined - small_angle := radians(30); - for i in 2..array_length(bends, 1) loop -- Predicate: two bends will always share an edge. Assuming (A,B,C,D,E,F) -- is a bend: