tilemaker
tilemaker copied to clipboard
Invalid polygons with simplification
Current master is very occasionally causing "leaking rivers" at high simplification factors. It's pretty rare but happens sometimes:
In this case it appears to be a self-intersection caused by a multipolygon inner:
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 }
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.