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

◆ lwline_from_ptarray()

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

Definition at line 238 of file lwline.c.

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

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(), and ptarray_construct_empty().

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: