Take in a LINESTRING and return a MULTILINESTRING of those portions of the LINESTRING between the from/to range for the specified ordinate (XYZM)
534 int added_last_point = 0;
535 POINT4D *p = NULL, *q = NULL, *
r = NULL;
536 double ordinate_value_p = 0.0, ordinate_value_q = 0.0;
547 if ((ordinate ==
'Z' && !hasz) || (ordinate ==
'M' && !hasm))
549 lwerror(
"Cannot clip on ordinate %d in a %d-d geometry.", ordinate, dims);
564 for (i = 0; i < pa_in->
npoints; i++)
569 ordinate_value_q = ordinate_value_p;
575 if (ordinate_value_p >= from && ordinate_value_p <= to)
578 if (!added_last_point)
590 (ordinate_value_p > from && ordinate_value_p < to) ||
591 (ordinate_value_p == from && ordinate_value_q > to) ||
592 (ordinate_value_p == to && ordinate_value_q < from)))
594 double interpolation_value;
595 (ordinate_value_q > to) ? (interpolation_value = to)
596 : (interpolation_value = from);
603 if (ordinate_value_p == from || ordinate_value_p == to)
604 added_last_point = 2;
606 added_last_point = 1;
611 if (added_last_point == 1)
615 double interpolation_value;
616 (ordinate_value_p > to) ? (interpolation_value = to) : (interpolation_value = from);
620 else if (added_last_point == 2)
625 if (from != to && ((ordinate_value_q == from && ordinate_value_p > from) ||
626 (ordinate_value_q == to && ordinate_value_p < to)))
628 double interpolation_value;
629 (ordinate_value_p > to) ? (interpolation_value = to)
630 : (interpolation_value = from);
635 else if (i && ordinate_value_q < from && ordinate_value_p > to)
647 else if (i && ordinate_value_q > to && ordinate_value_p < from)
679 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 void lwerror(const char *fmt,...) __attribute__((format(printf
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...