PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ lwpoint_clip_to_ordinate_range()

static LWCOLLECTION* lwpoint_clip_to_ordinate_range ( const LWPOINT point,
char  ordinate,
double  from,
double  to 
)
inlinestatic

Clip an input POINT between two values, on any ordinate input.

Definition at line 374 of file lwlinearreferencing.c.

375 {
376  LWCOLLECTION *lwgeom_out = NULL;
377  char hasz, hasm;
378  POINT4D p4d;
379  double ordinate_value;
380 
381  /* Read Z/M info */
382  hasz = lwgeom_has_z(lwpoint_as_lwgeom(point));
383  hasm = lwgeom_has_m(lwpoint_as_lwgeom(point));
384 
385  /* Prepare return object */
386  lwgeom_out = lwcollection_construct_empty(MULTIPOINTTYPE, point->srid, hasz, hasm);
387 
388  /* Test if ordinate is in range */
389  lwpoint_getPoint4d_p(point, &p4d);
390  ordinate_value = lwpoint_get_ordinate(&p4d, ordinate);
391  if (from <= ordinate_value && to >= ordinate_value)
392  {
393  LWPOINT *lwp = lwpoint_clone(point);
394  lwcollection_add_lwgeom(lwgeom_out, lwpoint_as_lwgeom(lwp));
395  }
396 
397  return lwgeom_out;
398 }
int lwpoint_getPoint4d_p(const LWPOINT *point, POINT4D *out)
Definition: lwpoint.c:57
#define MULTIPOINTTYPE
Definition: liblwgeom.h:119
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition: lwgeom.c:916
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
Definition: lwgeom.c:326
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int32_t srid, char hasz, char hasm)
Definition: lwcollection.c:92
LWCOLLECTION * lwcollection_add_lwgeom(LWCOLLECTION *col, const LWGEOM *geom)
Appends geom to the collection managed by col.
Definition: lwcollection.c:188
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
Definition: lwgeom.c:923
LWPOINT * lwpoint_clone(const LWPOINT *lwgeom)
Definition: lwpoint.c:239
double lwpoint_get_ordinate(const POINT4D *p, char ordinate)
Given a POINT4D and an ordinate number, return the value of the ordinate.
int32_t srid
Definition: liblwgeom.h:458

References lwcollection_add_lwgeom(), lwcollection_construct_empty(), lwgeom_has_m(), lwgeom_has_z(), lwpoint_as_lwgeom(), lwpoint_clone(), lwpoint_get_ordinate(), lwpoint_getPoint4d_p(), MULTIPOINTTYPE, and LWPOINT::srid.

Referenced by lwgeom_clip_to_ordinate_range().

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