PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ lwmpoint_clip_to_ordinate_range()

static LWCOLLECTION* lwmpoint_clip_to_ordinate_range ( const LWMPOINT mpoint,
char  ordinate,
double  from,
double  to 
)
inlinestatic

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

Definition at line 392 of file lwlinearreferencing.c.

393 {
394  LWCOLLECTION *lwgeom_out = NULL;
395  char hasz, hasm;
396  uint32_t i;
397 
398  /* Read Z/M info */
399  hasz = lwgeom_has_z(lwmpoint_as_lwgeom(mpoint));
400  hasm = lwgeom_has_m(lwmpoint_as_lwgeom(mpoint));
401 
402  /* Prepare return object */
403  lwgeom_out = lwcollection_construct_empty(MULTIPOINTTYPE, mpoint->srid, hasz, hasm);
404 
405  /* For each point, is its ordinate value between from and to? */
406  for (i = 0; i < mpoint->ngeoms; i++)
407  {
408  POINT4D p4d;
409  double ordinate_value;
410 
411  lwpoint_getPoint4d_p(mpoint->geoms[i], &p4d);
412  ordinate_value = lwpoint_get_ordinate(&p4d, ordinate);
413 
414  if (from <= ordinate_value && to >= ordinate_value)
415  {
416  LWPOINT *lwp = lwpoint_clone(mpoint->geoms[i]);
417  lwcollection_add_lwgeom(lwgeom_out, lwpoint_as_lwgeom(lwp));
418  }
419  }
420 
421  /* Set the bbox, if necessary */
422  if (mpoint->bbox)
423  lwgeom_refresh_bbox((LWGEOM *)lwgeom_out);
424 
425  return lwgeom_out;
426 }
void lwgeom_refresh_bbox(LWGEOM *lwgeom)
Drop current bbox and calculate a fresh one.
Definition: lwgeom.c:707
int lwpoint_getPoint4d_p(const LWPOINT *point, POINT4D *out)
Definition: lwpoint.c:57
LWGEOM * lwmpoint_as_lwgeom(const LWMPOINT *obj)
Definition: lwgeom.c:304
#define MULTIPOINTTYPE
Definition: liblwgeom.h:105
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition: lwgeom.c:934
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
Definition: lwgeom.c:344
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:189
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
Definition: lwgeom.c:941
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:534
GBOX * bbox
Definition: liblwgeom.h:532
uint32_t ngeoms
Definition: liblwgeom.h:538
LWPOINT ** geoms
Definition: liblwgeom.h:533

References LWMPOINT::bbox, LWMPOINT::geoms, lwcollection_add_lwgeom(), lwcollection_construct_empty(), lwgeom_has_m(), lwgeom_has_z(), lwgeom_refresh_bbox(), lwmpoint_as_lwgeom(), lwpoint_as_lwgeom(), lwpoint_clone(), lwpoint_get_ordinate(), lwpoint_getPoint4d_p(), MULTIPOINTTYPE, LWMPOINT::ngeoms, and LWMPOINT::srid.

Referenced by lwgeom_clip_to_ordinate_range().

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