-
Notifications
You must be signed in to change notification settings - Fork 447
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
Add Angle.sinSnap and .cosSnap to avoid small errors, e.g. with buffer operations #1016
Conversation
I think two separate functions would be best. Probably more optimal than allocating a new array each time.
There is |
Is it worth snapping sin and cos values near 0.5 as well? |
Do you mean something like As for trig values near 0.5, I've not found this to be important. It's only the near-zero ones that matter, which is why I went with the simplest implementation for GEOS. I should also note that this PR would make a buffer around point equal to GEOS (again). |
Yes, that's what I mean. And agreed, I don' think the performance is going to be a bottleneck.
Sounds good.
Excellent, that's what we like to have. |
This PR is rewritten as discussed, and ready for further review. |
What do you think about renaming these |
Good suggestion. Also, if there are suggestions to push back onto GEOS dev, I can entertain these ideas too. There are several other parts of the codebase that use |
Might be nice to align GEOS naming with the changed JTS naming.
That can be another PR, sometime. If there's no more changes required, I can merge this. |
Minor GEOS renaming done here: libgeos/geos@dcde8ad And yes, this PR is now set to merge. |
This is similar to libgeos/geos#978 which aims to remove small rounding errors from
Math.sin
andMath.cos
with (e.g.) pi and pi/2, which are near-zero.This will provide small differences to buffer operations. For example, consider a 1.0 buffer around
POINT (0 0)
. An intersection withLINESTRING (1 1, 1 -1, -1 -1, -1 1, 1 1)
will now beMULTIPOINT ((-1 0), (0 -1), (0 1), (1 0))
.Previously the intersection was
MULTIPOINT ((-1 -0.0000000000000001), (-0.0000000000000002 1), (0.0000000000000001 -1), (1 0))
.Several notes:
Angle.sinCos
returns an array. Perhaps there is a better way?BufferOpTest
to check the coordinate sequence ofPOINT(0 0)
with a buffer of 1. Is there a suitable place to check this?