From c3f362a9f082d64a8e7e2cd12f4efd80e0bd6cab Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Fri, 15 Oct 2004 15:00:26 +0000 Subject: [PATCH] Fixed a bug in make_lwline git-svn-id: http://svn.osgeo.org/postgis/trunk@1012 b70326c6-7e19-0410-871a-916f4a2858ee --- lwgeom/lwline.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/lwgeom/lwline.c b/lwgeom/lwline.c index a45add9c0..2aa87df00 100644 --- a/lwgeom/lwline.c +++ b/lwgeom/lwline.c @@ -6,6 +6,7 @@ #include "liblwgeom.h" //#define DEBUG_CALLS 1 +//#define DEBUG 1 // construct a new LWLINE. points will *NOT* be copied @@ -385,10 +386,16 @@ make_lwline(int SRID, unsigned int npoints, LWPOINT **points) POINTARRAY *pa; /* - * Find output dimensions + * Find output dimensions, check integrity */ for (i=0; itype) != POINTTYPE ) + { + lwerror("make_lwline: invalid input type: %s", + lwgeom_typename(TYPE_GETTYPE(points[i]->type))); + return NULL; + } zmflag = TYPE_GETZM(points[i]->type); if ( zmflag == 3 ) break; } @@ -396,6 +403,11 @@ make_lwline(int SRID, unsigned int npoints, LWPOINT **points) /* Allocate space for output pointarray */ pa = ptarray_construct(zmflag&2, zmflag&1, npoints); +#ifdef DEBUG + lwnotice("make_lwline: constructed pointarray for %d points, %d zmflag", + npoints, zmflag); +#endif + /* * Fill pointarray */ @@ -405,20 +417,30 @@ make_lwline(int SRID, unsigned int npoints, LWPOINT **points) for (i=0; ipoint, 0, (POINT2D *)getPoint(pa, i)); + break; + case 1: // 3dm for (i=0; ipoint, 0, (POINT3DM *)getPoint(pa, i)); + break; + case 2: // 3dz for (i=0; ipoint, 0, (POINT3DZ *)getPoint(pa, i)); - default: // 4d + break; + + case 3: // 4d for (i=0; ipoint, 0, (POINT4D *)getPoint(pa, i)); + break; + + default: + lwerror ("make_lwline: unespected ZMflag: %d", zmflag); + return NULL; } return lwline_construct(SRID, NULL, pa); } - -- 2.40.0