PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ lwline_get_lwpoint()

LWPOINT* lwline_get_lwpoint ( const LWLINE line,
int  where 

Returns freshly allocated LWPOINT that corresponds to the index where.

Returns NULL if the geometry is empty or the index invalid.

Definition at line 295 of file lwline.c.

References LWLINE::flags, FLAGS_GET_M, FLAGS_GET_Z, getPoint4d(), LW_TRUE, lwline_is_empty(), lwpoint_construct(), POINTARRAY::npoints, LWLINE::points, ptarray_append_point(), ptarray_construct_empty(), and LWLINE::srid.

Referenced by _lwt_AddLineEdge(), gserialized_distance_nd(), lwcompound_get_endpoint(), lwcompound_get_lwpoint(), lwgeom_collect_endpoints(), LWGEOM_dumppoints(), LWGEOM_endpoint_linestring(), LWGEOM_pointn_linestring(), and LWGEOM_startpoint_linestring().

296 {
297  POINT4D pt;
298  LWPOINT *lwpoint;
299  POINTARRAY *pa;
301  if ( lwline_is_empty(line) || where < 0 || where >= line->points->npoints )
302  return NULL;
305  pt = getPoint4d(line->points, where);
306  ptarray_append_point(pa, &pt, LW_TRUE);
307  lwpoint = lwpoint_construct(line->srid, NULL, pa);
308  return lwpoint;
309 }
int npoints
Definition: liblwgeom.h:355
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition: ptarray.c:70
int lwline_is_empty(const LWLINE *line)
Definition: lwline.c:496
int32_t srid
Definition: liblwgeom.h:405
POINT4D getPoint4d(const POINTARRAY *pa, int n)
Definition: lwgeom_api.c:216
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_TRUE, then a duplicate point will not be added.
Definition: ptarray.c:156
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:61
#define FLAGS_GET_Z(flags)
Macros for manipulating the &#39;flags&#39; byte.
Definition: liblwgeom.h:124
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:125
LWPOINT * lwpoint_construct(int srid, GBOX *bbox, POINTARRAY *point)
Definition: lwpoint.c:98
uint8_t flags
Definition: liblwgeom.h:403
Definition: liblwgeom.h:406
Here is the call graph for this function:
Here is the caller graph for this function: