better wm_debug

This commit is contained in:
Motiejus Jakštys 2021-05-19 22:57:49 +03:00 committed by Motiejus Jakštys
parent e7fa3b695e
commit 4df7ab4784
2 changed files with 17 additions and 19 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, 100, name) from wm_rivers; insert into wm_demo (name, way) select name, ST_SimplifyWM(way, 2000, name) from wm_rivers;

34
wm.sql
View File

@ -260,6 +260,8 @@ $$ language plpgsql;
drop function if exists wm_self_crossing; drop function if exists wm_self_crossing;
create function wm_self_crossing( create function wm_self_crossing(
INOUT bends geometry[], INOUT bends geometry[],
dbgname text default null,
dbggen integer default null,
OUT mutated boolean OUT mutated boolean
) as $$ ) as $$
declare declare
@ -313,6 +315,16 @@ begin
continue bendloop; continue bendloop;
end loop; end loop;
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 end
$$ language plpgsql; $$ language plpgsql;
@ -599,12 +611,7 @@ begin
while mutated loop while mutated loop
if dbgname is not null then if dbgname is not null then
insert into wm_debug (stage, name, gen, nbend, way) values( insert into wm_debug (stage, name, gen, nbend, way) values(
'afigures', 'afigures', dbgname, gen, i, lines[i]);
dbgname,
gen,
i,
lines[i]
);
end if; end if;
bends = wm_detect_bends(lines[i], dbgname, gen); bends = wm_detect_bends(lines[i], dbgname, gen);
@ -612,16 +619,6 @@ begin
select * from wm_self_crossing(bends) into bends, mutated; 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 if mutated then
lines[i] = st_linemerge(st_union(bends)); lines[i] = st_linemerge(st_union(bends));
gen = gen + 1; gen = gen + 1;
@ -632,7 +629,6 @@ begin
select * from wm_elimination( select * from wm_elimination(
bendattrs, dhalfcircle, dbgname, gen) into bendattrs, mutated; bendattrs, dhalfcircle, dbgname, gen) into bendattrs, mutated;
if mutated then if mutated then
for j in 1..array_length(bendattrs, 1) loop for j in 1..array_length(bendattrs, 1) loop
bends[j] = bendattrs[j].bend; bends[j] = bendattrs[j].bend;
@ -642,7 +638,9 @@ begin
continue; continue;
end if; 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;
end loop; end loop;