PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ lwline_from_lwmpoint()

LWLINE* lwline_from_lwmpoint ( int32_t  srid,
const LWMPOINT mpoint 
)

Definition at line 275 of file lwline.c.

276 {
277  uint32_t i;
278  POINTARRAY *pa = NULL;
279  LWGEOM *lwgeom = (LWGEOM*)mpoint;
280  POINT4D pt;
281 
282  char hasz = lwgeom_has_z(lwgeom);
283  char hasm = lwgeom_has_m(lwgeom);
284  uint32_t npoints = mpoint->ngeoms;
285 
286  if ( lwgeom_is_empty(lwgeom) )
287  {
288  return lwline_construct_empty(srid, hasz, hasm);
289  }
290 
291  pa = ptarray_construct(hasz, hasm, npoints);
292 
293  for (i=0; i < npoints; i++)
294  {
295  getPoint4d_p(mpoint->geoms[i]->point, 0, &pt);
296  ptarray_set_point4d(pa, i, &pt);
297  }
298 
299  LWDEBUGF(3, "lwline_from_lwmpoint: constructed pointarray for %d points", mpoint->ngeoms);
300 
301  return lwline_construct(srid, NULL, pa);
302 }
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:51
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition: lwgeom.c:916
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
Definition: lwgeom_api.c:125
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
Definition: lwgeom.c:923
void ptarray_set_point4d(POINTARRAY *pa, uint32_t n, const POINT4D *p4d)
Definition: lwgeom_api.c:376
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
Definition: lwinline.h:193
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 ngeoms
Definition: liblwgeom.h:524
LWPOINT ** geoms
Definition: liblwgeom.h:519
POINTARRAY * point
Definition: liblwgeom.h:457

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 encode_mpoint(), LWGEOM_line_from_mpoint(), lwmmpoint_to_encoded_polyline(), and test_lwline_from_lwmpoint().

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