improve observability

This commit is contained in:
Motiejus Jakštys 2021-04-05 10:05:16 +03:00
parent f81fcc02e9
commit 6cc76b96ef
2 changed files with 25 additions and 14 deletions

View File

@ -11,9 +11,9 @@ begin
end $$ LANGUAGE plpgsql;
-- to preview this somewhat conveniently in QGIS:
-- stage || '_' || name || ' iter:' || iter || ' nbend:'|| nbend
-- stage || '_' || name || ' gen:' || coalesce(gen, 'Ø')|| ' nbend:'|| lpad(nbend, 2, '0')
drop table if exists debug_wm;
create table debug_wm(stage text, name text, iter bigint, nbend bigint, way geometry, props json);
create table debug_wm(stage text, name text, gen bigint, nbend bigint, way geometry, props json);
drop table if exists figures;
create table figures (name text, way geometry);
@ -64,7 +64,7 @@ $$ language plpgsql;
-- COMBINED
drop table if exists demo_wm;
create table demo_wm (name text, i bigint, way geometry);
insert into demo_wm (name, way) select name, ST_SimplifyWM(way, name) from figures;
insert into demo_wm (name, way) select name, ST_SimplifyWM(way, name) from figures where name='fig6-combi';
do $$
declare
@ -125,7 +125,7 @@ begin
) from (select unnest(vcrossings) way) a)
);
elems1 = array((select way from debug_wm where stage='cinflections' and name='fig6-combi' and iter=1));
elems1 = array((select way from debug_wm where stage='cinflections' and name='fig6-combi' and gen=1));
elems2 = (select ways from inflections where name='fig6-combi');
foreach elem in array elems1 loop

View File

@ -299,10 +299,9 @@ begin
select (res.area*(0.75/res.cmp)) into res.adjsize;
end if;
if dbgname is not null then
insert into debug_wm (stage, name, iter, nbend, way, props) values(
insert into debug_wm (stage, name, nbend, way, props) values(
'ebendattrs',
dbgname,
1,
i,
bend,
json_build_object(
@ -346,10 +345,10 @@ begin
dbg_stage = 1;
while mutated loop
if dbgname is not null then
insert into debug_wm (stage, name, iter, nbend, way) values(
insert into debug_wm (stage, name, gen, nbend, way) values(
'afigures',
dbgname,
1,
dbg_stage,
i,
lines[i]
);
@ -358,22 +357,23 @@ begin
bends = detect_bends(lines[i]);
if dbgname is not null then
insert into debug_wm(stage, name, iter, nbend, way) values(
insert into debug_wm(stage, name, gen, nbend, way) values(
'bbends',
dbgname,
i,
dbg_stage,
generate_subscripts(bends, 1),
unnest(bends)
);
end if;
raise notice 'before inflections: %', dbg_geomsummary(bends);
bends = fix_gentle_inflections(bends);
if dbgname is not null then
insert into debug_wm(stage, name, iter, nbend, way) values(
insert into debug_wm(stage, name, gen, nbend, way) values(
'cinflections',
dbgname,
i,
dbg_stage,
generate_subscripts(bends, 1),
unnest(bends)
);
@ -382,10 +382,10 @@ begin
select * from self_crossing(bends) into bends, mutated;
if dbgname is not null then
insert into debug_wm(stage, name, iter, nbend, way) values(
insert into debug_wm(stage, name, gen, nbend, way) values(
'dcrossings',
dbgname,
i,
dbg_stage,
generate_subscripts(bends, 1),
unnest(bends)
);
@ -410,3 +410,14 @@ begin
end if;
end
$$ language plpgsql;
drop function if exists dbg_geomsummary;
create function dbg_geomsummary(geoms geometry[], OUT output text) as $$
declare i int4;
begin
output = format('len: %s;', array_length(geoms, 1));
for i in 1..array_length(geoms, 1) loop
output = output || format(' %s:%s;', i, st_astext(geoms[i]));
end loop;
end
$$ language plpgsql;