wm_elimination bugfixes

This commit is contained in:
Motiejus Jakštys 2021-05-01 15:47:44 +03:00
parent d71b8dbcc9
commit b9d8d23948
2 changed files with 14 additions and 7 deletions

View File

@ -54,7 +54,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, .1, name) from wm_figures where name != 'fig8';
insert into wm_demo (name, way) select name, ST_SimplifyWM(way, .1, name) from wm_figures where name = 'fig8';
insert into wm_demo (name, way) select name, ST_SimplifyWM(way, 10, name) from wm_figures where name = 'fig8';
do $$

View File

@ -392,8 +392,8 @@ begin
insert into wm_debug (stage, name, gen, nbend, way, props) values(
'ebendattrs',
dbgname,
i,
dbggen,
i,
bend,
jsonb_build_object(
'area', res.area,
@ -449,16 +449,23 @@ begin
continue when bendattrs[i].adjsize >= leftsize;
continue when bendattrs[i].adjsize >= rightsize;
-- Local minimum. Elminate!
-- Local minimum. Elminate bend!
mutated = true;
tmpbendattrs.bend = st_makeline(
st_pointn(bendattrs[i].bend, 1),
st_pointn(bendattrs[i].bend, -1)
);
bendattrs[i] = tmpbendattrs;
-- jump over the next bend, because the current bend disappeared,
-- and there is no way the other one can be a "local minima".
i = i + 1;
-- remove last vertex of the previous bend and
-- first vertex of the next bend, because bends always
-- share a line segment together
tmpbendattrs.bend = st_removepoint(bendattrs[i-1].bend, st_npoints(bendattrs[i-1].bend)-1);
bendattrs[i-1] = tmpbendattrs;
tmpbendattrs.bend = st_removepoint(bendattrs[i+1].bend, 0);
bendattrs[i+1] = tmpbendattrs;
-- the next bend's adjsize is now messed up; it should not be taken
-- into consideration for other local minimas. Skip over 2.
i = i + 2;
end loop;
if dbgname is not null then
@ -467,7 +474,7 @@ begin
end loop;
insert into wm_debug(stage, name, gen, nbend, way) values(
'eelimination',
'felimination',
dbgname,
dbggen,
generate_subscripts(dbgbends, 1),