Take in a LINESTRING and return a MULTILINESTRING of those portions of the LINESTRING between the from/to range for the specified ordinate (XYZM)
546 int added_last_point = 0;
547 POINT4D *p = NULL, *q = NULL, *
r = NULL;
548 double ordinate_value_p = 0.0, ordinate_value_q = 0.0;
559 if ((ordinate ==
'Z' && !hasz) || (ordinate ==
'M' && !hasm))
561 lwerror(
"Cannot clip on ordinate %d in a %d-d geometry.", ordinate, dims);
576 for (i = 0; i < pa_in->
npoints; i++)
581 ordinate_value_q = ordinate_value_p;
587 if (ordinate_value_p >= from && ordinate_value_p <= to)
590 if (!added_last_point)
602 (ordinate_value_p > from && ordinate_value_p < to) ||
603 (ordinate_value_p == from && ordinate_value_q > to) ||
604 (ordinate_value_p == to && ordinate_value_q < from)))
606 double interpolation_value;
607 (ordinate_value_q > to) ? (interpolation_value = to)
608 : (interpolation_value = from);
615 if (ordinate_value_p == from || ordinate_value_p == to)
616 added_last_point = 2;
618 added_last_point = 1;
623 if (added_last_point == 1)
627 double interpolation_value;
628 (ordinate_value_p > to) ? (interpolation_value = to) : (interpolation_value = from);
632 else if (added_last_point == 2)
637 if (from != to && ((ordinate_value_q == from && ordinate_value_p > from) ||
638 (ordinate_value_q == to && ordinate_value_p < to)))
640 double interpolation_value;
641 (ordinate_value_p > to) ? (interpolation_value = to)
642 : (interpolation_value = from);
647 else if (i && ordinate_value_q < from && ordinate_value_p > to)
659 else if (i && ordinate_value_q > to && ordinate_value_p < from)
691 added_last_point = 0;
void lwgeom_refresh_bbox(LWGEOM *lwgeom)
Drop current bbox and calculate a fresh one.
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
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...
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
LWLINE * lwline_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
#define FLAGS_NDIMS(flags)
LWPOINT * lwpoint_construct(int32_t srid, GBOX *bbox, POINTARRAY *point)
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int32_t srid, char hasz, char hasm)
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
void ptarray_free(POINTARRAY *pa)
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,...
LWCOLLECTION * lwcollection_add_lwgeom(LWCOLLECTION *col, const LWGEOM *geom)
Appends geom to the collection managed by col.
void * lwalloc(size_t size)
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
void ptarray_set_point4d(POINTARRAY *pa, uint32_t n, const POINT4D *p4d)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
double lwpoint_get_ordinate(const POINT4D *p, char ordinate)
Given a POINT4D and an ordinate number, return the value of the ordinate.
int point_interpolate(const POINT4D *p1, const POINT4D *p2, POINT4D *p, int hasz, int hasm, char ordinate, double interpolation_value)
Given two points, a dimensionality, an ordinate, and an interpolation value generate a new point that...