PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ empty_to_wkb_buf()

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

Definition at line 343 of file lwout_wkb.c.

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

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: