From b10179364deb5b627112b78a5aff55a9ab6f45a7 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Mon, 20 Sep 2004 09:21:29 +0000 Subject: [PATCH] fixed bugs in non-GEOS centroid function git-svn-id: http://svn.osgeo.org/postgis/trunk@841 b70326c6-7e19-0410-871a-916f4a2858ee --- lwgeom/lwgeom_functions_basic.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lwgeom/lwgeom_functions_basic.c b/lwgeom/lwgeom_functions_basic.c index 162e3a37d..c3264caf8 100644 --- a/lwgeom/lwgeom_functions_basic.c +++ b/lwgeom/lwgeom_functions_basic.c @@ -2338,6 +2338,7 @@ Datum LWGEOM_isempty(PG_FUNCTION_ARGS) #if ! USE_GEOS +Datum centroid(PG_FUNCTION_ARGS); PG_FUNCTION_INFO_V1(centroid); Datum centroid(PG_FUNCTION_ARGS) { @@ -2349,12 +2350,13 @@ Datum centroid(PG_FUNCTION_ARGS) LWPOLY *poly; LWPOINT *point; LWGEOM *result; - POINTARRAY *ring; + POINTARRAY *ring, *pa; POINT3D *p, cent; int i,j,k; uint32 num_points_tot = 0; char *srl; char wantbbox = 0; + double tot_x=0, tot_y=0, tot_z=0; if (type != POLYGONTYPE && type != MULTIPOLYGONTYPE) PG_RETURN_NULL(); @@ -2369,9 +2371,9 @@ Datum centroid(PG_FUNCTION_ARGS) for (k=0; knpoints-1; k++) { p = (POINT3D *)getPoint(ring, k); - tot_x += p.x; - tot_y += p.y; - if ( ring->ndims > 2 ) tot_z += p.z; + tot_x += p->x; + tot_y += p->y; + if ( ring->ndims > 2 ) tot_z += p->z; } num_points_tot += ring->npoints-1; } -- 2.40.0