point does not return a center of lseg - Mailing list pgsql-patches

From Kenji Sugita
Subject point does not return a center of lseg
Date
Msg-id 20021230.015442.74732139.sugita@sra.co.jp
Whole thread Raw
List pgsql-patches
The function point does not return a center of lseg.

    Before patch:

    =# select point(lseg '((1, 1), (2, 2))');
    point
    -------------
     (-0.5,-0.5)
    (1 row)

    =#

    After patch:

    =# select point(lseg '((1, 1), (2, 2))');
       point
    -----------
     (1.5,1.5)
    (1 row)

    =#
Index: src/backend/utils/adt/geo_ops.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/backend/utils/adt/geo_ops.c,v
retrieving revision 1.66.2.1
diff -u -r1.66.2.1 geo_ops.c
--- src/backend/utils/adt/geo_ops.c    2002/11/29 19:25:38    1.66.2.1
+++ src/backend/utils/adt/geo_ops.c    2002/12/29 16:49:17
@@ -2032,8 +2032,8 @@

     result = (Point *) palloc(sizeof(Point));

-    result->x = (lseg->p[0].x - lseg->p[1].x) / 2.0;
-    result->y = (lseg->p[0].y - lseg->p[1].y) / 2.0;
+    result->x = (lseg->p[0].x + lseg->p[1].x) / 2.0;
+    result->y = (lseg->p[0].y + lseg->p[1].y) / 2.0;

     PG_RETURN_POINT_P(result);
 }

pgsql-patches by date:

Previous
From: "Patric Bechtel"
Date:
Subject: Fwd: Patch for streaming resultsets
Next
From: Szekely Krisztian
Date:
Subject: pg_resetxlog Hungarian message file