tilemaker icon indicating copy to clipboard operation
tilemaker copied to clipboard

Invalid polygons with simplification

Open systemed opened this issue 2 years ago • 1 comments

Current master is very occasionally causing "leaking rivers" at high simplification factors. It's pretty rare but happens sometimes:

Screenshot 2022-06-28 at 21 51 57

In this case it appears to be a self-intersection caused by a multipolygon inner:

Screenshot 2022-06-28 at 21 52 39

I've spotted this at Liege (10/527/344), Limay (9/258/175) and Fribourg (9/266/180).

Layer config is:

"water_area":{"minzoom": 9 , "maxzoom": 14, "simplify_below": 14, "simplify_length": 10, "simplify_ratio": 2, "filter_below": 13, "filter_area": 0.5, "combine_polygons_below": 14 }

systemed avatar Jun 28 '22 20:06 systemed

This extract of Limay consistently reproduces it with simplify_length and simplify_ratio set as above. With less simplification it's ok.

The simplification appears to be making the water multipolygon's outer cross over the inners. If I comment out the code that simplifies the outer it's fine.

I can hack around it by adding a check to WriteGeometryVisitor::operator() and dropping the inners:

geom::validity_failure_type failure;
if (simplifyLevel>0) {
	current = simplify(round_coordinates(*bboxPtr, mp), simplifyLevel);
	for (auto &outer : current) {
		if (!geom::is_valid(current, failure) && failure==21) outer.inners().resize(0);
	}

but that's not ideal, and can in turn break coastline polygons.

systemed avatar Jul 03 '22 17:07 systemed