PostGIS  2.1.10dev-r@@SVN_REVISION@@
LWPOINT* lwline_get_lwpoint ( 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 294 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 lwgeom_collect_endpoints(), LWGEOM_dumppoints(), LWGEOM_endpoint_linestring(), LWGEOM_pointn_linestring(), and LWGEOM_startpoint_linestring().

295 {
296  POINT4D pt;
297  LWPOINT *lwpoint;
298  POINTARRAY *pa;
300  if ( lwline_is_empty(line) || where < 0 || where >= line->points->npoints )
301  return NULL;
304  pt = getPoint4d(line->points, where);
305  ptarray_append_point(pa, &pt, LW_TRUE);
306  lwpoint = lwpoint_construct(line->srid, NULL, pa);
307  return lwpoint;
308 }
int npoints
Definition: liblwgeom.h:327
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition: ptarray.c:57
int lwline_is_empty(const LWLINE *line)
Definition: lwline.c:464
int32_t srid
Definition: liblwgeom.h:377
POINT4D getPoint4d(const POINTARRAY *pa, int n)
Definition: lwgeom_api.c:202
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:141
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:51
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:106
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:107
LWPOINT * lwpoint_construct(int srid, GBOX *bbox, POINTARRAY *point)
Definition: lwpoint.c:96
uint8_t flags
Definition: liblwgeom.h:375
Definition: liblwgeom.h:378

Here is the call graph for this function:

Here is the caller graph for this function: