31 #define TWKB_IN_MAXCOORDS 4 86 lwerror(
"%s: TWKB structure does not match expected size!", __func__);
122 lwerror(
"%s: no varint to skip", __func__);
179 LWDEBUG(2,
"Entering ptarray_from_twkb_state");
180 LWDEBUGF(4,
"Pointarray has %d points", npoints);
188 for( i = 0; i < npoints; i++ )
226 LWDEBUG(2,
"Entering lwpoint_from_twkb_state");
243 LWDEBUG(2,
"Entering lwline_from_twkb_state");
278 LWDEBUG(2,
"Entering lwpoly_from_twkb_state");
289 LWDEBUGF(4,
"Polygon has %d rings", nrings);
295 for( i = 0; i < nrings; i++ )
324 LWDEBUG(2,
"Unable to add ring to polygon");
325 lwerror(
"Unable to add ring to polygon");
342 LWDEBUG(2,
"Entering lwmultipoint_from_twkb_state");
349 LWDEBUGF(4,
"Number of geometries %d", ngeoms);
354 for ( i = 0; i < ngeoms; i++ )
358 for ( i = 0; i < ngeoms; i++ )
363 lwerror(
"Unable to add geometry (%p) to collection (%p)", geom, col);
380 LWDEBUG(2,
"Entering lwmultilinestring_from_twkb_state");
388 LWDEBUGF(4,
"Number of geometries %d",ngeoms);
393 for ( i = 0; i < ngeoms; i++ )
397 for ( i = 0; i < ngeoms; i++ )
402 lwerror(
"Unable to add geometry (%p) to collection (%p)", geom, col);
419 LWDEBUG(2,
"Entering lwmultipolygon_from_twkb_state");
426 LWDEBUGF(4,
"Number of geometries %d",ngeoms);
431 for ( i = 0; i < ngeoms; i++ )
435 for ( i = 0; i < ngeoms; i++ )
440 lwerror(
"Unable to add geometry (%p) to collection (%p)", geom, col);
458 LWDEBUG(2,
"Entering lwcollection_from_twkb_state");
466 LWDEBUGF(4,
"Number of geometries %d",ngeoms);
471 for ( i = 0; i < ngeoms; i++ )
475 for ( i = 0; i < ngeoms; i++ )
480 lwerror(
"Unable to add geometry (%p) to collection (%p)", geom, col);
492 LWDEBUG(2,
"Entering magicbyte_from_twkb_state");
508 s->
factor = pow(10, (
double)precision);
512 s->
has_size = (metadata & 0x02) >> 1;
514 extended_dims = (metadata & 0x08) >> 3;
515 s->
is_empty = (metadata & 0x10) >> 4;
520 int8_t precision_z, precision_m;
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;
531 s->
factor_z = pow(10, (
double)precision_z);
532 s->
factor_m = pow(10, (
double)precision_m);
585 memset(&bbox, 0,
sizeof(
GBOX));
661 LWDEBUG(2,
"Entering lwgeom_from_twkb");
662 LWDEBUGF(4,
"twkb_size: %d",(
int) twkb_size);
POINTARRAY * ptarray_construct(char hasz, char hasm, uint32_t npoints)
Construct an empty pointarray, allocating storage and setting the npoints, but not filling in any inf...
LWLINE * lwline_construct_empty(int srid, char hasz, char hasm)
uint8_t * serialized_pointlist
static LWLINE * lwline_from_twkb_state(twkb_parse_state *s)
LINESTRING.
static LWCOLLECTION * lwcollection_from_twkb_state(twkb_parse_state *s)
COLLECTION, MULTIPOINTTYPE, MULTILINETYPE, MULTIPOLYGONTYPE.
#define LW_PARSER_CHECK_MINPOINTS
Parser check flags.
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
static LWPOLY * lwpoly_from_twkb_state(twkb_parse_state *s)
POLYGON.
#define LWDEBUG(level, msg)
static uint32_t lwtype_from_twkb_type(uint8_t twkb_type)
static POINTARRAY * ptarray_from_twkb_state(twkb_parse_state *s, uint32_t npoints)
POINTARRAY Read a dynamically sized point array and advance the parse state forward.
size_t varint_size(const uint8_t *the_start, const uint8_t *the_end)
LWPOINT * lwpoint_construct_empty(int srid, char hasz, char hasm)
int ptarray_is_closed_2d(const POINTARRAY *pa)
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
static uint8_t byte_from_twkb_state(twkb_parse_state *s)
Byte Read a byte and advance the parse state forward.
int64_t varint_s64_decode(const uint8_t *the_start, const uint8_t *the_end, size_t *size)
#define LW_PARSER_CHECK_NONE
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
#define TWKB_IN_MAXCOORDS
int ptarray_append_point(POINTARRAY *pa, const POINT4D *pt, int allow_duplicates)
Append a point to the end of an existing POINTARRAY If allow_duplicate is LW_FALSE, then a duplicate point will not be added.
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
#define SRID_UNKNOWN
Unknown SRID value.
LWGEOM * lwgeom_from_twkb(uint8_t *twkb, size_t twkb_size, char check)
WKB inputs must have a declared size, to prevent malformed WKB from reading off the end of the memory...
static LWCOLLECTION * lwmultipoint_from_twkb_state(twkb_parse_state *s)
MULTIPOINT.
Used for passing the parse state between the parsing functions.
static uint64_t twkb_parse_state_uvarint(twkb_parse_state *s)
static LWCOLLECTION * lwmultipoly_from_twkb_state(twkb_parse_state *s)
MULTIPOLYGON.
uint8_t gflags(int hasz, int hasm, int geodetic)
Construct a new flags char.
static LWPOINT * lwpoint_from_twkb_state(twkb_parse_state *s)
POINT.
uint64_t varint_u64_decode(const uint8_t *the_start, const uint8_t *the_end, size_t *size)
static double twkb_parse_state_double(twkb_parse_state *s, double factor)
LWGEOM * lwgeom_from_twkb_state(twkb_parse_state *s)
Internal function declarations.
static void twkb_parse_state_advance(twkb_parse_state *s, size_t next)
Check that we are not about to read off the end of the WKB array.
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
LWPOLY * lwpoly_construct_empty(int srid, char hasz, char hasm)
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
int lwpoly_add_ring(LWPOLY *poly, POINTARRAY *pa)
Add a ring, allocating extra space if necessary.
GBOX * gbox_clone(const GBOX *gbox)
LWPOINT * lwpoint_construct(int srid, GBOX *bbox, POINTARRAY *point)
static LWCOLLECTION * lwmultiline_from_twkb_state(twkb_parse_state *s)
MULTILINESTRING.
static void header_from_twkb_state(twkb_parse_state *s)
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
static int64_t twkb_parse_state_varint(twkb_parse_state *s)
#define LWDEBUGF(level, msg,...)
LWCOLLECTION * lwcollection_add_lwgeom(LWCOLLECTION *col, const LWGEOM *geom)
Appends geom to the collection managed by col.
static void twkb_parse_state_varint_skip(twkb_parse_state *s)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point)
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
int8_t unzigzag8(uint8_t val)