point does not return a center of lseg

Поиск
Список
Период
Сортировка
Искать

point does not return a center of lseg

От:
Kenji Sugita <sugita@sra.co.jp>
Дата:
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);
 }
FAQ