Ticket #1502 (closed defect: fixed)
Unrobustness in distance calculations
| Reported by: | nicklas | Owned by: | nicklas |
|---|---|---|---|
| Priority: | medium | Milestone: | PostGIS 2.0.0 |
| Component: | postgis | Version: | 1.5.X |
| Keywords: | Cc: |
Description
This one is quite ugly.
SELECT st_dwithin(a,b,0), st_intersects(a,b),st_distance(a,b) from (select 'LINESTRING(-97364 -97364, 9736.4 9736.4)'::geometry a, 'POINT(0 0)'::geometry b ) f;
returns :
f;t;3.086927381169e-11
This is also point-segment problem like #1459
The problem is that the distance is calculated by projecting the point to the segment and then calculating the distance from the projected point to the original point.
The projection of the point to the segment is done by calculating where along the segment from 0 to 1 that the point should be projected. That value, r, doesn't have enough precision when the segment is long and the distance to between the original point is small.
This was not a problem pre 1.5 because then the projected point was never calculated.
