PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ empty_to_wkb_buf()

static uint8_t* empty_to_wkb_buf ( const LWGEOM geom,
uint8_t *  buf,
uint8_t  variant 
)
static

Definition at line 344 of file lwout_wkb.c.

345 {
346  uint32_t wkb_type = lwgeom_wkb_type(geom, variant);
347 
348  /* Set the endian flag */
349  buf = endian_to_wkb_buf(buf, variant);
350 
351  /* Set the geometry type */
352  buf = integer_to_wkb_buf(wkb_type, buf, variant);
353 
354  /* Set the SRID if necessary */
355  if ( lwgeom_wkb_needs_srid(geom, variant) )
356  buf = integer_to_wkb_buf(geom->srid, buf, variant);
357 
358  /* Represent POINT EMPTY as POINT(NaN NaN) */
359  if ( geom->type == POINTTYPE )
360  {
361  const LWPOINT *pt = (LWPOINT*)geom;
362  for (int i = 0; i < FLAGS_NDIMS(pt->point->flags); i++)
363  {
364  buf = double_nan_to_wkb_buf(buf, variant);
365  }
366  }
367  /* Everything else is flagged as empty using num-elements == 0 */
368  else
369  {
370  /* Set nrings/npoints/ngeoms to zero */
371  buf = integer_to_wkb_buf(0, buf, variant);
372  }
373 
374  return buf;
375 }
static uint8_t variant
Definition: cu_in_twkb.c:26
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:102
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:179
static uint8_t * double_nan_to_wkb_buf(uint8_t *buf, uint8_t variant)
Definition: lwout_wkb.c:241
static int lwgeom_wkb_needs_srid(const LWGEOM *geom, uint8_t variant)
Definition: lwout_wkb.c:64
static uint8_t * endian_to_wkb_buf(uint8_t *buf, uint8_t variant)
Definition: lwout_wkb.c:164
static uint32_t lwgeom_wkb_type(const LWGEOM *geom, uint8_t variant)
Definition: lwout_wkb.c:83
static uint8_t * integer_to_wkb_buf(const uint32_t ival, uint8_t *buf, uint8_t variant)
Definition: lwout_wkb.c:197
uint8_t type
Definition: liblwgeom.h:462
int32_t srid
Definition: liblwgeom.h:460
POINTARRAY * point
Definition: liblwgeom.h:471
lwflags_t flags
Definition: liblwgeom.h:431

References double_nan_to_wkb_buf(), endian_to_wkb_buf(), POINTARRAY::flags, FLAGS_NDIMS, integer_to_wkb_buf(), lwgeom_wkb_needs_srid(), lwgeom_wkb_type(), LWPOINT::point, POINTTYPE, LWGEOM::srid, LWGEOM::type, and variant.

Referenced by lwgeom_to_wkb_buf(), lwline_to_wkb_buf(), lwpoint_to_wkb_buf(), lwpoly_to_wkb_buf(), and lwtriangle_to_wkb_buf().

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