PostGIS  2.2.8dev-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 265 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().

266 {
267  int i;
268  int nempty = 0;
269 
270  LWDEBUGF(2, "Entered %s", __func__);
271  LWDEBUGF(4, "Number of geometries in multi is %d", col->ngeoms);
272 
273  /* Deal with special case for MULTIPOINT: skip any empty points */
274  if ( col->type == MULTIPOINTTYPE )
275  {
276  for ( i = 0; i < col->ngeoms; i++ )
277  if ( lwgeom_is_empty(col->geoms[i]) )
278  nempty++;
279  }
280 
281  /* Set the number of geometries */
282  bytebuffer_append_uvarint(ts->geom_buf, (uint64_t) (col->ngeoms - nempty));
283 
284  /* We've been handed an idlist, so write it in */
285  if ( ts->idlist )
286  {
287  for ( i = 0; i < col->ngeoms; i++ )
288  {
289  /* Skip empty points in multipoints, we can't represent them */
290  if ( col->type == MULTIPOINTTYPE && lwgeom_is_empty(col->geoms[i]) )
291  continue;
292 
294  }
295 
296  /* Empty it out to nobody else uses it now */
297  ts->idlist = NULL;
298  }
299 
300  for ( i = 0; i < col->ngeoms; i++ )
301  {
302  /* Skip empty points in multipoints, we can't represent them */
303  if ( col->type == MULTIPOINTTYPE && lwgeom_is_empty(col->geoms[i]) )
304  continue;
305 
306  lwgeom_to_twkb_buf(col->geoms[i], globals, ts);
307  }
308  return 0;
309 }
uint8_t type
Definition: liblwgeom.h:487
static int lwgeom_to_twkb_buf(const LWGEOM *geom, TWKB_GLOBALS *globals, TWKB_STATE *ts)
Definition: lwout_twkb.c:348
#define MULTIPOINTTYPE
Definition: liblwgeom.h:73
const int64_t * idlist
Definition: lwout_twkb.h:68
void bytebuffer_append_uvarint(bytebuffer_t *b, const uint64_t val)
Writes a unsigned varInt to the buffer.
Definition: bytebuffer.c:212
LWGEOM ** geoms
Definition: liblwgeom.h:493
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
bytebuffer_t * geom_buf
Definition: lwout_twkb.h:65
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
void bytebuffer_append_varint(bytebuffer_t *b, const int64_t val)
Writes a signed varInt to the buffer.
Definition: bytebuffer.c:199
Here is the call graph for this function:
Here is the caller graph for this function: