PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ lwcollection_build_buffer()

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

Definition at line 62 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().

63 {
64  int i;
65 
66  if ( ! col ) return;
67  if ( lwgeom_is_empty(lwcollection_as_lwgeom(col)) ) return;
68  for ( i = 0; i < col->ngeoms; i++ )
69  {
70  LWGEOM *geom = col->geoms[i];
71  switch(geom->type)
72  {
73  case POINTTYPE:
74  case LINETYPE:
75  case CIRCSTRINGTYPE:
76  case COMPOUNDTYPE:
77  case TRIANGLETYPE:
78  case CURVEPOLYTYPE:
79  case POLYGONTYPE:
80  {
81  /* Init if necessary */
82  if ( ! buffer->buf[geom->type] )
83  {
85  bufcol->type = lwtype_get_collectiontype(geom->type);
86  buffer->buf[geom->type] = bufcol;
87  }
88  /* Add sub-geom to buffer */
89  lwcollection_add_lwgeom(buffer->buf[geom->type], lwgeom_clone(geom));
90  /* Increment count for this singleton type */
91  buffer->cnt[geom->type] = buffer->cnt[geom->type] + 1;
92  }
93  default:
94  {
96  }
97  }
98  }
99  return;
100 }
#define LINETYPE
Definition: liblwgeom.h:71
int lwtype_get_collectiontype(uint8_t type)
Given an lwtype number, what homogeneous collection can hold it?
Definition: lwgeom.c:1026
uint8_t type
Definition: liblwgeom.h:487
#define POLYGONTYPE
Definition: liblwgeom.h:72
#define CURVEPOLYTYPE
Definition: liblwgeom.h:79
#define COMPOUNDTYPE
Definition: liblwgeom.h:78
#define TRIANGLETYPE
Definition: liblwgeom.h:83
int cnt[NUMTYPES]
Definition: lwhomogenize.c:18
uint8_t flags
Definition: liblwgeom.h:488
LWGEOM ** geoms
Definition: liblwgeom.h:493
LWCOLLECTION * buf[NUMTYPES]
Definition: lwhomogenize.c:19
int32_t srid
Definition: liblwgeom.h:490
#define FLAGS_GET_Z(flags)
Macros for manipulating the &#39;flags&#39; byte.
Definition: liblwgeom.h:124
LWGEOM * lwgeom_clone(const LWGEOM *lwgeom)
Clone LWGEOM object.
Definition: lwgeom.c:395
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
Definition: lwgeom.c:143
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:70
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:125
uint8_t type
Definition: liblwgeom.h:380
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:77
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:1297
static void lwcollection_build_buffer(const LWCOLLECTION *col, HomogenizeBuffer *buffer)
Definition: lwhomogenize.c:62
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
Definition: lwcollection.c:81
LWCOLLECTION * lwcollection_add_lwgeom(LWCOLLECTION *col, const LWGEOM *geom)
Appends geom to the collection managed by col.
Definition: lwcollection.c:174
#define COLLECTIONTYPE
Definition: liblwgeom.h:76
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
Definition: lwgeom.c:219
Here is the call graph for this function:
Here is the caller graph for this function: