PostGIS  2.2.7dev-r@@SVN_REVISION@@
LWCOLLECTION* lwcollection_construct ( uint8_t  type,
int  srid,
GBOX bbox,
uint32_t  ngeoms,
LWGEOM **  geoms 
)

Definition at line 30 of file lwcollection.c.

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

Referenced by _lwt_FaceByEdges(), combine_geometries(), GenerateLineStringGeometry(), GeneratePointGeometry(), GeneratePolygonGeometry(), GEOS2LWGEOM(), lwcollection_extract(), lwcollection_force_dims(), lwcollection_locate_between_m(), lwcollection_remove_repeated_points(), lwcollection_segmentize2d(), lwcollection_split(), lwcollection_stroke(), 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_stroke(), lwmline_measured_from_lwmline(), lwmline_unstroke(), lwmpoint_remove_repeated_points(), lwmpolygon_unstroke(), lwmsurface_stroke(), lwpolygon_unstroke(), lwt_AddLine(), lwtin_from_geos(), RTreeFindLineSegments(), RTreeMergeMultiLines(), SFCGAL2LWGEOM(), wkt_parser_collection_new(), and wkt_parser_compound_new().

32 {
33  LWCOLLECTION *ret;
34  int hasz, hasm;
35 #ifdef CHECK_LWGEOM_ZM
36  char zm;
37  uint32_t i;
38 #endif
39 
40  LWDEBUGF(2, "lwcollection_construct called with %d, %d, %p, %d, %p.", type, srid, bbox, ngeoms, geoms);
41 
42  if( ! lwtype_is_collection(type) )
43  lwerror("Non-collection type specified in collection constructor!");
44 
45  hasz = 0;
46  hasm = 0;
47  if ( ngeoms > 0 )
48  {
49  hasz = FLAGS_GET_Z(geoms[0]->flags);
50  hasm = FLAGS_GET_M(geoms[0]->flags);
51 #ifdef CHECK_LWGEOM_ZM
52  zm = FLAGS_GET_ZM(geoms[0]->flags);
53 
54  LWDEBUGF(3, "lwcollection_construct type[0]=%d", geoms[0]->type);
55 
56  for (i=1; i<ngeoms; i++)
57  {
58  LWDEBUGF(3, "lwcollection_construct type=[%d]=%d", i, geoms[i]->type);
59 
60  if ( zm != FLAGS_GET_ZM(geoms[i]->flags) )
61  lwerror("lwcollection_construct: mixed dimension geometries: %d/%d", zm, FLAGS_GET_ZM(geoms[i]->flags));
62  }
63 #endif
64  }
65 
66 
67  ret = lwalloc(sizeof(LWCOLLECTION));
68  ret->type = type;
69  ret->flags = gflags(hasz,hasm,0);
70  FLAGS_SET_BBOX(ret->flags, bbox?1:0);
71  ret->srid = srid;
72  ret->ngeoms = ngeoms;
73  ret->maxgeoms = ngeoms;
74  ret->geoms = geoms;
75  ret->bbox = bbox;
76 
77  return ret;
78 }
uint8_t type
Definition: liblwgeom.h:487
GBOX * bbox
Definition: liblwgeom.h:489
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:137
uint8_t flags
Definition: liblwgeom.h:488
LWGEOM ** geoms
Definition: liblwgeom.h:493
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
Definition: lwgeom.c:999
int32_t srid
Definition: liblwgeom.h:490
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:124
uint8_t gflags(int hasz, int hasm, int geodetic)
Construct a new flags char.
Definition: g_util.c:130
#define FLAGS_SET_BBOX(flags, value)
Definition: liblwgeom.h:132
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:125
void * lwalloc(size_t size)
Definition: lwutil.c:199
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:74

Here is the call graph for this function:

Here is the caller graph for this function: