From 69008a26f2b85ee8a56d42c902c2aa73faa90c68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Sat, 1 May 2021 16:20:01 +0300 Subject: [PATCH] better wm_debug --- IV/tests-rivers.sql | 2 +- IV/wm.sql | 34 ++++++++++++++++------------------ 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/IV/tests-rivers.sql b/IV/tests-rivers.sql index c7c259f..7144b27 100644 --- a/IV/tests-rivers.sql +++ b/IV/tests-rivers.sql @@ -109,4 +109,4 @@ end $$ language plpgsql; delete from wm_debug where name in (select distinct name from wm_rivers); delete from wm_demo where name in (select distinct name from wm_rivers); -insert into wm_demo (name, way) select name, ST_SimplifyWM(way, 100, name) from wm_rivers; +insert into wm_demo (name, way) select name, ST_SimplifyWM(way, 2000, name) from wm_rivers; diff --git a/IV/wm.sql b/IV/wm.sql index dde5c27..85a6e5d 100644 --- a/IV/wm.sql +++ b/IV/wm.sql @@ -260,6 +260,8 @@ $$ language plpgsql; drop function if exists wm_self_crossing; create function wm_self_crossing( INOUT bends geometry[], + dbgname text default null, + dbggen integer default null, OUT mutated boolean ) as $$ declare @@ -313,6 +315,16 @@ begin continue bendloop; end loop; end loop; + + if dbgname is not null then + insert into wm_debug(stage, name, gen, nbend, way) values( + 'dcrossings', + dbgname, + dbggen, + generate_subscripts(bends, 1), + unnest(bends) + ); + end if; end $$ language plpgsql; @@ -599,12 +611,7 @@ begin while mutated loop if dbgname is not null then insert into wm_debug (stage, name, gen, nbend, way) values( - 'afigures', - dbgname, - gen, - i, - lines[i] - ); + 'afigures', dbgname, gen, i, lines[i]); end if; bends = wm_detect_bends(lines[i], dbgname, gen); @@ -612,16 +619,6 @@ begin select * from wm_self_crossing(bends) into bends, mutated; - if dbgname is not null then - insert into wm_debug(stage, name, gen, nbend, way) values( - 'dcrossings', - dbgname, - gen, - generate_subscripts(bends, 1), - unnest(bends) - ); - end if; - if mutated then lines[i] = st_linemerge(st_union(bends)); gen = gen + 1; @@ -632,7 +629,6 @@ begin select * from wm_elimination( bendattrs, dhalfcircle, dbgname, gen) into bendattrs, mutated; - if mutated then for j in 1..array_length(bendattrs, 1) loop bends[j] = bendattrs[j].bend; @@ -642,7 +638,9 @@ begin continue; end if; - perform wm_isolated_bends(bendattrs, dbgname, gen); + -- code to detect isolated bends is there, but bend exaggeration + -- is not implemented. + --perform wm_isolated_bends(bendattrs, dbgname, gen); end loop; end loop;