PostGIS  2.5.7dev-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 283 of file lwout_twkb.c.

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

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: