PostGIS  2.2.8dev-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 301 of file lwout_wkb.c.

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, and LWGEOM::type.

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

302 {
303  uint32_t wkb_type = lwgeom_wkb_type(geom, variant);
304 
305  /* Set the endian flag */
306  buf = endian_to_wkb_buf(buf, variant);
307 
308  /* Set the geometry type */
309  buf = integer_to_wkb_buf(wkb_type, buf, variant);
310 
311  /* Set the SRID if necessary */
312  if ( lwgeom_wkb_needs_srid(geom, variant) )
313  buf = integer_to_wkb_buf(geom->srid, buf, variant);
314 
315  /* Represent POINT EMPTY as POINT(NaN NaN) */
316  if ( geom->type == POINTTYPE )
317  {
318  const LWPOINT *pt = (LWPOINT*)geom;
319  static double nn = NAN;
320  int i;
321  for ( i = 0; i < FLAGS_NDIMS(pt->point->flags); i++ )
322  {
323  buf = double_to_wkb_buf(nn, buf, variant);
324  }
325  }
326  /* Everything else is flagged as empty using num-elements == 0 */
327  else
328  {
329  /* Set nrings/npoints/ngeoms to zero */
330  buf = integer_to_wkb_buf(0, buf, variant);
331  }
332 
333  return buf;
334 }
static int lwgeom_wkb_needs_srid(const LWGEOM *geom, uint8_t variant)
Definition: lwout_wkb.c:49
uint8_t variant
Definition: cu_in_twkb.c:26
static uint32_t lwgeom_wkb_type(const LWGEOM *geom, uint8_t variant)
Definition: lwout_wkb.c:68
#define NAN
Definition: lwgeodetic.h:22
POINTARRAY * point
Definition: liblwgeom.h:395
int32_t srid
Definition: liblwgeom.h:383
static uint8_t * integer_to_wkb_buf(const int ival, uint8_t *buf, uint8_t variant)
Definition: lwout_wkb.c:182
uint8_t flags
Definition: liblwgeom.h:353
static uint8_t * double_to_wkb_buf(const double d, uint8_t *buf, uint8_t variant)
Definition: lwout_wkb.c:229
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:70
uint8_t type
Definition: liblwgeom.h:380
static uint8_t * endian_to_wkb_buf(uint8_t *buf, uint8_t variant)
Definition: lwout_wkb.c:150
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:136
Here is the call graph for this function:
Here is the caller graph for this function: