PostGIS  2.5.7dev-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 315 of file lwout_wkb.c.

316 {
317  uint32_t wkb_type = lwgeom_wkb_type(geom, variant);
318 
319  /* Set the endian flag */
320  buf = endian_to_wkb_buf(buf, variant);
321 
322  /* Set the geometry type */
323  buf = integer_to_wkb_buf(wkb_type, buf, variant);
324 
325  /* Set the SRID if necessary */
326  if ( lwgeom_wkb_needs_srid(geom, variant) )
327  buf = integer_to_wkb_buf(geom->srid, buf, variant);
328 
329  /* Represent POINT EMPTY as POINT(NaN NaN) */
330  if ( geom->type == POINTTYPE )
331  {
332  const LWPOINT *pt = (LWPOINT*)geom;
333  static double nn = NAN;
334  int i;
335  for ( i = 0; i < FLAGS_NDIMS(pt->point->flags); i++ )
336  {
337  buf = double_to_wkb_buf(nn, buf, variant);
338  }
339  }
340  /* Everything else is flagged as empty using num-elements == 0 */
341  else
342  {
343  /* Set nrings/npoints/ngeoms to zero */
344  buf = integer_to_wkb_buf(0, buf, variant);
345  }
346 
347  return buf;
348 }
static uint8_t variant
Definition: cu_in_twkb.c:26
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:152
#define NAN
Definition: lwgeodetic.h:37
static int lwgeom_wkb_needs_srid(const LWGEOM *geom, uint8_t variant)
Definition: lwout_wkb.c:63
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:82
static uint8_t * double_to_wkb_buf(const double d, uint8_t *buf, uint8_t variant)
Definition: lwout_wkb.c:243
static uint8_t * integer_to_wkb_buf(const int ival, uint8_t *buf, uint8_t variant)
Definition: lwout_wkb.c:196
uint8_t type
Definition: liblwgeom.h:399
int32_t srid
Definition: liblwgeom.h:402
POINTARRAY * point
Definition: liblwgeom.h:414
uint8_t flags
Definition: liblwgeom.h:372
unsigned int uint32_t
Definition: uthash.h:78

References double_to_wkb_buf(), endian_to_wkb_buf(), POINTARRAY::flags, FLAGS_NDIMS, integer_to_wkb_buf(), lwgeom_wkb_needs_srid(), lwgeom_wkb_type(), NAN, 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: