PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ lwmulti_to_twkb_buf()

static int lwmulti_to_twkb_buf ( const LWCOLLECTION col,
TWKB_GLOBALS globals,
TWKB_STATE ts 
)
static

Definition at line 295 of file lwout_twkb.c.

296 {
297  uint32_t i;
298  int nempty = 0;
299 
300  LWDEBUGF(2, "Entered %s", __func__);
301  LWDEBUGF(4, "Number of geometries in multi is %d", col->ngeoms);
302 
303  /* Deal with special case for MULTIPOINT: skip any empty points */
304  if ( col->type == MULTIPOINTTYPE )
305  {
306  for ( i = 0; i < col->ngeoms; i++ )
307  if ( lwgeom_is_empty(col->geoms[i]) )
308  nempty++;
309  }
310 
311  /* Set the number of geometries */
312  bytebuffer_append_uvarint(ts->geom_buf, (uint64_t) (col->ngeoms - nempty));
313 
314  /* We've been handed an idlist, so write it in */
315  if ( ts->idlist )
316  {
317  for ( i = 0; i < col->ngeoms; i++ )
318  {
319  /* Skip empty points in multipoints, we can't represent them */
320  if ( col->type == MULTIPOINTTYPE && lwgeom_is_empty(col->geoms[i]) )
321  continue;
322 
324  }
325 
326  /* Empty it out to nobody else uses it now */
327  ts->idlist = NULL;
328  }
329 
330  for ( i = 0; i < col->ngeoms; i++ )
331  {
332  /* Skip empty points in multipoints, we can't represent them */
333  if ( col->type == MULTIPOINTTYPE && lwgeom_is_empty(col->geoms[i]) )
334  continue;
335 
336  lwgeom_to_twkb_buf(col->geoms[i], globals, ts);
337  }
338  return 0;
339 }
void bytebuffer_append_uvarint(bytebuffer_t *b, const uint64_t val)
Writes a unsigned varInt to the buffer.
Definition: bytebuffer.c:166
void bytebuffer_append_varint(bytebuffer_t *b, const int64_t val)
Writes a signed varInt to the buffer.
Definition: bytebuffer.c:155
#define MULTIPOINTTYPE
Definition: liblwgeom.h:119
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
Definition: lwinline.h:193
static int lwgeom_to_twkb_buf(const LWGEOM *geom, TWKB_GLOBALS *globals, TWKB_STATE *ts)
Definition: lwout_twkb.c:378
uint32_t ngeoms
Definition: liblwgeom.h:566
uint8_t type
Definition: liblwgeom.h:564
LWGEOM ** geoms
Definition: liblwgeom.h:561
const int64_t * idlist
Definition: lwout_twkb.h:92
bytebuffer_t * geom_buf
Definition: lwout_twkb.h:89

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().

Here is the call graph for this function:
Here is the caller graph for this function: