413 int i, is_empty, has_z = 0, has_m = 0, ndims;
414 size_t bbox_size = 0, optional_precision_byte = 0;
415 uint8_t flag = 0, type_prec = 0;
421 child_state.
geom_buf = &geom_bytebuffer;
437 optional_precision_byte = (has_z || has_m);
453 child_state.
bbox_max[i] = INT64_MIN;
454 child_state.
bbox_min[i] = INT64_MAX;
460 if ( abs(globals->
prec_xy) > 7 )
461 lwerror(
"%s: X/Z precision cannot be greater than 7 or less than -7", __func__);
486 if( optional_precision_byte )
490 if ( has_z && ( globals->
prec_z > 7 || globals->
prec_z < 0 ) )
491 lwerror(
"%s: Z precision cannot be negative or greater than 7", __func__);
493 if ( has_m && ( globals->
prec_m > 7 || globals->
prec_m < 0 ) )
494 lwerror(
"%s: M precision cannot be negative or greater than 7", __func__);
527 for ( i = 0; i < ndims; i++ )
540 LWDEBUG(4,
"We want boxes and will calculate required size");
550 size_to_register += bbox_size;
void bytebuffer_destroy_buffer(bytebuffer_t *s)
Free the bytebuffer_t and all memory managed within it.
void bytebuffer_append_bytebuffer(bytebuffer_t *write_to, bytebuffer_t *write_from)
Writes a uint8_t value to the buffer.
size_t bytebuffer_getlength(const bytebuffer_t *s)
Returns the length of the current buffer.
void bytebuffer_append_byte(bytebuffer_t *s, const uint8_t val)
Writes a uint8_t value to the buffer.
void bytebuffer_append_uvarint(bytebuffer_t *b, const uint64_t val)
Writes a unsigned varInt to the buffer.
void bytebuffer_init_with_size(bytebuffer_t *s, size_t size)
Allocate just the internal buffer of an existing bytebuffer_t struct.
int lwgeom_ndims(const LWGEOM *geom)
Return the number of dimensions (2, 3, 4) in a geometry.
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
#define LWDEBUG(level, msg)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
static uint8_t lwgeom_twkb_type(const LWGEOM *geom)
static int lwgeom_to_twkb_buf(const LWGEOM *geom, TWKB_GLOBALS *globals, TWKB_STATE *ts)
static void write_bbox(TWKB_STATE *ts, int ndims)
Writes the bbox in varints in the form: xmin, xdelta, ymin, ydelta.
static size_t sizeof_bbox(TWKB_STATE *ts, int ndims)
Calculates the size of the bbox in varints in the form: xmin, xdelta, ymin, ydelta.
#define FIRST_BYTE_SET_EXTENDED(flag, bool)
#define TYPE_PREC_SET_TYPE(flag, type)
Macros for manipulating the 'type_precision' int.
#define TYPE_PREC_SET_PREC(flag, prec)
#define HIGHER_DIM_SET_PRECM(flag, prec)
#define HIGHER_DIM_SET_HASM(flag, bool)
#define FIRST_BYTE_SET_EMPTY(flag, bool)
#define HIGHER_DIM_SET_PRECZ(flag, prec)
#define FIRST_BYTE_SET_IDLIST(flag, bool)
#define FIRST_BYTE_SET_BBOXES(flag, bool)
Header true/false flags.
#define HIGHER_DIM_SET_HASZ(flag, bool)
#define FIRST_BYTE_SET_SIZES(flag, bool)
int64_t bbox_min[MAX_N_DIMS]
bytebuffer_t * header_buf
int64_t accum_rels[MAX_N_DIMS]
int64_t bbox_max[MAX_N_DIMS]
uint8_t zigzag8(int8_t val)