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

◆ lwcircstring_from_wkb_state()

static LWCIRCSTRING * lwcircstring_from_wkb_state ( wkb_parse_state s)
static

CIRCULARSTRING Read a WKB circularstring, starting just after the endian byte, type number and optional srid number.

Advance the parse state forward appropriately. There is only one pointarray in a linestring. Optionally check for minimal following of rules (three point minimum, odd number of points).

Definition at line 502 of file lwin_wkb.c.

503{
505 if (s->error)
506 return NULL;
507
508 if( pa == NULL || pa->npoints == 0 )
509 {
510 if (pa)
511 ptarray_free(pa);
512 return lwcircstring_construct_empty(s->srid, s->has_z, s->has_m);
513 }
514
515 if( s->check & LW_PARSER_CHECK_MINPOINTS && pa->npoints < 3 )
516 {
517 lwerror("%s must have at least three points", lwtype_name(s->lwtype));
518 return NULL;
519 }
520
521 if( s->check & LW_PARSER_CHECK_ODD && ! (pa->npoints % 2) )
522 {
523 lwerror("%s must have an odd number of points", lwtype_name(s->lwtype));
524 return NULL;
525 }
526
527 return lwcircstring_construct(s->srid, NULL, pa);
528}
char * s
Definition cu_in_wkt.c:23
#define LW_PARSER_CHECK_ODD
Definition liblwgeom.h:2145
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition lwutil.c:216
#define LW_PARSER_CHECK_MINPOINTS
Parser check flags.
Definition liblwgeom.h:2144
void ptarray_free(POINTARRAY *pa)
Definition ptarray.c:327
LWCIRCSTRING * lwcircstring_construct_empty(int32_t srid, char hasz, char hasm)
LWCIRCSTRING * lwcircstring_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
static POINTARRAY * ptarray_from_wkb_state(wkb_parse_state *s)
POINTARRAY Read a dynamically sized point array and advance the parse state forward.
Definition lwin_wkb.c:347
uint32_t npoints
Definition liblwgeom.h:427

References LW_PARSER_CHECK_MINPOINTS, LW_PARSER_CHECK_ODD, lwcircstring_construct(), lwcircstring_construct_empty(), lwerror(), lwtype_name(), POINTARRAY::npoints, ptarray_free(), ptarray_from_wkb_state(), and s.

Referenced by lwgeom_from_wkb_state().

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