PostGIS  2.1.10dev-r@@SVN_REVISION@@
LWLINE* lwline_from_lwmpoint ( int  srid,
LWMPOINT mpoint 

Definition at line 260 of file lwline.c.

References LWMPOINT::geoms, getPoint4d_p(), LWDEBUGF, lwgeom_has_m(), lwgeom_has_z(), lwgeom_is_empty(), lwline_construct(), lwline_construct_empty(), LWMPOINT::ngeoms, LWPOINT::point, ptarray_construct(), and ptarray_set_point4d().

Referenced by LWGEOM_line_from_mpoint(), and test_lwline_from_lwmpoint().

261 {
262  uint32_t i;
264  LWGEOM *lwgeom = (LWGEOM*)mpoint;
265  POINT4D pt;
267  char hasz = lwgeom_has_z(lwgeom);
268  char hasm = lwgeom_has_m(lwgeom);
269  uint32_t npoints = mpoint->ngeoms;
271  if ( lwgeom_is_empty(lwgeom) )
272  {
273  return lwline_construct_empty(srid, hasz, hasm);
274  }
276  pa = ptarray_construct(hasz, hasm, npoints);
278  for (i=0; i < npoints; i++)
279  {
280  getPoint4d_p(mpoint->geoms[i]->point, 0, &pt);
281  ptarray_set_point4d(pa, i, &pt);
282  }
284  LWDEBUGF(3, "lwline_from_lwmpoint: constructed pointarray for %d points", mpoint->ngeoms);
286  return lwline_construct(srid, NULL, pa);
287 }
void ptarray_set_point4d(POINTARRAY *pa, int n, const POINT4D *p4d)
Definition: lwgeom_api.c:501
POINTARRAY * ptarray_construct(char hasz, char hasm, uint32_t npoints)
Construct an empty pointarray, allocating storage and setting the npoints, but not filling in any inf...
Definition: ptarray.c:49
LWLINE * lwline_construct_empty(int srid, char hasz, char hasm)
Definition: lwline.c:51
Definition: liblwgeom.h:367
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition: lwgeom.c:792
LWPOINT ** geoms
Definition: liblwgeom.h:426
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
Definition: lwgeom.c:1229
int ngeoms
Definition: liblwgeom.h:424
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
Definition: lwgeom.c:799
int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point)
Definition: lwgeom_api.c:217
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwline.c:29

Here is the call graph for this function:

Here is the caller graph for this function: