flutter_map icon indicating copy to clipboard operation
flutter_map copied to clipboard

[BUG] Polygon simplification may produce invalid polygons

Open JaffaKetchup opened this issue 1 year ago • 1 comments

What is the bug?

Some Polygons are not simplified correctly, and result in a polygon formed from less than 3 points. This results in long straight lines appearing on the map.

image

How can we reproduce it?

Any polygons which are small enough to be reduced down to less than 3 points should cause the issue.

Do you have a potential solution?

Either avoid displaying polygons with less than 3 points, or prevent the simplification from returning invalid polygons.

Platforms

All

Severity

Obtrusive: Prevents normal functioning but causes no errors in the console

JaffaKetchup avatar Sep 12 '24 19:09 JaffaKetchup

one thing to add is that previously polygon simplification did not create "bad" polygons. Sometimes it makes sense to render long thin polygons as a single line (or even a single point for roughly round shaped polygons!). rendering less polygons can help with performance, but ive found that not rendering polygons of less than 2 leads to a feeling of pop-in, especially with higher simplification values.

mootw avatar Sep 12 '24 19:09 mootw

geojson.txt

after some basic testing it seems like the error causes one polygon to have a chunk extend to the next. here is a sample geojson that i have seen the issue with. A few things to note. It is very possible (almost certain) this is not spec compliant. secondly, the error does not occur when simplification is off. I plan to make a reproducible example soon, and also a PR to fix it. I just haven't had the time to do it all right now. One thing that i saw during my limited testing is that it appears to happen when polygons get simplified to less than 3 points. Another thing to note is that it happens with normal polygons and multi-polyons

mootw avatar Nov 24 '24 06:11 mootw

might be due to flutter sdk?

i was on beta version (3.27), but moved to stable (3.24.5), and now the issue is gone

mootw avatar Dec 12 '24 04:12 mootw

to the best of my knowledge, this appears to be a flutter sdk issue. There are lots of new issues being tracked related to 3.27, specifically due to crashes and rendering bugs. I am going to close the issue in flutter map, as i believe it is the flutter SDK causing these artifacts. They appear entirely gone immediately after switching to 3.24.5 stable with zero code changes

example here: https://github.com/flutter/flutter/issues/160522

mootw avatar Dec 19 '24 16:12 mootw