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