-
Notifications
You must be signed in to change notification settings - Fork 366
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
ST_Intersection give results that are inconsistent with ST_Distance #1207
Comments
This seems to be caused by the inability to accurately represent geometric objects |
Correct. Note that 0.4 and 1.6 can't be represented as exact binary fractions (due to the presence of a factor of 5). Unfortunately, the extended-precision arithmetic used for the point-line orientation predicates is a little too exact in this case. One possible fix is to compute the point-line orientation using regular FP math first, and if the result is exact, use that result. Only when the point is not on the line is the extended-precision math used (to be more precise about which side of the line the point lies on). In the future the topological predicates may support a distance tolerance, which would solve this problem as well. |
Here's a repro in GEOS:
|
Yes, using a distance tolerance can effectively avoid such problems caused by discretization, but the tolerance needs to be controlled within an appropriate range. |
And when calculating the intersection of POINT (0.4 1.6) and LINESTRING (2 0, 0 2), we obtain an empty set, but POINT (0.4 1.6) is common sense on LINESTRING (2 0, 0 2), but the intersection result is an empty set.
Then I made the following attempts:
But when calculating their distances separately using ST_Distance, the result obtained is 0.
Version Info:
GEOS="3.13.0-CAPI-1.19.0"
The text was updated successfully, but these errors were encountered: