33 #define CHECK_LWGEOM_ZM 1
48 #ifdef CHECK_LWGEOM_ZM
53 LWDEBUGF(2,
"lwcollection_construct called with %d, %d, %p, %d, %p.",
type, srid, bbox, ngeoms, geoms);
56 lwerror(
"Non-collection type specified in collection constructor!");
64 #ifdef CHECK_LWGEOM_ZM
67 LWDEBUGF(3,
"lwcollection_construct type[0]=%d", geoms[0]->
type);
69 for (i=1; i<ngeoms; i++)
71 LWDEBUGF(3,
"lwcollection_construct type=[%d]=%d", i, geoms[i]->
type);
74 lwerror(
"lwcollection_construct: mixed dimension geometries: %d/%d", zm,
FLAGS_GET_ZM(geoms[i]->flags));
98 lwerror(
"Non-collection type specified in collection constructor!");
131 for (i=0; i<g->
ngeoms; i++)
157 for (i=0; i<g->
ngeoms; i++)
176 if ( ngeoms <= col->maxgeoms )
return;
189 if (!col || !geom)
return NULL;
193 lwerror(
"Collection is in inconsistent state. Null memory but non-zero collection counts.");
214 #if PARANOIA_LEVEL > 1
219 for (i = 0; i < col->
ngeoms; i++)
221 if (col->
geoms[i] == geom)
223 lwerror(
"%s [%d] found duplicate geometry in collection %p == %p", __FILE__, __LINE__, col->
geoms[i], geom);
243 if (!col1 || !col2)
return NULL;
244 for (i = 0; i < col2->
ngeoms; i++)
258 for (i = 0; i < col->
ngeoms; i++)
263 for (j = 0; j < i; j++)
282 LWDEBUG(2,
"lwcollection_same called");
287 for ( i = 0; i < c1->
ngeoms; i++ )
325 lwerror(
"Null input geometry.");
329 for ( i = 0; i < col->
ngeoms; i++ )
365 for ( i = 0; i < col->
ngeoms; i++ )
391 int geomlistsize = 16;
395 if (!col)
return NULL;
410 "Only POLYGON, LINESTRING and POINT are supported by "
411 "lwcollection_extract. %s requested.",
419 for (i = 0; i < col->
ngeoms; i++)
429 if (geomlistlen == geomlistsize)
433 geomlist,
sizeof(
LWGEOM*) * geomlistsize);
444 for (j = 0; j < tmpcol->
ngeoms; j++)
448 if (geomlistlen == geomlistsize)
455 geomlist[geomlistlen] = tmpcol->
geoms[j];
468 outtype, col->
srid, NULL, geomlistlen, geomlist);
499 for( i = 0; i < col->
ngeoms; i++ )
513 for( i = 0; i < col->
ngeoms; i++ )
526 for ( i = 0; i < col->
ngeoms; i++ )
562 if ( collectiontype ==
TINTYPE &&
GBOX * gbox_copy(const GBOX *box)
Return a copy of the GBOX, based on dimensionality of flags.
uint8_t gflags(int hasz, int hasm, int geodetic)
Construct a new flags char.
char lwgeom_same(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2)
geom1 same as geom2 iff
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
int lwgeom_startpoint(const LWGEOM *lwgeom, POINT4D *pt)
void lwgeom_free(LWGEOM *geom)
LWGEOM * lwgeom_segmentize2d(const LWGEOM *line, double dist)
#define FLAGS_SET_BBOX(flags, value)
LWGEOM * lwgeom_clone_deep(const LWGEOM *lwgeom)
Deep clone an LWGEOM, everything is copied.
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
uint32_t lwgeom_count_vertices(const LWGEOM *geom)
Count the total number of vertices in any LWGEOM.
void * lwrealloc(void *mem, size_t size)
#define POLYHEDRALSURFACETYPE
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
#define FLAGS_GET_M(flags)
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
#define FLAGS_GET_ZM(flags)
LWGEOM * lwgeom_clone(const LWGEOM *lwgeom)
Clone LWGEOM object.
int lwgeom_calculate_gbox(const LWGEOM *lwgeom, GBOX *gbox)
Calculate bounding box of a geometry, automatically taking into account whether it is cartesian or ge...
void * lwalloc(size_t size)
#define LW_TRUE
Return types for functions with status returns.
void lwgeom_release(LWGEOM *lwgeom)
Free the containing LWGEOM and the associated BOX.
LWGEOM * lwgeom_force_dims(const LWGEOM *lwgeom, int hasz, int hasm)
LWCOLLECTION * lwcollection_clone(const LWCOLLECTION *g)
Clone LWCOLLECTION object.
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
char lwcollection_same(const LWCOLLECTION *c1, const LWCOLLECTION *c2)
check for same geometry composition
LWCOLLECTION * lwcollection_force_dims(const LWCOLLECTION *col, int hasz, int hasm)
LWCOLLECTION * lwcollection_segmentize2d(const LWCOLLECTION *col, double dist)
LWGEOM * lwcollection_getsubgeom(LWCOLLECTION *col, int gnum)
int lwcollection_startpoint(const LWCOLLECTION *col, POINT4D *pt)
void lwcollection_release(LWCOLLECTION *lwcollection)
void lwcollection_free(LWCOLLECTION *col)
int lwcollection_ngeoms(const LWCOLLECTION *col)
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
LWCOLLECTION * lwcollection_concat_in_place(LWCOLLECTION *col1, const LWCOLLECTION *col2)
Appends all geometries from col2 to col1 in place.
void lwcollection_reserve(LWCOLLECTION *col, uint32_t ngeoms)
Ensure the collection can hold up at least ngeoms.
LWCOLLECTION * lwcollection_extract(LWCOLLECTION *col, int type)
Takes a potentially heterogeneous collection and returns a homogeneous collection consisting only of ...
LWCOLLECTION * lwcollection_add_lwgeom(LWCOLLECTION *col, const LWGEOM *geom)
Appends geom to the collection managed by col.
uint32_t lwcollection_count_vertices(LWCOLLECTION *col)
int lwcollection_allows_subtype(int collectiontype, int subtype)
Check if subtype is allowed in collectiontype.
int lwcollection_is_empty(const LWCOLLECTION *col)
LWCOLLECTION * lwcollection_clone_deep(const LWCOLLECTION *g)
Deep clone LWCOLLECTION object.
#define LWDEBUG(level, msg)
#define LWDEBUGF(level, msg,...)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.