[postgis-commits] svn - r3520 - in trunk: liblwgeom lwgeom

postgis-commits at postgis.refractions.net postgis-commits at postgis.refractions.net
Tue Jan 13 04:27:42 PST 2009


Author: mcayland
Date: 2009-01-13 04:27:39 -0800 (Tue, 13 Jan 2009)
New Revision: 3520

Added:
   trunk/liblwgeom/lwcircstring.c
Removed:
   trunk/liblwgeom/lwcurve.c
Modified:
   trunk/liblwgeom/Makefile.in
   trunk/liblwgeom/liblwgeom.h
   trunk/liblwgeom/lwcollection.c
   trunk/liblwgeom/lwcompound.c
   trunk/liblwgeom/lwcurvepoly.c
   trunk/liblwgeom/lwgeom.c
   trunk/liblwgeom/lwgeom_api.c
   trunk/liblwgeom/lwgparse.c
   trunk/liblwgeom/lwgunparse.c
   trunk/liblwgeom/lwmcurve.c
   trunk/liblwgeom/lwsegmentize.c
   trunk/liblwgeom/wktparse.h
   trunk/lwgeom/lwgeom_functions_basic.c
   trunk/lwgeom/lwgeom_ogc.c
   trunk/lwgeom/lwgeom_transform.c
Log:
Commit for GBT#97: Rename LWCURVE to LWCIRCSTRING (also know as restoring balance to the universe). 

Having gone through and re-read sections of the CIRCULARSTRING code, it is amazing how much easier the code is to read without the confusion of a curve being either a CIRCULARSTRING or LINESTRING as per the SQL-MM spec. The resulting commit compiles & installs cleanly for me, passes "make check" and also Regina's torture script. Please let me know if I accidentally broke anything :)


Modified: trunk/liblwgeom/Makefile.in
===================================================================
--- trunk/liblwgeom/Makefile.in	2009-01-12 19:29:57 UTC (rev 3519)
+++ trunk/liblwgeom/Makefile.in	2009-01-13 12:27:39 UTC (rev 3520)
@@ -30,7 +30,7 @@
 	lwmline.o \
 	lwmpoly.o \
 	lwcollection.o \
-	lwcurve.o \
+	lwcircstring.o \
 	lwcompound.o \
 	lwcurvepoly.o \
 	lwmcurve.o \

Modified: trunk/liblwgeom/liblwgeom.h
===================================================================
--- trunk/liblwgeom/liblwgeom.h	2009-01-12 19:29:57 UTC (rev 3519)
+++ trunk/liblwgeom/liblwgeom.h	2009-01-13 12:27:39 UTC (rev 3520)
@@ -630,7 +630,7 @@
 extern size_t lwgeom_size(const uchar *serialized_form);
 extern size_t lwgeom_size_subgeom(const uchar *serialized_form, int geom_number);
 extern size_t lwgeom_size_line(const uchar *serialized_line);
-extern size_t lwgeom_size_curve(const uchar *serialized_curve);
+extern size_t lwgeom_size_circstring(const uchar *serialized_curve);
 extern size_t lwgeom_size_point(const uchar *serialized_point);
 extern size_t lwgeom_size_poly(const uchar *serialized_line);
 
@@ -1274,14 +1274,14 @@
 
 void errorIfSRIDMismatch(int srid1, int srid2);
 
-/* CURVETYPE */
+/* CIRCSTRINGTYPE */
 typedef struct
 {
-        uchar type; /* CURVETYPE */
+        uchar type; /* CIRCSTRINGTYPE */
         BOX2DFLOAT4 *bbox;
         uint32 SRID;
         POINTARRAY *points; /* array of POINT(3D/3DM) */
-} LWCURVE; /* "light-weight arcline" */
+} LWCIRCSTRING; /* "light-weight circularstring" */
 
 /* COMPOUNDTYPE */
 typedef struct
@@ -1323,54 +1323,54 @@
         LWGEOM **geoms;
 } LWMSURFACE;
 
-#define CURVETYPE         8
+#define CIRCSTRINGTYPE    8
 #define COMPOUNDTYPE      9
 #define CURVEPOLYTYPE    13
 #define MULTICURVETYPE   14
 #define MULTISURFACETYPE 15
 
 /******************************************************************
- * LWCURVE functions
+ * LWCIRCSTRING functions
  ******************************************************************/
 
 /* Casts LWGEOM->LW* (return NULL if cast is illegal) */
-extern LWCURVE *lwgeom_as_lwcurve(LWGEOM *lwgeom);
+extern LWCIRCSTRING *lwgeom_as_lwcircstring(LWGEOM *lwgeom);
 
 
-LWCURVE *lwcurve_construct(int SRID, BOX2DFLOAT4 *bbox, POINTARRAY *points);
+LWCIRCSTRING *lwcircstring_construct(int SRID, BOX2DFLOAT4 *bbox, POINTARRAY *points);
 
 /*
  * given the LWGEOM serialized form (or a pointer into a muli* one)
- * construct a proper LWCURVE.
+ * construct a proper LWCIRCSTRING.
  * serialized_form should point to the 8bit type format (with type = 2)
  * See SERIALIZED_FORM doc
  */
-extern LWCURVE *lwcurve_deserialize(uchar *serialized_form);
+extern LWCIRCSTRING *lwcircstring_deserialize(uchar *serialized_form);
 
 /* find the size this curve would get when serialized */
-extern size_t lwcurve_serialize_size(LWCURVE *curve);
+extern size_t lwcircstring_serialize_size(LWCIRCSTRING *curve);
 
 /*
- * convert this curve into its serialize form
+ * convert this circularstring into its serialize form
  * result's first char will be the 8bit type.  See serialized form doc
  * copies data.
  */
-extern uchar *lwcurve_serialize(LWCURVE *curve);
+extern uchar *lwcircstring_serialize(LWCIRCSTRING *curve);
 
 /* same as above, writes to buf */
-extern void lwcurve_serialize_buf(LWCURVE *curve, uchar *buf, size_t *size);
+extern void lwcircstring_serialize_buf(LWCIRCSTRING *curve, uchar *buf, size_t *size);
 
 /*
  * find bounding box (standard one)  zmin=zmax=0 if 2d (might change to NaN)
  */
-extern BOX3D *lwcurve_compute_box3d(LWCURVE *curve);
+extern BOX3D *lwcircstring_compute_box3d(LWCIRCSTRING *curve);
 
-LWGEOM *lwcurve_add(const LWCURVE *to, uint32 where, const LWGEOM *what);
-extern int lwcurve_compute_box2d_p(LWCURVE *curve, BOX2DFLOAT4 *box);
-extern BOX3D *lwcurve_compute_box3d(LWCURVE *curve);
-LWCURVE *lwcurve_clone(const LWCURVE *curve);
-extern LWCURVE *lwgeom_getcurve_inspected(LWGEOM_INSPECTED *inspected, int geom_number);
-extern void lwfree_curve(LWCURVE  *curve);
+LWGEOM *lwcircstring_add(const LWCIRCSTRING *to, uint32 where, const LWGEOM *what);
+extern int lwcircstring_compute_box2d_p(LWCIRCSTRING *curve, BOX2DFLOAT4 *box);
+extern BOX3D *lwcircstring_compute_box3d(LWCIRCSTRING *curve);
+LWCIRCSTRING *lwcircstring_clone(const LWCIRCSTRING *curve);
+extern LWCIRCSTRING *lwgeom_getcircstring_inspected(LWGEOM_INSPECTED *inspected, int geom_number);
+extern void lwfree_circstring(LWCIRCSTRING  *curve);
 
 /******************************************************************
  * LWMULTIx and LWCOLLECTION functions

Copied: trunk/liblwgeom/lwcircstring.c (from rev 3519, trunk/liblwgeom/lwcurve.c)
===================================================================
--- trunk/liblwgeom/lwcurve.c	2009-01-12 19:29:57 UTC (rev 3519)
+++ trunk/liblwgeom/lwcircstring.c	2009-01-13 12:27:39 UTC (rev 3520)
@@ -0,0 +1,759 @@
+/**********************************************************************
+ * $Id$
+ *
+ * PostGIS - Spatial Types for PostgreSQL
+ * http://postgis.refractions.net
+ * Copyright 2001-2006 Refractions Research Inc.
+ *
+ * This is free software; you can redistribute and/or modify it under
+ * the terms of the GNU General Public Licence. See the COPYING file.
+ * 
+ **********************************************************************/
+
+/* basic LWCIRCSTRING functions */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include "liblwgeom.h"
+
+BOX3D *lwcircle_compute_box3d(POINT4D *p1, POINT4D *p2, POINT4D *p3);
+void printLWCIRCSTRING(LWCIRCSTRING *curve);
+void lwcircstring_reverse(LWCIRCSTRING *curve);
+LWCIRCSTRING *lwcircstring_segmentize2d(LWCIRCSTRING *curve, double dist);
+char lwcircstring_same(const LWCIRCSTRING *me, const LWCIRCSTRING *you);
+LWCIRCSTRING *lwcircstring_from_lwpointarray(int SRID, unsigned int npoints, LWPOINT **points);
+LWCIRCSTRING *lwcircstring_from_lwmpoint(int SRID, LWMPOINT *mpoint);
+LWCIRCSTRING *lwcircstring_addpoint(LWCIRCSTRING *curve, LWPOINT *point, unsigned int where);
+LWCIRCSTRING *lwcircstring_removepoint(LWCIRCSTRING *curve, unsigned int index);
+void lwcircstring_setPoint4d(LWCIRCSTRING *curve, unsigned int index, POINT4D *newpoint);
+
+
+
+#ifndef MAXFLOAT
+  #define MAXFLOAT      3.402823466e+38F
+#endif
+
+/*
+ * Construct a new LWCIRCSTRING.  points will *NOT* be copied
+ * use SRID=-1 for unknown SRID (will have 8bit type's S = 0)
+ */
+LWCIRCSTRING *
+lwcircstring_construct(int SRID, BOX2DFLOAT4 *bbox, POINTARRAY *points)
+{
+        LWCIRCSTRING *result;
+        
+	/*
+         * The first arc requires three points.  Each additional
+         * arc requires two more points.  Thus the minimum point count
+         * is three, and the count must be odd.
+         */
+        if(points->npoints % 2 != 1 || points->npoints < 3) 
+        {
+                lwerror("lwcircstring_construct: invalid point count %d", points->npoints);
+                return NULL;
+        }
+        
+        result = (LWCIRCSTRING*) lwalloc(sizeof(LWCIRCSTRING));
+
+        result->type = lwgeom_makeType_full(
+                TYPE_HASZ(points->dims),
+                TYPE_HASM(points->dims),
+                (SRID!=-1), CIRCSTRINGTYPE, 0);
+        result->SRID = SRID;
+        result->points = points;
+        result->bbox = bbox;
+         
+        return result;
+}
+
+/*
+ * given the LWGEOM serialized form (or a point into a multi* one)
+ * construct a proper LWCIRCSTRING.
+ * serialized_form should point to the 8bit type format (with type = 8)
+ * See serialized form doc
+ */
+LWCIRCSTRING *
+lwcircstring_deserialize(uchar *serialized_form)
+{
+        uchar type;
+        LWCIRCSTRING *result;
+        uchar *loc=NULL;
+        uint32 npoints;
+        POINTARRAY *pa;
+
+        type = (uchar)serialized_form[0];
+        if(lwgeom_getType(type) != CIRCSTRINGTYPE)
+        {
+                lwerror("lwcircstring_deserialize: attempt to deserialize a circularstring which is really a %s", lwgeom_typename(type));
+                return NULL;
+        }
+
+        result = (LWCIRCSTRING*) lwalloc(sizeof(LWCIRCSTRING));
+        result->type = type;
+
+        loc = serialized_form + 1;
+
+        if(lwgeom_hasBBOX(type))
+        {
+                LWDEBUG(3, "lwcircstring_deserialize: input has bbox");
+
+                result->bbox = lwalloc(sizeof(BOX2DFLOAT4));
+                memcpy(result->bbox, loc, sizeof(BOX2DFLOAT4));
+                loc += sizeof(BOX2DFLOAT4);               
+         }
+         else
+         {
+                LWDEBUG(3, "lwcircstring_deserialize: input lacks bbox");           
+               
+                result->bbox = NULL;
+         }
+
+         if(lwgeom_hasSRID(type))
+         {
+                LWDEBUG(3, "lwcircstring_deserialize: input has srid");
+
+                result->SRID = lw_get_int32(loc);               
+                loc += 4; /* type + SRID */
+         }
+         else
+         {
+                LWDEBUG(3, "lwcircstring_deserialize: input lacks srid");
+
+                result->SRID = -1;                
+         }
+
+         /* we've read the type (1 byte) and SRID (4 bytes, if present) */
+
+         npoints = lw_get_uint32(loc);
+
+         LWDEBUGF(3, "circstring npoints = %d", npoints);
+         
+         loc += 4;
+         pa = pointArray_construct(loc, TYPE_HASZ(type), TYPE_HASM(type), npoints);
+         result->points = pa;
+         return result;
+}
+
+/*
+ * convert this circularstring into its serialized form
+ * result's first char will be the 8bit type. See serialized form doc
+ */
+uchar *
+lwcircstring_serialize(LWCIRCSTRING *curve)
+{
+        size_t size, retsize;
+        uchar * result;
+
+        if(curve == NULL) {
+                lwerror("lwcircstring_serialize:: given null curve");
+                return NULL;
+        }
+
+        size = lwcircstring_serialize_size(curve);
+        result = lwalloc(size);
+        lwcircstring_serialize_buf(curve, result, &retsize);
+        if(retsize != size)
+                lwerror("lwcircstring_serialize_size returned %d, ..serialize_buf returned %d", size, retsize);
+        return result;
+}
+
+/*
+ * convert this circularstring into its serialized form writing it into 
+ * the given buffer, and returning number of bytes written into 
+ * the given int pointer.
+ * result's first char will be the 8bit type.  See serialized form doc
+ */
+void lwcircstring_serialize_buf(LWCIRCSTRING *curve, uchar *buf, size_t *retsize)
+{
+        char hasSRID;
+        uchar *loc;
+        int ptsize;
+        size_t size;
+
+        LWDEBUGF(2, "lwcircstring_serialize_buf(%p, %p, %p) called",
+                curve, buf, retsize);
+
+        if(curve == NULL) 
+        {
+                lwerror("lwcircstring_serialize:: given null curve");
+                return;
+        }
+
+        if(TYPE_GETZM(curve->type) != TYPE_GETZM(curve->points->dims))
+        {
+                lwerror("Dimensions mismatch in lwcircstring");
+                return;
+        }
+
+        ptsize = pointArray_ptsize(curve->points);
+
+        hasSRID = (curve->SRID != -1);
+
+        buf[0] = (uchar)lwgeom_makeType_full(
+                TYPE_HASZ(curve->type), TYPE_HASM(curve->type),
+                hasSRID, CIRCSTRINGTYPE, curve->bbox ? 1 : 0);
+        loc = buf+1;
+
+        LWDEBUGF(3, "lwcircstring_serialize_buf added type (%d)", curve->type);
+
+        if(curve->bbox)
+        {
+                memcpy(loc, curve->bbox, sizeof(BOX2DFLOAT4));
+                loc += sizeof(BOX2DFLOAT4);
+
+                LWDEBUG(3, "lwcircstring_serialize_buf added BBOX");
+        }                
+
+        if(hasSRID)
+        {
+                memcpy(loc, &curve->SRID, sizeof(int32));
+                loc += sizeof(int32);
+
+                LWDEBUG(3, "lwcircstring_serialize_buf added SRID");
+        }
+
+        memcpy(loc, &curve->points->npoints, sizeof(uint32));
+        loc += sizeof(uint32);
+
+        LWDEBUGF(3, "lwcircstring_serialize_buf added npoints (%d)",
+            curve->points->npoints);
+
+        /* copy in points */
+        size = curve->points->npoints * ptsize;
+        memcpy(loc, getPoint_internal(curve->points, 0), size);
+        loc += size;
+
+        LWDEBUGF(3, "lwcircstring_serialize_buf copied serialized_pointlist (%d bytes)",
+                ptsize * curve->points->npoints);        
+
+        if(retsize) *retsize = loc-buf;
+
+        LWDEBUGF(3, "lwcircstring_serialize_buf returning (loc: %p, size: %d)",
+                loc, loc-buf);
+}
+
+/* find length of this deserialized circularstring */
+size_t
+lwcircstring_serialize_size(LWCIRCSTRING *curve)
+{
+        size_t size = 1; /* type */
+
+        LWDEBUG(2, "lwcircstring_serialize_size called");        
+
+        if(curve->SRID != -1) size += 4; /* SRID */
+        if(curve->bbox) size += sizeof(BOX2DFLOAT4);
+
+        size += 4; /* npoints */
+        size += pointArray_ptsize(curve->points) * curve->points->npoints;
+
+        LWDEBUGF(3, "lwcircstring_serialize_size returning %d", size);
+
+        return size;
+}
+
+BOX3D *
+lwcircle_compute_box3d(POINT4D *p1, POINT4D *p2, POINT4D *p3)
+{
+        double x1, x2, y1, y2, z1, z2;
+        double angle, radius, sweep;
+	/* angles from center */
+        double a1, a2, a3;
+	/* angles from center once a1 is rotated to zero */
+	double r2, r3;
+        double xe = 0.0, ye = 0.0;
+        POINT4D *center;
+        int i;
+        BOX3D *box;
+
+        LWDEBUG(2, "lwcircle_compute_box3d called.");
+
+        center = lwalloc(sizeof(POINT4D));
+        radius = lwcircle_center(p1, p2, p3, &center);
+        if(radius < 0.0) return NULL;
+
+        /*
+        top = center->y + radius;
+        left = center->x - radius;
+
+        LWDEBUGF(3, "lwcircle_compute_box3d: center (%.16f, %.16f)", center->x, center->y);
+        */
+
+        x1 = MAXFLOAT;
+        x2 = -1 * MAXFLOAT;
+        y1 = MAXFLOAT;
+        y2 = -1 * MAXFLOAT;
+
+        a1 = atan2(p1->y - center->y, p1->x - center->x);
+        a2 = atan2(p2->y - center->y, p2->x - center->x);
+        a3 = atan2(p3->y - center->y, p3->x - center->x);
+
+	/* Rotate a2 and a3 such that a1 = 0 */
+	r2 = a2 - a1;
+	r3 = a3 - a1;
+
+        /*
+         * There are six cases here I'm interested in
+         * Clockwise:
+         *   1. a1-a2 < 180 == r2 < 0 && (r3 > 0 || r3 < r2)
+         *   2. a1-a2 > 180 == r2 > 0 && (r3 > 0 && r3 < r2)
+         *   3. a1-a2 > 180 == r2 > 0 && (r3 > r2 || r3 < 0)
+         * Counter-clockwise:
+         *   4. a1-a2 < 180 == r2 > 0 && (r3 < 0 || r3 > r2)
+         *   5. a1-a2 > 180 == r2 < 0 && (r3 < 0 && r3 > r2)
+         *   6. a1-a2 > 180 == r2 < 0 && (r3 < r2 || r3 > 0)
+         * 3 and 6 are invalid cases where a3 is the midpoint.
+         * BBOX is fundamental, so these cannot error out and will instead
+         * calculate the sweep using a3 as the middle point.
+         */
+
+        /* clockwise 1 */
+        if(FP_LT(r2, 0) && (FP_GT(r3, 0) || FP_LT(r3, r2)))
+        {
+            sweep = (FP_GT(r3, 0)) ? (r3 - 2 * M_PI) : r3;
+        }
+        /* clockwise 2 */
+        else if(FP_GT(r2, 0) && FP_GT(r3, 0) && FP_LT(r3, r2))
+        {
+            sweep = (FP_GT(r3, 0)) ? (r3 - 2 * M_PI) : r3;
+        }
+        /* counter-clockwise 4 */
+        else if(FP_GT(r2, 0) && (FP_LT(r3, 0) || FP_GT(r3, r2)))
+        {
+            sweep = (FP_LT(r3, 0)) ? (r3 + 2 * M_PI) : r3;
+        }
+        /* counter-clockwise 5 */
+        else if(FP_LT(r2, 0) && FP_LT(r3, 0) && FP_GT(r3, r2))
+        {
+            sweep = (FP_LT(r3, 0)) ? (r3 + 2 * M_PI) : r3;
+        }
+        /* clockwise invalid 3 */
+        else if(FP_GT(r2, 0) && (FP_GT(r3, r2) || FP_LT(r3, 0)))
+        {
+            sweep = (FP_GT(r2, 0)) ? (r2 - 2 * M_PI) : r2;
+        }
+        /* clockwise invalid 6 */
+        else
+        {
+            sweep = (FP_LT(r2, 0)) ? (r2 + 2 * M_PI) : r2;
+        }
+
+        LWDEBUGF(3, "a1 %.16f, a2 %.16f, a3 %.16f, sweep %.16f", a1, a2, a3, sweep);
+
+        angle = 0.0;
+        for(i=0; i < 6; i++)
+        {
+                switch(i) {
+		/* right extent */
+                case 0:
+                        angle = 0.0;
+                        xe = center->x + radius;
+                        ye = center->y;
+                        break;
+		/* top extent */
+                case 1:
+                        angle = M_PI_2;
+                        xe = center->x;
+                        ye = center->y + radius;
+                        break;
+		/* left extent */
+                case 2:
+                        angle = M_PI;
+                        xe = center->x - radius;
+                        ye = center->y;
+                        break;
+		/* bottom extent */
+                case 3:
+                        angle = -1 * M_PI_2;
+                        xe = center->x;
+                        ye = center->y - radius;
+                        break;
+		/* first point */
+                case 4:
+                        angle = a1;
+                        xe = p1->x;
+                        ye = p1->y;
+                        break;
+		/* last point */
+                case 5:
+                        angle = a3;
+                        xe = p3->x;
+                        ye = p3->y;
+                        break;
+                }
+		/* determine if the extents are outside the arc */
+                if(i < 4) 
+                {
+		    if(FP_GT(sweep, 0.0))
+		    {
+		        if(FP_LT(a3, a1))
+		        {
+			    if(FP_GT(angle, (a3 + 2 * M_PI)) || FP_LT(angle, a1)) continue;
+		        }
+		        else
+		        {
+			    if(FP_GT(angle, a3) || FP_LT(angle, a1)) continue;
+		        }
+                    }
+		    else
+		    {
+		        if(FP_GT(a3, a1))
+		        {
+			    if(FP_LT(angle, (a3 - 2 * M_PI)) || FP_GT(angle, a1)) continue;
+		        }
+		        else
+		        {
+			    if(FP_LT(angle, a3) || FP_GT(angle, a1)) continue;
+		        }
+		    }
+		}
+
+                LWDEBUGF(3, "lwcircle_compute_box3d: potential extreame %d (%.16f, %.16f)", i, xe, ye);
+
+                x1 = (FP_LT(x1, xe)) ? x1 : xe;
+                y1 = (FP_LT(y1, ye)) ? y1 : ye;
+                x2 = (FP_GT(x2, xe)) ? x2 : xe;
+                y2 = (FP_GT(y2, ye)) ? y2 : ye;
+        }
+
+        LWDEBUGF(3, "lwcircle_compute_box3d: extreames found (%.16f %.16f, %.16f %.16f)", x1, y1, x2, y2);
+
+        /*
+        x1 = center->x + x1 * radius;
+        x2 = center->x + x2 * radius;
+        y1 = center->y + y1 * radius;
+        y2 = center->y + y2 * radius;
+        */
+        z1 = (FP_LT(p1->z, p2->z)) ? p1->z : p2->z;
+        z1 = (FP_LT(z1, p3->z)) ? z1 : p3->z;
+        z2 = (FP_GT(p1->z, p2->z)) ? p1->z : p2->z;
+        z2 = (FP_GT(z2, p3->z)) ? z2 : p3->z;
+
+        box = lwalloc(sizeof(BOX3D));
+        box->xmin = x1; box->xmax = x2;
+        box->ymin = y1; box->ymax = y2;
+        box->zmin = z1; box->zmax = z2;
+
+        lwfree(center);
+
+        return box;
+}
+
+/*
+ * Find bounding box (standard one)
+ * zmin=zmax=NO_Z_VALUE if 2d
+ * TODO: This ignores curvature, which should be taken into account.
+ */
+BOX3D *
+lwcircstring_compute_box3d(LWCIRCSTRING *curve)
+{
+        BOX3D *box, *tmp; 
+        int i;
+        POINT4D *p1 = lwalloc(sizeof(POINT4D));
+        POINT4D *p2 = lwalloc(sizeof(POINT4D));
+        POINT4D *p3 = lwalloc(sizeof(POINT4D));
+
+        LWDEBUG(2, "lwcircstring_compute_box3d called.");
+
+        /* initialize box values */
+        box = lwalloc(sizeof(BOX3D));
+        box->xmin = MAXFLOAT; box->xmax = -1 * MAXFLOAT;
+        box->ymin = MAXFLOAT; box->ymax = -1 * MAXFLOAT;
+        box->zmin = MAXFLOAT; box->zmax = -1 * MAXFLOAT;
+        
+        for(i = 2; i < curve->points->npoints; i+=2)
+        {
+                getPoint4d_p(curve->points, i-2, p1);
+                getPoint4d_p(curve->points, i-1, p2);
+                getPoint4d_p(curve->points, i, p3);
+                tmp = lwcircle_compute_box3d(p1, p2, p3);
+                if(tmp == NULL) continue;
+                box->xmin = (box->xmin < tmp->xmin) ? box->xmin : tmp->xmin;
+                box->xmax = (box->xmax > tmp->xmax) ? box->xmax : tmp->xmax;
+                box->ymin = (box->ymin < tmp->ymin) ? box->ymin : tmp->ymin;
+                box->ymax = (box->ymax > tmp->ymax) ? box->ymax : tmp->ymax;
+                box->zmin = (box->zmin < tmp->zmin) ? box->zmin : tmp->zmin;
+                box->zmax = (box->zmax > tmp->zmax) ? box->zmax : tmp->zmax;
+
+                LWDEBUGF(4, "circularstring %d x=(%.16f,%.16f) y=(%.16f,%.16f) z=(%.16f,%.16f)", i/2, box->xmin, box->xmax, box->ymin, box->ymax, box->zmin, box->zmax);
+        }
+
+        
+        return box;
+}
+
+int
+lwcircstring_compute_box2d_p(LWCIRCSTRING *curve, BOX2DFLOAT4 *result)
+{
+        BOX3D *box = lwcircstring_compute_box3d(curve);
+        LWDEBUG(2, "lwcircstring_compute_box2d_p called.");
+
+        if(box == NULL) return 0;
+        box3d_to_box2df_p(box, result);
+        return 1;
+}
+
+void lwfree_circstring(LWCIRCSTRING *curve)
+{
+        lwfree(curve->points);
+        lwfree(curve);
+}
+
+/* find length of this serialized curve */
+size_t
+lwgeom_size_circstring(const uchar *serialized_curve)
+{
+        int type = (uchar)serialized_curve[0];
+        uint32 result = 1; /* type */
+        const uchar *loc;
+        uint32 npoints;
+
+        LWDEBUG(2, "lwgeom_size_circstring called");
+
+        if(lwgeom_getType(type) != CIRCSTRINGTYPE)
+                lwerror("lwgeom_size_circstring::attempt to find the length of a non-circularstring");
+
+        loc = serialized_curve + 1;
+        if(lwgeom_hasBBOX(type))
+        {
+                loc += sizeof(BOX2DFLOAT4);
+                result += sizeof(BOX2DFLOAT4);
+        }
+
+        if(lwgeom_hasSRID(type))
+        {
+                loc += 4; /* type + SRID */
+                result += 4;
+        }
+
+        /* we've read the type (1 byte) and SRID (4 bytes, if present) */
+        npoints = lw_get_uint32(loc);
+        result += sizeof(uint32); /* npoints */
+
+        result += TYPE_NDIMS(type) * sizeof(double) * npoints;
+
+        LWDEBUGF(3, "lwgeom_size_circstring returning %d", result);
+
+        return result;
+}
+
+void printLWCIRCSTRING(LWCIRCSTRING *curve)
+{
+        lwnotice("LWCIRCSTRING {");
+        lwnotice("    ndims = %i", (int)TYPE_NDIMS(curve->type));
+        lwnotice("    SRID = %i", (int)curve->SRID);
+        printPA(curve->points);
+        lwnotice("}");
+}
+
+/* Clone LWCIRCSTRING object.  POINTARRAY is not copied. */
+LWCIRCSTRING *
+lwcircstring_clone(const LWCIRCSTRING *g)
+{
+        LWCIRCSTRING *ret = lwalloc(sizeof(LWCIRCSTRING));
+        memcpy(ret, g, sizeof(LWCIRCSTRING));
+        if(g->bbox) ret->bbox = box2d_clone(g->bbox);
+        return ret;
+}
+
+/*
+ * Add 'what' to this curve at position 'where'.
+ * where=0 == prepend
+ * where=-1 == append
+ * Returns a MULTICURVE or a GEOMETRYCOLLECTION
+ */
+LWGEOM *
+lwcircstring_add(const LWCIRCSTRING *to, uint32 where, const LWGEOM *what)
+{
+        LWCOLLECTION *col;
+        LWGEOM **geoms;
+        int newtype;
+        
+        if(where != -1 && where != 0)
+        {
+                lwerror("lwcurve_add only supports 0 or -1 as second argument %d", where);
+                return NULL;
+        }
+
+        /* dimensions compatibility are checked by caller */
+
+        /* Construct geoms array */
+        geoms = lwalloc(sizeof(LWGEOM *)*2);
+        if(where == -1) /* append */
+        {
+                geoms[0] = lwgeom_clone((LWGEOM *)to);
+                geoms[1] = lwgeom_clone(what);
+        }
+        else /* prepend */
+        {
+                geoms[0] = lwgeom_clone(what);
+                geoms[1] = lwgeom_clone((LWGEOM *)to);
+        }
+        
+        /* reset SRID and wantbbox flag from component types */
+        geoms[0]->SRID = geoms[1]->SRID = -1;
+        TYPE_SETHASSRID(geoms[0]->type, 0);
+        TYPE_SETHASSRID(geoms[1]->type, 0);
+        TYPE_SETHASBBOX(geoms[0]->type, 0);
+        TYPE_SETHASBBOX(geoms[1]->type, 0);
+
+        /* Find appropriate geom type */
+        if(TYPE_GETTYPE(what->type) == CIRCSTRINGTYPE || TYPE_GETTYPE(what->type) == LINETYPE) newtype = MULTICURVETYPE;
+        else newtype = COLLECTIONTYPE;
+
+        col = lwcollection_construct(newtype, 
+                to->SRID, NULL, 
+                2, geoms);
+
+        return (LWGEOM *)col;
+}
+
+void lwcircstring_reverse(LWCIRCSTRING *curve)
+{
+        ptarray_reverse(curve->points);
+}
+
+/*
+ * TODO: Invalid segmentization.  This should accomodate the curvature.
+ */
+LWCIRCSTRING *
+lwcircstring_segmentize2d(LWCIRCSTRING *curve, double dist)
+{
+        return lwcircstring_construct(curve->SRID, NULL,
+                ptarray_segmentize2d(curve->points, dist));
+}
+                    
+/* check coordinate equality */
+char
+lwcircstring_same(const LWCIRCSTRING *me, const LWCIRCSTRING *you)
+{
+        return ptarray_same(me->points, you->points);
+}
+
+/*
+ * Construct a LWCIRCSTRING from an array of LWPOINTs
+ * LWCIRCSTRING dimensions are large enough to host all input dimensions.
+ */
+LWCIRCSTRING *
+lwcircstring_from_lwpointarray(int SRID, unsigned int npoints, LWPOINT **points)
+{
+        int zmflag=0;
+        unsigned int i;
+        POINTARRAY *pa;
+        uchar *newpoints, *ptr;
+        size_t ptsize, size;
+
+        /*
+         * Find output dimensions, check integrity
+         */
+        for(i = 0; i < npoints; i++)
+        {
+                if(TYPE_GETTYPE(points[i]->type) != POINTTYPE)
+                {
+                        lwerror("lwcurve_from_lwpointarray: invalid input type: %s",
+                            lwgeom_typename(TYPE_GETTYPE(points[i]->type)));
+                        return NULL;
+                }
+                if(TYPE_HASZ(points[i]->type)) zmflag |= 2;
+                if(TYPE_HASM(points[i]->type)) zmflag |=1;
+                if(zmflag == 3) break;
+        }
+
+        if(zmflag == 0) ptsize = 2 * sizeof(double);
+        else if(zmflag == 3) ptsize = 4 * sizeof(double);
+        else ptsize = 3 * sizeof(double);
+
+        /*
+         * Allocate output points array
+         */
+        size = ptsize * npoints;
+        newpoints = lwalloc(size);
+        memset(newpoints, 0, size);
+
+        ptr = newpoints;
+        for(i = 0; i < npoints; i++)
+        {
+                size = pointArray_ptsize(points[i]->point);
+                memcpy(ptr, getPoint_internal(points[i]->point, 0), size);
+                ptr += ptsize;
+        }
+        pa = pointArray_construct(newpoints, zmflag&2, zmflag&1, npoints);
+
+        return lwcircstring_construct(SRID, NULL, pa);
+}
+
+/*
+ * Construct a LWCIRCSTRING from a LWMPOINT
+ */
+LWCIRCSTRING *
+lwcircstring_from_lwmpoint(int SRID, LWMPOINT *mpoint)
+{
+        unsigned int i;
+        POINTARRAY *pa;
+        char zmflag = TYPE_GETZM(mpoint->type);
+        size_t ptsize, size;
+        uchar *newpoints, *ptr;
+
+        if(zmflag == 0) ptsize = 2 * sizeof(double);
+        else if(zmflag == 3) ptsize = 4 * sizeof(double);
+        else ptsize = 3 * sizeof(double);
+
+        /* Allocate space for output points */
+        size = ptsize * mpoint->ngeoms;
+        newpoints = lwalloc(size);
+        memset(newpoints, 0, size);
+
+        ptr = newpoints;
+        for(i = 0; i < mpoint->ngeoms; i++)
+        {
+                memcpy(ptr,
+                        getPoint_internal(mpoint->geoms[i]->point, 0),
+                        ptsize);
+                ptr += ptsize;
+        }
+
+        pa = pointArray_construct(newpoints, zmflag&2, zmflag&1,
+                mpoint->ngeoms);
+
+        LWDEBUGF(3, "lwcurve_from_lwmpoint: constructed pointarray for %d points, %d zmflag", mpoint->ngeoms, zmflag);
+        
+        return lwcircstring_construct(SRID, NULL, pa);
+}
+
+LWCIRCSTRING *
+lwcircstring_addpoint(LWCIRCSTRING *curve, LWPOINT *point, unsigned int where)
+{
+        POINTARRAY *newpa;
+        LWCIRCSTRING *ret;
+
+        newpa = ptarray_addPoint(curve->points, 
+                getPoint_internal(point->point, 0),
+                TYPE_NDIMS(point->type), where);
+        ret = lwcircstring_construct(curve->SRID, NULL, newpa);
+
+        return ret;
+}
+
+LWCIRCSTRING *
+lwcircstring_removepoint(LWCIRCSTRING *curve, unsigned int index)
+{
+        POINTARRAY *newpa;
+        LWCIRCSTRING *ret;
+
+        newpa = ptarray_removePoint(curve->points, index);
+        ret = lwcircstring_construct(curve->SRID, NULL, newpa);
+
+        return ret;
+}
+
+/*
+ * Note: input will be changed, make sure you have permissions for this.
+ * */
+void
+lwcircstring_setPoint4d(LWCIRCSTRING *curve, unsigned int index, POINT4D *newpoint)
+{
+        setPoint4d(curve->points, index, newpoint);
+}
+
+


Property changes on: trunk/liblwgeom/lwcircstring.c
___________________________________________________________________
Name: svn:mergeinfo
   + 

Modified: trunk/liblwgeom/lwcollection.c
===================================================================
--- trunk/liblwgeom/lwcollection.c	2009-01-12 19:29:57 UTC (rev 3519)
+++ trunk/liblwgeom/lwcollection.c	2009-01-13 12:27:39 UTC (rev 3520)
@@ -378,7 +378,7 @@
 			switch(TYPE_GETTYPE(col->geoms[i]->type)) {
 				case POINTTYPE:
 				case LINETYPE:
-				case CURVETYPE:
+				case CIRCSTRINGTYPE:
 				case POLYGONTYPE:
 					ngeoms += 1;
 					break;

Modified: trunk/liblwgeom/lwcompound.c
===================================================================
--- trunk/liblwgeom/lwcompound.c	2009-01-12 19:29:57 UTC (rev 3519)
+++ trunk/liblwgeom/lwcompound.c	2009-01-13 12:27:39 UTC (rev 3520)
@@ -49,10 +49,10 @@
                 if(lwgeom_getType(insp->sub_geoms[i][0]) == LINETYPE)
                         result->geoms[i] = (LWGEOM *)lwline_deserialize(insp->sub_geoms[i]);
                 else
-                        result->geoms[i] = (LWGEOM *)lwcurve_deserialize(insp->sub_geoms[i]);
+                        result->geoms[i] = (LWGEOM *)lwcircstring_deserialize(insp->sub_geoms[i]);
                 if(TYPE_NDIMS(result->geoms[i]->type) != TYPE_NDIMS(result->type))
                 {
-                        lwerror("Mixed dimensions (compound:%d, line/curve%d:%d)",
+                        lwerror("Mixed dimensions (compound: %d, line/circularstring %d:%d)",
                             TYPE_NDIMS(result->type), i,
                             TYPE_NDIMS(result->geoms[i]->type)
                         );
@@ -107,7 +107,7 @@
         TYPE_SETHASBBOX(geoms[1]->type, 0);
 
         /* Find appropriate geom type */
-        if(TYPE_GETTYPE(what->type) == LINETYPE || TYPE_GETTYPE(what->type) == CURVETYPE) newtype = COMPOUNDTYPE;
+        if(TYPE_GETTYPE(what->type) == LINETYPE || TYPE_GETTYPE(what->type) == CIRCSTRINGTYPE) newtype = COMPOUNDTYPE;
         else newtype = COLLECTIONTYPE;
 
         col = lwcollection_construct(newtype,

Deleted: trunk/liblwgeom/lwcurve.c
===================================================================
--- trunk/liblwgeom/lwcurve.c	2009-01-12 19:29:57 UTC (rev 3519)
+++ trunk/liblwgeom/lwcurve.c	2009-01-13 12:27:39 UTC (rev 3520)
@@ -1,759 +0,0 @@
-/**********************************************************************
- * $Id$
- *
- * PostGIS - Spatial Types for PostgreSQL
- * http://postgis.refractions.net
- * Copyright 2001-2006 Refractions Research Inc.
- *
- * This is free software; you can redistribute and/or modify it under
- * the terms of the GNU General Public Licence. See the COPYING file.
- * 
- **********************************************************************/
-
-/* basic LWCURVE functions */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include "liblwgeom.h"
-
-BOX3D *lwcircle_compute_box3d(POINT4D *p1, POINT4D *p2, POINT4D *p3);
-void printLWCURVE(LWCURVE *curve);
-void lwcurve_reverse(LWCURVE *curve);
-LWCURVE *lwcurve_segmentize2d(LWCURVE *curve, double dist);
-char lwcurve_same(const LWCURVE *me, const LWCURVE *you);
-LWCURVE *lwcurve_from_lwpointarray(int SRID, unsigned int npoints, LWPOINT **points);
-LWCURVE *lwcurve_from_lwmpoint(int SRID, LWMPOINT *mpoint);
-LWCURVE *lwcurve_addpoint(LWCURVE *curve, LWPOINT *point, unsigned int where);
-LWCURVE *lwcurve_removepoint(LWCURVE *curve, unsigned int index);
-void lwcurve_setPoint4d(LWCURVE *curve, unsigned int index, POINT4D *newpoint);
-
-
-
-#ifndef MAXFLOAT
-  #define MAXFLOAT      3.402823466e+38F
-#endif
-
-/*
- * Construct a new LWCURVE.  points will *NOT* be copied
- * use SRID=-1 for unknown SRID (will have 8bit type's S = 0)
- */
-LWCURVE *
-lwcurve_construct(int SRID, BOX2DFLOAT4 *bbox, POINTARRAY *points)
-{
-        LWCURVE *result;
-        
-	/*
-         * The first arc requires three points.  Each additional
-         * arc requires two more points.  Thus the minimum point count
-         * is three, and the count must be odd.
-         */
-        if(points->npoints % 2 != 1 || points->npoints < 3) 
-        {
-                lwerror("lwcurve_construct: invalid point count %d", points->npoints);
-                return NULL;
-        }
-        
-        result = (LWCURVE*) lwalloc(sizeof(LWCURVE));
-
-        result->type = lwgeom_makeType_full(
-                TYPE_HASZ(points->dims),
-                TYPE_HASM(points->dims),
-                (SRID!=-1), CURVETYPE, 0);
-        result->SRID = SRID;
-        result->points = points;
-        result->bbox = bbox;
-         
-        return result;
-}
-
-/*
- * given the LWGEOM serialized form (or a point into a multi* one)
- * construct a propert LWCURVE.
- * serialized_form should point to the 8bit type format (with type = 8)
- * See serialized form doc
- */
-LWCURVE *
-lwcurve_deserialize(uchar *serialized_form)
-{
-        uchar type;
-        LWCURVE *result;
-        uchar *loc=NULL;
-        uint32 npoints;
-        POINTARRAY *pa;
-
-        type = (uchar)serialized_form[0];
-        if(lwgeom_getType(type) != CURVETYPE)
-        {
-                lwerror("lwcurve_deserialize: attempt to deserialize a curve which is really a %s", lwgeom_typename(type));
-                return NULL;
-        }
-
-        result = (LWCURVE*) lwalloc(sizeof(LWCURVE));
-        result->type = type;
-
-        loc = serialized_form + 1;
-
-        if(lwgeom_hasBBOX(type))
-        {
-                LWDEBUG(3, "lwcurve_deserialize: input has bbox");
-
-                result->bbox = lwalloc(sizeof(BOX2DFLOAT4));
-                memcpy(result->bbox, loc, sizeof(BOX2DFLOAT4));
-                loc += sizeof(BOX2DFLOAT4);               
-         }
-         else
-         {
-                LWDEBUG(3, "lwcurve_deserialize: input lacks bbox");           
-               
-                result->bbox = NULL;
-         }
-
-         if(lwgeom_hasSRID(type))
-         {
-                LWDEBUG(3, "lwcurve_deserialize: input has srid");
-
-                result->SRID = lw_get_int32(loc);               
-                loc += 4; /* type + SRID */
-         }
-         else
-         {
-                LWDEBUG(3, "lwcurve_deserialize: input lacks srid");
-
-                result->SRID = -1;                
-         }
-
-         /* we've read the type (1 byte) and SRID (4 bytes, if present) */
-
-         npoints = lw_get_uint32(loc);
-
-         LWDEBUGF(3, "curve npoints = %d", npoints);
-         
-         loc += 4;
-         pa = pointArray_construct(loc, TYPE_HASZ(type), TYPE_HASM(type), npoints);
-         result->points = pa;
-         return result;
-}
-
-/*
- * convert this curve into its serialized form
- * result's first char will be the 8bit type. See serialized form doc
- */
-uchar *
-lwcurve_serialize(LWCURVE *curve)
-{
-        size_t size, retsize;
-        uchar * result;
-
-        if(curve == NULL) {
-                lwerror("lwcurve_serialize:: given null curve");
-                return NULL;
-        }
-
-        size = lwcurve_serialize_size(curve);
-        result = lwalloc(size);
-        lwcurve_serialize_buf(curve, result, &retsize);
-        if(retsize != size)
-                lwerror("lwcurve_serialize_size returned %d, ..selialize_buf returned %d", size, retsize);
-        return result;
-}
-
-/*
- * convert this curve into its serialized form writing it into 
- * the given buffer, and returning number of bytes written into 
- * the given int pointer.
- * result's first char will be the 8bit type.  See serialized form doc
- */
-void lwcurve_serialize_buf(LWCURVE *curve, uchar *buf, size_t *retsize)
-{
-        char hasSRID;
-        uchar *loc;
-        int ptsize;
-        size_t size;
-
-        LWDEBUGF(2, "lwcurve_serialize_buf(%p, %p, %p) called",
-                curve, buf, retsize);
-
-        if(curve == NULL) 
-        {
-                lwerror("lwcurve_serialize:: given null curve");
-                return;
-        }
-
-        if(TYPE_GETZM(curve->type) != TYPE_GETZM(curve->points->dims))
-        {
-                lwerror("Dimensions mismatch in lwcurve");
-                return;
-        }
-
-        ptsize = pointArray_ptsize(curve->points);
-
-        hasSRID = (curve->SRID != -1);
-
-        buf[0] = (uchar)lwgeom_makeType_full(
-                TYPE_HASZ(curve->type), TYPE_HASM(curve->type),
-                hasSRID, CURVETYPE, curve->bbox ? 1 : 0);
-        loc = buf+1;
-
-        LWDEBUGF(3, "lwcurve_serialize_buf added type (%d)", curve->type);
-
-        if(curve->bbox)
-        {
-                memcpy(loc, curve->bbox, sizeof(BOX2DFLOAT4));
-                loc += sizeof(BOX2DFLOAT4);
-
-                LWDEBUG(3, "lwcurve_serialize_buf added BBOX");
-        }                
-
-        if(hasSRID)
-        {
-                memcpy(loc, &curve->SRID, sizeof(int32));
-                loc += sizeof(int32);
-
-                LWDEBUG(3, "lwcurve_serialize_buf added SRID");
-        }
-
-        memcpy(loc, &curve->points->npoints, sizeof(uint32));
-        loc += sizeof(uint32);
-
-        LWDEBUGF(3, "lwcurve_serialize_buf added npoints (%d)",
-            curve->points->npoints);
-
-        /* copy in points */
-        size = curve->points->npoints * ptsize;
-        memcpy(loc, getPoint_internal(curve->points, 0), size);
-        loc += size;
-
-        LWDEBUGF(3, "lwcurve_serialize_buf copied serialized_pointlist (%d bytes)",
-                ptsize * curve->points->npoints);        
-
-        if(retsize) *retsize = loc-buf;
-
-        LWDEBUGF(3, "lwcurve_serialize_buf returning (loc: %p, size: %d)",
-                loc, loc-buf);
-}
-
-/* find length of this deserialized curve */
-size_t
-lwcurve_serialize_size(LWCURVE *curve)
-{
-        size_t size = 1; /* type */
-
-        LWDEBUG(2, "lwcurve_serialize_size called");        
-
-        if(curve->SRID != -1) size += 4; /* SRID */
-        if(curve->bbox) size += sizeof(BOX2DFLOAT4);
-
-        size += 4; /* npoints */
-        size += pointArray_ptsize(curve->points) * curve->points->npoints;
-
-        LWDEBUGF(3, "lwcurve_serialize_size returning %d", size);
-
-        return size;
-}
-
-BOX3D *
-lwcircle_compute_box3d(POINT4D *p1, POINT4D *p2, POINT4D *p3)
-{
-        double x1, x2, y1, y2, z1, z2;
-        double angle, radius, sweep;
-	/* angles from center */
-        double a1, a2, a3;
-	/* angles from center once a1 is rotated to zero */
-	double r2, r3;
-        double xe = 0.0, ye = 0.0;
-        POINT4D *center;
-        int i;
-        BOX3D *box;
-
-        LWDEBUG(2, "lwcircle_compute_box3d called.");
-
-        center = lwalloc(sizeof(POINT4D));
-        radius = lwcircle_center(p1, p2, p3, &center);
-        if(radius < 0.0) return NULL;
-
-        /*
-        top = center->y + radius;
-        left = center->x - radius;
-
-        LWDEBUGF(3, "lwcircle_compute_box3d: center (%.16f, %.16f)", center->x, center->y);
-        */
-
-        x1 = MAXFLOAT;
-        x2 = -1 * MAXFLOAT;
-        y1 = MAXFLOAT;
-        y2 = -1 * MAXFLOAT;
-
-        a1 = atan2(p1->y - center->y, p1->x - center->x);
-        a2 = atan2(p2->y - center->y, p2->x - center->x);
-        a3 = atan2(p3->y - center->y, p3->x - center->x);
-
-	/* Rotate a2 and a3 such that a1 = 0 */
-	r2 = a2 - a1;
-	r3 = a3 - a1;
-
-        /*
-         * There are six cases here I'm interested in
-         * Clockwise:
-         *   1. a1-a2 < 180 == r2 < 0 && (r3 > 0 || r3 < r2)
-         *   2. a1-a2 > 180 == r2 > 0 && (r3 > 0 && r3 < r2)
-         *   3. a1-a2 > 180 == r2 > 0 && (r3 > r2 || r3 < 0)
-         * Counter-clockwise:
-         *   4. a1-a2 < 180 == r2 > 0 && (r3 < 0 || r3 > r2)
-         *   5. a1-a2 > 180 == r2 < 0 && (r3 < 0 && r3 > r2)
-         *   6. a1-a2 > 180 == r2 < 0 && (r3 < r2 || r3 > 0)
-         * 3 and 6 are invalid cases where a3 is the midpoint.
-         * BBOX is fundamental, so these cannot error out and will instead
-         * calculate the sweep using a3 as the middle point.
-         */
-
-        /* clockwise 1 */
-        if(FP_LT(r2, 0) && (FP_GT(r3, 0) || FP_LT(r3, r2)))
-        {
-            sweep = (FP_GT(r3, 0)) ? (r3 - 2 * M_PI) : r3;
-        }
-        /* clockwise 2 */
-        else if(FP_GT(r2, 0) && FP_GT(r3, 0) && FP_LT(r3, r2))
-        {
-            sweep = (FP_GT(r3, 0)) ? (r3 - 2 * M_PI) : r3;
-        }
-        /* counter-clockwise 4 */
-        else if(FP_GT(r2, 0) && (FP_LT(r3, 0) || FP_GT(r3, r2)))
-        {
-            sweep = (FP_LT(r3, 0)) ? (r3 + 2 * M_PI) : r3;
-        }
-        /* counter-clockwise 5 */
-        else if(FP_LT(r2, 0) && FP_LT(r3, 0) && FP_GT(r3, r2))
-        {
-            sweep = (FP_LT(r3, 0)) ? (r3 + 2 * M_PI) : r3;
-        }
-        /* clockwise invalid 3 */
-        else if(FP_GT(r2, 0) && (FP_GT(r3, r2) || FP_LT(r3, 0)))
-        {
-            sweep = (FP_GT(r2, 0)) ? (r2 - 2 * M_PI) : r2;
-        }
-        /* clockwise invalid 6 */
-        else
-        {
-            sweep = (FP_LT(r2, 0)) ? (r2 + 2 * M_PI) : r2;
-        }
-
-        LWDEBUGF(3, "a1 %.16f, a2 %.16f, a3 %.16f, sweep %.16f", a1, a2, a3, sweep);
-
-        angle = 0.0;
-        for(i=0; i < 6; i++)
-        {
-                switch(i) {
-		/* right extent */
-                case 0:
-                        angle = 0.0;
-                        xe = center->x + radius;
-                        ye = center->y;
-                        break;
-		/* top extent */
-                case 1:
-                        angle = M_PI_2;
-                        xe = center->x;
-                        ye = center->y + radius;
-                        break;
-		/* left extent */
-                case 2:
-                        angle = M_PI;
-                        xe = center->x - radius;
-                        ye = center->y;
-                        break;
-		/* bottom extent */
-                case 3:
-                        angle = -1 * M_PI_2;
-                        xe = center->x;
-                        ye = center->y - radius;
-                        break;
-		/* first point */
-                case 4:
-                        angle = a1;
-                        xe = p1->x;
-                        ye = p1->y;
-                        break;
-		/* last point */
-                case 5:
-                        angle = a3;
-                        xe = p3->x;
-                        ye = p3->y;
-                        break;
-                }
-		/* determine if the extents are outside the arc */
-                if(i < 4) 
-                {
-		    if(FP_GT(sweep, 0.0))
-		    {
-		        if(FP_LT(a3, a1))
-		        {
-			    if(FP_GT(angle, (a3 + 2 * M_PI)) || FP_LT(angle, a1)) continue;
-		        }
-		        else
-		        {
-			    if(FP_GT(angle, a3) || FP_LT(angle, a1)) continue;
-		        }
-                    }
-		    else
-		    {
-		        if(FP_GT(a3, a1))
-		        {
-			    if(FP_LT(angle, (a3 - 2 * M_PI)) || FP_GT(angle, a1)) continue;
-		        }
-		        else
-		        {
-			    if(FP_LT(angle, a3) || FP_GT(angle, a1)) continue;
-		        }
-		    }
-		}
-
-                LWDEBUGF(3, "lwcircle_compute_box3d: potential extreame %d (%.16f, %.16f)", i, xe, ye);
-
-                x1 = (FP_LT(x1, xe)) ? x1 : xe;
-                y1 = (FP_LT(y1, ye)) ? y1 : ye;
-                x2 = (FP_GT(x2, xe)) ? x2 : xe;
-                y2 = (FP_GT(y2, ye)) ? y2 : ye;
-        }
-
-        LWDEBUGF(3, "lwcircle_compute_box3d: extreames found (%.16f %.16f, %.16f %.16f)", x1, y1, x2, y2);
-
-        /*
-        x1 = center->x + x1 * radius;
-        x2 = center->x + x2 * radius;
-        y1 = center->y + y1 * radius;
-        y2 = center->y + y2 * radius;
-        */
-        z1 = (FP_LT(p1->z, p2->z)) ? p1->z : p2->z;
-        z1 = (FP_LT(z1, p3->z)) ? z1 : p3->z;
-        z2 = (FP_GT(p1->z, p2->z)) ? p1->z : p2->z;
-        z2 = (FP_GT(z2, p3->z)) ? z2 : p3->z;
-
-        box = lwalloc(sizeof(BOX3D));
-        box->xmin = x1; box->xmax = x2;
-        box->ymin = y1; box->ymax = y2;
-        box->zmin = z1; box->zmax = z2;
-
-        lwfree(center);
-
-        return box;
-}
-
-/*
- * Find bounding box (standard one)
- * zmin=zmax=NO_Z_VALUE if 2d
- * TODO: This ignores curvature, which should be taken into account.
- */
-BOX3D *
-lwcurve_compute_box3d(LWCURVE *curve)
-{
-        BOX3D *box, *tmp; 
-        int i;
-        POINT4D *p1 = lwalloc(sizeof(POINT4D));
-        POINT4D *p2 = lwalloc(sizeof(POINT4D));
-        POINT4D *p3 = lwalloc(sizeof(POINT4D));
-
-        LWDEBUG(2, "lwcurve_compute_box3d called.");
-
-        /* initialize box values */
-        box = lwalloc(sizeof(BOX3D));
-        box->xmin = MAXFLOAT; box->xmax = -1 * MAXFLOAT;
-        box->ymin = MAXFLOAT; box->ymax = -1 * MAXFLOAT;
-        box->zmin = MAXFLOAT; box->zmax = -1 * MAXFLOAT;
-        
-        for(i = 2; i < curve->points->npoints; i+=2)
-        {
-                getPoint4d_p(curve->points, i-2, p1);
-                getPoint4d_p(curve->points, i-1, p2);
-                getPoint4d_p(curve->points, i, p3);
-                tmp = lwcircle_compute_box3d(p1, p2, p3);
-                if(tmp == NULL) continue;
-                box->xmin = (box->xmin < tmp->xmin) ? box->xmin : tmp->xmin;
-                box->xmax = (box->xmax > tmp->xmax) ? box->xmax : tmp->xmax;
-                box->ymin = (box->ymin < tmp->ymin) ? box->ymin : tmp->ymin;
-                box->ymax = (box->ymax > tmp->ymax) ? box->ymax : tmp->ymax;
-                box->zmin = (box->zmin < tmp->zmin) ? box->zmin : tmp->zmin;
-                box->zmax = (box->zmax > tmp->zmax) ? box->zmax : tmp->zmax;
-
-                LWDEBUGF(4, "curve %d x=(%.16f,%.16f) y=(%.16f,%.16f) z=(%.16f,%.16f)", i/2, box->xmin, box->xmax, box->ymin, box->ymax, box->zmin, box->zmax);
-        }
-
-        
-        return box;
-}
-
-int
-lwcurve_compute_box2d_p(LWCURVE *curve, BOX2DFLOAT4 *result)
-{
-        BOX3D *box = lwcurve_compute_box3d(curve);
-        LWDEBUG(2, "lwcurve_compute_box2d_p called.");
-
-        if(box == NULL) return 0;
-        box3d_to_box2df_p(box, result);
-        return 1;
-}
-
-void lwfree_curve(LWCURVE *curve)
-{
-        lwfree(curve->points);
-        lwfree(curve);
-}
-
-/* find length of this serialized curve */
-size_t
-lwgeom_size_curve(const uchar *serialized_curve)
-{
-        int type = (uchar)serialized_curve[0];
-        uint32 result = 1; /* type */
-        const uchar *loc;
-        uint32 npoints;
-
-        LWDEBUG(2, "lwgeom_size_curve called");
-
-        if(lwgeom_getType(type) != CURVETYPE)
-                lwerror("lwgeom_size_curve::attempt to find the length of a non-curve");
-
-        loc = serialized_curve + 1;
-        if(lwgeom_hasBBOX(type))
-        {
-                loc += sizeof(BOX2DFLOAT4);
-                result += sizeof(BOX2DFLOAT4);
-        }
-
-        if(lwgeom_hasSRID(type))
-        {
-                loc += 4; /* type + SRID */
-                result += 4;
-        }
-
-        /* we've read the type (1 byte) and SRID (4 bytes, if present) */
-        npoints = lw_get_uint32(loc);
-        result += sizeof(uint32); /* npoints */
-
-        result += TYPE_NDIMS(type) * sizeof(double) * npoints;
-
-        LWDEBUGF(3, "lwgeom_size_curve returning %d", result);
-
-        return result;
-}
-
-void printLWCURVE(LWCURVE *curve)
-{
-        lwnotice("LWCURVE {");
-        lwnotice("    ndims = %i", (int)TYPE_NDIMS(curve->type));
-        lwnotice("    SRID = %i", (int)curve->SRID);
-        printPA(curve->points);
-        lwnotice("}");
-}
-
-/* Clone LWCURVE object.  POINTARRAY is not copied. */
-LWCURVE *
-lwcurve_clone(const LWCURVE *g)
-{
-        LWCURVE *ret = lwalloc(sizeof(LWCURVE));
-        memcpy(ret, g, sizeof(LWCURVE));
-        if(g->bbox) ret->bbox = box2d_clone(g->bbox);
-        return ret;
-}
-
-/*
- * Add 'what' to this curve at position 'where'.
- * where=0 == prepend
- * where=-1 == append
- * Returns a MULTICURVE or a GEOMETRYCOLLECTION
- */
-LWGEOM *
-lwcurve_add(const LWCURVE *to, uint32 where, const LWGEOM *what)
-{
-        LWCOLLECTION *col;
-        LWGEOM **geoms;
-        int newtype;
-        
-        if(where != -1 && where != 0)
-        {
-                lwerror("lwcurve_add only supports 0 or -1 as second argument %d", where);
-                return NULL;
-        }
-
-        /* dimensions compatibility are checked by caller */
-
-        /* Construct geoms array */
-        geoms = lwalloc(sizeof(LWGEOM *)*2);
-        if(where == -1) /* append */
-        {
-                geoms[0] = lwgeom_clone((LWGEOM *)to);
-                geoms[1] = lwgeom_clone(what);
-        }
-        else /* prepend */
-        {
-                geoms[0] = lwgeom_clone(what);
-                geoms[1] = lwgeom_clone((LWGEOM *)to);
-        }
-        
-        /* reset SRID and wantbbox flag from component types */
-        geoms[0]->SRID = geoms[1]->SRID = -1;
-        TYPE_SETHASSRID(geoms[0]->type, 0);
-        TYPE_SETHASSRID(geoms[1]->type, 0);
-        TYPE_SETHASBBOX(geoms[0]->type, 0);
-        TYPE_SETHASBBOX(geoms[1]->type, 0);
-
-        /* Find appropriate geom type */
-        if(TYPE_GETTYPE(what->type) == CURVETYPE || TYPE_GETTYPE(what->type) == LINETYPE) newtype = MULTICURVETYPE;
-        else newtype = COLLECTIONTYPE;
-
-        col = lwcollection_construct(newtype, 
-                to->SRID, NULL, 
-                2, geoms);
-
-        return (LWGEOM *)col;
-}
-
-void lwcurve_reverse(LWCURVE *curve)
-{
-        ptarray_reverse(curve->points);
-}
-
-/*
- * TODO: Invalid segmentization.  This should accomodate the curvature.
- */
-LWCURVE *
-lwcurve_segmentize2d(LWCURVE *curve, double dist)
-{
-        return lwcurve_construct(curve->SRID, NULL,
-                ptarray_segmentize2d(curve->points, dist));
-}
-                    
-/* check coordinate equality */
-char
-lwcurve_same(const LWCURVE *me, const LWCURVE *you)
-{
-        return ptarray_same(me->points, you->points);
-}
-
-/*
- * Construct a LWCURVE from an array of LWPOINTs
- * LWCURVE dimensions are large enough to host all input dimensions.
- */
-LWCURVE *
-lwcurve_from_lwpointarray(int SRID, unsigned int npoints, LWPOINT **points)
-{
-        int zmflag=0;
-        unsigned int i;
-        POINTARRAY *pa;
-        uchar *newpoints, *ptr;
-        size_t ptsize, size;
-
-        /*
-         * Find output dimensions, check integrity
-         */
-        for(i = 0; i < npoints; i++)
-        {
-                if(TYPE_GETTYPE(points[i]->type) != POINTTYPE)
-                {
-                        lwerror("lwcurve_from_lwpointarray: invalid input type: %s",
-                            lwgeom_typename(TYPE_GETTYPE(points[i]->type)));
-                        return NULL;
-                }
-                if(TYPE_HASZ(points[i]->type)) zmflag |= 2;
-                if(TYPE_HASM(points[i]->type)) zmflag |=1;
-                if(zmflag == 3) break;
-        }
-
-        if(zmflag == 0) ptsize = 2 * sizeof(double);
-        else if(zmflag == 3) ptsize = 4 * sizeof(double);
-        else ptsize = 3 * sizeof(double);
-
-        /*
-         * Allocate output points array
-         */
-        size = ptsize * npoints;
-        newpoints = lwalloc(size);
-        memset(newpoints, 0, size);
-
-        ptr = newpoints;
-        for(i = 0; i < npoints; i++)
-        {
-                size = pointArray_ptsize(points[i]->point);
-                memcpy(ptr, getPoint_internal(points[i]->point, 0), size);
-                ptr += ptsize;
-        }
-        pa = pointArray_construct(newpoints, zmflag&2, zmflag&1, npoints);
-
-        return lwcurve_construct(SRID, NULL, pa);
-}
-
-/*
- * Construct a LWCURVE from a LWMPOINT
- */
-LWCURVE *
-lwcurve_from_lwmpoint(int SRID, LWMPOINT *mpoint)
-{
-        unsigned int i;
-        POINTARRAY *pa;
-        char zmflag = TYPE_GETZM(mpoint->type);
-        size_t ptsize, size;
-        uchar *newpoints, *ptr;
-
-        if(zmflag == 0) ptsize = 2 * sizeof(double);
-        else if(zmflag == 3) ptsize = 4 * sizeof(double);
-        else ptsize = 3 * sizeof(double);
-
-        /* Allocate space for output points */
-        size = ptsize * mpoint->ngeoms;
-        newpoints = lwalloc(size);
-        memset(newpoints, 0, size);
-
-        ptr = newpoints;
-        for(i = 0; i < mpoint->ngeoms; i++)
-        {
-                memcpy(ptr,
-                        getPoint_internal(mpoint->geoms[i]->point, 0),
-                        ptsize);
-                ptr += ptsize;
-        }
-
-        pa = pointArray_construct(newpoints, zmflag&2, zmflag&1,
-                mpoint->ngeoms);
-
-        LWDEBUGF(3, "lwcurve_from_lwmpoint: constructed pointarray for %d points, %d zmflag", mpoint->ngeoms, zmflag);
-        
-        return lwcurve_construct(SRID, NULL, pa);
-}
-
-LWCURVE *
-lwcurve_addpoint(LWCURVE *curve, LWPOINT *point, unsigned int where)
-{
-        POINTARRAY *newpa;
-        LWCURVE *ret;
-
-        newpa = ptarray_addPoint(curve->points, 
-                getPoint_internal(point->point, 0),
-                TYPE_NDIMS(point->type), where);
-        ret = lwcurve_construct(curve->SRID, NULL, newpa);
-
-        return ret;
-}
-
-LWCURVE *
-lwcurve_removepoint(LWCURVE *curve, unsigned int index)
-{
-        POINTARRAY *newpa;
-        LWCURVE *ret;
-
-        newpa = ptarray_removePoint(curve->points, index);
-        ret = lwcurve_construct(curve->SRID, NULL, newpa);
-
-        return ret;
-}
-
-/*
- * Note: input will be changed, make sure you have permissions for this.
- * */
-void
-lwcurve_setPoint4d(LWCURVE *curve, unsigned int index, POINT4D *newpoint)
-{
-        setPoint4d(curve->points, index, newpoint);
-}
-
-

Modified: trunk/liblwgeom/lwcurvepoly.c
===================================================================
--- trunk/liblwgeom/lwcurvepoly.c	2009-01-12 19:29:57 UTC (rev 3519)
+++ trunk/liblwgeom/lwcurvepoly.c	2009-01-13 12:27:39 UTC (rev 3520)
@@ -53,10 +53,10 @@
         for(i = 0; i < insp->ngeometries; i++)
         {
                 result->rings[i] = lwgeom_deserialize(insp->sub_geoms[i]);
-                if(lwgeom_getType(result->rings[i]->type) != CURVETYPE 
+                if(lwgeom_getType(result->rings[i]->type) != CIRCSTRINGTYPE 
                         && lwgeom_getType(result->rings[i]->type) != LINETYPE)
                 {
-                        lwerror("Only Circular curves and Linestrings are currently supported as rings, not %s (%d)", lwgeom_typename(result->rings[i]->type), result->rings[i]->type);
+                        lwerror("Only Circularstrings and Linestrings are currently supported as rings, not %s (%d)", lwgeom_typename(result->rings[i]->type), result->rings[i]->type);
                         lwfree(result);
                         lwfree(insp);
                         return NULL;

Modified: trunk/liblwgeom/lwgeom.c
===================================================================
--- trunk/liblwgeom/lwgeom.c	2009-01-12 19:29:57 UTC (rev 3519)
+++ trunk/liblwgeom/lwgeom.c	2009-01-13 12:27:39 UTC (rev 3520)
@@ -31,8 +31,8 @@
 			return (LWGEOM *)lwpoint_deserialize(srl);
 		case LINETYPE:
 			return (LWGEOM *)lwline_deserialize(srl);
-                case CURVETYPE:
-                        return (LWGEOM *)lwcurve_deserialize(srl);
+                case CIRCSTRINGTYPE:
+                        return (LWGEOM *)lwcircstring_deserialize(srl);
 		case POLYGONTYPE:
 			return (LWGEOM *)lwpoly_deserialize(srl);
 		case MULTIPOINTTYPE:
@@ -74,8 +74,8 @@
 			return lwline_serialize_size((LWLINE *)lwgeom);
 		case POLYGONTYPE:
 			return lwpoly_serialize_size((LWPOLY *)lwgeom);
-                case CURVETYPE:
-                        return lwcurve_serialize_size((LWCURVE *)lwgeom);
+                case CIRCSTRINGTYPE:
+                        return lwcircstring_serialize_size((LWCIRCSTRING *)lwgeom);
                 case CURVEPOLYTYPE:
                 case COMPOUNDTYPE:
 		case MULTIPOINTTYPE:
@@ -111,8 +111,8 @@
 		case POLYGONTYPE:
 			lwpoly_serialize_buf((LWPOLY *)lwgeom, buf, retsize);
 			break;
-                case CURVETYPE:
-                        lwcurve_serialize_buf((LWCURVE *)lwgeom, buf, retsize);
+                case CIRCSTRINGTYPE:
+                        lwcircstring_serialize_buf((LWCIRCSTRING *)lwgeom, buf, retsize);
                         break;
                 case CURVEPOLYTYPE:
                 case COMPOUNDTYPE:
@@ -210,8 +210,8 @@
 			return lwpoint_compute_box2d_p((LWPOINT *)lwgeom, buf);
 		case LINETYPE:
 			return lwline_compute_box2d_p((LWLINE *)lwgeom, buf);
-                case CURVETYPE:
-                        return lwcurve_compute_box2d_p((LWCURVE *)lwgeom, buf);
+                case CIRCSTRINGTYPE:
+                        return lwcircstring_compute_box2d_p((LWCIRCSTRING *)lwgeom, buf);
 		case POLYGONTYPE:
 			return lwpoly_compute_box2d_p((LWPOLY *)lwgeom, buf);
                 case COMPOUNDTYPE:
@@ -257,11 +257,11 @@
 	else return NULL;
 }
 
-LWCURVE *
-lwgeom_as_lwcurve(LWGEOM *lwgeom)
+LWCIRCSTRING *
+lwgeom_as_lwcircstring(LWGEOM *lwgeom)
 {
-        if( TYPE_GETTYPE(lwgeom->type) == CURVETYPE )
-                return (LWCURVE *)lwgeom;
+        if( TYPE_GETTYPE(lwgeom->type) == CIRCSTRINGTYPE )
+                return (LWCIRCSTRING *)lwgeom;
         else return NULL;
 }
 
@@ -362,8 +362,8 @@
 			return (LWGEOM *)lwpoint_clone((LWPOINT *)lwgeom);
 		case LINETYPE:
 			return (LWGEOM *)lwline_clone((LWLINE *)lwgeom);
-                case CURVETYPE:
-                        return (LWGEOM *)lwcurve_clone((LWCURVE *)lwgeom);
+                case CIRCSTRINGTYPE:
+                        return (LWGEOM *)lwcircstring_clone((LWCIRCSTRING *)lwgeom);
 		case POLYGONTYPE:
 			return (LWGEOM *)lwpoly_clone((LWPOLY *)lwgeom);
                 case COMPOUNDTYPE:
@@ -409,8 +409,8 @@
 		case LINETYPE:
 			return (LWGEOM *)lwline_add((const LWLINE *)to, where, what);
 
-                case CURVETYPE:
-                        return (LWGEOM *)lwcurve_add((const LWCURVE *)to, where, what);
+                case CIRCSTRINGTYPE:
+                        return (LWGEOM *)lwcircstring_add((const LWCIRCSTRING *)to, where, what);
 
 		case POLYGONTYPE:
 			return (LWGEOM *)lwpoly_add((const LWPOLY *)to, where, what);

Modified: trunk/liblwgeom/lwgeom_api.c
===================================================================
--- trunk/liblwgeom/lwgeom_api.c	2009-01-12 19:29:57 UTC (rev 3519)
+++ trunk/liblwgeom/lwgeom_api.c	2009-01-13 12:27:39 UTC (rev 3520)
@@ -948,9 +948,9 @@
 		loc += 4;
 	}
 
-	if ( (type==POINTTYPE) || (type==LINETYPE) || (type==POLYGONTYPE) || (type == CURVETYPE))
+	if ( (type==POINTTYPE) || (type==LINETYPE) || (type==POLYGONTYPE) || (type == CIRCSTRINGTYPE))
 	{
-		/* simple geometry (point/line/polygon)-- not multi! */
+		/* simple geometry (point/line/polygon/circstring)-- not multi! */
 		result->ngeometries = 1;
 		sub_geoms = (uchar**) lwalloc(sizeof(char*));
 		sub_geoms[0] = (uchar *)serialized_form;
@@ -1155,8 +1155,8 @@
  * if there arent enough geometries, return null.
  * this is fine to call on a circularstring
  */
-LWCURVE *
-lwgeom_getcurve_inspected(LWGEOM_INSPECTED *inspected, int geom_number)
+LWCIRCSTRING *
+lwgeom_getcircstring_inspected(LWGEOM_INSPECTED *inspected, int geom_number)
 {
 	uchar *sub_geom;
 	uchar type;
@@ -1166,9 +1166,9 @@
 	if (sub_geom == NULL) return NULL;
 
 	type = lwgeom_getType(sub_geom[0]);
-	if (type != CURVETYPE) return NULL;
+	if (type != CIRCSTRINGTYPE) return NULL;
 
-	return lwcurve_deserialize(sub_geom);
+	return lwcircstring_deserialize(sub_geom);
 }
 
 /*
@@ -1275,7 +1275,7 @@
 	uchar *loc;
 
 	if ( (type==POINTTYPE) || (type==LINETYPE) || (type==POLYGONTYPE) ||
-            (type==CURVETYPE) || (type==COMPOUNDTYPE) || (type==CURVEPOLYTYPE) )
+            (type==CIRCSTRINGTYPE) || (type==COMPOUNDTYPE) || (type==CURVEPOLYTYPE) )
 	{
 		return 1;
 	}
@@ -1511,11 +1511,11 @@
 
 		return lwgeom_size_line(serialized_form);
 	}
-        else if(type == CURVETYPE)
+        else if(type == CIRCSTRINGTYPE)
         {
-                LWDEBUG(3, "lwgeom_size: is a curve");
+                LWDEBUG(3, "lwgeom_size: is a circularstring");
 
-                return lwgeom_size_curve(serialized_form);
+                return lwgeom_size_circstring(serialized_form);
         }
 	else if (type == POLYGONTYPE)
 	{
@@ -1676,11 +1676,11 @@
 		return result;
 
 	}
-        else if (type == CURVETYPE)
+        else if (type == CIRCSTRINGTYPE)
         {
-                LWCURVE *curve = lwcurve_deserialize(srl);
-                result = lwcurve_compute_box3d(curve);
-                lwfree_curve(curve);
+                LWCIRCSTRING *curve = lwcircstring_deserialize(srl);
+                result = lwcircstring_compute_box3d(curve);
+                lwfree_circstring(curve);
                 return result;
         }
 	else if (type == POLYGONTYPE)

Modified: trunk/liblwgeom/lwgparse.c
===================================================================
--- trunk/liblwgeom/lwgparse.c	2009-01-12 19:29:57 UTC (rev 3519)
+++ trunk/liblwgeom/lwgparse.c	2009-01-13 12:27:39 UTC (rev 3520)
@@ -208,7 +208,7 @@
 void read_wkb_point(const char **b);
 void read_wkb_polygon(const char **b);
 void read_wkb_linestring(const char **b);
-void read_wkb_curve(const char **b);
+void read_wkb_circstring(const char **b);
 void read_wkb_ordinate_array(const char **b);
 void read_collection(const char **b, read_col_func f);
 void parse_wkb(const char **b);
@@ -640,7 +640,7 @@
 {
         LWDEBUG(2, "alloc_circularstring");
 
-        alloc_stack_tuple(CURVETYPE,write_type,1);
+        alloc_stack_tuple(CIRCSTRINGTYPE,write_type,1);
         minpoints=3;
         checkclosed=0;
         isodd=1;
@@ -988,10 +988,10 @@
 
 
 void
-read_wkb_curve(const char **b)
+read_wkb_circstring(const char **b)
 {
 
-	/* Things to check for CURVE ORDINATE_ARRAYs */
+	/* Things to check for CIRCULARSTRING ORDINATE_ARRAYs */
 	minpoints=3;
 	checkclosed=0;
 	isodd=-1;
@@ -1103,8 +1103,8 @@
 			read_wkb_linestring(b);
 			break;
 
-                case    CURVETYPE:
-                        read_wkb_curve(b);
+                case    CIRCSTRINGTYPE:
+                        read_wkb_circstring(b);
                         break;
 
 		case	POLYGONTYPE:

Modified: trunk/liblwgeom/lwgunparse.c
===================================================================
--- trunk/liblwgeom/lwgunparse.c	2009-01-12 19:29:57 UTC (rev 3519)
+++ trunk/liblwgeom/lwgunparse.c	2009-01-13 12:27:39 UTC (rev 3520)
@@ -43,7 +43,7 @@
 uchar* output_line_collection(uchar* geom,outfunc func,int supress);
 uchar* output_polygon_collection(uchar* geom,int suppress);
 uchar* output_polygon_ring_collection(uchar* geom,outfunc func,int supress);
-uchar* output_curve_collection(uchar* geom,outfunc func,int supress);
+uchar* output_circstring_collection(uchar* geom,outfunc func,int supress);
 uchar* output_multipoint(uchar* geom,int suppress);
 uchar* output_compound(uchar* geom, int suppress);
 uchar* output_multisurface(uchar* geom, int suppress);
@@ -58,7 +58,7 @@
 uchar* output_wkb_polygon_collection(uchar* geom);
 uchar* output_wkb_polygon_ring_collection(uchar* geom,outwkbfunc func);
 uchar* output_wkb_line_collection(uchar* geom,outwkbfunc func);
-uchar* output_wkb_curve_collection(uchar* geom,outwkbfunc func);
+uchar* output_wkb_circstring_collection(uchar* geom,outwkbfunc func);
 uchar* output_wkb_point(uchar* geom);
 uchar* output_wkb(uchar* geom);
 
@@ -358,7 +358,7 @@
 
 /* Ouput the points from a CIRCULARSTRING */
 uchar *
-output_curve_collection(uchar* geom,outfunc func,int supress)
+output_circstring_collection(uchar* geom,outfunc func,int supress)
 {
 	int cnt = read_int(&geom);
 	int orig_cnt = cnt;
@@ -428,7 +428,7 @@
                 case LINETYPE:
                         geom = output_wkt(geom,2);
                         break;
-                case CURVETYPE:
+                case CIRCSTRINGTYPE:
                         geom = output_wkt(geom,1);
                         break;
         }
@@ -500,13 +500,13 @@
 			}
 			geom = output_line_collection(geom,output_point,0);
 			break;
-                case CURVETYPE:
+                case CIRCSTRINGTYPE:
                         if ( supress < 2 )
                         {
                                 if(writeM) write_str("CIRCULARSTRINGM");
                                 else write_str("CIRCULARSTRING");
                         }
-                        geom = output_curve_collection(geom,output_point,0);
+                        geom = output_circstring_collection(geom,output_point,0);
                         break;
 		case POLYGONTYPE:
 			if ( supress < 2 )
@@ -832,7 +832,7 @@
 
 /* Ouput the points from a CIRCULARSTRING */
 uchar *
-output_wkb_curve_collection(uchar* geom,outwkbfunc func)
+output_wkb_circstring_collection(uchar* geom,outwkbfunc func)
 {
 	int cnt = read_int(&geom);
 	int orig_cnt = cnt;
@@ -897,8 +897,8 @@
 		case LINETYPE:
 			geom=output_wkb_line_collection(geom,output_wkb_point);
 			break;
-                case CURVETYPE:
-                        geom=output_wkb_curve_collection(geom,output_wkb_point);
+                case CIRCSTRINGTYPE:
+                        geom=output_wkb_circstring_collection(geom,output_wkb_point);
                         break;
 		case POLYGONTYPE:
 			geom=output_wkb_collection(geom,output_wkb_polygon_collection);

Modified: trunk/liblwgeom/lwmcurve.c
===================================================================
--- trunk/liblwgeom/lwmcurve.c	2009-01-12 19:29:57 UTC (rev 3519)
+++ trunk/liblwgeom/lwmcurve.c	2009-01-13 12:27:39 UTC (rev 3520)
@@ -36,7 +36,7 @@
         result->type = insp->type;
         result->SRID = insp->SRID;
         result->ngeoms = insp->ngeometries;
-        result->geoms = lwalloc(sizeof(LWCURVE *)*insp->ngeometries);
+        result->geoms = lwalloc(sizeof(LWGEOM *)*insp->ngeometries);
 
         if(lwgeom_hasBBOX(srl[0]))
         {
@@ -48,9 +48,9 @@
         for(i = 0; i < insp->ngeometries; i++)
         {
                 stype = lwgeom_getType(insp->sub_geoms[i][0]);
-                if(stype == CURVETYPE)
+                if(stype == CIRCSTRINGTYPE)
                 {
-                        result->geoms[i] = (LWGEOM *)lwcurve_deserialize(insp->sub_geoms[i]);
+                        result->geoms[i] = (LWGEOM *)lwcircstring_deserialize(insp->sub_geoms[i]);
                 }
                 else if(stype == LINETYPE)
                 {
@@ -113,7 +113,7 @@
                 geoms[i+1] = lwgeom_clone((LWGEOM *)to->geoms[i]);
         }
 
-        if(TYPE_GETTYPE(what->type) == CURVETYPE) newtype = MULTICURVETYPE;
+        if(TYPE_GETTYPE(what->type) == CIRCSTRINGTYPE) newtype = MULTICURVETYPE;
         else newtype = COLLECTIONTYPE;
 
         col = lwcollection_construct(newtype,

Modified: trunk/liblwgeom/lwsegmentize.c
===================================================================
--- trunk/liblwgeom/lwsegmentize.c	2009-01-12 19:29:57 UTC (rev 3519)
+++ trunk/liblwgeom/lwsegmentize.c	2009-01-13 12:27:39 UTC (rev 3520)
@@ -21,7 +21,7 @@
 
 double interpolate_arc(double angle, double zm1, double a1, double zm2, double a2);
 POINTARRAY *lwcircle_segmentize(POINT4D *p1, POINT4D *p2, POINT4D *p3, uint32 perQuad);
-LWLINE *lwcurve_segmentize(LWCURVE *icurve, uint32 perQuad);
+LWLINE *lwcurve_segmentize(LWCIRCSTRING *icurve, uint32 perQuad);
 LWLINE *lwcompound_segmentize(LWCOMPOUND *icompound, uint32 perQuad);
 LWPOLY *lwcurvepoly_segmentize(LWCURVEPOLY *curvepoly, uint32 perQuad);
 LWMLINE *lwmcurve_segmentize(LWMCURVE *mcurve, uint32 perQuad);
@@ -63,7 +63,7 @@
         case MULTILINETYPE:
         case MULTIPOLYGONTYPE:
                 return 0;
-        case CURVETYPE:
+        case CIRCSTRINGTYPE:
                 return 1;
         /* It's a collection that MAY contain an arc */
         default:
@@ -281,7 +281,7 @@
 }
 
 LWLINE *
-lwcurve_segmentize(LWCURVE *icurve, uint32 perQuad)
+lwcurve_segmentize(LWCIRCSTRING *icurve, uint32 perQuad)
 {
         LWLINE *oline;
         DYNPTARRAY *ptarray;
@@ -349,9 +349,9 @@
         for(i = 0; i < icompound->ngeoms; i++)
         {
                 geom = icompound->geoms[i];
-                if(lwgeom_getType(geom->type) == CURVETYPE)
+                if(lwgeom_getType(geom->type) == CIRCSTRINGTYPE)
                 {
-                        tmp = lwcurve_segmentize((LWCURVE *)geom, perQuad);
+                        tmp = lwcurve_segmentize((LWCIRCSTRING *)geom, perQuad);
                         for(j = 0; j < tmp->points->npoints; j++)
                         {
                                 getPoint4d_p(tmp->points, j, p);
@@ -396,9 +396,9 @@
         for(i = 0; i < curvepoly->nrings; i++)
         {
                 tmp = curvepoly->rings[i];
-                if(lwgeom_getType(tmp->type) == CURVETYPE)
+                if(lwgeom_getType(tmp->type) == CIRCSTRINGTYPE)
                 {
-                        line = lwcurve_segmentize((LWCURVE *)tmp, perQuad);
+                        line = lwcurve_segmentize((LWCIRCSTRING *)tmp, perQuad);
                         ptarray[i] = ptarray_clone(line->points);
                         lwfree(line);
                 }
@@ -433,9 +433,9 @@
         for(i = 0; i < mcurve->ngeoms; i++)
         {
                 tmp = mcurve->geoms[i];
-                if(lwgeom_getType(tmp->type) == CURVETYPE)
+                if(lwgeom_getType(tmp->type) == CIRCSTRINGTYPE)
                 {
-                        lines[i] = (LWGEOM *)lwcurve_segmentize((LWCURVE *)tmp, perQuad);
+                        lines[i] = (LWGEOM *)lwcurve_segmentize((LWCIRCSTRING *)tmp, perQuad);
                 }
                 else if(lwgeom_getType(tmp->type) == LINETYPE)
                 {
@@ -509,8 +509,8 @@
         {
                 tmp = collection->geoms[i];
                 switch(lwgeom_getType(tmp->type)) {
-                case CURVETYPE:
-                        geoms[i] = (LWGEOM *)lwcurve_segmentize((LWCURVE *)tmp, perQuad);
+                case CIRCSTRINGTYPE:
+                        geoms[i] = (LWGEOM *)lwcurve_segmentize((LWCIRCSTRING *)tmp, perQuad);
                         break;
                 case COMPOUNDTYPE:
                         geoms[i] = (LWGEOM *)lwcompound_segmentize((LWCOMPOUND *)tmp, perQuad);
@@ -532,8 +532,8 @@
 {
         LWGEOM * ogeom = NULL;
         switch(lwgeom_getType(geom->type)) {
-        case CURVETYPE:
-                ogeom = (LWGEOM *)lwcurve_segmentize((LWCURVE *)geom, perQuad);
+        case CIRCSTRINGTYPE:
+                ogeom = (LWGEOM *)lwcurve_segmentize((LWCIRCSTRING *)geom, perQuad);
                 break;
         case COMPOUNDTYPE:
                 ogeom = (LWGEOM *)lwcompound_segmentize((LWCOMPOUND *)geom, perQuad);
@@ -575,7 +575,7 @@
 
                         return (LWGEOM *)lwline_construct(SRID, NULL, pts);
                 }
-                else if(type == CURVETYPE)
+                else if(type == CIRCSTRINGTYPE)
                 {
 #if POSTGIS_DEBUG_LEVEL >= 4
                         POINT4D tmp;
@@ -588,7 +588,7 @@
                                 LWDEBUGF(4, "new point: (%.16f,%.16f)",tmp.x,tmp.y);
                         }
 #endif
-                        return (LWGEOM *)lwcurve_construct(SRID, NULL, pts);
+                        return (LWGEOM *)lwcircstring_construct(SRID, NULL, pts);
                 }
                 else
                 {
@@ -620,13 +620,13 @@
                 lwgeom_release(geom);
                 return result;
         }
-        else if(currentType == CURVETYPE && type == CURVETYPE)
+        else if(currentType == CIRCSTRINGTYPE && type == CIRCSTRINGTYPE)
         {
                 POINTARRAY *newPoints;
                 POINT4D pt;
-                LWCURVE *curve = (LWCURVE *)geom;
+                LWCIRCSTRING *curve = (LWCIRCSTRING *)geom;
 
-                LWDEBUG(3, "append_segment: curve to curve");
+                LWDEBUG(3, "append_segment: circularstring to circularstring");
 
                 newPoints = ptarray_construct(TYPE_HASZ(pts->dims), TYPE_HASM(pts->dims), pts->npoints + curve->points->npoints - 1);
 
@@ -648,11 +648,11 @@
 
                         setPoint4d(newPoints, i + curve->points->npoints - 1, &pt);
                 }
-                result = (LWGEOM *)lwcurve_construct(SRID, NULL, newPoints);
+                result = (LWGEOM *)lwcircstring_construct(SRID, NULL, newPoints);
                 lwgeom_release(geom);
                 return result;
         }
-        else if(currentType == CURVETYPE && type == LINETYPE)
+        else if(currentType == CIRCSTRINGTYPE && type == LINETYPE)
         {
                 LWLINE *line;
                 LWGEOM **geomArray;
@@ -670,17 +670,17 @@
                 lwgeom_release(geom);
                 return result;
         }
-        else if(currentType == LINETYPE && type == CURVETYPE)
+        else if(currentType == LINETYPE && type == CIRCSTRINGTYPE)
         {
-                LWCURVE *curve;
+                LWCIRCSTRING *curve;
                 LWGEOM **geomArray;
 
-                LWDEBUG(3, "append_segment: curve to line");
+                LWDEBUG(3, "append_segment: circularstring to line");
 
                 geomArray = lwalloc(sizeof(LWGEOM *)*2);
                 geomArray[0] = lwgeom_clone(geom);
 
-                curve = lwcurve_construct(SRID, NULL, pts);
+                curve = lwcircstring_construct(SRID, NULL, pts);
                 geomArray[1] = lwgeom_clone((LWGEOM *)curve);
 
                 result = (LWGEOM *)lwcollection_construct(COMPOUNDTYPE, SRID, NULL, 2, geomArray);
@@ -708,11 +708,11 @@
 
                         newGeom = (LWGEOM *)lwline_construct(SRID, NULL, pts);
                 }
-                else if(type == CURVETYPE)
+                else if(type == CIRCSTRINGTYPE)
                 {
-                        LWDEBUG(3, "append_segment: curve to compound");
+                        LWDEBUG(3, "append_segment: circularstring to compound");
 
-                        newGeom = (LWGEOM *)lwcurve_construct(SRID, NULL, pts);
+                        newGeom = (LWGEOM *)lwcircstring_construct(SRID, NULL, pts);
                 }
                 else
                 {
@@ -796,10 +796,10 @@
                         if(isline > 0)
                         {
                         }
-                        /* We were tracking a curve, commit it and start line*/
+                        /* We were tracking a circularstring, commit it and start line*/
                         else if(isline == 0)
                         {
-                                LWDEBUGF(3, "Building curve, %d - %d", commit, i);
+                                LWDEBUGF(3, "Building circularstring, %d - %d", commit, i);
 
                                 count = i - commit;
                                 pts = ptarray_construct(
@@ -815,7 +815,7 @@
                                 setPoint4d(pts, 2, &tmp);
 
                                 commit = i-1;
-                                geom = append_segment(geom, pts, CURVETYPE, SRID);
+                                geom = append_segment(geom, pts, CIRCSTRINGTYPE, SRID);
                                 isline = -1;
 
                                 /* 
@@ -857,10 +857,10 @@
                                 isline = 1;
                         }
                 }
-                /* Found a curve segment */
+                /* Found a circularstring segment */
                 else
                 {
-                        /* We were tracking a curve, commit it and start line */
+                        /* We were tracking a circularstring, commit it and start line */
                         if(isline > 0)
                         {
                                 LWDEBUGF(3, "Building line, %d - %d", commit, i-2);
@@ -881,7 +881,7 @@
                                 geom = append_segment(geom, pts, LINETYPE, SRID);
                                 isline = -1;
                         }
-                        /* We are tracking a curve, keep going */
+                        /* We are tracking a circularstring, keep going */
                         else if(isline == 0)
                         {
                                 ;
@@ -889,7 +889,7 @@
                         /* We didn't know what we were tracking, now we do */
                         else
                         {
-                                LWDEBUG(3, "It's a curve");
+                                LWDEBUG(3, "It's a circularstring");
                                 isline = 0;
                         }
                 }
@@ -897,7 +897,7 @@
         count = i - commit;
         if(isline == 0 && count > 2)
         {
-                LWDEBUGF(3, "Finishing curve %d,%d.", commit, i);
+                LWDEBUGF(3, "Finishing circularstring %d,%d.", commit, i);
 
                 pts = ptarray_construct(
                         TYPE_HASZ(type),
@@ -910,7 +910,7 @@
                 getPoint4d_p(points, i - 1, &tmp);
                 setPoint4d(pts, 2, &tmp);
 
-                geom = append_segment(geom, pts, CURVETYPE, SRID);
+                geom = append_segment(geom, pts, CIRCSTRINGTYPE, SRID);
         }
         else 
         {
@@ -950,7 +950,7 @@
         for(i=0; i<poly->nrings; i++)
         {
                 geoms[i] = pta_desegmentize(poly->rings[i], poly->type, poly->SRID);
-                if(lwgeom_getType(geoms[i]->type) == CURVETYPE ||
+                if(lwgeom_getType(geoms[i]->type) == CIRCSTRINGTYPE ||
                         lwgeom_getType(geoms[i]->type) == COMPOUNDTYPE)
                 {
                         hascurve = 1;
@@ -980,7 +980,7 @@
         for(i=0; i<mline->ngeoms; i++)
         {
                 geoms[i] = lwline_desegmentize((LWLINE *)mline->geoms[i]);
-                if(lwgeom_getType(geoms[i]->type) == CURVETYPE ||
+                if(lwgeom_getType(geoms[i]->type) == CIRCSTRINGTYPE ||
                         lwgeom_getType(geoms[i]->type) == COMPOUNDTYPE)
                 {
                         hascurve = 1;

Modified: trunk/liblwgeom/wktparse.h
===================================================================
--- trunk/liblwgeom/wktparse.h	2009-01-12 19:29:57 UTC (rev 3519)
+++ trunk/liblwgeom/wktparse.h	2009-01-13 12:27:39 UTC (rev 3520)
@@ -63,7 +63,7 @@
 #define LINETYPEI     11
 #define POLYGONTYPEI  12
 
-#define CURVETYPE       8
+#define CIRCSTRINGTYPE       8
 #define COMPOUNDTYPE    9
 #define CURVEPOLYTYPE   13
 #define MULTICURVETYPE          14

Modified: trunk/lwgeom/lwgeom_functions_basic.c
===================================================================
--- trunk/lwgeom/lwgeom_functions_basic.c	2009-01-12 19:29:57 UTC (rev 3519)
+++ trunk/lwgeom/lwgeom_functions_basic.c	2009-01-13 12:27:39 UTC (rev 3520)
@@ -207,7 +207,7 @@
 		LWLINE *line=NULL;
 		LWPOINT *point=NULL;
 		LWPOLY *poly=NULL;
-		LWCURVE *curve=NULL;
+		LWCIRCSTRING *curve=NULL;
 		uchar *subgeom=NULL;
 
 		point = lwgeom_getpoint_inspected(inspected, i);
@@ -234,7 +234,7 @@
 			continue;
 		}
 
-		curve = lwgeom_getcurve_inspected(inspected, i);
+		curve = lwgeom_getcircstring_inspected(inspected, i);
 		if (curve != NULL)
 		{
 			npoints += curve->points->npoints;
@@ -500,7 +500,7 @@
 	uchar newtypefl;
 	LWPOINT *point = NULL;
 	LWLINE *line = NULL;
-	LWCURVE *curve = NULL;
+	LWCIRCSTRING *curve = NULL;
 	LWPOLY *poly = NULL;
 	POINTARRAY newpts;
 	POINTARRAY **nrings;
@@ -562,11 +562,11 @@
 		return;
 	}
 
-	if ( type == CURVETYPE )
+	if ( type == CIRCSTRINGTYPE )
 	{
-		curve = lwcurve_deserialize(serialized);
+		curve = lwcircstring_deserialize(serialized);
 
-		LWDEBUGF(3, "lwgeom_force2d_recursize: it's a curve with %d points", curve->points->npoints);
+		LWDEBUGF(3, "lwgeom_force2d_recursize: it's a circularstring with %d points", curve->points->npoints);
 
 		TYPE_SETZM(newpts.dims, 0, 0);
 		newpts.npoints = curve->points->npoints;
@@ -583,7 +583,7 @@
 		}
 		curve->points = &newpts;
 		TYPE_SETZM(curve->type, 0, 0);
-		lwcurve_serialize_buf(curve, optr, retsize);
+		lwcircstring_serialize_buf(curve, optr, retsize);
 		lwfree(newpts.serialized_pointlist);
 		lwfree(curve);
 		return;
@@ -725,7 +725,7 @@
 	int type;
 	LWPOINT *point = NULL;
 	LWLINE *line = NULL;
-	LWCURVE *curve = NULL;
+	LWCIRCSTRING *curve = NULL;
 	LWPOLY *poly = NULL;
 	POINTARRAY newpts;
 	POINTARRAY **nrings;
@@ -780,11 +780,11 @@
 		return;
 	}
 
-	if ( type == CURVETYPE )
+	if ( type == CIRCSTRINGTYPE )
 	{
-		curve = lwcurve_deserialize(serialized);
+		curve = lwcircstring_deserialize(serialized);
 
-		LWDEBUG(3, "lwgeom_force3dz_recursize: it's a curve");
+		LWDEBUG(3, "lwgeom_force3dz_recursize: it's a circularstring");
 
 		TYPE_SETZM(newpts.dims, 1, 0);
 		newpts.npoints = curve->points->npoints;
@@ -798,9 +798,9 @@
 		}
 		curve->points = &newpts;
 		TYPE_SETZM(curve->type, 1, 0);
-		lwcurve_serialize_buf(curve, optr, retsize);
+		lwcircstring_serialize_buf(curve, optr, retsize);
 
-		LWDEBUGF(3, "lwgeom_force3dz_recursive: it's a curve, size:%d", *retsize);
+		LWDEBUGF(3, "lwgeom_force3dz_recursive: it's a circularstring, size:%d", *retsize);
 
 		return;
 	}
@@ -912,7 +912,7 @@
 	uchar newtypefl;
 	LWPOINT *point = NULL;
 	LWLINE *line = NULL;
-	LWCURVE *curve = NULL;
+	LWCIRCSTRING *curve = NULL;
 	LWPOLY *poly = NULL;
 	POINTARRAY newpts;
 	POINTARRAY **nrings;
@@ -974,11 +974,11 @@
 		return;
 	}
 
-	if ( type == CURVETYPE )
+	if ( type == CIRCSTRINGTYPE )
 	{
-		curve = lwcurve_deserialize(serialized);
+		curve = lwcircstring_deserialize(serialized);
 
-		LWDEBUGF(3, "lwgeom_force3dm_recursize: it's a curve with %d points", curve->points->npoints);
+		LWDEBUGF(3, "lwgeom_force3dm_recursize: it's a circularstring with %d points", curve->points->npoints);
 
 		TYPE_SETZM(newpts.dims, 0, 1);
 		newpts.npoints = curve->points->npoints;
@@ -993,7 +993,7 @@
 		}
 		curve->points = &newpts;
 		TYPE_SETZM(curve->type, 0, 1);
-		lwcurve_serialize_buf(curve, optr, retsize);
+		lwcircstring_serialize_buf(curve, optr, retsize);
 		lwfree(newpts.serialized_pointlist);
 		lwfree(curve);
 		return;
@@ -1135,7 +1135,7 @@
 	int type;
 	LWPOINT *point = NULL;
 	LWLINE *line = NULL;
-	LWCURVE *curve = NULL;
+	LWCIRCSTRING *curve = NULL;
 	LWPOLY *poly = NULL;
 	POINTARRAY newpts;
 	POINTARRAY **nrings;
@@ -1189,9 +1189,9 @@
 		return;
 	}
 
-	if ( type == CURVETYPE )
+	if ( type == CIRCSTRINGTYPE )
 	{
-		curve = lwcurve_deserialize(serialized);
+		curve = lwcircstring_deserialize(serialized);
 		TYPE_SETZM(newpts.dims, 1, 1);
 		newpts.npoints = curve->points->npoints;
 		newpts.serialized_pointlist = lwalloc(sizeof(POINT4D)*curve->points->npoints);
@@ -1204,9 +1204,9 @@
 		}
 		curve->points = &newpts;
 		TYPE_SETZM(curve->type, 1, 1);
-		lwcurve_serialize_buf(curve, optr, retsize);
+		lwcircstring_serialize_buf(curve, optr, retsize);
 
-		LWDEBUGF(3, "lwgeom_force4d_recursive: it's a curve, size:%d", *retsize);
+		LWDEBUGF(3, "lwgeom_force4d_recursive: it's a circularstring, size:%d", *retsize);
 
 		return;
 	}
@@ -3191,7 +3191,7 @@
 		LWLINE *line=NULL;
 		LWPOINT *point=NULL;
 		LWPOLY *poly=NULL;
-		LWCURVE *curve=NULL;
+		LWCIRCSTRING *curve=NULL;
 		uchar *subgeom=NULL;
 
 		point = lwgeom_getpoint_inspected(inspected, i);
@@ -3233,7 +3233,7 @@
 			continue;
 		}
 
-		curve = lwgeom_getcurve_inspected(inspected, i);
+		curve = lwgeom_getcircstring_inspected(inspected, i);
 		if (curve != NULL)
 		{
 			lwgeom_affine_ptarray(curve->points,

Modified: trunk/lwgeom/lwgeom_ogc.c
===================================================================
--- trunk/lwgeom/lwgeom_ogc.c	2009-01-12 19:29:57 UTC (rev 3519)
+++ trunk/lwgeom/lwgeom_ogc.c	2009-01-13 12:27:39 UTC (rev 3520)
@@ -77,7 +77,7 @@
 static int32 lwgeom_numpoints_linestring_recursive(const uchar *serialized);
 static int32 lwgeom_dimension_recursive(const uchar *serialized);
 char line_is_closed(LWLINE *line);
-char curve_is_closed(LWCURVE *curve);
+char circstring_is_closed(LWCIRCSTRING *curve);
 char compound_is_closed(LWCOMPOUND *compound);
 
 /*------------------------------------------------------------------*/
@@ -132,7 +132,7 @@
 		strcpy(result,"MULTIPOINT");
 	else if (type == LINETYPE)
 		strcpy(result,"LINESTRING");
-        else if (type == CURVETYPE)
+        else if (type == CIRCSTRINGTYPE)
                 strcpy(result,"CIRCULARSTRING");
         else if (type == COMPOUNDTYPE)
                 strcpy(result, "COMPOUNDCURVE");
@@ -277,7 +277,7 @@
 	/* elog(NOTICE, "GeometryN called"); */
 
 	/* call is valid on multi* geoms only */
-	if (type==POINTTYPE || type==LINETYPE || type==CURVETYPE ||
+	if (type==POINTTYPE || type==LINETYPE || type==CIRCSTRINGTYPE ||
                 type==COMPOUNDTYPE || type==POLYGONTYPE || type==CURVEPOLYTYPE)
 	{
 		/* elog(NOTICE, "geometryn: geom is of type %d, requires >=4", type); */
@@ -342,7 +342,7 @@
 		if ( type == POINTTYPE ) dims = 0;
 		else if ( type == MULTIPOINTTYPE ) dims=0;
 		else if ( type == LINETYPE ) dims=1;
-                else if ( type == CURVETYPE ) dims=1;
+                else if ( type == CIRCSTRINGTYPE ) dims=1;
                 else if ( type == COMPOUNDTYPE ) dims=1;
 		else if ( type == MULTILINETYPE ) dims=1;
                 else if ( type == MULTICURVETYPE ) dims=1;
@@ -622,7 +622,7 @@
 	int32 wanted_index;
 	LWGEOM_INSPECTED *inspected;
 	LWLINE *line = NULL;
-        LWCURVE *curve = NULL;
+        LWCIRCSTRING *curve = NULL;
         LWGEOM *tmp = NULL;
 	POINTARRAY *pts;
 	LWPOINT *point;
@@ -649,7 +649,7 @@
 	        {
 		        tmp = lwgeom_getgeom_inspected(inspected, i);
 		        if (lwgeom_getType(tmp->type) == LINETYPE ||
-                                lwgeom_getType(tmp->type) == CURVETYPE) 
+                                lwgeom_getType(tmp->type) == CIRCSTRINGTYPE) 
                             break;
 	        }
 
@@ -658,9 +658,9 @@
 		        PG_FREE_IF_COPY(geom, 0);
 		        PG_RETURN_NULL();
 	        }
-                if(lwgeom_getType(tmp->type) == CURVETYPE)
+                if(lwgeom_getType(tmp->type) == CIRCSTRINGTYPE)
                 {
-                        curve = (LWCURVE *)tmp;
+                        curve = (LWCIRCSTRING *)tmp;
                         if(wanted_index > curve->points->npoints)
                         {
                                 lwinspected_release(inspected);
@@ -1155,11 +1155,11 @@
 	return 1;
 }
 
-char curve_is_closed(LWCURVE *curve)
+char circstring_is_closed(LWCIRCSTRING *curve)
 {
         POINT3DZ sp, ep;
 
-        LWDEBUG(2, "curve_is_closed called.");
+        LWDEBUG(2, "circstring_is_closed called.");
 
         getPoint3dz_p(curve->points, 0, &sp);
         getPoint3dz_p(curve->points, curve->points->npoints-1, &ep);
@@ -1187,7 +1187,7 @@
         }
         else 
         {
-                getPoint3dz_p(((LWCURVE *)tmp)->points, 0, &sp);
+                getPoint3dz_p(((LWCIRCSTRING *)tmp)->points, 0, &sp);
         }
 
         tmp = compound->geoms[compound->ngeoms - 1];
@@ -1197,7 +1197,7 @@
         }
         else
         {
-                getPoint3dz_p(((LWCURVE *)tmp)->points, ((LWCURVE *)tmp)->points->npoints - 1, &ep);
+                getPoint3dz_p(((LWCIRCSTRING *)tmp)->points, ((LWCIRCSTRING *)tmp)->points->npoints - 1, &ep);
         }
 
         if(sp.x != ep.x) return 0;
@@ -1258,8 +1258,8 @@
                         PG_FREE_IF_COPY(geom, 0);
                         PG_RETURN_BOOL(FALSE);
                 }
-                else if(lwgeom_getType(sub->type) == CURVETYPE &&
-                        !curve_is_closed((LWCURVE *)sub))
+                else if(lwgeom_getType(sub->type) == CIRCSTRINGTYPE &&
+                        !circstring_is_closed((LWCIRCSTRING *)sub))
                 {
                         lwgeom_release(sub);
                         lwinspected_release(inspected);

Modified: trunk/lwgeom/lwgeom_transform.c
===================================================================
--- trunk/lwgeom/lwgeom_transform.c	2009-01-12 19:29:57 UTC (rev 3519)
+++ trunk/lwgeom/lwgeom_transform.c	2009-01-13 12:27:39 UTC (rev 3520)
@@ -662,7 +662,7 @@
 		LWLINE *line=NULL;
 		LWPOINT *point=NULL;
 		LWPOLY *poly=NULL;
-		LWCURVE *curve=NULL;
+		LWCIRCSTRING *curve=NULL;
 		POINT4D p;
 		uchar *subgeom=NULL;
 
@@ -708,7 +708,7 @@
 			continue;
 		}
 
-		curve = lwgeom_getcurve_inspected(inspected, j);
+		curve = lwgeom_getcircstring_inspected(inspected, j);
 		if (curve != NULL)
 		{
 			POINTARRAY *pts = curve->points;



More information about the postgis-commits mailing list