PostGIS  2.3.8dev-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:85
int lwtype_get_collectiontype(uint8_t type)
Given an lwtype number, what homogeneous collection can hold it?
Definition: lwgeom.c:1039
uint8_t type
Definition: liblwgeom.h:502
#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
uint8_t flags
Definition: liblwgeom.h:503
LWGEOM ** geoms
Definition: liblwgeom.h:508
LWCOLLECTION * buf[NUMTYPES]
Definition: lwhomogenize.c:33
int32_t srid
Definition: liblwgeom.h:505
#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:408
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
Definition: lwgeom.c:156
#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:395
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:91
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:1310
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
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
Definition: lwgeom.c:232
Here is the call graph for this function:
Here is the caller graph for this function: