-
Notifications
You must be signed in to change notification settings - Fork 187
Infinite loop in RegionCoverer Interior Covering #152
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
Comments
One point I forgot to mention:
|
Not validating is by design/mis-design and based on the C++. We should probably have |
So we're OK paying the cost for a Validate call on all PolygonFrom* calls? (NB: Validate still isn't fully implemented) |
There would be the |
Changing the constructors to return an error seems somewhat disruptive and awkward, particularly since there's also a Validate method, which suggests that one can construct and validate separately. If we add this for Polygon constructors we should probably take a holistic approach and add it to Poyline and Loop too. This wouldn't fully protect Polyline, though, since its type is just S2Polygon in Java was ported with C++ DCHECK turned into Java assertions but commented out, so it's not currently validating on construction either. There are some other S2 Java classes that aren't currently validating but which should be; Torrey is working with some internal clients who are depending on the non-validating behavior. I agree that we should avoid getting into an infinite loop, even if the polygon's invalid. Making it impossible to get an invalid polygon is a good goal, but if there's a good way to get RegionCoverer to detect the problem, it might be more expedient to detect and abort there. |
On this test case with DCHECKs turned off, the C++ version runs for 50s before returning an empty set of cells. So refreshing the golang implementation from the C++ one might fix this. |
It seems like the go code terminates too? So should we just close this as WAI? |
Hi,
I've just stumbled upon a case where
RegionCoverer.InteriorCovering
results in an infinite loop.To be fair, the
s2.Polygon
in question isn't a valid polygon according to the restrictions:both the interior and exterior of any other loop.
no other loop may contain AB or BA.
since it consists of the same loop two times.
I still think this might be worth looking into - since an infinite loop is pretty dangerous to trigger in any case.
And it does work (even correctly) for the
RegionCoverer.Covering
variant.Below is a fully reproducible example:
The text was updated successfully, but these errors were encountered: