PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lwline_from_ptarray()

LWLINE* lwline_from_ptarray ( int  srid,
uint32_t  npoints,
LWPOINT **  points 
)

Definition at line 237 of file lwline.c.

238 {
239  uint32_t i;
240  int hasz = LW_FALSE;
241  int hasm = LW_FALSE;
242  POINTARRAY *pa;
243  LWLINE *line;
244  POINT4D pt;
245 
246  /*
247  * Find output dimensions, check integrity
248  */
249  for (i=0; i<npoints; i++)
250  {
251  if ( points[i]->type != POINTTYPE )
252  {
253  lwerror("lwline_from_ptarray: invalid input type: %s", lwtype_name(points[i]->type));
254  return NULL;
255  }
256  if ( FLAGS_GET_Z(points[i]->flags) ) hasz = LW_TRUE;
257  if ( FLAGS_GET_M(points[i]->flags) ) hasm = LW_TRUE;
258  if ( hasz && hasm ) break; /* Nothing more to learn! */
259  }
260 
261  pa = ptarray_construct_empty(hasz, hasm, npoints);
262 
263  for ( i=0; i < npoints; i++ )
264  {
265  if ( ! lwpoint_is_empty(points[i]) )
266  {
267  lwpoint_getPoint4d_p(points[i], &pt);
268  ptarray_append_point(pa, &pt, LW_TRUE);
269  }
270  }
271 
272  if ( pa->npoints > 0 )
273  line = lwline_construct(srid, NULL, pa);
274  else
275  line = lwline_construct_empty(srid, hasz, hasm);
276 
277  return line;
278 }
int lwpoint_getPoint4d_p(const LWPOINT *point, POINT4D *out)
Definition: lwpoint.c:57
#define LW_FALSE
Definition: liblwgeom.h:77
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:140
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition: ptarray.c:70
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:141
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,...
Definition: ptarray.c:156
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
int lwpoint_is_empty(const LWPOINT *point)
Definition: lwpoint.c:291
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
LWLINE * lwline_construct_empty(int srid, char hasz, char hasm)
Definition: lwline.c:64
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwline.c:42
type
Definition: ovdump.py:41
uint32_t npoints
Definition: liblwgeom.h:374
unsigned int uint32_t
Definition: uthash.h:78

References FLAGS_GET_M, FLAGS_GET_Z, LW_FALSE, LW_TRUE, lwerror(), lwline_construct(), lwline_construct_empty(), lwpoint_getPoint4d_p(), lwpoint_is_empty(), lwtype_name(), POINTARRAY::npoints, POINTTYPE, ptarray_append_point(), ptarray_construct_empty(), and ovdump::type.

Referenced by create_v_line(), lw_dist2d_distanceline(), and lw_dist3d_distanceline().

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