PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ lwcollection_construct()

LWCOLLECTION * lwcollection_construct ( uint8_t  type,
int32_t  srid,
GBOX bbox,
uint32_t  ngeoms,
LWGEOM **  geoms 
)
extern

Definition at line 42 of file lwcollection.c.

43{
44 LWCOLLECTION *ret;
45 int hasz, hasm;
46#ifdef CHECK_LWGEOM_ZM
47 char zm;
48 uint32_t i;
49#endif
50
51 LWDEBUGF(2, "lwcollection_construct called with %d, %d, %p, %d, %p.", type, srid, bbox, ngeoms, geoms);
52
53 if( ! lwtype_is_collection(type) )
54 lwerror("Non-collection type specified in collection constructor!");
55
56 hasz = 0;
57 hasm = 0;
58 if ( ngeoms > 0 )
59 {
60 hasz = FLAGS_GET_Z(geoms[0]->flags);
61 hasm = FLAGS_GET_M(geoms[0]->flags);
62#ifdef CHECK_LWGEOM_ZM
63 zm = FLAGS_GET_ZM(geoms[0]->flags);
64
65 LWDEBUGF(3, "lwcollection_construct type[0]=%d", geoms[0]->type);
66
67 for (i=1; i<ngeoms; i++)
68 {
69 LWDEBUGF(3, "lwcollection_construct type=[%d]=%d", i, geoms[i]->type);
70
71 if ( zm != FLAGS_GET_ZM(geoms[i]->flags) )
72 lwerror("lwcollection_construct: mixed dimension geometries: %d/%d", zm, FLAGS_GET_ZM(geoms[i]->flags));
73 }
74#endif
75 }
76
77
78 ret = lwalloc(sizeof(LWCOLLECTION));
79 ret->type = type;
80 ret->flags = lwflags(hasz,hasm,0);
81 FLAGS_SET_BBOX(ret->flags, bbox?1:0);
82 ret->srid = srid;
83 ret->ngeoms = ngeoms;
84 ret->maxgeoms = ngeoms;
85 ret->geoms = geoms;
86 ret->bbox = bbox;
87
88 return ret;
89}
#define FLAGS_SET_BBOX(flags, value)
Definition liblwgeom.h:174
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
Definition lwgeom.c:1196
#define FLAGS_GET_Z(flags)
Definition liblwgeom.h:165
void * lwalloc(size_t size)
Definition lwutil.c:227
#define FLAGS_GET_M(flags)
Definition liblwgeom.h:166
#define FLAGS_GET_ZM(flags)
Definition liblwgeom.h:180
lwflags_t lwflags(int hasz, int hasm, int geodetic)
Construct a new flags bitmask.
Definition lwutil.c:477
#define LWDEBUGF(level, msg,...)
Definition lwgeom_log.h:106
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
lwflags_t flags
Definition liblwgeom.h:577
uint32_t ngeoms
Definition liblwgeom.h:580
uint32_t maxgeoms
Definition liblwgeom.h:581
uint8_t type
Definition liblwgeom.h:578
GBOX * bbox
Definition liblwgeom.h:574
LWGEOM ** geoms
Definition liblwgeom.h:575
int32_t srid
Definition liblwgeom.h:576

References LWCOLLECTION::bbox, LWCOLLECTION::flags, FLAGS_GET_M, FLAGS_GET_Z, FLAGS_GET_ZM, FLAGS_SET_BBOX, LWCOLLECTION::geoms, lwalloc(), LWDEBUGF, lwerror(), lwflags(), lwtype_is_collection(), LWCOLLECTION::maxgeoms, LWCOLLECTION::ngeoms, LWCOLLECTION::srid, and LWCOLLECTION::type.

Referenced by _lwt_AddLine(), _lwt_FaceByEdges(), BOX3D_to_LWGEOM(), combine_geometries(), GenerateLineStringGeometry(), GeneratePointGeometry(), GeneratePolygonGeometry(), GEOS2LWGEOM(), gserialized_list_union(), lwcollection_force_dims(), lwcollection_linearize(), lwcollection_segmentize2d(), lwcollection_split(), lwcollection_wrapx(), lwgeom_as_multi(), LWGEOM_collect(), LWGEOM_collect_garray(), LWGEOM_force_collection(), LWGEOM_line_substring(), lwgeom_make_valid_params(), lwline_split_by_line(), lwmcurve_linearize(), lwmline_measured_from_lwmline(), lwmline_unstroke(), lwmpolygon_unstroke(), lwmsurface_linearize(), lwpolygon_unstroke(), lwtin_from_geos(), SFCGAL2LWGEOM(), wkt_parser_collection_new(), and wkt_parser_compound_new().

Here is the call graph for this function:
Here is the caller graph for this function: