PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwcollection_build_buffer()

static void lwcollection_build_buffer ( const LWCOLLECTION col,
HomogenizeBuffer buffer 
)
static

Definition at line 76 of file lwhomogenize.c.

References HomogenizeBuffer::buf, CIRCSTRINGTYPE, HomogenizeBuffer::cnt, COLLECTIONTYPE, COMPOUNDTYPE, CURVEPOLYTYPE, LWCOLLECTION::flags, FLAGS_GET_M, FLAGS_GET_Z, LWCOLLECTION::geoms, LINETYPE, lwcollection_add_lwgeom(), lwcollection_as_lwgeom(), lwcollection_construct_empty(), lwgeom_as_lwcollection(), lwgeom_clone(), lwgeom_is_empty(), lwtype_get_collectiontype(), LWCOLLECTION::ngeoms, POINTTYPE, POLYGONTYPE, LWCOLLECTION::srid, TRIANGLETYPE, LWGEOM::type, and LWCOLLECTION::type.

Referenced by lwcollection_homogenize().

77 {
78  int i;
79 
80  if ( ! col ) return;
81  if ( lwgeom_is_empty(lwcollection_as_lwgeom(col)) ) return;
82  for ( i = 0; i < col->ngeoms; i++ )
83  {
84  LWGEOM *geom = col->geoms[i];
85  switch(geom->type)
86  {
87  case POINTTYPE:
88  case LINETYPE:
89  case CIRCSTRINGTYPE:
90  case COMPOUNDTYPE:
91  case TRIANGLETYPE:
92  case CURVEPOLYTYPE:
93  case POLYGONTYPE:
94  {
95  /* Init if necessary */
96  if ( ! buffer->buf[geom->type] )
97  {
99  bufcol->type = lwtype_get_collectiontype(geom->type);
100  buffer->buf[geom->type] = bufcol;
101  }
102  /* Add sub-geom to buffer */
103  lwcollection_add_lwgeom(buffer->buf[geom->type], lwgeom_clone(geom));
104  /* Increment count for this singleton type */
105  buffer->cnt[geom->type] = buffer->cnt[geom->type] + 1;
106  }
107  default:
108  {
110  }
111  }
112  }
113  return;
114 }
#define LINETYPE
Definition: liblwgeom.h:86
int lwtype_get_collectiontype(uint8_t type)
Given an lwtype number, what homogeneous collection can hold it?
Definition: lwgeom.c:1075
uint8_t type
Definition: liblwgeom.h:503
#define POLYGONTYPE
Definition: liblwgeom.h:87
#define CURVEPOLYTYPE
Definition: liblwgeom.h:94
#define COMPOUNDTYPE
Definition: liblwgeom.h:93
#define TRIANGLETYPE
Definition: liblwgeom.h:98
int cnt[NUMTYPES]
Definition: lwhomogenize.c:32
uint8_t flags
Definition: liblwgeom.h:504
LWGEOM ** geoms
Definition: liblwgeom.h:509
LWCOLLECTION * buf[NUMTYPES]
Definition: lwhomogenize.c:33
int32_t srid
Definition: liblwgeom.h:506
#define FLAGS_GET_Z(flags)
Macros for manipulating the &#39;flags&#39; byte.
Definition: liblwgeom.h:140
LWGEOM * lwgeom_clone(const LWGEOM *lwgeom)
Clone LWGEOM object.
Definition: lwgeom.c:444
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
Definition: lwgeom.c:192
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:141
uint8_t type
Definition: liblwgeom.h:396
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:92
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
Definition: lwgeom.c:1346
static void lwcollection_build_buffer(const LWCOLLECTION *col, HomogenizeBuffer *buffer)
Definition: lwhomogenize.c:76
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
Definition: lwcollection.c:94
LWCOLLECTION * lwcollection_add_lwgeom(LWCOLLECTION *col, const LWGEOM *geom)
Appends geom to the collection managed by col.
Definition: lwcollection.c:187
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
Definition: lwgeom.c:268
Here is the call graph for this function:
Here is the caller graph for this function: