aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2010-11-10 16:51:39 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2010-11-10 16:52:24 -0500
commitb0f2d681bdfd6a5b3e90d092f9d924f943b4fc5f (patch)
tree8c013f775828e519547571bdcd6ebde225d87322 /src
parent8f742d1cdab987ba4624ad0c6aa008ced15cd87c (diff)
downloadpostgresql-b0f2d681bdfd6a5b3e90d092f9d924f943b4fc5f.tar.gz
postgresql-b0f2d681bdfd6a5b3e90d092f9d924f943b4fc5f.zip
Fix line_construct_pm() for the case of "infinite" (DBL_MAX) slope.
This code was just plain wrong: what you got was not a line through the given point but a line almost indistinguishable from the Y-axis, although not truly vertical. The only caller that tries to use this function with m == DBL_MAX is dist_ps_internal for the case where the lseg is horizontal; it would end up producing the distance from the given point to the place where the lseg's line crosses the Y-axis. That function is used by other operators too, so there are several operators that could compute wrong distances from a line segment to something else. Per bug #5745 from jindiax. Back-patch to all supported branches.
Diffstat (limited to 'src')
-rw-r--r--src/backend/utils/adt/geo_ops.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c
index f3b6a389ff4..8a99df1356c 100644
--- a/src/backend/utils/adt/geo_ops.c
+++ b/src/backend/utils/adt/geo_ops.c
@@ -1072,13 +1072,20 @@ line_construct_pm(Point *pt, double m)
{
LINE *result = (LINE *) palloc(sizeof(LINE));
- /* use "mx - y + yinter = 0" */
- result->A = m;
- result->B = -1.0;
if (m == DBL_MAX)
- result->C = pt->y;
+ {
+ /* vertical - use "x = C" */
+ result->A = -1;
+ result->B = 0;
+ result->C = pt->x;
+ }
else
+ {
+ /* use "mx - y + yinter = 0" */
+ result->A = m;
+ result->B = -1.0;
result->C = pt->y - m * pt->x;
+ }
#ifdef NOT_USED
result->m = m;