PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lwcollection_construct()

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

Definition at line 43 of file lwcollection.c.

45 {
46  LWCOLLECTION *ret;
47  int hasz, hasm;
48 #ifdef CHECK_LWGEOM_ZM
49  char zm;
50  uint32_t i;
51 #endif
52 
53  LWDEBUGF(2, "lwcollection_construct called with %d, %d, %p, %d, %p.", type, srid, bbox, ngeoms, geoms);
54 
55  if( ! lwtype_is_collection(type) )
56  lwerror("Non-collection type specified in collection constructor!");
57 
58  hasz = 0;
59  hasm = 0;
60  if ( ngeoms > 0 )
61  {
62  hasz = FLAGS_GET_Z(geoms[0]->flags);
63  hasm = FLAGS_GET_M(geoms[0]->flags);
64 #ifdef CHECK_LWGEOM_ZM
65  zm = FLAGS_GET_ZM(geoms[0]->flags);
66 
67  LWDEBUGF(3, "lwcollection_construct type[0]=%d", geoms[0]->type);
68 
69  for (i=1; i<ngeoms; i++)
70  {
71  LWDEBUGF(3, "lwcollection_construct type=[%d]=%d", i, geoms[i]->type);
72 
73  if ( zm != FLAGS_GET_ZM(geoms[i]->flags) )
74  lwerror("lwcollection_construct: mixed dimension geometries: %d/%d", zm, FLAGS_GET_ZM(geoms[i]->flags));
75  }
76 #endif
77  }
78 
79 
80  ret = lwalloc(sizeof(LWCOLLECTION));
81  ret->type = type;
82  ret->flags = gflags(hasz,hasm,0);
83  FLAGS_SET_BBOX(ret->flags, bbox?1:0);
84  ret->srid = srid;
85  ret->ngeoms = ngeoms;
86  ret->maxgeoms = ngeoms;
87  ret->geoms = geoms;
88  ret->bbox = bbox;
89 
90  return ret;
91 }
uint8_t gflags(int hasz, int hasm, int geodetic)
Construct a new flags char.
Definition: g_util.c:145
#define FLAGS_SET_BBOX(flags, value)
Definition: liblwgeom.h:148
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
Definition: lwgeom.c:1093
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:140
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:141
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:153
void * lwalloc(size_t size)
Definition: lwutil.c:229
#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:41
uint32_t ngeoms
Definition: liblwgeom.h:510
uint32_t maxgeoms
Definition: liblwgeom.h:511
uint8_t type
Definition: liblwgeom.h:506
GBOX * bbox
Definition: liblwgeom.h:508
uint8_t flags
Definition: liblwgeom.h:507
LWGEOM ** geoms
Definition: liblwgeom.h:512
int32_t srid
Definition: liblwgeom.h:509
unsigned int uint32_t
Definition: uthash.h:78

References LWCOLLECTION::bbox, LWCOLLECTION::flags, FLAGS_GET_M, FLAGS_GET_Z, FLAGS_GET_ZM, FLAGS_SET_BBOX, LWCOLLECTION::geoms, gflags(), lwalloc(), LWDEBUGF, lwerror(), 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(), 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: