PostGIS  2.5.7dev-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.

239 {
240  uint32_t npoints;
241  POINTARRAY *pa;
242 
243  LWDEBUG(2,"Entering lwline_from_twkb_state");
244 
245  if ( s->is_empty )
246  return lwline_construct_empty(SRID_UNKNOWN, s->has_z, s->has_m);
247 
248  /* Read number of points */
249  npoints = twkb_parse_state_uvarint(s);
250 
251  if ( npoints == 0 )
252  return lwline_construct_empty(SRID_UNKNOWN, s->has_z, s->has_m);
253 
254  /* Read coordinates */
255  pa = ptarray_from_twkb_state(s, npoints);
256 
257  if( pa == NULL )
258  return lwline_construct_empty(SRID_UNKNOWN, s->has_z, s->has_m);
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 }
char * s
Definition: cu_in_wkt.c:23
LWLINE * lwline_construct_empty(int srid, char hasz, char hasm)
Definition: lwline.c:64
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
#define LW_PARSER_CHECK_MINPOINTS
Parser check flags.
Definition: liblwgeom.h:2000
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:188
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwline.c:42
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
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
static uint64_t twkb_parse_state_uvarint(twkb_parse_state *s)
Definition: lwin_twkb.c:101
uint32_t npoints
Definition: liblwgeom.h:374
unsigned int uint32_t
Definition: uthash.h:78

References LW_PARSER_CHECK_MINPOINTS, LWDEBUG, lwerror(), lwline_construct(), lwline_construct_empty(), lwtype_name(), POINTARRAY::npoints, ptarray_from_twkb_state(), s, SRID_UNKNOWN, and twkb_parse_state_uvarint().

Referenced by lwgeom_from_twkb_state(), and lwmultiline_from_twkb_state().

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