]> granicus.if.org Git - postgis/commitdiff
More common flags between LW<type>s.
authorSandro Santilli <strk@keybit.net>
Thu, 30 Sep 2004 11:45:40 +0000 (11:45 +0000)
committerSandro Santilli <strk@keybit.net>
Thu, 30 Sep 2004 11:45:40 +0000 (11:45 +0000)
LWGEOM_summary output made cleaner and moved to lwgeom_debug.c

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

12 files changed:
lwgeom/Makefile
lwgeom/liblwgeom.c
lwgeom/liblwgeom.h
lwgeom/lwcollection.c
lwgeom/lwgeom_functions_basic.c
lwgeom/lwgeom_pg.c
lwgeom/lwline.c
lwgeom/lwmline.c
lwgeom/lwmpoint.c
lwgeom/lwmpoly.c
lwgeom/lwpoint.c
lwgeom/lwpoly.c

index 3cbb66287827f1023a3c12445ec30f1929f906ba..13c4a80b6d8b09f844af5c9be97243c046a88ff4 100644 (file)
@@ -66,7 +66,7 @@ ifeq ($(USE_STATS),1)
        override CFLAGS += -DUSE_STATS
 endif
  
-OBJS=lwgeom_pg.o liblwgeom.o lwgeom.o lwpoint.o lwline.o lwpoly.o lwmpoint.o lwmline.o lwmpoly.o lwcollection.o lwgeom_spheroid.o lwgeom_api.o lwgeom_ogc.o lwgeom_functions_analytic.o lwgeom_geos.o lwgeom_inout.o lwgeom_estimate.o lwgeom_functions_basic.o lwgeom_gist.o lwgeom_btree.o lwgeom_transform.o stringBuffer.o lwgeom_box.o lwgeom_box3d.o lwgeom_box2dfloat4.o lwgeom_chip.o lex.yy.o wktparse.tab.o lwgparse.o wktunparse.o lwgeom_svg.o lwgeom_gml.o $(GEOS_WRAPPER)
+OBJS=lwgeom_pg.o lwgeom_debug.o liblwgeom.o lwgeom.o lwpoint.o lwline.o lwpoly.o lwmpoint.o lwmline.o lwmpoly.o lwcollection.o lwgeom_spheroid.o lwgeom_api.o lwgeom_ogc.o lwgeom_functions_analytic.o lwgeom_geos.o lwgeom_inout.o lwgeom_estimate.o lwgeom_functions_basic.o lwgeom_gist.o lwgeom_btree.o lwgeom_transform.o stringBuffer.o lwgeom_box.o lwgeom_box3d.o lwgeom_box2dfloat4.o lwgeom_chip.o lex.yy.o wktparse.tab.o lwgparse.o wktunparse.o lwgeom_svg.o lwgeom_gml.o $(GEOS_WRAPPER)
 
 OTHERS=y.output lex.yy.c wktparse.tab.c wktparse.tab.h lwpostgis.sql
 
index a3b688333110750a110d53c31d40adb95f3f3c10..5c43e406cee7d615a6f305dfc574c502d2e6508f 100644 (file)
@@ -25,6 +25,16 @@ lwreporter lwerror = pg_error;
 lwreporter lwnotice = pg_notice;
 #endif
 
+static char *lwgeomTypeName[] = {
+       "Unknown",
+       "Point",
+       "Line",
+       "Polygon",
+       "MultiPoint",
+       "MultiLine",
+       "MultiPolygon",
+       "GeometryCollection"
+};
 
 void *
 default_allocator(size_t size)
@@ -63,8 +73,8 @@ default_noticereporter(const char *fmt, ...)
                va_end (ap);
                return;
        }
-       va_end(ap);
        printf("%s", msg);
+       va_end(ap);
        free(msg);
 }
 
@@ -85,7 +95,13 @@ default_errorreporter(const char *fmt, ...)
                va_end (ap);
                return;
        }
-       va_end(ap);
        fprintf(stderr, "%s", msg);
+       va_end(ap);
        free(msg);
 }
+
+const char *
+lwgeom_typename(int type)
+{
+       return lwgeomTypeName[type];
+}
index 0ec1b1ea7facbd9c34788e0315840646cc4ec242..a9cc9cc63f76a2c22334d7fca0acd55fc7f09b13 100644 (file)
@@ -123,6 +123,8 @@ typedef struct
         double m;
 } POINT4D;
 
+//-----------------------------------------------------------
+
 // Point array abstracts a lot of the complexity of points and point lists.
 // It handles miss-alignment in the serialized form, 2d/3d translation
 //    (2d points converted to 3d will have z=0 or NaN)
@@ -136,6 +138,95 @@ typedef struct
     uint32 npoints;
 }  POINTARRAY;
 
+//-----------------------------------------------------------
+
+// LWGEOM (any type)
+typedef struct
+{
+       int type; // POINT|LINE|POLY|MPOINT|MLINE|MPOLY|COLLECTION
+       char ndims; // 2=2d, 3=3d, 4=4d
+       uint32 SRID; // -1 == unneeded
+       char hasbbox; 
+       void *data;
+} LWGEOM;
+
+// POINTYPE
+typedef struct
+{
+       int type; // POINTTYPE
+       char ndims;
+       uint32 SRID;    
+       char hasbbox; 
+       POINTARRAY *point;  // hide 2d/3d (this will be an array of 1 point)
+}  LWPOINT; // "light-weight point"
+
+// LINETYPE
+typedef struct
+{
+       int type; // LINETYPE
+       char ndims;
+       uint32 SRID;    
+       char hasbbox; 
+       POINTARRAY    *points; // array of POINT3D
+} LWLINE; //"light-weight line"
+
+// POLYGONTYPE
+typedef struct
+{
+       int type; // POLYGONTYPE
+       char ndims;
+       uint32 SRID;    
+       char hasbbox; 
+       int  nrings;
+       POINTARRAY **rings; // list of rings (list of points)
+} LWPOLY; // "light-weight polygon"
+
+// MULTIPOINTTYPE
+typedef struct
+{
+       int type; // MULTIPOINTTYPE
+       char ndims;
+       uint32 SRID;    
+       char hasbbox; 
+       int  ngeoms;
+       LWPOINT **geoms;
+} LWMPOINT; 
+
+// MULTILINETYPE
+typedef struct
+{  
+       int type; // MULTILINETYPE
+       char ndims;
+       uint32 SRID;    
+       char hasbbox; 
+       int  ngeoms;
+       LWLINE **geoms;
+} LWMLINE; 
+
+// MULTIPOLYGONTYPE
+typedef struct
+{  
+       int type; // MULTIPOLYGONTYPE
+       char ndims;
+       uint32 SRID;    
+       char hasbbox; 
+       int  ngeoms;
+       LWPOLY **geoms;
+} LWMPOLY; 
+
+// COLLECTIONTYPE
+typedef struct
+{   
+       int type; // COLLECTIONTYPE
+       char ndims;
+       uint32 SRID;    
+       char hasbbox; 
+       int  ngeoms;
+       LWGEOM **geoms;
+} LWCOLLECTION; 
+
+//-------------------------------------------------------------
+
 // copies a point from the point array into the parameter point
 // will set point's z=0 (or NaN) if pa is 2d
 // will set point's m=0 (or NaN( if pa is 3d or 2d
@@ -289,14 +380,6 @@ extern uint32 lwgeom_size_poly(const char *serialized_line);
 // bounding box finder and (TODO) serialized form size finder.
 //--------------------------------------------------------
 
-typedef struct
-{
-       int type;
-       char ndims;     // 2=2d, 3=3d, 4=4d, 5=undef
-       int SRID;       // spatial ref sys
-       POINTARRAY *point;  // hide 2d/3d (this will be an array of 1 point)
-}  LWPOINT; // "light-weight point"
-
 // construct a new point.  point will NOT be copied
 // use SRID=-1 for unknown SRID (will have 8bit type's S = 0)
 extern LWPOINT  *lwpoint_construct(int ndims, int SRID, POINTARRAY *point);
@@ -327,14 +410,6 @@ extern POINT3D lwpoint_getPoint3d(const LWPOINT *point);
 
 //--------------------------------------------------------
 
-typedef struct
-{
-       int type;
-       char ndims; // 2=2d, 3=3d, 4=4d, 5=undef
-       int  SRID;   // spatial ref sys -1=none
-       POINTARRAY    *points; // array of POINT3D
-} LWLINE; //"light-weight line"
-
 // construct a new LWLINE.  points will *NOT* be copied
 // use SRID=-1 for unknown SRID (will have 8bit type's S = 0)
 extern LWLINE *lwline_construct(int ndims, int SRID, POINTARRAY *points);
@@ -361,15 +436,6 @@ extern BOX3D *lwline_findbbox(LWLINE *line);
 
 //--------------------------------------------------------
 
-typedef struct
-{
-       int type;
-       int32 SRID;
-       char ndims;
-       int  nrings;
-       POINTARRAY **rings; // list of rings (list of points)
-} LWPOLY; // "light-weight polygon"
-
 // construct a new LWPOLY.  arrays (points/points per ring) will NOT be copied
 // use SRID=-1 for unknown SRID (will have 8bit type's S = 0)
 extern LWPOLY *lwpoly_construct(int ndims, int SRID, int nrings,POINTARRAY **points);
@@ -396,66 +462,21 @@ extern BOX3D *lwpoly_findbbox(LWPOLY *poly);
 
 //--------------------------------------------------------
 
-// MULTIPOINTTYPE
-typedef struct
-{
-       int type;
-       int32 SRID;
-       char ndims;
-       int  ngeoms;
-       LWPOINT **geoms;
-} LWMPOINT; 
 
 extern size_t lwmpoint_serialize_size(LWMPOINT *mpoint);
 extern void lwmpoint_serialize_buf(LWMPOINT *mpoint, char *buf, int *size);
 
-// MULTILINETYPE
-typedef struct
-{  
-       int type;
-       int32 SRID;
-       char ndims;
-       int  ngeoms;
-       LWLINE **geoms;
-} LWMLINE; 
-
 extern size_t lwmline_serialize_size(LWMLINE *mline);
 extern void lwmline_serialize_buf(LWMLINE *mline, char *buf, int *size);
 
-// MULTIPOLYGONTYPE
-typedef struct
-{  
-       int type;
-       int32 SRID;
-       char ndims;
-       int  ngeoms;
-       LWPOLY **geoms;
-} LWMPOLY; 
-
 extern size_t lwmpoly_serialize_size(LWMPOLY *mpoly);
 extern void lwmpoly_serialize_buf(LWMPOLY *mpoly, char *buf, int *size);
 
-// LWGEOM (any type)
-typedef struct
-{
-       int type;
-       void *data;
-} LWGEOM;
 
 extern size_t lwgeom_serialize_size(LWGEOM *geom);
 extern void lwgeom_serialize_buf(LWGEOM *geom, char *buf, int *size);
 extern char *lwgeom_serialize(LWGEOM *geom, char wantbbox);
 
-// COLLECTIONTYPE
-typedef struct
-{   
-       int type;
-       int32 SRID;
-       char ndims;
-       int  ngeoms;
-       LWGEOM **geoms;
-} LWCOLLECTION; 
-
 extern size_t lwcollection_serialize_size(LWCOLLECTION *coll);
 extern void lwcollection_serialize_buf(LWCOLLECTION *mcoll, char *buf, int *size);
 
@@ -866,5 +887,7 @@ extern void lwline_reverse(LWLINE *line);
 extern void lwpoly_reverse(LWPOLY *poly);
 extern void lwpoly_forceRHR(LWPOLY *poly);
 extern void lwgeom_forceRHR(LWGEOM *lwgeom);
+extern char *lwgeom_summary(LWGEOM *lwgeom, int offset);
+extern const char *lwgeom_typename(int type);
 
 #endif // !defined _LIBLWGEOM_H 
index 875327e02052eead584dfe08b499485d0d54af92..d0d6d0c4ba5510a5c5c76bfdb2ceba279482771e 100644 (file)
@@ -8,7 +8,8 @@ lwcollection_deserialize(char *srl)
 {
        LWCOLLECTION *result;
        LWGEOM_INSPECTED *insp;
-       int type = lwgeom_getType(srl[0]);
+       char typefl = srl[0];
+       int type = lwgeom_getType(typefl);
        int i;
 
        if ( type != COLLECTIONTYPE ) 
@@ -22,8 +23,9 @@ lwcollection_deserialize(char *srl)
 
        result = lwalloc(sizeof(LWCOLLECTION));
        result->type = COLLECTIONTYPE;
+       result->hasbbox = lwgeom_hasBBOX(typefl);
+       result->ndims = lwgeom_ndims(typefl);
        result->SRID = insp->SRID;
-       result->ndims = lwgeom_ndims(insp->type);
        result->ngeoms = insp->ngeometries;
        result->geoms = lwalloc(sizeof(LWGEOM *)*insp->ngeometries);
 
index a717b7eaca1735cbbea37be4c074f6d2c2a5ce98..c43b0b4191a4d7dba026c4b124faadc10d486ef8 100644 (file)
@@ -49,8 +49,6 @@ Datum LWGEOM_reverse(PG_FUNCTION_ARGS);
 Datum LWGEOM_forceRHR_poly(PG_FUNCTION_ARGS);
 
 // internal
-char * lwgeom_summary_recursive(char *serialized, int offset);
-char * lwgeom_summary(LWGEOM *serialized, int offset);
 int32 lwgeom_nrings_recursive(char *serialized);
 void dump_lwexploded(LWGEOM_EXPLODED *exploded);
 void ptarray_reverse(POINTARRAY *pa);
@@ -832,243 +830,6 @@ Datum LWGEOM_mem_size(PG_FUNCTION_ARGS)
        PG_RETURN_INT32(size);
 }
 
-char *lwcollection_summary(LWCOLLECTION *collection, int offset);
-char *lwmpoly_summary(LWMPOLY *mpoly, int offset);
-char *lwmline_summary(LWMLINE *mline, int offset);
-char *lwmpoint_summary(LWMPOINT *mpoint, int offset);
-char *lwpoly_summary(LWPOLY *poly, int offset);
-char *lwline_summary(LWLINE *line, int offset);
-char *lwpoint_summary(LWPOINT *point, int offset);
-
-/*
- * Returns an alloced string containing summary for the LWGEOM object
- */
-char *
-lwpoint_summary(LWPOINT *point, int offset)
-{
-       char *result;
-       result = lwalloc(256);
-       sprintf(result, "Object %d is a POINT()\n", offset);
-       return result;
-}
-
-char *
-lwline_summary(LWLINE *line, int offset)
-{
-       char *result;
-       result = lwalloc(32);
-       sprintf(result, "Object %d is a LINE()\n", offset);
-       return result;
-}
-
-char *
-lwpoly_summary(LWPOLY *poly, int offset)
-{
-       char tmp[256];
-       char *result = lwalloc(64*(poly->nrings+1));
-       int i;
-
-       result[0] = '\0';
-       sprintf(tmp, "Object %d is a POLYGON() with %i rings\n",
-               offset, poly->nrings);
-       strcat(result, tmp);
-       for (i=0; i<poly->nrings;i++)
-       {
-               sprintf(tmp,"     + ring %i has %i points\n",
-                       i, poly->rings[i]->npoints);
-               strcat(result,tmp);
-       }
-       return result;
-}
-
-char *
-lwmpoint_summary(LWMPOINT *mpoint, int offset)
-{
-       char *result = lwalloc(60);
-       sprintf(result, "Object %d is a MULTIPOINT() with %d points\n",
-               offset, mpoint->ngeoms);
-       return result;
-}
-
-char *
-lwmline_summary(LWMLINE *mline, int offset)
-{
-       char *result = lwalloc(60*(mline->ngeoms+1));
-       sprintf(result, "Object %d is a MULTILINE() with %d lines\n",
-               offset, mline->ngeoms);
-       return result;
-}
-
-char *
-lwmpoly_summary(LWMPOLY *mpoly, int offset)
-{
-       size_t size = 128;
-       char *result = lwalloc(size);
-       char *tmp;
-       int i;
-
-       sprintf(result, "Object %d is a MULTIPOLYGON() with %d polys\n",
-               offset, mpoly->ngeoms);
-
-       for (i=0; i<mpoly->ngeoms; i++)
-       {
-               tmp = lwpoly_summary(mpoly->geoms[i], i);
-               size += strlen(tmp)+1;
-               result = lwrealloc(result, size);
-               strcat(result, tmp);
-               //lwfree(tmp);
-       }
-
-       return result;
-}
-
-
-char *
-lwcollection_summary(LWCOLLECTION *collection, int offset)
-{
-       char *result = lwalloc(60*(collection->ngeoms+1));
-       char *tmp;
-       int i;
-
-       sprintf(result, "Object %d is a COLLECTION() with %d subgeoms\n",
-               offset, collection->ngeoms);
-
-       for (i=0; i<collection->ngeoms; i++)
-       {
-               tmp = lwgeom_summary(lwcollection_getsubgeom(collection, i), i);
-               strcat(result, tmp);
-               lwfree(tmp);
-       }
-
-       return result;
-}
-
-char *
-lwgeom_summary(LWGEOM *lwgeom, int offset)
-{
-       char *result;
-
-       switch (lwgeom->type)
-       {
-               case POINTTYPE:
-                       return lwpoint_summary((LWPOINT *)lwgeom, offset);
-
-               case LINETYPE:
-                       return lwline_summary((LWLINE *)lwgeom, offset);
-
-               case POLYGONTYPE:
-                       return lwpoly_summary((LWPOLY *)lwgeom, offset);
-
-               case MULTIPOINTTYPE:
-                       return lwmpoint_summary((LWMPOINT *)lwgeom, offset);
-
-               case MULTILINETYPE:
-                       return lwmline_summary((LWMLINE *)lwgeom, offset);
-
-               case MULTIPOLYGONTYPE:
-                       return lwmpoly_summary((LWMPOLY *)lwgeom, offset);
-
-               case COLLECTIONTYPE:
-                       return lwcollection_summary((LWCOLLECTION *)lwgeom, offset);
-               default:
-                       result = palloc(256);
-                       sprintf(result, "Object is of unknown type: %d", 
-                               lwgeom->type);
-                       return result;
-       }
-
-       return NULL;
-}
-
-/*
- * Returns a lwalloced string containing summary for the serialized
- * LWGEOM object
- */
-char *
-lwgeom_summary_recursive(char *serialized, int offset)
-{
-       static int idx = 0;
-       LWGEOM_INSPECTED *inspected;
-       char *result;
-       char *ptr;
-       char tmp[100];
-       int size;
-       int32 j,i;
-
-       size = 1;
-       result = lwalloc(1);
-       result[0] = '\0';
-
-       if ( offset == 0 ) idx = 0;
-
-       inspected = lwgeom_inspect(serialized);
-
-       //now have to do a scan of each object
-       for (j=0; j<inspected->ngeometries; j++)
-       {
-               LWLINE *line=NULL;
-               LWPOINT *point=NULL;
-               LWPOLY *poly=NULL;
-               char *subgeom=lwgeom_getsubgeometry_inspected(inspected, j);
-
-               if ( lwgeom_getType(subgeom[0]) == 0 )
-               {
-                       size += 32;
-                       result = lwrealloc(result,size);
-                       sprintf(tmp,"Object %i is EMPTY()\n", idx++);
-                       strcat(result,tmp);
-                       continue;
-               }
-
-
-               point = lwgeom_getpoint_inspected(inspected,j);
-               if (point !=NULL)
-               {
-                       size += 32;
-                       result = lwrealloc(result,size);
-                       sprintf(tmp,"Object %i is a POINT()\n", idx++);
-                       strcat(result,tmp);
-                       continue;
-               }
-
-               poly = lwgeom_getpoly_inspected(inspected, j);
-               if (poly !=NULL)
-               {
-                       size += 60*(poly->nrings+1);
-                       result = lwrealloc(result,size);
-                       sprintf(tmp,"Object %i is a POLYGON() with %i rings\n",
-                               idx++, poly->nrings);
-                       strcat(result,tmp);
-                       for (i=0; i<poly->nrings;i++)
-                       {
-                               sprintf(tmp,"     + ring %i has %i points\n",
-                                       i, poly->rings[i]->npoints);
-                               strcat(result,tmp);
-                       }
-                       continue;
-               }
-
-               line = lwgeom_getline_inspected(inspected, j);
-               if (line != NULL)
-               {
-                       size += 57;
-                       result = lwrealloc(result,size);
-                       sprintf(tmp, "Object %i is a LINESTRING() with %i points\n", idx++, line->points->npoints);
-                       strcat(result,tmp);
-                       continue;
-               }
-
-               ptr = lwgeom_summary_recursive(subgeom, j);
-               size += strlen(ptr);
-               result = lwrealloc(result,size);
-               strcat(result, ptr);
-               lwfree(ptr);
-       }
-
-       pfree_inspected(inspected);
-       return result;
-}
-
 /*
  * Translate a pointarray.
  */
@@ -1161,13 +922,13 @@ Datum LWGEOM_summary(PG_FUNCTION_ARGS)
 
        lwgeom = lwgeom_deserialize(SERIALIZED_FORM(geom));
 
-       //result = lwgeom_summary_recursive(SERIALIZED_FORM(geom), 0);
        result = lwgeom_summary(lwgeom, 0);
 
        // create a text obj to return
-       mytext = (text *) lwalloc(VARHDRSZ  + strlen(result) );
-       VARATT_SIZEP(mytext) = VARHDRSZ + strlen(result) ;
-       memcpy(VARDATA(mytext) , result, strlen(result) );
+       mytext = (text *) lwalloc(VARHDRSZ  + strlen(result) + 1);
+       VARATT_SIZEP(mytext) = VARHDRSZ + strlen(result) + 1;
+       VARDATA(mytext)[0] = '\n';
+       memcpy(VARDATA(mytext)+1, result, strlen(result) );
        lwfree(result);
        PG_RETURN_POINTER(mytext);
 }
index f5306398e4a9d003e92c9242f1d9517c710bc6cc..b81c7056103e8e5c225d2c83072617251894ad55 100644 (file)
@@ -5,12 +5,19 @@
 #include "liblwgeom.h"
 #include "lwgeom_pg.h"
 
+#undef DEBUG
+
 void *
 pg_alloc(size_t size)
 {
        void * result;
+#ifdef DEBUG
+       lwnotice("  pg_alloc(%d) called", size);
+#endif
        result = palloc(size);
-       //elog(NOTICE,"  palloc(%d) = %p", size, result);
+#ifdef DEBUG
+       lwnotice("  pg_alloc(%d) returning %p", size, result);
+#endif
        return result;
 }
 
@@ -18,7 +25,13 @@ void *
 pg_realloc(void *mem, size_t size)
 {
        void * result;
+#ifdef DEBUG
+       lwnotice("  pg_realloc(%p, %d) called", mem, size);
+#endif
        result = repalloc(mem, size);
+#ifdef DEBUG
+       lwnotice("  pg_realloc(%p, %d) returning %p", mem, size, result);
+#endif
        return result;
 }
 
@@ -45,8 +58,8 @@ pg_error(const char *fmt, ...)
                va_end (ap);
                return;
        }
-       va_end(ap);
        elog(ERROR, "%s", msg);
+       va_end(ap);
        free(msg);
 }
 
@@ -67,8 +80,8 @@ pg_notice(const char *fmt, ...)
                va_end (ap);
                return;
        }
-       va_end(ap);
        elog(NOTICE, "%s", msg);
+       va_end(ap);
        free(msg);
 }
 
index c687663828df988db5bc1284598f0d926bce5d11..7999711c1ef2eec82569e656a3dfc52aa6b3bc39 100644 (file)
@@ -49,9 +49,11 @@ LWLINE *lwline_deserialize(char *serialized_form)
        {
                //lwnotice("line has bbox");
                loc += sizeof(BOX2DFLOAT4);
+               result->hasbbox = 1;
        }
        else
        {
+               result->hasbbox = 0;
                //lwnotice("line has NO bbox");
        }
 
@@ -108,7 +110,7 @@ if (line == NULL)
        }
        else if (line->ndims == 4)
        {
-                       size += 32 * line->points->npoints; //x,y
+               size += 32 * line->points->npoints; //x,y
        }
 
 
index 2b69faba26e01055aa48070a69b3639c18dc0f7a..17886c97369d715aaef2112665efe2ac4910f69d 100644 (file)
@@ -24,6 +24,7 @@ lwmline_deserialize(char *srl)
        result->type = MULTILINETYPE;
        result->SRID = insp->SRID;
        result->ndims = lwgeom_ndims(insp->type);
+       result->hasbbox = lwgeom_hasBBOX(insp->type);
        result->ngeoms = insp->ngeometries;
        result->geoms = lwalloc(sizeof(LWLINE *)*insp->ngeometries);
 
index 98054666337a3b07e1959ba5dc00a47cb69eb5b4..0417d111199ec98a608be9aff475a9b8a7d36de7 100644 (file)
@@ -23,6 +23,7 @@ lwmpoint_deserialize(char *srl)
        result = lwalloc(sizeof(LWMPOINT));
        result->type = MULTIPOINTTYPE;
        result->SRID = insp->SRID;
+       result->hasbbox = lwgeom_hasBBOX(insp->type);
        result->ndims = lwgeom_ndims(insp->type);
        result->ngeoms = insp->ngeometries;
        result->geoms = lwalloc(sizeof(LWPOINT *)*result->ngeoms);
index dba76d135f9718cbca14226f02afaafafa120cd8..bb1faf9833b83fa393ca3ca60b8811491c581d99 100644 (file)
@@ -29,6 +29,7 @@ lwmpoly_deserialize(char *srl)
        result = lwalloc(sizeof(LWMPOLY));
        result->type = MULTIPOLYGONTYPE;
        result->SRID = insp->SRID;
+       result->hasbbox = lwgeom_hasBBOX(insp->type);
        result->ndims = lwgeom_ndims(insp->type);
        result->ngeoms = insp->ngeometries;
        result->geoms = lwalloc(sizeof(LWPOLY *)*insp->ngeometries);
index e2eaa3ff6950c3b256f306db375f387c22cd684f..a50b0f59e1ad679805a8f5987095aa9bfa07ac5d 100644 (file)
@@ -188,8 +188,10 @@ lwpoint_deserialize(char *serialized_form)
 #ifdef DEBUG
                lwnotice("lwpoint_deserialize: input has bbox");
 #endif
+               result->hasbbox = 1;
                loc += sizeof(BOX2DFLOAT4);
        }
+       else result->hasbbox = 0;
 
        if ( lwgeom_hasSRID(type))
        {
@@ -224,6 +226,7 @@ void printLWPOINT(LWPOINT *point)
 {
        lwnotice("LWPOINT {");
        lwnotice("    ndims = %i", (int)point->ndims);
+       lwnotice("    BBOX = %i", point->hasbbox ? 1 : 0 );
        lwnotice("    SRID = %i", (int)point->SRID);
        printPA(point->point);
        lwnotice("}");
index 98cb11c3513318a0e024d85582ca7040bb3d4626..76b6b04fda53b8f2eb41a57fa2a43a3384f06634 100644 (file)
@@ -66,6 +66,11 @@ lwpoly_deserialize(char *serialized_form)
        if (lwgeom_hasBBOX(type))
        {
                loc += sizeof(BOX2DFLOAT4);
+               result->hasbbox = 1;
+       }
+       else
+       {
+               result->hasbbox = 0;
        }
 
        if ( lwgeom_hasSRID(type))