PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lwgeom_trim_bits_in_place()

void lwgeom_trim_bits_in_place ( LWGEOM geom,
int32_t  prec_x,
int32_t  prec_y,
int32_t  prec_z,
int32_t  prec_m 
)

Trim the bits of an LWGEOM in place, to optimize it for compression.

Sets all bits to zero that are not required to maintain a specified number of digits after the decimal point. Negative precision values indicate digits before the decimal point do not need to be preserved.

Parameters
geominput geometry
prec_xprecision (digits after decimal point) in x dimension
prec_yprecision (digits after decimal point) in y dimension
prec_zprecision (digits after decimal point) in z dimension
prec_mprecision (digits after decimal point) in m dimension

Definition at line 2518 of file lwgeom.c.

2519 {
2521  POINT4D p;
2522 
2523  while (lwpointiterator_has_next(it))
2524  {
2525  lwpointiterator_peek(it, &p);
2526  p.x = trim_preserve_decimal_digits(p.x, prec_x);
2527  p.y = trim_preserve_decimal_digits(p.y, prec_y);
2528  if (lwgeom_has_z(geom))
2529  p.z = trim_preserve_decimal_digits(p.z, prec_z);
2530  if (lwgeom_has_m(geom))
2531  p.m = trim_preserve_decimal_digits(p.m, prec_m);
2533  }
2534 
2536 }
int lwpointiterator_peek(LWPOINTITERATOR *s, POINT4D *p)
Attempts to assigns the next point in the iterator to p.
Definition: lwiterator.c:195
void lwpointiterator_destroy(LWPOINTITERATOR *s)
Free all memory associated with the iterator.
Definition: lwiterator.c:269
int lwpointiterator_modify_next(LWPOINTITERATOR *s, const POINT4D *p)
Attempts to replace the next point int the iterator with p, and advances the iterator to the next poi...
Definition: lwiterator.c:226
LWPOINTITERATOR * lwpointiterator_create_rw(LWGEOM *g)
Create a new LWPOINTITERATOR over supplied LWGEOM* Supports modification of coordinates during iterat...
Definition: lwiterator.c:253
int lwpointiterator_has_next(LWPOINTITERATOR *s)
Returns LW_TRUE if there is another point available in the iterator.
Definition: lwiterator.c:204
static double trim_preserve_decimal_digits(double d, int32_t decimal_digits)
Definition: lwgeom.c:2501
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition: lwgeom.c:930
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
Definition: lwgeom.c:937
double m
Definition: liblwgeom.h:355
double x
Definition: liblwgeom.h:355
double z
Definition: liblwgeom.h:355
double y
Definition: liblwgeom.h:355

References lwgeom_has_m(), lwgeom_has_z(), lwpointiterator_create_rw(), lwpointiterator_destroy(), lwpointiterator_has_next(), lwpointiterator_modify_next(), lwpointiterator_peek(), POINT4D::m, trim_preserve_decimal_digits(), POINT4D::x, POINT4D::y, and POINT4D::z.

Referenced by ST_QuantizeCoordinates(), and test_trim_bits().

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