PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ 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 472 of file lwin_wkb.c.

References wkb_parse_state::check, wkb_parse_state::has_m, wkb_parse_state::has_z, LW_PARSER_CHECK_MINPOINTS, LW_PARSER_CHECK_ODD, lwcircstring_construct(), lwcircstring_construct_empty(), lwerror(), wkb_parse_state::lwtype, lwtype_name(), POINTARRAY::npoints, ptarray_from_wkb_state(), and wkb_parse_state::srid.

Referenced by lwgeom_from_wkb_state().

473 {
475 
476  if( pa == NULL || pa->npoints == 0 )
477  return lwcircstring_construct_empty(s->srid, s->has_z, s->has_m);
478 
479  if( s->check & LW_PARSER_CHECK_MINPOINTS && pa->npoints < 3 )
480  {
481  lwerror("%s must have at least three points", lwtype_name(s->lwtype));
482  return NULL;
483  }
484 
485  if( s->check & LW_PARSER_CHECK_ODD && ! (pa->npoints % 2) )
486  {
487  lwerror("%s must have an odd number of points", lwtype_name(s->lwtype));
488  return NULL;
489  }
490 
491  return lwcircstring_construct(s->srid, NULL, pa);
492 }
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:329
int npoints
Definition: liblwgeom.h:371
#define LW_PARSER_CHECK_MINPOINTS
Parser check flags.
Definition: liblwgeom.h:2008
uint32_t lwtype
Definition: lwin_wkb.c:41
#define LW_PARSER_CHECK_ODD
Definition: liblwgeom.h:2009
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
LWCIRCSTRING * lwcircstring_construct_empty(int srid, char hasz, char hasm)
Definition: lwcircstring.c:80
LWCIRCSTRING * lwcircstring_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwcircstring.c:51
uint32_t srid
Definition: lwin_wkb.c:42
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
Here is the call graph for this function:
Here is the caller graph for this function: