PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ lwcollection_construct()

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

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:188
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
Definition: lwgeom.c:1087
#define FLAGS_GET_Z(flags)
Definition: liblwgeom.h:179
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:180
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:194
void * lwalloc(size_t size)
Definition: lwutil.c:227
lwflags_t lwflags(int hasz, int hasm, int geodetic)
Construct a new flags bitmask.
Definition: lwutil.c:471
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
type
Definition: ovdump.py:42
lwflags_t flags
Definition: liblwgeom.h:563
uint32_t ngeoms
Definition: liblwgeom.h:566
uint32_t maxgeoms
Definition: liblwgeom.h:567
uint8_t type
Definition: liblwgeom.h:564
GBOX * bbox
Definition: liblwgeom.h:560
LWGEOM ** geoms
Definition: liblwgeom.h:561
int32_t srid
Definition: liblwgeom.h:562

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, LWCOLLECTION::type, and ovdump::type.

Referenced by _lwt_AddLine(), _lwt_FaceByEdges(), BOX3D_to_LWGEOM(), combine_geometries(), GenerateLineStringGeometry(), GeneratePointGeometry(), GeneratePolygonGeometry(), GEOS2LWGEOM(), lwcollection_extract(), lwcollection_force_dims(), lwcollection_linearize(), lwcollection_locate_between_m(), lwcollection_segmentize2d(), lwcollection_split(), lwcollection_wrapx(), lwgeom_as_multi(), LWGEOM_collect(), LWGEOM_collect_garray(), LWGEOM_force_collection(), LWGEOM_line_substring(), lwgeom_make_valid(), lwline_locate_between_m(), lwline_split_by_line(), lwmcurve_linearize(), lwmline_measured_from_lwmline(), lwmline_unstroke(), lwmpolygon_unstroke(), lwmsurface_linearize(), lwpolygon_unstroke(), lwtin_from_geos(), pgis_geometry_union_finalfn(), RTreeFindLineSegments(), RTreeMergeMultiLines(), 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: