]> granicus.if.org Git - postgis/commitdiff
Remove old deserialze and inspected functions.
authorPaul Ramsey <pramsey@cleverelephant.ca>
Thu, 27 Oct 2011 20:05:32 +0000 (20:05 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Thu, 27 Oct 2011 20:05:32 +0000 (20:05 +0000)
serialized_lwgeom_size
lwgeom_size_subgeom
lwgeom_size_point
lwgeom_size_line
lwgeom_size_circstring
lwgeom_size_poly
lwgeom_size_triangle
lwgeom_deserialize
lwpoint_deserialize
lwline_deserialize
lwpoly_deserialize
lwtriangle_deserialize
lwcircstring_deserialize
lwmpoint_deserialize
lwmline_deserialize
lwmpoly_deserialize
lwcollection_deserialize
lwcompound_deserialize
lwcurvepoly_deserialize
lwmcurve_deserialize
lwmsurface_deserialize
lwpsurface_deserialize
lwtin_deserialize
printMULTI
lwgeom_inspect
lwgeom_getpoint_inspected
lwgeom_getpoint
lwgeom_getline_inspected
lwgeom_getline
lwgeom_getpoly
lwgeom_getpoly_inspected
lwgeom_gettriangle
lwgeom_gettriangle_inspected
lwgeom_getcircstring_inspected
lwgeom_getgeom_inspected
lwgeom_getsubgeometry
lwgeom_getsubgeometry_inspected
lwgeom_getsubtype
lwgeom_getsubtype_inspected
lwgeom_getnumgeometries
lwgeom_getnumgeometries_inspected

git-svn-id: http://svn.osgeo.org/postgis/trunk@8018 b70326c6-7e19-0410-871a-916f4a2858ee

18 files changed:
liblwgeom/liblwgeom.h.in
liblwgeom/lwcircstring.c
liblwgeom/lwcollection.c
liblwgeom/lwcompound.c
liblwgeom/lwcurvepoly.c
liblwgeom/lwgeom.c
liblwgeom/lwgeom_api.c
liblwgeom/lwline.c
liblwgeom/lwmcurve.c
liblwgeom/lwmline.c
liblwgeom/lwmpoint.c
liblwgeom/lwmpoly.c
liblwgeom/lwmsurface.c
liblwgeom/lwpoint.c
liblwgeom/lwpoly.c
liblwgeom/lwpsurface.c
liblwgeom/lwtin.c
liblwgeom/lwtriangle.c

index e39568745eab2ede2829c036f8259247cacc3009..8847ef917ae65a159b7e86cbac2bd2c741a2ebfb 100644 (file)
@@ -836,34 +836,12 @@ extern int  lwgeom_getType(uint8_t type); /* returns the tttt value */
 extern uint8_t lwgeom_makeType(char hasZ, char hasM, char has_srid, int type);
 extern uint8_t lwgeom_makeType_full(char hasZ, char hasM, char has_srid, int type, char hasBBOX);
 
-/*
- * This function computes the size in bytes
- * of the serialized geometries.
- */
-extern size_t serialized_lwgeom_size(const uint8_t *serialized_form);
-extern size_t lwgeom_size_subgeom(const uint8_t *serialized_form, int geom_number);
-extern size_t lwgeom_size_line(const uint8_t *serialized_line);
-extern size_t lwgeom_size_circstring(const uint8_t *serialized_curve);
-extern size_t lwgeom_size_point(const uint8_t *serialized_point);
-extern size_t lwgeom_size_poly(const uint8_t *serialized_line);
-extern size_t lwgeom_size_triangle(const uint8_t *serialized_line);
-
-
 /*--------------------------------------------------------
  * all the base types (point/line/polygon) will have a
  * basic constructor, basic de-serializer, basic serializer,
  * bounding box finder and (TODO) serialized form size finder.
  *--------------------------------------------------------*/
 
-/*
- * given the LWPOINT serialized form (or a pointer into a muli* one)
- * construct a proper LWPOINT.
- * serialized_form should point to the 8bit type format (with type = 1)
- * Returns NULL if serialized form is not a point.
- * See serialized form doc
- */
-extern LWPOINT *lwpoint_deserialize(uint8_t *serialized_form);
-
 /*
  * Find size this point would get when serialized (no BBOX)
  */
@@ -897,14 +875,6 @@ extern int lwpoint_getPoint4d_p(const LWPOINT *point, POINT4D *out);
  * LWLINE functions
  ******************************************************************/
 
-/*
- * given the LWGEOM serialized form (or a pointer into a muli* one)
- * construct a proper LWLINE.
- * serialized_form should point to the 8bit type format (with type = 2)
- * See SERIALIZED_FORM doc
- */
-extern LWLINE *lwline_deserialize(uint8_t *serialized_form);
-
 /* find the size this line would get when serialized */
 extern size_t lwline_serialize_size(LWLINE *line);
 
@@ -932,14 +902,6 @@ extern int lwline_add_lwpoint(LWLINE *line, LWPOINT *point, int where);
  * LWPOLY functions
  ******************************************************************/
 
-/*
- * given the LWPOLY serialized form (or a pointer into a muli* one)
- * construct a proper LWPOLY.
- * serialized_form should point to the 8bit type format (with type = 3)
- * See SERIALIZED_FORM doc
- */
-extern LWPOLY *lwpoly_deserialize(uint8_t *serialized_form);
-
 /* find the size this polygon would get when serialized */
 extern size_t lwpoly_serialize_size(LWPOLY *poly);
 
@@ -982,14 +944,6 @@ extern int lwcompound_add_lwgeom(LWCOMPOUND *comp, LWGEOM *geom);
  * LWTRIANGLE functions
  ******************************************************************/
 
-/*
- * given the LWGEOM serialized form 
- * construct a proper LWTRIANGLE.
- * serialized_form should point to the 8bit type format 
- * See SERIALIZED_FORM doc
- */
-extern LWTRIANGLE *lwtriangle_deserialize(uint8_t *serialized_form);
-
 /* find the size this triangle would get when serialized */
 extern size_t lwtriangle_serialize_size(LWTRIANGLE *triangle);
 
@@ -1012,14 +966,6 @@ extern BOX3D *lwtriangle_compute_box3d(LWTRIANGLE *triangle);
  * LWCIRCSTRING functions
  ******************************************************************/
 
-/*
- * given the LWGEOM serialized form (or a pointer into a muli* one)
- * construct a proper LWCIRCSTRING.
- * serialized_form should point to the 8bit type format (with type = 2)
- * See SERIALIZED_FORM doc
- */
-extern LWCIRCSTRING *lwcircstring_deserialize(uint8_t *serialized_form);
-
 /* find the size this curve would get when serialized */
 extern size_t lwcircstring_serialize_size(LWCIRCSTRING *curve);
 
@@ -1060,7 +1006,6 @@ extern LWGEOM *lwcollection_homogenize(const LWCOLLECTION *col);
  * The deserialized (recursive) structure will store
  * pointers to the serialized form (POINTARRAYs).
  */
-LWGEOM *lwgeom_deserialize(uint8_t *serializedform);
 BOX3D *lwgeom_compute_box3d(const LWGEOM *geom);
 
 
@@ -1068,21 +1013,11 @@ BOX3D *lwgeom_compute_box3d(const LWGEOM *geom);
  * LWMULTIx and LWCOLLECTION functions
  ******************************************************************/
 
-LWMPOINT *lwmpoint_deserialize(uint8_t *serializedform);
-LWMLINE *lwmline_deserialize(uint8_t *serializedform);
-LWMPOLY *lwmpoly_deserialize(uint8_t *serializedform);
-LWCOLLECTION *lwcollection_deserialize(uint8_t *serializedform);
-LWCOMPOUND *lwcompound_deserialize(uint8_t *serialized_form);
-LWCURVEPOLY *lwcurvepoly_deserialize(uint8_t *serialized_form);
-LWMCURVE *lwmcurve_deserialize(uint8_t *serialized_form);
-LWMSURFACE *lwmsurface_deserialize(uint8_t *serialized_form);
-LWPSURFACE *lwpsurface_deserialize(uint8_t *serialized_form);
-LWTIN *lwtin_deserialize(uint8_t *serialized_form);
-
 LWGEOM *lwcollection_getsubgeom(LWCOLLECTION *col, int gnum);
 BOX3D *lwcollection_compute_box3d(LWCOLLECTION *col);
 LWCOLLECTION* lwcollection_extract(LWCOLLECTION *col, int type);
 
+
 /******************************************************************
  * SERIALIZED FORM functions
  ******************************************************************/
@@ -1119,107 +1054,6 @@ typedef struct
 LWGEOM_INSPECTED;
 
 
-/*
- * note - for a simple type (ie. point), this will have
- * sub_geom[0] = serialized_form.
- * for multi-geomtries sub_geom[0] will be a few bytes into the
- * serialized form.
- * This function just computes the length of each sub-object and
- * pre-caches this info.
- * For a geometry collection of multi* geometries, you can inspect
- * the sub-components as well.
- */
-extern LWGEOM_INSPECTED *lwgeom_inspect(const uint8_t *serialized_form);
-
-
-/*
- * 1st geometry has geom_number = 0
- * if the actual sub-geometry isnt a POINT, null is returned (see _gettype()).
- * if there arent enough geometries, return null.
- * this is fine to call on a point (with geom_num=0), multipoint
- * or geometrycollection
- */
-extern LWPOINT *lwgeom_getpoint(uint8_t *serialized_form, int geom_number);
-extern LWPOINT *lwgeom_getpoint_inspected(LWGEOM_INSPECTED *inspected, int geom_number);
-
-/*
- * 1st geometry has geom_number = 0
- * if the actual geometry isnt a LINE, null is returned (see _gettype()).
- * if there arent enough geometries, return null.
- * this is fine to call on a line, multiline or geometrycollection
- */
-extern LWLINE *lwgeom_getline(uint8_t *serialized_form, int geom_number);
-extern LWLINE *lwgeom_getline_inspected(LWGEOM_INSPECTED *inspected, int geom_number);
-
-/*
- * 1st geometry has geom_number = 0
- * if the actual geometry isnt a POLYGON, null is returned (see _gettype()).
- * if there arent enough geometries, return null.
- * this is fine to call on a polygon, multipolygon or geometrycollection
- */
-extern LWPOLY *lwgeom_getpoly(uint8_t *serialized_form, int geom_number);
-extern LWPOLY *lwgeom_getpoly_inspected(LWGEOM_INSPECTED *inspected, int geom_number);
-
-/*
- * 1st geometry has geom_number = 0
- * if the actual geometry isnt a TRIANGLE, null is returned (see _gettype()).
- * if there arent enough geometries, return null.
- * this is fine to call on a triangle, Tin or geometrycollection
- */
-extern LWTRIANGLE *lwgeom_gettriangle(uint8_t *serialized_form, int geom_number);
-extern LWTRIANGLE *lwgeom_gettriangle_inspected(LWGEOM_INSPECTED *inspected, int geom_number);
-
-/*
- * 1st geometry has geom_number = 0
- * if the actual geometry isnt a POLYGON, null is returned (see _gettype()).
- * if there arent enough geometries, return null.
- * this is fine to call on a polygon, multipolygon or geometrycollection
- */
-extern LWCIRCSTRING *lwgeom_getcircstring_inspected(LWGEOM_INSPECTED *inspected, int geom_number);
-
-extern LWGEOM *lwgeom_getgeom_inspected(LWGEOM_INSPECTED *inspected, int geom_number);
-
-
-
-/*
- * this gets the serialized form of a sub-geometry
- * 1st geometry has geom_number = 0
- * if this isnt a multi* geometry, and geom_number ==0 then it returns
- * itself
- * returns null on problems.
- * in the future this is how you would access a muli* portion of a
- * geometry collection.
- *    GEOMETRYCOLLECTION(MULTIPOINT(0 0, 1 1), LINESTRING(0 0, 1 1))
- *   ie. lwgeom_getpoint( lwgeom_getsubgeometry( serialized, 0), 1)
- *           --> POINT(1 1)
- * you can inspect the sub-geometry as well if you wish.
- */
-extern uint8_t *lwgeom_getsubgeometry(const uint8_t *serialized_form, int geom_number);
-extern uint8_t *lwgeom_getsubgeometry_inspected(LWGEOM_INSPECTED *inspected, int geom_number);
-
-
-/*
- * 1st geometry has geom_number = 0
- *  use geom_number = -1 to find the actual type of the serialized form.
- *    ie lwgeom_gettype( <'MULTIPOINT(0 0, 1 1)'>, -1)
- *                 --> multipoint
- *   ie lwgeom_gettype( <'MULTIPOINT(0 0, 1 1)'>, 0)
- *                 --> point
- * gets the 8bit type of the geometry at location geom_number
- */
-extern uint8_t lwgeom_getsubtype(uint8_t *serialized_form, int geom_number);
-extern uint8_t lwgeom_getsubtype_inspected(LWGEOM_INSPECTED *inspected, int geom_number);
-
-
-/*
- * how many sub-geometries are there?
- *  for point,line,polygon will return 1.
- */
-extern int lwgeom_getnumgeometries(uint8_t *serialized_form);
-extern int lwgeom_getnumgeometries_inspected(LWGEOM_INSPECTED *inspected);
-
-
-
 /*
  * set finalType to COLLECTIONTYPE or 0 (0 means choose a best type)
  *   (ie. give it 2 points and ask it to be a multipoint)
@@ -1342,7 +1176,6 @@ extern void printLWTRIANGLE(LWTRIANGLE *triangle);
 extern void printLWPSURFACE(LWPSURFACE *psurf);
 extern void printLWTIN(LWTIN *tin);
 extern void printBYTES(uint8_t *a, int n);
-extern void printMULTI(uint8_t *serialized);
 
 
 extern float LWGEOM_Minf(float a, float b);
index 90b61ab5c68fc539ef4f10a81d701d4ac1bf643c..902534ad3cf1826dcf7ec9899bf43d47aecb2db6 100644 (file)
@@ -83,80 +83,7 @@ lwcircstring_release(LWCIRCSTRING *lwcirc)
        lwgeom_release(lwcircstring_as_lwgeom(lwcirc));
 }
 
-/*
- * 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(uint8_t *serialized_form)
-{
-       uint8_t type;
-       LWCIRCSTRING *result;
-       uint8_t *loc=NULL;
-       uint32_t npoints;
-       POINTARRAY *pa;
-
-       type = (uint8_t)serialized_form[0];
-       if (lwgeom_getType(type) != CIRCSTRINGTYPE)
-       {
-               lwerror("lwcircstring_deserialize: attempt to deserialize a circularstring which is really a %s",
-                       lwtype_name(TYPE_GETTYPE(type)));
-               return NULL;
-       }
-
-       result = (LWCIRCSTRING*) lwalloc(sizeof(LWCIRCSTRING));
-       result->type = CIRCSTRINGTYPE;
-       result->flags = gflags(TYPE_HASZ(type),TYPE_HASM(type),0);
-
-       loc = serialized_form + 1;
 
-       if (lwgeom_hasBBOX(type))
-       {
-               BOX2DFLOAT4 *box2df;
-               LWDEBUG(3, "lwcircstring_deserialize: input has bbox");
-
-               FLAGS_SET_BBOX(result->flags, 1);
-               box2df = lwalloc(sizeof(BOX2DFLOAT4));
-               memcpy(box2df, loc, sizeof(BOX2DFLOAT4));
-               result->bbox = gbox_from_box2df(result->flags, box2df);
-               lwfree(box2df);
-               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_t(loc);
-               loc += 4; /* type + SRID */
-       }
-       else
-       {
-               LWDEBUG(3, "lwcircstring_deserialize: input lacks srid");
-
-               result->srid = SRID_UNKNOWN;
-       }
-
-       /* we've read the type (1 byte) and SRID (4 bytes, if present) */
-
-       npoints = lw_get_uint32_t(loc);
-
-       LWDEBUGF(3, "circstring npoints = %d", npoints);
-
-       loc += 4;
-       pa = ptarray_construct_reference_data(FLAGS_GET_Z(result->flags), FLAGS_GET_M(result->flags), npoints, loc);
-       
-       result->points = pa;
-       return result;
-}
 
 /*
  * convert this circularstring into its serialized form
@@ -533,43 +460,7 @@ void lwcircstring_free(LWCIRCSTRING *curve)
        lwfree(curve);
 }
 
-/* find length of this serialized curve */
-size_t
-lwgeom_size_circstring(const uint8_t *serialized_curve)
-{
-       int type = (uint8_t)serialized_curve[0];
-       uint32_t result = 1; /* type */
-       const uint8_t *loc;
-       uint32_t 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_t(loc);
-       result += sizeof(uint32_t); /* npoints */
-
-       result += TYPE_NDIMS(type) * sizeof(double) * npoints;
-
-       LWDEBUGF(3, "lwgeom_size_circstring returning %d", result);
-
-       return result;
-}
 
 void printLWCIRCSTRING(LWCIRCSTRING *curve)
 {
index 1a40e0501f977f455c87ea49f53c2d61bfeb54be..ff923ef9052bc2f89aa4dfe0778560230913481e 100644 (file)
@@ -94,60 +94,7 @@ lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
 }
 
 
-LWCOLLECTION *
-lwcollection_deserialize(uint8_t *srl)
-{
-       LWCOLLECTION *result;
-       LWGEOM_INSPECTED *insp;
-       char typefl = srl[0];
-       int type = lwgeom_getType(typefl);
-       int i;
-
-       if ( type != COLLECTIONTYPE )
-       {
-               lwerror("lwcollection_deserialize called on NON geometrycollection: %d - %s", type, lwtype_name(type));
-               return NULL;
-       }
 
-       insp = lwgeom_inspect(srl);
-
-       result = lwalloc(sizeof(LWCOLLECTION));
-       result->type = type;
-       result->flags = gflags(TYPE_HASZ(typefl),TYPE_HASM(typefl),0);
-       result->srid = insp->srid;
-       result->ngeoms = insp->ngeometries;
-
-       if (lwgeom_hasBBOX(srl[0]))
-       {
-               BOX2DFLOAT4 *box2df;
-               
-               FLAGS_SET_BBOX(result->flags, 1);               
-               box2df = lwalloc(sizeof(BOX2DFLOAT4));
-               memcpy(box2df, srl+1, sizeof(BOX2DFLOAT4));
-               result->bbox = gbox_from_box2df(result->flags, box2df);
-               lwfree(box2df);
-       }
-       else
-       {
-               result->bbox = NULL;
-       }
-
-
-       if ( insp->ngeometries )
-       {
-               result->geoms = lwalloc(sizeof(LWGEOM *)*insp->ngeometries);
-               for (i=0; i<insp->ngeometries; i++)
-               {
-                       result->geoms[i] = lwgeom_deserialize(insp->sub_geoms[i]);
-               }
-       }
-       else
-       {
-               result->geoms = NULL;
-       }
-
-       return result;
-}
 
 LWGEOM *
 lwcollection_getsubgeom(LWCOLLECTION *col, int gnum)
index d0591ec4890f382578eeed9184fdab0a1b9d5ed8..64ce3493ddb32a951e5ec343db20cbbf996e1c38 100644 (file)
 #include "liblwgeom_internal.h"
 #include "lwgeom_log.h"
 
-LWCOMPOUND *
-lwcompound_deserialize(uint8_t *serialized)
-{
-       LWCOMPOUND *result;
-       LWGEOM_INSPECTED *insp;
-       int type = lwgeom_getType(serialized[0]);
-       int i;
-
-       if (type != COMPOUNDTYPE)
-       {
-               lwerror("lwcompound_deserialize called on non compound: %d - %s", type, lwtype_name(type));
-               return NULL;
-       }
 
-       insp = lwgeom_inspect(serialized);
-
-       result = lwalloc(sizeof(LWCOMPOUND));
-       result->type = COMPOUNDTYPE;
-       result->flags = gflags(TYPE_HASZ(insp->type),TYPE_HASM(insp->type),0);
-       result->srid = insp->srid;
-       result->ngeoms = insp->ngeometries;
-       result->geoms = lwalloc(sizeof(LWGEOM *)*insp->ngeometries);
-
-       if (lwgeom_hasBBOX(serialized[0]))
-       {
-               BOX2DFLOAT4 *box2df;
-               
-               FLAGS_SET_BBOX(result->flags, 1);
-               box2df = lwalloc(sizeof(BOX2DFLOAT4));
-               memcpy(box2df, serialized + 1, sizeof(BOX2DFLOAT4));
-               result->bbox = gbox_from_box2df(result->flags, box2df);
-               lwfree(box2df);
-       }
-       else result->bbox = NULL;
-
-       for (i = 0; i < insp->ngeometries; i++)
-       {
-               if (lwgeom_getType(insp->sub_geoms[i][0]) == LINETYPE)
-                       result->geoms[i] = (LWGEOM *)lwline_deserialize(insp->sub_geoms[i]);
-               else
-                       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/circularstring %d:%d)",
-                               TYPE_NDIMS(result->type), i,
-                               TYPE_NDIMS(result->geoms[i]->type)
-                              );
-                       lwfree(result);
-                       return NULL;
-               }
-       }
-       return result;
-}
 
 int
 lwcompound_is_closed(const LWCOMPOUND *compound)
index 690ac4be0f544ad91dd6c96ee317998e1ce03d8a..0235c7549493842df78f647df13529bfe4416c12 100644 (file)
 #include "lwgeom_log.h"
 
 
-LWCURVEPOLY *
-lwcurvepoly_deserialize(uint8_t *srl)
-{
-       LWCURVEPOLY *result;
-       LWGEOM_INSPECTED *insp;
-       uint8_t type = (uint8_t)srl[0];
-       int geomtype = lwgeom_getType(type);
-       int i;
-
-       LWDEBUG(3, "lwcurvepoly_deserialize called.");
-
-       if (geomtype != CURVEPOLYTYPE)
-       {
-               lwerror("lwcurvepoly_deserialize called on NON curvepoly: %d",
-                       geomtype);
-               return NULL;
-       }
-
-       insp = lwgeom_inspect(srl);
-
-       result = lwalloc(sizeof(LWCURVEPOLY));
-       result->type = CURVEPOLYTYPE;
-       result->flags = gflags(TYPE_HASZ(type),TYPE_HASM(type),0);
-       result->srid = insp->srid;
-       result->nrings = insp->ngeometries;
-       result->rings = lwalloc(sizeof(LWGEOM *)*insp->ngeometries);
-
-       if (lwgeom_hasBBOX(srl[0]))
-       {
-               BOX2DFLOAT4 *box2df;
-               
-               FLAGS_SET_BBOX(result->flags, 1);
-               box2df = lwalloc(sizeof(BOX2DFLOAT4));
-               memcpy(box2df, srl + 1, sizeof(BOX2DFLOAT4));
-               result->bbox = gbox_from_box2df(result->flags, box2df);
-               lwfree(box2df);
-       }
-       else result->bbox = NULL;
-
-       for (i = 0; i < insp->ngeometries; i++)
-       {
-               result->rings[i] = lwgeom_deserialize(insp->sub_geoms[i]);
-               if (result->rings[i]->type != CIRCSTRINGTYPE
-                       && result->rings[i]->type != LINETYPE
-                       && result->rings[i]->type != COMPOUNDTYPE)
-               {
-                       lwerror("Only Circular curves, Linestrings and Compound curves are supported as rings, not %s (%d)", lwtype_name(result->rings[i]->type), result->rings[i]->type);
-                       lwfree(result);
-                       lwfree(insp);
-                       return NULL;
-               }
-               if (FLAGS_NDIMS(result->rings[i]->flags) != FLAGS_NDIMS(result->flags))
-               {
-                       lwerror("Mixed dimensions (curvepoly %d, ring %d)",
-                               FLAGS_NDIMS(result->flags), i,
-                               FLAGS_NDIMS(result->rings[i]->flags));
-                       lwfree(result);
-                       lwfree(insp);
-                       return NULL;
-               }
-       }
-       return result;
-}
-
 LWCURVEPOLY *
 lwcurvepoly_construct_empty(int srid, char hasz, char hasm)
 {
index 86a4f297a526d2c8fa9f1174b53b580e5521ea38..3d8e3e1a212d0ef415aae0bf0ca26d98d078bff5 100644 (file)
 #include "libtgeom.h"
 
 
-LWGEOM *
-lwgeom_deserialize(uint8_t *srl)
-{
-       int type = TYPE_GETTYPE(srl[0]);
-
-       LWDEBUGF(2, "lwgeom_deserialize got %d - %s", type, lwtype_name(type));
-
-       switch (type)
-       {
-       case POINTTYPE:
-               return (LWGEOM *)lwpoint_deserialize(srl);
-       case LINETYPE:
-               return (LWGEOM *)lwline_deserialize(srl);
-       case CIRCSTRINGTYPE:
-               return (LWGEOM *)lwcircstring_deserialize(srl);
-       case POLYGONTYPE:
-               return (LWGEOM *)lwpoly_deserialize(srl);
-       case TRIANGLETYPE:
-               return (LWGEOM *)lwtriangle_deserialize(srl);
-       case MULTIPOINTTYPE:
-               return (LWGEOM *)lwmpoint_deserialize(srl);
-       case MULTILINETYPE:
-               return (LWGEOM *)lwmline_deserialize(srl);
-       case MULTIPOLYGONTYPE:
-               return (LWGEOM *)lwmpoly_deserialize(srl);
-       case COLLECTIONTYPE:
-               return (LWGEOM *)lwcollection_deserialize(srl);
-       case COMPOUNDTYPE:
-               return (LWGEOM *)lwcompound_deserialize(srl);
-       case CURVEPOLYTYPE:
-               return (LWGEOM *)lwcurvepoly_deserialize(srl);
-       case MULTICURVETYPE:
-               return (LWGEOM *)lwmcurve_deserialize(srl);
-       case MULTISURFACETYPE:
-               return (LWGEOM *)lwmsurface_deserialize(srl);
-       case POLYHEDRALSURFACETYPE:
-               return (LWGEOM *)lwpsurface_deserialize(srl);
-       case TINTYPE:
-               return (LWGEOM *)lwtin_deserialize(srl);
-       default:
-               lwerror("lwgeom_deserialize: Unknown geometry type: %s", lwtype_name(type));
-               return NULL;
-       }
-
-}
-
 size_t
 lwgeom_serialize_size(LWGEOM *lwgeom)
 {
index a9385083769f6b8233a63cf53ff2c68f3f70826b..8689e9a69bda8edeca148e5d67e01fc28b473a50 100644 (file)
@@ -797,468 +797,6 @@ lw_get_int32_t(const uint8_t *loc)
 }
 
 
-/*************************************************************************
- *
- * Multi-geometry support
- *
- * Note - for a simple type (ie. point), this will have
- * sub_geom[0] = serialized_form.
- *
- * For multi-geomtries sub_geom[0] will be a few bytes
- * into the serialized form.
- *
- * This function just computes the length of each sub-object and
- * pre-caches this info.
- *
- * For a geometry collection of multi* geometries, you can inspect
- * the sub-components
- * as well.
- */
-LWGEOM_INSPECTED *
-lwgeom_inspect(const uint8_t *serialized_form)
-{
-       LWGEOM_INSPECTED *result = lwalloc(sizeof(LWGEOM_INSPECTED));
-       uint8_t typefl = (uint8_t)serialized_form[0];
-       uint8_t type;
-       uint8_t **sub_geoms;
-       const uint8_t *loc;
-       int     t;
-
-       LWDEBUGF(2, "lwgeom_inspect: serialized@%p", serialized_form);
-
-       if (serialized_form == NULL)
-               return NULL;
-
-       result->serialized_form = serialized_form;
-       result->type = (uint8_t) serialized_form[0];
-       result->srid = SRID_UNKNOWN; /* assume */
-
-       type = lwgeom_getType(typefl);
-
-       loc = serialized_form+1;
-
-       if ( lwgeom_hasBBOX(typefl) )
-       {
-               loc += sizeof(BOX2DFLOAT4);
-       }
-
-       if ( lwgeom_hasSRID(typefl) )
-       {
-               result->srid = lw_get_int32_t(loc);
-               loc += 4;
-       }
-
-       if ( (type==POINTTYPE) || (type==LINETYPE) || (type==POLYGONTYPE) ||
-               (type == CIRCSTRINGTYPE) || (type == TRIANGLETYPE))
-       {
-               /* simple geometry (point/line/polygon/circstring/triangle)-- not multi! */
-               result->ngeometries = 1;
-               sub_geoms = (uint8_t**) lwalloc(sizeof(char*));
-               sub_geoms[0] = (uint8_t *)serialized_form;
-               result->sub_geoms = (uint8_t **)sub_geoms;
-               return result;
-       }
-
-       /* its a GeometryCollection or multi* geometry */
-
-       result->ngeometries = lw_get_uint32_t(loc);
-       loc +=4;
-
-       LWDEBUGF(3, "lwgeom_inspect: geometry is a collection of %d elements",
-                result->ngeometries);
-
-       if ( ! result->ngeometries ) return result;
-
-       sub_geoms = lwalloc(sizeof(uint8_t*) * result->ngeometries );
-       result->sub_geoms = sub_geoms;
-       sub_geoms[0] = (uint8_t *)loc;
-
-       LWDEBUGF(3, "subgeom[0] @ %p (+%d)", sub_geoms[0], sub_geoms[0]-serialized_form);
-
-       for (t=1; t<result->ngeometries; t++)
-       {
-               /* -1 = entire object */
-               int sub_length = lwgeom_size_subgeom(sub_geoms[t-1], -1);
-               sub_geoms[t] = sub_geoms[t-1] + sub_length;
-
-               LWDEBUGF(3, "subgeom[%d] @ %p (+%d)",
-                        t, sub_geoms[t], sub_geoms[0]-serialized_form);
-       }
-
-       return result;
-
-}
-
-
-/*
- * 1st geometry has geom_number = 0
- * if the actual sub-geometry isnt a POINT, null is returned (see _gettype()).
- * if there arent enough geometries, return null.
- * this is fine to call on a point (with geom_num=0),
- * multipoint or geometrycollection
- */
-LWPOINT *
-lwgeom_getpoint(uint8_t *serialized_form, int geom_number)
-{
-       int type = lwgeom_getType((uint8_t)serialized_form[0]);
-       uint8_t *sub_geom;
-
-       if ((type == POINTTYPE)  && (geom_number == 0))
-       {
-               /* Be nice and do as they want instead of what they say */
-               return lwpoint_deserialize(serialized_form);
-       }
-
-       if ((type != MULTIPOINTTYPE) && (type != COLLECTIONTYPE) )
-               return NULL;
-
-       sub_geom = lwgeom_getsubgeometry(serialized_form, geom_number);
-       if (sub_geom == NULL)
-               return NULL;
-
-       type = lwgeom_getType(sub_geom[0]);
-       if (type != POINTTYPE)
-               return NULL;
-
-       return lwpoint_deserialize(sub_geom);
-}
-
-/*
- * 1st geometry has geom_number = 0
- * if the actual sub-geometry isnt a POINT, null is returned (see _gettype()).
- * if there arent enough geometries, return null.
- * this is fine to call on a point (with geom_num=0), multipoint
- * or geometrycollection
- */
-LWPOINT *lwgeom_getpoint_inspected(LWGEOM_INSPECTED *inspected, int geom_number)
-{
-       uint8_t *sub_geom;
-       uint8_t type;
-
-       sub_geom = lwgeom_getsubgeometry_inspected(inspected, geom_number);
-
-       if (sub_geom == NULL) return NULL;
-
-       type = lwgeom_getType(sub_geom[0]);
-       if (type != POINTTYPE) return NULL;
-
-       return lwpoint_deserialize(sub_geom);
-}
-
-
-/*
- * 1st geometry has geom_number = 0
- * if the actual geometry isnt a LINE, null is returned (see _gettype()).
- * if there arent enough geometries, return null.
- * this is fine to call on a line, multiline or geometrycollection
- */
-LWLINE *
-lwgeom_getline(uint8_t *serialized_form, int geom_number)
-{
-       uint8_t type = lwgeom_getType( (uint8_t) serialized_form[0]);
-       uint8_t *sub_geom;
-
-       if ((type == LINETYPE)  && (geom_number == 0))
-       {
-               /* be nice and do as they want instead of what they say */
-               return lwline_deserialize(serialized_form);
-       }
-
-       if ((type != MULTILINETYPE) && (type != COLLECTIONTYPE) )
-               return NULL;
-
-       sub_geom = lwgeom_getsubgeometry(serialized_form, geom_number);
-       if (sub_geom == NULL) return NULL;
-
-       type = lwgeom_getType((uint8_t) sub_geom[0]);
-       if (type != LINETYPE) return NULL;
-
-       return lwline_deserialize(sub_geom);
-}
-
-/*
- * 1st geometry has geom_number = 0
- * if the actual geometry isnt a LINE, null is returned (see _gettype()).
- * if there arent enough geometries, return null.
- * this is fine to call on a line, multiline or geometrycollection
- */
-LWLINE *
-lwgeom_getline_inspected(LWGEOM_INSPECTED *inspected, int geom_number)
-{
-       uint8_t *sub_geom;
-       uint8_t type;
-
-       sub_geom = lwgeom_getsubgeometry_inspected(inspected, geom_number);
-
-       if (sub_geom == NULL) return NULL;
-
-       type = lwgeom_getType((uint8_t) sub_geom[0]);
-       if (type != LINETYPE) return NULL;
-
-       return lwline_deserialize(sub_geom);
-}
-
-/*
- * 1st geometry has geom_number = 0
- * if the actual geometry isnt a POLYGON, null is returned (see _gettype()).
- * if there arent enough geometries, return null.
- * this is fine to call on a polygon, multipolygon or geometrycollection
- */
-LWPOLY *
-lwgeom_getpoly(uint8_t *serialized_form, int geom_number)
-{
-       uint8_t type = lwgeom_getType((uint8_t)serialized_form[0]);
-       uint8_t *sub_geom;
-
-       if ((type == POLYGONTYPE)  && (geom_number == 0))
-       {
-               /* Be nice and do as they want instead of what they say */
-               return lwpoly_deserialize(serialized_form);
-       }
-
-       if ((type != MULTIPOLYGONTYPE) && (type != COLLECTIONTYPE) )
-               return NULL;
-
-       sub_geom = lwgeom_getsubgeometry(serialized_form, geom_number);
-       if (sub_geom == NULL) return NULL;
-
-       type = lwgeom_getType(sub_geom[0]);
-       if (type != POLYGONTYPE) return NULL;
-
-       return lwpoly_deserialize(sub_geom);
-}
-
-/*
- * 1st geometry has geom_number = 0
- * if the actual geometry isnt a POLYGON, null is returned (see _gettype()).
- * if there arent enough geometries, return null.
- * this is fine to call on a polygon, multipolygon or geometrycollection
- */
-LWPOLY *
-lwgeom_getpoly_inspected(LWGEOM_INSPECTED *inspected, int geom_number)
-{
-       uint8_t *sub_geom;
-       uint8_t type;
-
-       sub_geom = lwgeom_getsubgeometry_inspected(inspected, geom_number);
-
-       if (sub_geom == NULL) return NULL;
-
-       type = lwgeom_getType(sub_geom[0]);
-       if (type != POLYGONTYPE) return NULL;
-
-       return lwpoly_deserialize(sub_geom);
-}
-
-/*
- * 1st geometry has geom_number = 0
- * if the actual geometry isnt a TRIANGLE, null is returned (see _gettype()).
- * if there arent enough geometries, return null.
- * this is fine to call on a Triangle, Tin or geometrycollection
- */
-LWTRIANGLE *
-lwgeom_gettriangle(uint8_t *serialized_form, int geom_number)
-{
-       uint8_t type = lwgeom_getType( (uint8_t) serialized_form[0]);
-       uint8_t *sub_geom;
-
-       if ((type == TRIANGLETYPE)  && (geom_number == 0))
-       {
-               /* be nice and do as they want instead of what they say */
-               return lwtriangle_deserialize(serialized_form);
-       }
-
-       if ((type != TINTYPE) && (type != COLLECTIONTYPE) )
-               return NULL;
-
-       sub_geom = lwgeom_getsubgeometry(serialized_form, geom_number);
-       if (sub_geom == NULL) return NULL;
-
-       type = lwgeom_getType((uint8_t) sub_geom[0]);
-       if (type != TRIANGLETYPE) return NULL;
-
-       return lwtriangle_deserialize(sub_geom);
-}
-
-/*
- * 1st geometry has geom_number = 0
- * if the actual geometry isnt a TRIANGLE, null is returned (see _gettype()).
- * if there arent enough geometries, return null.
- * this is fine to call on a Triangle, Tin or geometrycollection
- */
-LWTRIANGLE *
-lwgeom_gettriangle_inspected(LWGEOM_INSPECTED *inspected, int geom_number)
-{
-       uint8_t *sub_geom;
-       uint8_t type;
-
-       sub_geom = lwgeom_getsubgeometry_inspected(inspected, geom_number);
-
-       if (sub_geom == NULL) return NULL;
-
-       type = lwgeom_getType(sub_geom[0]);
-       if (type != TRIANGLETYPE) return NULL;
-
-       return lwtriangle_deserialize(sub_geom);
-}
-
-/*
- * 1st geometry has geom_number = 0
- * if the actual geometry isnt a CIRCULARSTRING, null is returned (see _gettype()).
- * if there arent enough geometries, return null.
- * this is fine to call on a circularstring
- */
-LWCIRCSTRING *
-lwgeom_getcircstring_inspected(LWGEOM_INSPECTED *inspected, int geom_number)
-{
-       uint8_t *sub_geom;
-       uint8_t type;
-
-       sub_geom = lwgeom_getsubgeometry_inspected(inspected, geom_number);
-
-       if (sub_geom == NULL) return NULL;
-
-       type = lwgeom_getType(sub_geom[0]);
-       if (type != CIRCSTRINGTYPE) return NULL;
-
-       return lwcircstring_deserialize(sub_geom);
-}
-
-/*
- * 1st geometry has geom_number = 0
- * if there arent enough geometries, return null.
- */
-LWGEOM *lwgeom_getgeom_inspected(LWGEOM_INSPECTED *inspected, int geom_number)
-{
-       uint8_t *sub_geom;
-       uint8_t type;
-
-       sub_geom = lwgeom_getsubgeometry_inspected(inspected, geom_number);
-
-       if (sub_geom == NULL) return NULL;
-
-       type = lwgeom_getType(sub_geom[0]);
-
-       return lwgeom_deserialize(sub_geom);
-}
-
-
-/*
- * This gets the serialized form of a sub-geometry
- *
- * 1st geometry has geom_number = 0
- * if this isnt a multi* geometry, and geom_number ==0 then it returns
- * itself.
- *
- * Returns null on problems.
- *
- * In the future this is how you would access a muli* portion of a
- * geometry collection.
- *    GEOMETRYCOLLECTION(MULTIPOINT(0 0, 1 1), LINESTRING(0 0, 1 1))
- *   ie. lwgeom_getpoint( lwgeom_getsubgeometry( serialized, 0), 1)
- *           --> POINT(1 1)
- *
- * You can inspect the sub-geometry as well if you wish.
- *
- */
-uint8_t *
-lwgeom_getsubgeometry(const uint8_t *serialized_form, int geom_number)
-{
-       uint8_t *result;
-       /*major cheat!! */
-       LWGEOM_INSPECTED *inspected = lwgeom_inspect(serialized_form);
-
-       result = lwgeom_getsubgeometry_inspected(inspected, geom_number);
-       lwinspected_release(inspected);
-       return result;
-}
-
-uint8_t *
-lwgeom_getsubgeometry_inspected(LWGEOM_INSPECTED *inspected, int geom_number)
-{
-       if ((geom_number <0) || (geom_number >= inspected->ngeometries) )
-       {
-               lwerror("lwgeom_getsubgeometry_inspected: geom_number out of range");
-               return NULL;
-       }
-
-       return inspected->sub_geoms[geom_number];
-}
-
-
-/*
- * 1st geometry has geom_number = 0
- *  use geom_number = -1 to find the actual type of the serialized form.
- *    ie lwgeom_gettype( <'MULTIPOINT(0 0, 1 1)'>, -1)
- *                 --> multipoint
- *   ie lwgeom_gettype( <'MULTIPOINT(0 0, 1 1)'>, 0)
- *                 --> point
- * gets the 8bit type of the geometry at location geom_number
- */
-uint8_t
-lwgeom_getsubtype(uint8_t *serialized_form, int geom_number)
-{
-       char  result;
-       /*major cheat!! */
-       LWGEOM_INSPECTED *inspected = lwgeom_inspect(serialized_form);
-
-       result = lwgeom_getsubtype_inspected(inspected, geom_number);
-       lwinspected_release(inspected);
-       return result;
-}
-
-uint8_t
-lwgeom_getsubtype_inspected(LWGEOM_INSPECTED *inspected, int geom_number)
-{
-       if ((geom_number <0) || (geom_number >= inspected->ngeometries) )
-               return 99;
-
-       return inspected->sub_geoms[geom_number][0]; /* 1st byte is type */
-}
-
-
-/*
- * How many sub-geometries are there?
- * for point,line,polygon will return 1.
- */
-int
-lwgeom_getnumgeometries(uint8_t *serialized_form)
-{
-       uint8_t type = lwgeom_getType((uint8_t)serialized_form[0]);
-       uint8_t *loc;
-
-       if ( (type==POINTTYPE) || (type==LINETYPE) || (type==POLYGONTYPE) || (type==TRIANGLETYPE) ||
-               (type==CIRCSTRINGTYPE) || (type==COMPOUNDTYPE) || (type==CURVEPOLYTYPE) )
-       {
-               return 1;
-       }
-
-       loc = serialized_form+1;
-
-       if (lwgeom_hasBBOX((uint8_t) serialized_form[0]))
-       {
-               loc += sizeof(BOX2DFLOAT4);
-       }
-
-       if (lwgeom_hasSRID((uint8_t) serialized_form[0]) )
-       {
-               loc += 4;
-       }
-       /* its a GeometryCollection or multi* geometry */
-       return lw_get_uint32_t(loc);
-}
-
-/*
- * How many sub-geometries are there?
- * for point,line,polygon will return 1.
- */
-int
-lwgeom_getnumgeometries_inspected(LWGEOM_INSPECTED *inspected)
-{
-       return inspected->ngeometries;
-}
-
-
 /*
  * Set finalType to COLLECTIONTYPE or 0 (0 means choose a best type)
  *   (ie. give it 2 points and ask it to be a multipoint)
@@ -1285,7 +823,8 @@ lwgeom_serialized_construct(int srid, int finalType, char hasz, char hasm,
 
        for (t=0; t<nsubgeometries; t++)
        {
-               lengths[t] = lwgeom_size_subgeom(serialized_subs[t],-1);
+//             lengths[t] = lwgeom_size_subgeom(serialized_subs[t],-1);
+        lengths[t] = 0;
                total_length += lengths[t];
                this_type = lwgeom_getType((uint8_t) (serialized_subs[t][0]));
                if (type == (char)-1)
@@ -1429,130 +968,6 @@ lwgeom_constructempty_buf(int srid, char hasz, char hasm,
        if (retsize) *retsize = lwgeom_empty_length(srid);
 }
 
-/**
- * helper function (not for general use)
- * find the size a geometry (or a sub-geometry)
- * 1st geometry has geom_number = 0
- *  use geom_number = -1 to find the actual type of the serialized form.
- *    ie lwgeom_gettype( <'MULTIPOINT(0 0, 1 1)'>, -1)
- *                 --> size of the multipoint
- *   ie lwgeom_gettype( <'MULTIPOINT(0 0, 1 1)'>, 0)
- *         --> size of the point
- * take a geometry, and find its length
- */
-size_t
-serialized_lwgeom_size(const uint8_t *serialized_form)
-{
-       uint8_t type = lwgeom_getType((uint8_t) serialized_form[0]);
-       int t;
-       const uint8_t *loc;
-       uint32_t ngeoms;
-       int sub_size;
-       int result = 1; /* type */
-
-       LWDEBUG(2, "lwgeom_size called");
-
-       if (type == POINTTYPE)
-       {
-               LWDEBUG(3, "lwgeom_size: is a point");
-
-               return lwgeom_size_point(serialized_form);
-       }
-       else if (type == LINETYPE)
-       {
-               LWDEBUG(3, "lwgeom_size: is a line");
-
-               return lwgeom_size_line(serialized_form);
-       }
-       else if (type == CIRCSTRINGTYPE)
-       {
-               LWDEBUG(3, "lwgeom_size: is a circularstring");
-
-               return lwgeom_size_circstring(serialized_form);
-       }
-       else if (type == POLYGONTYPE)
-       {
-               LWDEBUG(3, "lwgeom_size: is a polygon");
-
-               return lwgeom_size_poly(serialized_form);
-       }
-       else if (type == TRIANGLETYPE)
-       {
-               LWDEBUG(3, "lwgeom_size: is a triangle");
-
-               return lwgeom_size_triangle(serialized_form);
-       }
-       else if (type == COMPOUNDTYPE)
-       {
-               LWDEBUG(3, "lwgeom_size: is a compound curve");
-       }
-
-       if ( type == 0 )
-       {
-               lwerror("lwgeom_size called with unknown-typed serialized geometry");
-               return 0;
-       }
-
-       /*
-        * Handle all the multi* and geometrycollections the same
-        *
-        * NOTE: for a geometry collection of GC of GC of GC we will
-        *       be recursing...
-        */
-
-       LWDEBUGF(3, "lwgeom_size called on a geoemtry with type %d", type);
-
-       loc = serialized_form+1;
-
-       if (lwgeom_hasBBOX((uint8_t) serialized_form[0]))
-       {
-               LWDEBUG(3, "lwgeom_size: has bbox");
-
-               loc += sizeof(BOX2DFLOAT4);
-               result +=sizeof(BOX2DFLOAT4);
-       }
-
-       if (lwgeom_hasSRID( (uint8_t) serialized_form[0]) )
-       {
-               LWDEBUG(3, "lwgeom_size: has srid");
-
-               result +=4;
-               loc +=4;
-       }
-
-
-       ngeoms = lw_get_uint32_t(loc);
-       loc +=4;
-       result += 4; /* numgeoms */
-
-       LWDEBUGF(3, "lwgeom_size called on a geoemtry with %d elems (result so far: %d)", ngeoms, result);
-
-       for (t=0; t<ngeoms; t++)
-       {
-               sub_size = serialized_lwgeom_size(loc);
-
-               LWDEBUGF(3, " subsize %d", sub_size);
-
-               loc += sub_size;
-               result += sub_size;
-       }
-
-       LWDEBUGF(3, "lwgeom_size returning %d", result);
-
-       return result;
-}
-
-size_t
-lwgeom_size_subgeom(const uint8_t *serialized_form, int geom_number)
-{
-       if (geom_number == -1)
-       {
-               return serialized_lwgeom_size(serialized_form);
-       }
-       return serialized_lwgeom_size( lwgeom_getsubgeometry(serialized_form,geom_number));
-}
-
-
 
 /****************************************************************
  * memory management
@@ -1638,46 +1053,6 @@ void printBYTES(uint8_t *a, int n)
 }
 
 
-void
-printMULTI(uint8_t *serialized)
-{
-       LWGEOM_INSPECTED *inspected = lwgeom_inspect(serialized);
-       LWLINE  *line;
-       LWPOINT *point;
-       LWPOLY  *poly;
-       int t;
-
-       lwnotice("MULTI* geometry (type = %i), with %i sub-geoms",lwgeom_getType((uint8_t)serialized[0]), inspected->ngeometries);
-
-       for (t=0; t<inspected->ngeometries; t++)
-       {
-               lwnotice("      sub-geometry %i:", t);
-               line = NULL;
-               point = NULL;
-               poly = NULL;
-
-               line = lwgeom_getline_inspected(inspected,t);
-               if (line !=NULL)
-               {
-                       printLWLINE(line);
-               }
-               poly = lwgeom_getpoly_inspected(inspected,t);
-               if (poly !=NULL)
-               {
-                       printLWPOLY(poly);
-               }
-               point = lwgeom_getpoint_inspected(inspected,t);
-               if (point !=NULL)
-               {
-                       printPA(point->point);
-               }
-       }
-
-       lwnotice("end multi*");
-
-       lwinspected_release(inspected);
-}
-
 
 /**
  * Get the srid from the LWGEOM.
index 0d6d0c2c7177a25d02ec60f078e48b58c8c0d8d1..aabedc4c1de16d8973ac7700792157ab491fc65b 100644 (file)
@@ -59,78 +59,7 @@ lwline_construct_empty(int srid, char hasz, char hasm)
 }
 
 
-/*
- * given the LWGEOM serialized form (or a pointer into a muli* one)
- * construct a proper LWLINE.
- * serialized_form should point to the 8bit type format (with type = 2)
- * See serialized form doc
- */
-LWLINE *
-lwline_deserialize(uint8_t *serialized_form)
-{
-       uint8_t type;
-       LWLINE *result;
-       uint8_t *loc =NULL;
-       uint32_t npoints;
-       POINTARRAY *pa;
-
-       type = (uint8_t) serialized_form[0];
-
-       if ( lwgeom_getType(type) != LINETYPE)
-       {
-               lwerror("lwline_deserialize: attempt to deserialize a line which is really a %s", lwtype_name(type));
-               return NULL;
-       }
-
-       result = (LWLINE*) lwalloc(sizeof(LWLINE)) ;
-       result->type = LINETYPE;
-       result->flags = gflags(TYPE_HASZ(type),TYPE_HASM(type),0);
-
-       loc = serialized_form+1;
 
-       if (lwgeom_hasBBOX(type))
-       {
-               BOX2DFLOAT4 *box2df;
-
-               LWDEBUG(3, "lwline_deserialize: input has bbox");
-
-               FLAGS_SET_BBOX(result->flags, 1);
-               box2df = lwalloc(sizeof(BOX2DFLOAT4));
-               memcpy(box2df, loc, sizeof(BOX2DFLOAT4));
-               result->bbox = gbox_from_box2df(result->flags, box2df);
-               lwfree(box2df);
-               loc += sizeof(BOX2DFLOAT4);
-       }
-       else
-       {
-               result->bbox = NULL;
-               /*lwnotice("line has NO bbox"); */
-       }
-
-       if ( lwgeom_hasSRID(type))
-       {
-               /*lwnotice("line has srid"); */
-               result->srid = lw_get_int32_t(loc);
-               loc +=4; /* type + SRID */
-       }
-       else
-       {
-               /*lwnotice("line has NO srid"); */
-               result->srid = SRID_UNKNOWN;
-       }
-
-       /* we've read the type (1 byte) and SRID (4 bytes, if present) */
-
-       npoints = lw_get_uint32_t(loc);
-       /*lwnotice("line npoints = %d", npoints); */
-       loc +=4;
-       pa = ptarray_construct_reference_data(TYPE_HASZ(type)?1:0,
-                               TYPE_HASM(type)?1:0, npoints, loc);
-       
-       result->points = pa;
-
-       return result;
-}
 
 /*
  * convert this line into its serialize form
@@ -276,45 +205,6 @@ void lwline_free (LWLINE  *line)
        lwfree(line);
 }
 
-/* find length of this serialized line */
-size_t
-lwgeom_size_line(const uint8_t *serialized_line)
-{
-       int type = (uint8_t) serialized_line[0];
-       uint32_t result = 1;  /*type */
-       const uint8_t *loc;
-       uint32_t npoints;
-
-       LWDEBUG(2, "lwgeom_size_line called");
-
-       if ( lwgeom_getType(type) != LINETYPE)
-               lwerror("lwgeom_size_line::attempt to find the length of a non-line");
-
-
-       loc = serialized_line+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_t(loc);
-       result += sizeof(uint32_t); /* npoints */
-
-       result += TYPE_NDIMS(type) * sizeof(double) * npoints;
-
-       LWDEBUGF(3, "lwgeom_size_line returning %d", result);
-
-       return result;
-}
 
 void printLWLINE(LWLINE *line)
 {
index ea5564bd03801d0660a4a05353fff5db34a9611e..8a4dd8e56882ba602a2fef177e26522864b7c29f 100644 (file)
 #include <string.h>
 #include "liblwgeom_internal.h"
 
-LWMCURVE *
-lwmcurve_deserialize(uint8_t *srl)
-{
-       LWMCURVE *result;
-       LWGEOM_INSPECTED *insp;
-       int stype;
-       uint8_t type = (uint8_t)srl[0];
-       int geomtype = lwgeom_getType(type);
-       int i;
-
-       if (geomtype != MULTICURVETYPE)
-       {
-               lwerror("lwmcurve_deserialize called on NON multicurve: %d - %s", geomtype, lwtype_name(geomtype));
-               return NULL;
-       }
-
-       insp = lwgeom_inspect(srl);
-
-       result = lwalloc(sizeof(LWMCURVE));
-       result->type = MULTICURVETYPE;
-       result->flags = gflags(TYPE_HASZ(type), TYPE_HASM(type), 0);
-       result->srid = insp->srid;
-       result->ngeoms = insp->ngeometries;
-
-       if ( insp->ngeometries )
-       {
-               result->geoms = lwalloc(sizeof(LWGEOM *)*insp->ngeometries);
-       }
-       else
-       {
-               result->geoms = NULL;
-       }
-
-       if (lwgeom_hasBBOX(type))
-       {
-               BOX2DFLOAT4 *box2df;
-               
-               FLAGS_SET_BBOX(result->flags, 1);
-               box2df = lwalloc(sizeof(BOX2DFLOAT4));
-               memcpy(box2df, srl+1, sizeof(BOX2DFLOAT4));
-               result->bbox = gbox_from_box2df(result->flags, box2df);
-               lwfree(box2df);
-       }
-       else result->bbox = NULL;
-
-       for (i = 0; i < insp->ngeometries; i++)
-       {
-               stype = lwgeom_getType(insp->sub_geoms[i][0]);
-               if (stype == CIRCSTRINGTYPE)
-               {
-                       result->geoms[i] = (LWGEOM *)lwcircstring_deserialize(insp->sub_geoms[i]);
-               }
-               else if (stype == LINETYPE)
-               {
-                       result->geoms[i] = (LWGEOM *)lwline_deserialize(insp->sub_geoms[i]);
-               }
-               else if (stype == COMPOUNDTYPE)
-               {
-                       result->geoms[i] = (LWGEOM *)lwcompound_deserialize(insp->sub_geoms[i]);
-               }
-               else
-               {
-                       lwerror("Only Circular strings, Line strings or Compound curves are permitted in a MultiCurve.");
-
-                       lwfree(result);
-                       lwfree(insp);
-                       return NULL;
-               }
-
-               if (FLAGS_NDIMS(result->geoms[i]->flags) != FLAGS_NDIMS(result->flags))
-               {
-                       lwerror("Mixed dimensions (multicurve: %d, curve %d:%d)",
-                               FLAGS_NDIMS(result->flags), i,
-                               FLAGS_NDIMS(result->geoms[i]->flags));
-                       lwfree(result);
-                       lwfree(insp);
-                       return NULL;
-               }
-       }
-       lwinspected_release(insp);
-
-       return result;
-}
 
 
 
index 6ee9a15ab830242d01beca74ef85884691286bb3..da3134814918bf42af49a925d8c85f5a2bf8ef00 100644 (file)
@@ -28,68 +28,7 @@ lwmline_construct_empty(int srid, char hasz, char hasm)
        return ret;
 }
 
-LWMLINE *
-lwmline_deserialize(uint8_t *srl)
-{
-       LWMLINE *result;
-       LWGEOM_INSPECTED *insp;
-       uint8_t type = (uint8_t)srl[0];
-       int geomtype = TYPE_GETTYPE(srl[0]);
-       int i;
-
-       if ( geomtype != MULTILINETYPE )
-       {
-               lwerror("lwmline_deserialize called on NON multiline: %d - %s",
-                       geomtype, lwtype_name(geomtype));
-               return NULL;
-       }
-
-       insp = lwgeom_inspect(srl);
-
-       result = lwalloc(sizeof(LWMLINE));
-       result->type = geomtype;
-       result->flags = gflags( TYPE_HASZ(type), TYPE_HASM(type), 0);
-       result->srid = insp->srid;
-       result->ngeoms = insp->ngeometries;
-
-       if ( insp->ngeometries )
-       {
-               result->geoms = lwalloc(sizeof(LWLINE *)*insp->ngeometries);
-       }
-       else
-       {
-               result->geoms = NULL;
-       }
-
-       if (lwgeom_hasBBOX(type))
-       {
-               BOX2DFLOAT4 *box2df;
-               
-               FLAGS_SET_BBOX(result->flags, 1);
-               box2df = lwalloc(sizeof(BOX2DFLOAT4));
-               memcpy(box2df, srl+1, sizeof(BOX2DFLOAT4));
-               result->bbox = gbox_from_box2df(result->flags, box2df);
-               lwfree(box2df);
-       }
-       else result->bbox = NULL;
-
 
-       for (i=0; i<insp->ngeometries; i++)
-       {
-               result->geoms[i] = lwline_deserialize(insp->sub_geoms[i]);
-               if ( FLAGS_NDIMS(result->geoms[i]->flags) != FLAGS_NDIMS(result->flags) )
-               {
-                       lwerror("Mixed dimensions (multiline:%d, line%d:%d)",
-                               FLAGS_NDIMS(result->flags), i,
-                               FLAGS_NDIMS(result->geoms[i]->flags)
-                              );
-                       return NULL;
-               }
-       }
-       lwinspected_release(insp);
-
-       return result;
-}
 
 LWMLINE* lwmline_add_lwline(LWMLINE *mobj, const LWLINE *obj)
 {
index 04924d5f0fdae87b4fab914704e635dc0ba94c66..ff4e54babe9c8b9aa6634a2af639e1f7cacf96eb 100644 (file)
@@ -30,70 +30,7 @@ lwmpoint_construct_empty(int srid, char hasz, char hasm)
 }
 
 
-LWMPOINT *
-lwmpoint_deserialize(uint8_t *srl)
-{
-       LWMPOINT *result;
-       LWGEOM_INSPECTED *insp;
-       uint8_t type = (uint8_t)srl[0];
-       int geomtype = lwgeom_getType(type);
-       int i;
-
-       if ( geomtype != MULTIPOINTTYPE )
-       {
-               lwerror("lwmpoint_deserialize called on NON multipoint: %d - %s",
-                       geomtype, lwtype_name(geomtype));
-               return NULL;
-       }
-
-       insp = lwgeom_inspect(srl);
-
-       result = lwalloc(sizeof(LWMPOINT));
-       result->type = geomtype;
-       result->flags = gflags(TYPE_HASZ(type), TYPE_HASM(type), 0);
-       result->srid = insp->srid;
-       result->ngeoms = insp->ngeometries;
-
-       if ( insp->ngeometries )
-       {
-               result->geoms = lwalloc(sizeof(LWPOINT *)*insp->ngeometries);
-       }
-       else
-       {
-               result->geoms = NULL;
-       }
 
-       if (lwgeom_hasBBOX(type))
-       {
-               BOX2DFLOAT4 *box2df;
-
-               FLAGS_SET_BBOX(result->flags, 1);
-               box2df = lwalloc(sizeof(BOX2DFLOAT4));
-               memcpy(box2df, srl+1, sizeof(BOX2DFLOAT4));
-               result->bbox = gbox_from_box2df(result->flags, box2df);
-               lwfree(box2df);
-       }
-       else
-       {
-               result->bbox = NULL;
-       }
-
-       for (i=0; i<insp->ngeometries; i++)
-       {
-               result->geoms[i] = lwpoint_deserialize(insp->sub_geoms[i]);
-               if ( FLAGS_NDIMS(result->geoms[i]->flags) != FLAGS_NDIMS(result->flags) )
-               {
-                       lwerror("Mixed dimensions (multipoint:%d, point%d:%d)",
-                               FLAGS_NDIMS(result->flags), i,
-                               FLAGS_NDIMS(result->geoms[i]->flags)
-                              );
-                       return NULL;
-               }
-       }
-       lwinspected_release(insp);
-
-       return result;
-}
 
 LWMPOINT* lwmpoint_add_lwpoint(LWMPOINT *mobj, const LWPOINT *obj)
 {
index a4659d8127249abc9e736aec335a97833d0a1b42..730ca4b6b2b623ef7b97d02e1adc0d92b61e2d34 100644 (file)
@@ -30,69 +30,6 @@ lwmpoly_construct_empty(int srid, char hasz, char hasm)
        return ret;
 }
 
-LWMPOLY *
-lwmpoly_deserialize(uint8_t *srl)
-{
-       LWMPOLY *result;
-       LWGEOM_INSPECTED *insp;
-       uint8_t type = (uint8_t)srl[0];
-       int geomtype = TYPE_GETTYPE(type);
-       int i;
-
-       LWDEBUG(2, "lwmpoly_deserialize called");
-
-       if ( geomtype != MULTIPOLYGONTYPE )
-       {
-               lwerror("lwmpoly_deserialize called on NON multipoly: %d - %s",
-                       geomtype, lwtype_name(geomtype));
-               return NULL;
-       }
-
-       insp = lwgeom_inspect(srl);
-
-       result = lwalloc(sizeof(LWMPOLY));
-       result->type = geomtype;
-       result->flags = gflags(TYPE_HASZ(type),TYPE_HASM(type),0);
-       result->srid = insp->srid;
-       result->ngeoms = insp->ngeometries;
-
-       if ( insp->ngeometries )
-       {
-               result->geoms = lwalloc(sizeof(LWPOLY *)*insp->ngeometries);
-       }
-       else
-       {
-               result->geoms = NULL;
-       }
-
-       if (lwgeom_hasBBOX(type))
-       {
-               BOX2DFLOAT4 *box2df;
-               
-               FLAGS_SET_BBOX(result->flags, 1);
-               box2df = lwalloc(sizeof(BOX2DFLOAT4));
-               memcpy(box2df, srl+1, sizeof(BOX2DFLOAT4));
-               result->bbox = gbox_from_box2df(result->flags, box2df);
-               lwfree(box2df);
-       }
-       else result->bbox = NULL;
-
-       for (i=0; i<insp->ngeometries; i++)
-       {
-               result->geoms[i] = lwpoly_deserialize(insp->sub_geoms[i]);
-               if ( FLAGS_NDIMS(result->geoms[i]->flags) != FLAGS_NDIMS(result->flags) )
-               {
-                       lwerror("Mixed dimensions (multipoly:%d, poly%d:%d)",
-                               FLAGS_NDIMS(result->flags), i,
-                               FLAGS_NDIMS(result->geoms[i]->flags)
-                              );
-                       return NULL;
-               }
-       }
-       lwinspected_release(insp);
-
-       return result;
-}
 
 LWMPOLY* lwmpoly_add_lwpoly(LWMPOLY *mobj, const LWPOLY *obj)
 {
index bb864fb678b5e805cff2c07ef7cdf4ef707e6131..81a2e29f3304df62e11e3f635df7bdf7f8c1dcc5 100644 (file)
 #include "lwgeom_log.h"
 
 
-LWMSURFACE *
-lwmsurface_deserialize(uint8_t *srl)
-{
-       LWMSURFACE *result;
-       LWGEOM_INSPECTED *insp;
-       int stype;
-       uint8_t type = (uint8_t)srl[0];
-       int geomtype = lwgeom_getType(type);
-       int i;
-
-       LWDEBUG(2, "lwmsurface_deserialize called");
-
-       if (geomtype != MULTISURFACETYPE)
-       {
-               lwerror("lwmsurface_deserialize called on a non-multisurface: %d - %s", geomtype, lwtype_name(geomtype));
-               return NULL;
-       }
-
-       insp = lwgeom_inspect(srl);
-
-       result = lwalloc(sizeof(LWMSURFACE));
-       result->type = geomtype;
-       result->flags = gflags(TYPE_HASZ(type), TYPE_HASM(type), 0);
-       result->srid = insp->srid;
-       result->ngeoms = insp->ngeometries;
-
-       if ( insp->ngeometries )
-       {
-               result->geoms = lwalloc(sizeof(LWPOLY *)*insp->ngeometries);
-       }
-       else
-       {
-               result->geoms = NULL;
-       }
-
-       if (lwgeom_hasBBOX(type))
-       {
-               BOX2DFLOAT4 *box2df;
-               
-               FLAGS_SET_BBOX(result->flags, 1);
-               box2df = lwalloc(sizeof(BOX2DFLOAT4));
-               memcpy(box2df, srl + 1, sizeof(BOX2DFLOAT4));
-               result->bbox = gbox_from_box2df(result->flags, box2df);
-               lwfree(box2df);
-       }
-       else result->bbox = NULL;
-
-       for (i = 0; i < insp->ngeometries; i++)
-       {
-               stype = lwgeom_getType(insp->sub_geoms[i][0]);
-               if (stype == POLYGONTYPE)
-               {
-                       result->geoms[i] = (LWGEOM *)lwpoly_deserialize(insp->sub_geoms[i]);
-               }
-               else if (stype == CURVEPOLYTYPE)
-               {
-                       result->geoms[i] = (LWGEOM *)lwcurvepoly_deserialize(insp->sub_geoms[i]);
-               }
-               else
-               {
-                       lwerror("Only Polygons and Curved Polygons are supported in a MultiSurface.");
-                       lwfree(result);
-                       lwfree(insp);
-                       return NULL;
-               }
-
-               if (FLAGS_NDIMS(result->geoms[i]->flags) != FLAGS_NDIMS(result->flags))
-               {
-                       lwerror("Mixed dimensions (multisurface: %d, surface %d:%d",
-                               FLAGS_NDIMS(result->flags), i,
-                               FLAGS_NDIMS(result->geoms[i]->flags));
-                       lwfree(result);
-                       lwfree(insp);
-                       return NULL;
-               }
-       }
-       lwinspected_release(insp);
-
-       return result;
-}
-
 
index f5270d1009c93116a9d7e6f62d40f5e1a339abcd..1713b62279973668c1473e67e6e5006ba2b3391d 100644 (file)
@@ -305,74 +305,6 @@ lwpoint_make4d(int srid, double x, double y, double z, double m)
        return lwpoint_construct(srid, NULL, pa);
 }
 
-/*
- * Given the LWPOINT serialized form (or a pointer into a muli* one)
- * construct a proper LWPOINT.
- * serialized_form should point to the 8bit type format (with type = 1)
- * See serialized form doc
- */
-LWPOINT *
-lwpoint_deserialize(uint8_t *serialized_form)
-{
-       int geom_type;
-       LWPOINT *result;
-       uint8_t *loc = NULL;
-       POINTARRAY *pa;
-       uint8_t type;
-
-       LWDEBUG(2, "lwpoint_deserialize called");
-
-       result = (LWPOINT*) lwalloc(sizeof(LWPOINT)) ;
-
-       type = (uint8_t) serialized_form[0];
-       geom_type = TYPE_GETTYPE(type);
-
-       if ( geom_type != POINTTYPE)
-       {
-               lwerror("lwpoint_deserialize: attempt to deserialize a point which is really a %s", lwtype_name(geom_type));
-               return NULL;
-       }
-       result->type = geom_type;
-       result->flags = gflags(TYPE_HASZ(type),TYPE_HASM(type),0);
-
-       loc = serialized_form+1;
-
-       if (TYPE_HASBBOX(type))
-       {
-               BOX2DFLOAT4 box2df;
-
-               LWDEBUG(3, "lwpoint_deserialize: input has bbox");
-
-               FLAGS_SET_BBOX(result->flags, 1);
-               memcpy(&box2df, loc, sizeof(BOX2DFLOAT4));
-               result->bbox = gbox_from_box2df(result->flags, &box2df);
-               loc += sizeof(BOX2DFLOAT4);
-       }
-       else
-       {
-               result->bbox = NULL;
-       }
-
-       if ( TYPE_HASSRID(type))
-       {
-               LWDEBUG(3, "lwpoint_deserialize: input has SRID");
-
-               result->srid = lw_get_int32_t(loc);
-               loc += 4; /* type + SRID */
-       }
-       else
-       {
-               result->srid = SRID_UNKNOWN;
-       }
-
-       /* we've read the type (1 byte) and SRID (4 bytes, if present) */
-       pa = ptarray_construct_reference_data(FLAGS_GET_Z(result->flags), FLAGS_GET_M(result->flags), 1, loc);
-       
-       result->point = pa;
-
-       return result;
-}
-
 void lwpoint_free(LWPOINT *pt)
 {
        if ( pt->bbox )
@@ -412,42 +344,6 @@ lwpoint_clone(const LWPOINT *g)
 }
 
 
-/* Find length of this serialized point */
-size_t
-lwgeom_size_point(const uint8_t *serialized_point)
-{
-       uint32_t  result = 1;
-       uint8_t type;
-       const uint8_t *loc;
-
-       type = serialized_point[0];
-
-       if ( lwgeom_getType(type) != POINTTYPE) return 0;
-
-       LWDEBUGF(2, "lwgeom_size_point called (%d)", result);
-
-       loc = serialized_point+1;
-
-       if (lwgeom_hasBBOX(type))
-       {
-               loc += sizeof(BOX2DFLOAT4);
-               result +=sizeof(BOX2DFLOAT4);
-
-               LWDEBUGF(3, "lwgeom_size_point: has bbox (%d)", result);
-       }
-
-       if ( lwgeom_hasSRID(type))
-       {
-               LWDEBUGF(3, "lwgeom_size_point: has srid (%d)", result);
-
-               loc +=4; /* type + SRID */
-               result +=4;
-       }
-
-       result += TYPE_NDIMS(type)*sizeof(double);
-
-       return result;
-}
 
 void
 lwpoint_release(LWPOINT *lwpoint)
index 3ac7ab93c570e65cd0b366811a490458278f1e8e..378a861bb517c4024fa245409ea4abb3d2629971 100644 (file)
@@ -76,103 +76,6 @@ lwpoly_construct_empty(int srid, char hasz, char hasm)
 }
 
 
-/*
- * given the LWPOLY serialized form (or a pointer into a muli* one)
- * construct a proper LWPOLY.
- * serialized_form should point to the 8bit type format (with type = 3)
- * See serialized form doc
- */
-LWPOLY *
-lwpoly_deserialize(uint8_t *serialized_form)
-{
-
-       LWPOLY *result;
-       uint32_t nrings;
-       int ndims, hasz, hasm;
-       uint32_t npoints;
-       uint8_t type;
-       uint8_t *loc;
-       int t;
-
-       if (serialized_form == NULL)
-       {
-               lwerror("lwpoly_deserialize called with NULL arg");
-               return NULL;
-       }
-
-       type = serialized_form[0];
-       ndims = TYPE_NDIMS(type);
-       hasz = TYPE_HASZ(type);
-       hasm = TYPE_HASM(type);
-
-       result = (LWPOLY*) lwalloc(sizeof(LWPOLY));
-       result->type = TYPE_GETTYPE(type);
-       result->flags = gflags(hasz, hasm, 0);
-
-       loc = serialized_form;
-
-       if ( TYPE_GETTYPE(type) != POLYGONTYPE)
-       {
-               lwerror("lwpoly_deserialize: attempt to deserialize a poly which is really a %s", lwtype_name(type));
-               return NULL;
-       }
-
-
-       loc = serialized_form+1;
-
-       if (lwgeom_hasBBOX(type))
-       {
-               BOX2DFLOAT4 *box2df;
-
-               LWDEBUG(3, "lwpoly_deserialize: input has bbox");
-
-               FLAGS_SET_BBOX(result->flags, 1);
-               box2df = lwalloc(sizeof(BOX2DFLOAT4));
-                memcpy(box2df, loc, sizeof(BOX2DFLOAT4));
-                result->bbox = gbox_from_box2df(result->flags, box2df);
-                lwfree(box2df);
-               loc += sizeof(BOX2DFLOAT4);
-       }
-       else
-       {
-               result->bbox = NULL;
-       }
-
-       if ( lwgeom_hasSRID(type))
-       {
-               result->srid = lw_get_int32_t(loc);
-               loc +=4; /* type + SRID */
-       }
-       else
-       {
-               result->srid = SRID_UNKNOWN;
-       }
-
-       nrings = lw_get_uint32_t(loc);
-       result->nrings = nrings;
-       result->maxrings = nrings;
-       loc +=4;
-       if ( nrings )
-       {
-               result->rings = (POINTARRAY**) lwalloc(nrings* sizeof(POINTARRAY*));
-       }
-       else
-       {
-               result->rings = NULL;
-       }
-
-       for (t =0; t<nrings; t++)
-       {
-               /* read in a single ring and make a PA */
-               npoints = lw_get_uint32_t(loc);
-               loc +=4;
-               result->rings[t] = ptarray_construct_reference_data(hasz, hasm, npoints, loc);
-               loc += sizeof(double)*ndims*npoints;
-       }
-
-       return result;
-}
-
 /*
  * create the serialized form of the polygon
  * result's first char will be the 8bit type.  See serialized form doc
@@ -291,84 +194,6 @@ lwpoly_compute_box3d(LWPOLY *poly)
 }
 
 
-/* find length of this serialized polygon */
-size_t
-lwgeom_size_poly(const uint8_t *serialized_poly)
-{
-       uint32_t result = 1; /* char type */
-       uint32_t nrings;
-       int ndims;
-       int t;
-       uint8_t type;
-       uint32_t npoints;
-       const uint8_t *loc;
-
-       if (serialized_poly == NULL)
-               return -9999;
-
-
-       type = (uint8_t) serialized_poly[0];
-       ndims = TYPE_NDIMS(type);
-
-       if ( lwgeom_getType(type) != POLYGONTYPE)
-               return -9999;
-
-
-       loc = serialized_poly+1;
-
-       if (lwgeom_hasBBOX(type))
-       {
-               LWDEBUG(3, "lwgeom_size_poly: has bbox");
-
-               loc += sizeof(BOX2DFLOAT4);
-               result +=sizeof(BOX2DFLOAT4);
-       }
-
-
-       if ( lwgeom_hasSRID(type))
-       {
-               LWDEBUG(3, "lwgeom_size_poly: has srid");
-
-               loc +=4; /* type + SRID */
-               result += 4;
-       }
-
-
-       nrings = lw_get_uint32_t(loc);
-       loc +=4;
-       result +=4;
-
-       LWDEBUGF(3, "lwgeom_size_poly contains %d rings", nrings);
-
-       for (t =0; t<nrings; t++)
-       {
-               /* read in a single ring and make a PA */
-               npoints = lw_get_uint32_t(loc);
-               loc += 4;
-               result += 4;
-
-               if (ndims == 3)
-               {
-                       loc += 24*npoints;
-                       result += 24*npoints;
-               }
-               else if (ndims == 2)
-               {
-                       loc += 16*npoints;
-                       result += 16*npoints;
-               }
-               else if (ndims == 4)
-               {
-                       loc += 32*npoints;
-                       result += 32*npoints;
-               }
-       }
-
-       LWDEBUGF(3, "lwgeom_size_poly returning %d", result);
-
-       return result;
-}
-
 /* find length of this deserialized polygon */
 size_t
 lwpoly_serialize_size(LWPOLY *poly)
index e4c746c3afa2d06a31badc408d7b53d4f0026cf5..2732f1b05782a8c4cb4adc73532d38c47d54b4e0 100644 (file)
 #include "lwgeom_log.h"
 
 
-LWPSURFACE *
-lwpsurface_deserialize(uint8_t *srl)
-{
-       LWPSURFACE *result;
-       LWGEOM_INSPECTED *insp;
-       int type = lwgeom_getType(srl[0]);
-       int i;
-
-       LWDEBUG(2, "lwpsurface_deserialize called");
-
-       if ( type != POLYHEDRALSURFACETYPE )
-       {
-               lwerror("lwpsurface_deserialize called on NON polyhedralsurface: %d - %s",
-                       type, lwtype_name(type));
-               return NULL;
-       }
-
-       insp = lwgeom_inspect(srl);
-
-       result = lwalloc(sizeof(LWPSURFACE));
-       result->type = type;
-       result->flags = gflags(TYPE_HASZ(srl[0]), TYPE_HASM(srl[0]), 0);
-       result->srid = insp->srid;
-       result->ngeoms = insp->ngeometries;
-
-       if ( insp->ngeometries )
-       {
-               result->geoms = lwalloc(sizeof(LWPOLY *)*insp->ngeometries);
-       }
-       else
-       {
-               result->geoms = NULL;
-       }
-
-       if (lwgeom_hasBBOX(srl[0]))
-       {
-               BOX2DFLOAT4 *box2df;
-
-               FLAGS_SET_BBOX(result->flags, 1);
-               box2df = lwalloc(sizeof(BOX2DFLOAT4));
-               memcpy(box2df, srl+1, sizeof(BOX2DFLOAT4));
-               result->bbox = gbox_from_box2df(result->flags, box2df);
-               lwfree(box2df);
-       }
-       else result->bbox = NULL;
-
-       for (i=0; i<insp->ngeometries; i++)
-       {
-               result->geoms[i] = lwpoly_deserialize(insp->sub_geoms[i]);
-               if ( TYPE_NDIMS(result->geoms[i]->type) != TYPE_NDIMS(result->type) )
-               {
-                       lwerror("Mixed dimensions (polyhedralsurface:%d, face%d:%d)",
-                               TYPE_NDIMS(result->type), i,
-                               TYPE_NDIMS(result->geoms[i]->type)
-                              );
-                       return NULL;
-               }
-       }
-
-       return result;
-}
-
-
 LWPSURFACE* lwpsurface_add_lwpoly(LWPSURFACE *mobj, const LWPOLY *obj)
 {
        return (LWPSURFACE*)lwcollection_add_lwgeom((LWCOLLECTION*)mobj, (LWGEOM*)obj);
index ecae808b3e016ef0688434c938d62522e742ff88..76654d5abe19c0ed00b6b2954dd40e45c7d2a80d 100644 (file)
 #include "lwgeom_log.h"
 
 
-LWTIN *
-lwtin_deserialize(uint8_t *srl)
-{
-       LWTIN *result;
-       LWGEOM_INSPECTED *insp;
-       int type = lwgeom_getType(srl[0]);
-       int i;
-
-       LWDEBUG(2, "lwtin_deserialize called");
-
-       if ( type != TINTYPE )
-       {
-               lwerror("lwtin called on NON tin: %d - %s", type, lwtype_name(type));
-               return NULL;
-       }
-
-       insp = lwgeom_inspect(srl);
-
-       result = lwalloc(sizeof(LWTIN));
-       result->type = TINTYPE;
-       result->flags = gflags(TYPE_HASZ(insp->type), TYPE_HASM(insp->type), 0);
-       result->srid = insp->srid;
-       result->ngeoms = insp->ngeometries;
-
-       if ( insp->ngeometries )
-       {
-               result->geoms = lwalloc(sizeof(LWTRIANGLE *)*insp->ngeometries);
-       }
-       else
-       {
-               result->geoms = NULL;
-       }
-
-       if (lwgeom_hasBBOX(srl[0]))
-       {
-               BOX2DFLOAT4 *box2df;
-
-               FLAGS_SET_BBOX(result->flags, 1);
-               box2df = lwalloc(sizeof(BOX2DFLOAT4));
-               memcpy(box2df, srl+1, sizeof(BOX2DFLOAT4));
-               result->bbox = gbox_from_box2df(result->flags, box2df);
-               lwfree(box2df);
-       }
-       else result->bbox = NULL;
-
-       for (i=0; i<insp->ngeometries; i++)
-       {
-               result->geoms[i] = lwtriangle_deserialize(insp->sub_geoms[i]);
-               if ( FLAGS_NDIMS(result->geoms[i]->flags) != FLAGS_NDIMS(result->flags) )
-               {
-                       lwerror("Mixed dimensions (tin:%d, triangle%d:%d)",
-                               FLAGS_NDIMS(result->flags), i,
-                               FLAGS_NDIMS(result->geoms[i]->flags)
-                              );
-                       return NULL;
-               }
-       }
-
-       return result;
-}
-
 
 LWTIN* lwtin_add_lwtriangle(LWTIN *mobj, const LWTRIANGLE *obj)
 {
index e3c62d2ae5ec256ba9d5670f2e91084399696e9a..95cd5daef01972ffb5650ac9906066e865f3d476 100644 (file)
@@ -54,87 +54,6 @@ lwtriangle_construct_empty(int srid, char hasz, char hasm)
 }
 
 
-/*
- * given the LWTRIANGLE serialized form
- * construct a proper LWTRIANGLE.
- * serialized_form should point to the 8bit type format
- * See serialized form doc
- */
-LWTRIANGLE *
-lwtriangle_deserialize(uint8_t *serialized_form)
-{
-       LWTRIANGLE *result;
-       POINTARRAY *pa;
-       int ndims;
-       uint32_t npoints;
-       uint8_t type;
-       uint8_t *loc;
-
-       LWDEBUG(3, "lwtriangle_deserialize called");
-
-       if (serialized_form == NULL)
-       {
-               lwerror("lwtriangle_deserialize called with NULL arg");
-               return NULL;
-       }
-
-       result = (LWTRIANGLE*) lwalloc(sizeof(LWTRIANGLE));
-
-       type = serialized_form[0];
-       result->type = TRIANGLETYPE;
-
-       ndims = TYPE_NDIMS(type);
-       result->flags = gflags(TYPE_HASZ(type),TYPE_HASM(type),0);
-       loc = serialized_form;
-
-       if ( TYPE_GETTYPE(type) != TRIANGLETYPE)
-       {
-               lwerror("lwtriangle_deserialize: attempt to deserialize a triangle which is really a %s",
-                       lwtype_name(TYPE_GETTYPE(type)));
-               return NULL;
-       }
-
-       loc = serialized_form+1;
-
-       if (lwgeom_hasBBOX(type))
-       {
-               BOX2DFLOAT4 *box2df;
-
-               LWDEBUG(3, "lwtriangle_deserialize: input has bbox");
-
-               FLAGS_SET_BBOX(result->flags, 1);
-               box2df = lwalloc(sizeof(BOX2DFLOAT4));
-               memcpy(box2df, loc, sizeof(BOX2DFLOAT4));
-               result->bbox = gbox_from_box2df(result->flags, box2df);
-               lwfree(box2df);
-
-               loc += sizeof(BOX2DFLOAT4);
-       }
-       else
-       {
-               result->bbox = NULL;
-       }
-
-       if ( lwgeom_hasSRID(type))
-       {
-               result->srid = lw_get_int32_t(loc);
-               loc +=4; /* type + SRID */
-       }
-       else
-       {
-               result->srid = SRID_UNKNOWN;
-       }
-
-       npoints = lw_get_uint32_t(loc);
-       /*lwnotice("triangle npoints = %d", npoints); */
-       loc +=4;
-       pa = ptarray_construct_reference_data(FLAGS_GET_Z(result->flags), FLAGS_GET_M(result->flags), npoints, loc);
-       
-       result->points = pa;
-
-       return result;
-}
-
 /*
  * create the serialized form of the triangle
  * result's first char will be the 8bit type.  See serialized form doc
@@ -250,44 +169,6 @@ lwtriangle_compute_box3d(LWTRIANGLE *triangle)
        return result;
 }
 
-size_t
-lwgeom_size_triangle(const uint8_t *serialized_triangle)
-{
-       int type = (uint8_t) serialized_triangle[0];
-       uint32_t result = 1;  /*type */
-       const uint8_t *loc;
-       uint32_t npoints;
-
-       LWDEBUG(2, "lwgeom_size_triangle called");
-
-       if ( lwgeom_getType(type) != TRIANGLETYPE)
-               lwerror("lwgeom_size_triangle::attempt to find the length of a non-triangle");
-
-
-       loc = serialized_triangle+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_t(loc);
-       result += sizeof(uint32_t); /* npoints */
-
-       result += TYPE_NDIMS(type) * sizeof(double) * npoints;
-
-       LWDEBUGF(3, "lwgeom_size_triangle returning %d", result);
-
-       return result;
-}
 
 
 /* find length of this deserialized triangle */