From 2e5535e0bdd2ad0cc50f309823e2d41ff637c9bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Fri, 30 Apr 2021 15:25:53 +0300 Subject: [PATCH] wip elimination --- IV/tests-rivers.sql | 2 +- IV/tests.sql | 2 +- IV/wm.sql | 26 ++++++++++++++++++++++++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/IV/tests-rivers.sql b/IV/tests-rivers.sql index 4f0ce7b..c7c259f 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, name) from wm_rivers; +insert into wm_demo (name, way) select name, ST_SimplifyWM(way, 100, name) from wm_rivers; diff --git a/IV/tests.sql b/IV/tests.sql index a8cef4e..c0921b2 100644 --- a/IV/tests.sql +++ b/IV/tests.sql @@ -53,7 +53,7 @@ insert into wm_figures (name, way) values ('selfcrossing-1-rev',ST_Reverse(ST_Tr delete from wm_debug where name in (select distinct name from wm_figures); delete from wm_demo where name in (select distinct name from wm_figures); -insert into wm_demo (name, way) select name, ST_SimplifyWM(way, name) from wm_figures; +insert into wm_demo (name, way) select name, ST_SimplifyWM(way, null, name) from wm_figures; do $$ declare fig6b1 geometry; diff --git a/IV/wm.sql b/IV/wm.sql index e809f93..2c37564 100644 --- a/IV/wm.sql +++ b/IV/wm.sql @@ -482,9 +482,15 @@ $$ language plpgsql; -- ST_SimplifyWM simplifies a given geometry using Wang & Müller's -- "Line Generalization Based on Analysis of Shape Characteristics" algorithm, -- 1998. +-- Input parameters: +-- - geom: ST_LineString or ST_MultiLineString: the geometry to be simplified +-- - diameter: the diameter of a half-circle, whose area is an approximate +-- threshold for small bend elimination. If bend's area is larger than that, +-- the bend will be left alone. drop function if exists ST_SimplifyWM; create function ST_SimplifyWM( geom geometry, + diameter float, dbgname text default null ) returns geometry as $$ declare @@ -541,9 +547,25 @@ begin continue; end if; - -- self-crossing mutations are done, calculate bend properties - bend_attrs = array((select bend_attrs(bends, dbgname))); + --select * from elimination(bends, diameter) into bends, mutated; + --if dbgname is not null then + -- insert into wm_debug(stage, name, gen, nbend, way) values( + -- 'eelimination', + -- dbgname, + -- stagenum, + -- generate_subscripts(bends, 1), + -- unnest(bends) + -- ); + --end if; + + --if mutated then + -- lines[i] = st_linemerge(st_union(bends)); + -- stagenum = stagenum + 1; + -- continue; + --end if; + + bend_attrs = array((select bend_attrs(bends, dbgname))); perform isolated_bends(bend_attrs, dbgname); end loop;