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 == NULL || geom == NULL )
return NULL;
192 lwerror(
"Collection is in inconsistent state. Null memory but non-zero collection counts.");
203 if ( col->
geoms == NULL )
213 #if PARANOIA_LEVEL > 1 218 for ( i = 0; i < col->
ngeoms; i++ )
220 if ( col->
geoms[i] == geom )
222 lwerror(
"%s [%d] found duplicate geometry in collection %p == %p", __FILE__, __LINE__, col->
geoms[i], geom);
223 LWDEBUGF(4,
"Found duplicate geometry in collection %p == %p", col->
geoms[i], geom);
245 for (i=0; i<col->
ngeoms; i++)
248 if ( ! newgeoms[i] ) {
266 LWDEBUG(2,
"lwcollection_same called");
271 for ( i = 0; i < c1->
ngeoms; i++ )
309 lwerror(
"Null input geometry.");
313 for ( i = 0; i < col->
ngeoms; i++ )
349 for ( i = 0; i < col->
ngeoms; i++ )
374 int geomlistsize = 16;
378 if ( ! col )
return NULL;
392 lwerror(
"Only POLYGON, LINESTRING and POINT are supported by lwcollection_extract. %s requested.",
lwtype_name(type));
399 for ( i = 0; i < col->
ngeoms; i++ )
408 if ( subtype == type )
411 if ( geomlistlen == geomlistsize )
424 for ( j = 0; j < tmpcol->
ngeoms; j++ )
427 if ( geomlistlen == geomlistsize )
432 geomlist[geomlistlen] = tmpcol->
geoms[j];
443 if ( geomlistlen > 0 )
466 for (i=0; i<coll->
ngeoms; i++)
492 for( i = 0; i < col->
ngeoms; i++ )
506 for( i = 0; i < col->
ngeoms; i++ )
519 for ( i = 0; i < col->
ngeoms; i++ )
534 for( i = 0; i < igeom->
ngeoms; i++ )
571 if ( collectiontype ==
TINTYPE &&
596 for (i=0; i<coll->ngeoms; i++)
GBOX * gbox_copy(const GBOX *box)
Return a copy of the GBOX, based on dimensionality of flags.
void lwcollection_release(LWCOLLECTION *lwcollection)
void lwcollection_reserve(LWCOLLECTION *col, int ngeoms)
Ensure the collection can hold up at least ngeoms.
LWGEOM * lwgeom_grid(const LWGEOM *lwgeom, const gridspec *grid)
int lwcollection_count_vertices(LWCOLLECTION *col)
int lwgeom_startpoint(const LWGEOM *lwgeom, POINT4D *pt)
LWCOLLECTION * lwcollection_clone(const LWCOLLECTION *g)
Clone LWCOLLECTION object.
void lwgeom_free(LWGEOM *geom)
#define FLAGS_GET_ZM(flags)
void lwcollection_free(LWCOLLECTION *col)
#define LWDEBUG(level, msg)
#define POLYHEDRALSURFACETYPE
LWCOLLECTION * lwcollection_segmentize2d(LWCOLLECTION *col, double dist)
LWGEOM * lwgeom_clone_deep(const LWGEOM *lwgeom)
Deep clone an LWGEOM, everything is copied.
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
LWCOLLECTION * lwcollection_grid(const LWCOLLECTION *coll, const gridspec *grid)
int lwcollection_is_empty(const LWCOLLECTION *col)
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
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...
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
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.
int lwcollection_ngeoms(const LWCOLLECTION *col)
#define LW_TRUE
Return types for functions with status returns.
LWGEOM * lwgeom_simplify(const LWGEOM *igeom, double dist, int preserve_collapsed)
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
char lwcollection_same(const LWCOLLECTION *c1, const LWCOLLECTION *c2)
check for same geometry composition
int lwcollection_allows_subtype(int collectiontype, int subtype)
Check if subtype is allowed in collectiontype.
LWCOLLECTION * lwcollection_clone_deep(const LWCOLLECTION *g)
Deep clone LWCOLLECTION object.
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
LWGEOM * lwgeom_force_dims(const LWGEOM *lwgeom, int hasz, int hasm)
LWGEOM * lwgeom_clone(const LWGEOM *lwgeom)
Clone LWGEOM object.
char lwgeom_same(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2)
geom1 same as geom2 iff
uint8_t gflags(int hasz, int hasm, int geodetic)
Construct a new flags char.
#define FLAGS_SET_BBOX(flags, value)
LWCOLLECTION * lwcollection_force_dims(const LWCOLLECTION *col, int hasz, int hasm)
int lwcollection_startpoint(const LWCOLLECTION *col, POINT4D *pt)
LWGEOM * lwcollection_remove_repeated_points(const LWCOLLECTION *coll, double tolerance)
LWGEOM * lwcollection_getsubgeom(LWCOLLECTION *col, int gnum)
void * lwrealloc(void *mem, size_t size)
LWGEOM * lwgeom_segmentize2d(LWGEOM *line, double dist)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
#define FLAGS_GET_M(flags)
void lwgeom_release(LWGEOM *lwgeom)
Free the containing LWGEOM and the associated BOX.
LWGEOM * lwgeom_remove_repeated_points(const LWGEOM *in, double tolerance)
Remove repeated points!
void * lwalloc(size_t size)
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
int lwgeom_count_vertices(const LWGEOM *geom)
Count the total number of vertices in any LWGEOM.
#define LWDEBUGF(level, msg,...)
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
LWCOLLECTION * lwcollection_simplify(const LWCOLLECTION *igeom, double dist, int preserve_collapsed)
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)