From f712a96f54f7b7ecaa5892fa1cf93ab7dd55a4f9 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Thu, 6 Jan 2005 13:44:45 +0000 Subject: [PATCH] Added ptarray_clone() and ptarray_isclosed2d() git-svn-id: http://svn.osgeo.org/postgis/trunk@1231 b70326c6-7e19-0410-871a-916f4a2858ee --- lwgeom/ptarray.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lwgeom/ptarray.c b/lwgeom/ptarray.c index 9a27c3b99..3b0a99822 100644 --- a/lwgeom/ptarray.c +++ b/lwgeom/ptarray.c @@ -313,3 +313,32 @@ ptarray_addPoint(POINTARRAY *pa, char *p, size_t pdims, unsigned int where) return ret; } + +/* + * Clone a pointarray + */ +POINTARRAY * +ptarray_clone(const POINTARRAY *in) +{ + POINTARRAY *out = lwalloc(sizeof(POINTARRAY)); + size_t size; + + out->dims = in->dims; + out->npoints = in->npoints; + + size = in->npoints*sizeof(double)*TYPE_NDIMS(in->dims); + out->serialized_pointlist = lwalloc(size); + memcpy(out->serialized_pointlist, in->serialized_pointlist, size); + + return out; +} + +int +ptarray_isclosed2d(const POINTARRAY *in) +{ + POINT2D *p1, *p2; + p1 = (POINT2D *)getPoint(in, 0); + p2 = (POINT2D *)getPoint(in, in->npoints-1); + if ( p1->x != p2->x || p1->y != p2->y ) return 0; + else return 1; +} -- 2.50.1