wip elimination

This commit is contained in:
Motiejus Jakštys 2021-05-19 22:57:49 +03:00 committed by Motiejus Jakštys
parent 51919df86e
commit 077738c28c
3 changed files with 26 additions and 4 deletions

View File

@ -109,4 +109,4 @@ end $$ language plpgsql;
delete from wm_debug where name in (select distinct name from wm_rivers); 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); 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;

View File

@ -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_debug where name in (select distinct name from wm_figures);
delete from wm_demo 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 $$ do $$
declare fig6b1 geometry; declare fig6b1 geometry;

26
wm.sql
View File

@ -482,9 +482,15 @@ $$ language plpgsql;
-- ST_SimplifyWM simplifies a given geometry using Wang & Müller's -- ST_SimplifyWM simplifies a given geometry using Wang & Müller's
-- "Line Generalization Based on Analysis of Shape Characteristics" algorithm, -- "Line Generalization Based on Analysis of Shape Characteristics" algorithm,
-- 1998. -- 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; drop function if exists ST_SimplifyWM;
create function ST_SimplifyWM( create function ST_SimplifyWM(
geom geometry, geom geometry,
diameter float,
dbgname text default null dbgname text default null
) returns geometry as $$ ) returns geometry as $$
declare declare
@ -541,9 +547,25 @@ begin
continue; continue;
end if; end if;
-- self-crossing mutations are done, calculate bend properties --select * from elimination(bends, diameter) into bends, mutated;
bend_attrs = array((select bend_attrs(bends, dbgname)));
--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); perform isolated_bends(bend_attrs, dbgname);
end loop; end loop;