PostGIS  3.0.0dev-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_construct_empty(), lwcollection_is_empty(), lwgeom_as_lwcollection(), lwgeom_clone(), lwtype_get_collectiontype(), LWCOLLECTION::ngeoms, POINTTYPE, POLYGONTYPE, LWCOLLECTION::srid, TRIANGLETYPE, LWGEOM::type, and LWCOLLECTION::type.

Referenced by lwcollection_homogenize().

77 {
78  uint32_t i;
79 
80  if (!col || lwcollection_is_empty(col))
81  return;
82 
83  for (i = 0; i < col->ngeoms; i++)
84  {
85  LWGEOM *geom = col->geoms[i];
86  switch (geom->type)
87  {
88  case POINTTYPE:
89  case LINETYPE:
90  case CIRCSTRINGTYPE:
91  case COMPOUNDTYPE:
92  case TRIANGLETYPE:
93  case CURVEPOLYTYPE:
94  case POLYGONTYPE:
95  /* Init if necessary */
96  if (!buffer->buf[geom->type])
97  {
100  bufcol->type = lwtype_get_collectiontype(geom->type);
101  buffer->buf[geom->type] = bufcol;
102  }
103  /* Add sub-geom to buffer */
104  lwcollection_add_lwgeom(buffer->buf[geom->type], lwgeom_clone(geom));
105  /* Increment count for this singleton type */
106  buffer->cnt[geom->type]++;
107  break;
108  default:
110  break;
111  }
112  }
113 }
#define LINETYPE
Definition: liblwgeom.h:85
uint8_t type
Definition: liblwgeom.h:505
#define POLYGONTYPE
Definition: liblwgeom.h:86
#define CURVEPOLYTYPE
Definition: liblwgeom.h:93
#define COMPOUNDTYPE
Definition: liblwgeom.h:92
#define TRIANGLETYPE
Definition: liblwgeom.h:97
int cnt[NUMTYPES]
Definition: lwhomogenize.c:32
uint32_t ngeoms
Definition: liblwgeom.h:509
unsigned int uint32_t
Definition: uthash.h:78
uint8_t flags
Definition: liblwgeom.h:506
int lwcollection_is_empty(const LWCOLLECTION *col)
LWGEOM ** geoms
Definition: liblwgeom.h:511
LWCOLLECTION * buf[NUMTYPES]
Definition: lwhomogenize.c:33
int32_t srid
Definition: liblwgeom.h:508
#define FLAGS_GET_Z(flags)
Macros for manipulating the &#39;flags&#39; byte.
Definition: liblwgeom.h:139
LWGEOM * lwgeom_clone(const LWGEOM *lwgeom)
Clone LWGEOM object.
Definition: lwgeom.c:473
uint32_t lwtype_get_collectiontype(uint8_t type)
Given an lwtype number, what homogeneous collection can hold it?
Definition: lwgeom.c:1104
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
Definition: lwgeom.c:215
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:84
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:140
uint8_t type
Definition: liblwgeom.h:398
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:91
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:90
Here is the call graph for this function:
Here is the caller graph for this function: