-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A few test cases with bad triangulations #56
Comments
The script I used to test polygons in vector tiles: https://github.com/mapbox/earcut-reduce |
@mourner that's a good regression test-suite! Currently busy getting things finished before vacation, but I'll get back to it. Could you extract the failing polygons - or failing tiles? I don't have the full mapbox tileset here :) The above polygon should be handled by case 3 in Eberly's algorithm. |
@hjanetzek the failing polygons are extracted in the gist I linked above. |
@hjanetzek @flippmoke @jakepruitt fixing the 3rd Eberly algorithm case with cf5f2f1 brings us down from 79 to 28 failures, without collinear filtering. \o/ Updated the gist with new failures, looking further... |
The latest commit fixes |
Fixed the case above with d13c8dc and it's down to 4 bad cases! 🚀 |
Damn, this one is tough: [
[[4224,1776],[4224,2064],[4200,2088],[4184,2080],[4168,2112],[4136,2104],[4136,2072],[4072,2096],[4072,2128],[4032,2160],[4032,2184],[4064,2184],[4064,2200],[4040,2208],[4040,2240],[3992,2280],[3936,2280],[3928,2336],[3888,2376],[3880,2408],[3864,2408],[3864,2432],[3888,2440],[3920,2440],[3968,2408],[3976,2464],[3960,2472],[3960,2496],[3976,2496],[3976,2528],[4000,2528],[4024,2488],[4064,2504],[4056,2536],[4032,2536],[4032,2576],[4056,2584],[4056,2624],[4024,2656],[3944,2672],[3888,2736],[3848,2712],[3840,2768],[3800,2800],[3784,2960],[3744,2976],[3760,3000],[3744,3048],[3768,3144],[3760,3200],[3768,3240],[3792,3256],[3784,3320],[3752,3328],[3688,3248],[3672,3200],[3632,3168],[3632,3104],[3600,3024],[3608,2944],[3648,2864],[3648,2832],[3624,2808],[3632,2728],[3648,2728],[3688,2672],[3672,2560],[3728,2528],[3728,2496],[3712,2496],[3704,2464],[3704,2288],[3728,2168],[3744,2128],[3768,2120],[3768,2088],[3792,2088],[3816,2064],[3840,2064],[3848,2080],[3888,2072],[3920,2024],[3968,2032],[3968,2016],[4000,2008],[4032,1968],[4008,1928],[4096,1896],[4096,1792],[4120,1752],[4144,1744],[4152,1680],[4224,1624],[4224,1776]],
[[3816,2616],[3800,2624],[3808,2656],[3840,2632],[3840,2616],[3816,2616]],
[[3728,2632],[3760,2632],[3752,2592],[3728,2632]],
[[3968,2552],[3960,2568],[3936,2600],[3952,2624],[3992,2600],[3992,2560],[4008,2560],[4008,2544],[3968,2552]],
[[3768,2472],[3752,2520],[3768,2552],[3752,2592],[3768,2568],[3816,2568],[3840,2552],[3832,2488],[3808,2464],[3768,2472]],
] Basically the bug seems to sometimes happen when a hole bridge routine takes a segment that was previously another hole connection, takes the wrong of the two matching segments, and hole elimination rewires the polygon in some invalid way. I've been trying to fix this with |
@mrgreywater thanks for reducing, this is indeed much easier to reason about! |
It looks like all 4 remaining problems have the same look like the above reduced case. However I'm out of ideas for fixing them for now — I thought the most promising fix would be to just check if the node found by the |
Processed ~5 million polygons from a Mapbox Terrain subset and found just 79 cases with deviations that are not fixed by filtering out collinear points (
fix-alt
branch): https://gist.github.com/mourner/738f8ff6c7dae5a1144e (for reference, it's 159 on master without filtering).edit: it's down to 4 failing cases with the latest patches.
This is a great set of cases to investigate and fix remaining Earcut issues. A lot of them seem to be about rings sharing a point (edges touching by an endpoint).
I'll look into them in the next few days but any help is appreciated too. cc @hjanetzek @mrgreywater
The biggest failing sample looks like this (it's a hole on the left):
The text was updated successfully, but these errors were encountered: