PostGIS  2.5.0dev-r@@SVN_REVISION@@
static int lwmulti_to_twkb_buf ( const LWCOLLECTION col,
TWKB_GLOBALS globals,
TWKB_STATE ts 
)
static

Definition at line 279 of file lwout_twkb.c.

References bytebuffer_append_uvarint(), bytebuffer_append_varint(), TWKB_STATE::geom_buf, LWCOLLECTION::geoms, TWKB_STATE::idlist, LWDEBUGF, lwgeom_is_empty(), lwgeom_to_twkb_buf(), MULTIPOINTTYPE, LWCOLLECTION::ngeoms, and LWCOLLECTION::type.

Referenced by lwgeom_to_twkb_buf().

280 {
281  uint32_t i;
282  int nempty = 0;
283 
284  LWDEBUGF(2, "Entered %s", __func__);
285  LWDEBUGF(4, "Number of geometries in multi is %d", col->ngeoms);
286 
287  /* Deal with special case for MULTIPOINT: skip any empty points */
288  if ( col->type == MULTIPOINTTYPE )
289  {
290  for ( i = 0; i < col->ngeoms; i++ )
291  if ( lwgeom_is_empty(col->geoms[i]) )
292  nempty++;
293  }
294 
295  /* Set the number of geometries */
296  bytebuffer_append_uvarint(ts->geom_buf, (uint64_t) (col->ngeoms - nempty));
297 
298  /* We've been handed an idlist, so write it in */
299  if ( ts->idlist )
300  {
301  for ( i = 0; i < col->ngeoms; i++ )
302  {
303  /* Skip empty points in multipoints, we can't represent them */
304  if ( col->type == MULTIPOINTTYPE && lwgeom_is_empty(col->geoms[i]) )
305  continue;
306 
308  }
309 
310  /* Empty it out to nobody else uses it now */
311  ts->idlist = NULL;
312  }
313 
314  for ( i = 0; i < col->ngeoms; i++ )
315  {
316  /* Skip empty points in multipoints, we can't represent them */
317  if ( col->type == MULTIPOINTTYPE && lwgeom_is_empty(col->geoms[i]) )
318  continue;
319 
320  lwgeom_to_twkb_buf(col->geoms[i], globals, ts);
321  }
322  return 0;
323 }
uint8_t type
Definition: liblwgeom.h:502
static int lwgeom_to_twkb_buf(const LWGEOM *geom, TWKB_GLOBALS *globals, TWKB_STATE *ts)
Definition: lwout_twkb.c:362
#define MULTIPOINTTYPE
Definition: liblwgeom.h:87
uint32_t ngeoms
Definition: liblwgeom.h:506
unsigned int uint32_t
Definition: uthash.h:78
const int64_t * idlist
Definition: lwout_twkb.h:92
void bytebuffer_append_uvarint(bytebuffer_t *b, const uint64_t val)
Writes a unsigned varInt to the buffer.
Definition: bytebuffer.c:250
LWGEOM ** geoms
Definition: liblwgeom.h:508
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:1386
bytebuffer_t * geom_buf
Definition: lwout_twkb.h:89
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
void bytebuffer_append_varint(bytebuffer_t *b, const int64_t val)
Writes a signed varInt to the buffer.
Definition: bytebuffer.c:239

Here is the call graph for this function:

Here is the caller graph for this function: