debugging exaggeration

This commit is contained in:
Motiejus Jakštys 2021-05-19 22:57:49 +03:00 committed by Motiejus Jakštys
parent 7faaa88309
commit e20781aa85

26
wm.sql
View File

@ -550,22 +550,24 @@ declare
this_mutated boolean; this_mutated boolean;
begin begin
mutated = false; mutated = false;
<<bendloop>> i = 0;
for i in 1..array_length(attrs, 1) loop while i < array_length(attrs, 1) loop
i = i + 1;
continue when not attrs[i].isolated; continue when not attrs[i].isolated;
size = attrs[i].adjsize;
this_mutated = false; this_mutated = false;
-- keep increasing this bend until either size permits, or it hits a -- keep increasing this bend until either size permits, or it hits a
-- neighboring bend (intersect_patience number of neighbors will be -- neighboring bend (intersect_patience number of neighbors will be
-- checked). When the size is right, stick it to the line. -- checked). When the size is right, stick it to the line.
size = attrs[i].adjsize;
while size < desired_size loop while size < desired_size loop
bend = wm_exaggerate_bend(bends[i]); bend = wm_exaggerate_bend(bends[i]);
exit when wm_st_intersects_neighbors(bends, bend, i, intersect_patience); exit when wm_st_intersects_neighbors(bends, bend, i, intersect_patience);
this_mutated = true; this_mutated = true;
bends[i] = bend; bends[i] = bend;
size = wm_adjsize(bends[i]); size = wm_adjsize(bend);
end loop; end loop;
continue when not this_mutated; continue when not this_mutated;
@ -583,6 +585,10 @@ begin
insert into wm_debug (stage, name, gen, nbend, way) values( insert into wm_debug (stage, name, gen, nbend, way) values(
'gexaggeration', dbgname, dbggen, i, bends[i]); 'gexaggeration', dbgname, dbggen, i, bends[i]);
end if; end if;
-- Next bend was modified, so `isolated` is not valid for neighbor's
-- neighbor. Skip over.
i = i + 2;
end loop; end loop;
end $$ language plpgsql; end $$ language plpgsql;
@ -746,18 +752,18 @@ begin
lines[i] = st_linemerge(st_union(bends)); lines[i] = st_linemerge(st_union(bends));
if st_geometrytype(lines[i]) != 'ST_LineString' then if st_geometrytype(lines[i]) != 'ST_LineString' then
raise 'Got % (in %) instead of ST_LineString. ' raise notice 'Got % (in %) instead of ST_LineString. '
'Does the exaggerated bend intersect with the line? ' 'Does the exaggerated bend intersect with the line? '
'If so, try increasing intersect_patience.', 'If so, try increasing intersect_patience.',
st_geometrytype(lines[i]), dbgname; st_geometrytype(lines[i]), dbgname;
-- For manual debugging, usually when wm_exaggeration returns -- For manual debugging, usually when wm_exaggeration returns
-- ST_MultiLineString. Uncomment the code below and change `raise` -- ST_MultiLineString. Uncomment the code below and change `raise`
-- to `raise notice` above. -- to `raise notice` above.
--insert into wm_manual(name, way) insert into wm_manual(name, way)
--select 'non-linestring-' || a.path[1], a.geom select 'non-linestring-' || a.path[1], a.geom
--from st_dump(lines[i]) a from st_dump(lines[i]) a
--order by a.path[1]; order by a.path[1];
--exit lineloop; exit lineloop;
end if; end if;
gen = gen + 1; gen = gen + 1;
continue; continue;