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

◆ header_from_twkb_state()

static void header_from_twkb_state ( twkb_parse_state s)
static

Definition at line 490 of file lwin_twkb.c.

491{
492 LWDEBUG(2,"Entering magicbyte_from_twkb_state");
493
494 uint8_t extended_dims;
495
496 /* Read the first two bytes */
497 uint8_t type_precision = byte_from_twkb_state(s);
498 uint8_t metadata = byte_from_twkb_state(s);
499
500 /* Strip type and precision out of first byte */
501 uint8_t type = type_precision & 0x0F;
502 int8_t precision = unzigzag8((type_precision & 0xF0) >> 4);
503
504 /* Convert TWKB type to internal type */
505 s->lwtype = lwtype_from_twkb_type(type);
506
507 /* Convert the precision into factor */
508 s->factor = pow(10, (double)precision);
509
510 /* Strip metadata flags out of second byte */
511 s->has_bbox = metadata & 0x01;
512 s->has_size = (metadata & 0x02) >> 1;
513 s->has_idlist = (metadata & 0x04) >> 2;
514 extended_dims = (metadata & 0x08) >> 3;
515 s->is_empty = (metadata & 0x10) >> 4;
516
517 /* Flag for higher dims means read a third byte */
518 if ( extended_dims )
519 {
520 int8_t precision_z, precision_m;
521
522 extended_dims = byte_from_twkb_state(s);
523
524 /* Strip Z/M presence and precision from ext byte */
525 s->has_z = (extended_dims & 0x01);
526 s->has_m = (extended_dims & 0x02) >> 1;
527 precision_z = (extended_dims & 0x1C) >> 2;
528 precision_m = (extended_dims & 0xE0) >> 5;
529
530 /* Convert the precision into factor */
531 s->factor_z = pow(10, (double)precision_z);
532 s->factor_m = pow(10, (double)precision_m);
533 }
534 else
535 {
536 s->has_z = 0;
537 s->has_m = 0;
538 s->factor_z = 0;
539 s->factor_m = 0;
540 }
541
542 /* Read the size, if there is one */
543 if ( s->has_size )
544 {
546 }
547
548 /* Calculate the number of dimensions */
549 s->ndims = 2 + s->has_z + s->has_m;
550
551 return;
552}
static uint8_t precision
Definition cu_in_twkb.c:25
char * s
Definition cu_in_wkt.c:23
#define LWDEBUG(level, msg)
Definition lwgeom_log.h:101
static uint8_t byte_from_twkb_state(twkb_parse_state *s)
Byte Read a byte and advance the parse state forward.
Definition lwin_twkb.c:160
static uint32_t lwtype_from_twkb_type(uint8_t twkb_type)
Definition lwin_twkb.c:130
static uint64_t twkb_parse_state_uvarint(twkb_parse_state *s)
Definition lwin_twkb.c:101
int8_t unzigzag8(uint8_t val)
Definition varint.c:204

References byte_from_twkb_state(), LWDEBUG, lwtype_from_twkb_type(), precision, s, twkb_parse_state_uvarint(), and unzigzag8().

Referenced by lwgeom_from_twkb_state().

Here is the call graph for this function:
Here is the caller graph for this function: