PostGIS  2.5.0dev-r@@SVN_REVISION@@

◆ lwline_from_twkb_state()

static LWLINE* lwline_from_twkb_state ( twkb_parse_state s)
static

LINESTRING.

Definition at line 238 of file lwin_twkb.c.

References twkb_parse_state::check, twkb_parse_state::has_m, twkb_parse_state::has_z, twkb_parse_state::is_empty, LW_PARSER_CHECK_MINPOINTS, LWDEBUG, lwerror(), lwline_construct(), lwline_construct_empty(), twkb_parse_state::lwtype, lwtype_name(), POINTARRAY::npoints, ptarray_from_twkb_state(), SRID_UNKNOWN, and twkb_parse_state_uvarint().

Referenced by lwgeom_from_twkb_state(), and lwmultiline_from_twkb_state().

239 {
240  uint32_t npoints;
241  POINTARRAY *pa;
242 
243  LWDEBUG(2,"Entering lwline_from_twkb_state");
244 
245  if ( s->is_empty )
247 
248  /* Read number of points */
249  npoints = twkb_parse_state_uvarint(s);
250 
251  if ( npoints == 0 )
253 
254  /* Read coordinates */
255  pa = ptarray_from_twkb_state(s, npoints);
256 
257  if( pa == NULL )
259 
260  if( s->check & LW_PARSER_CHECK_MINPOINTS && pa->npoints < 2 )
261  {
262  lwerror("%s must have at least two points", lwtype_name(s->lwtype));
263  return NULL;
264  }
265 
266  return lwline_construct(SRID_UNKNOWN, NULL, pa);
267 }
uint8_t has_z
Definition: lwin_twkb.c:49
uint8_t is_empty
Definition: lwin_twkb.c:51
LWLINE * lwline_construct_empty(int srid, char hasz, char hasm)
Definition: lwline.c:64
#define LW_PARSER_CHECK_MINPOINTS
Parser check flags.
Definition: liblwgeom.h:1999
uint8_t has_m
Definition: lwin_twkb.c:50
uint32_t check
Definition: lwin_twkb.c:43
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
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.
Definition: lwin_twkb.c:172
unsigned int uint32_t
Definition: uthash.h:78
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
uint32_t lwtype
Definition: lwin_twkb.c:44
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwline.c:42
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:187
static uint64_t twkb_parse_state_uvarint(twkb_parse_state *s)
Definition: lwin_twkb.c:101
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
uint32_t npoints
Definition: liblwgeom.h:373
Here is the call graph for this function:
Here is the caller graph for this function: