PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ 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 2693 of file lwgeom.c.

2694{
2696 POINT4D p;
2697
2698 while (lwpointiterator_has_next(it))
2699 {
2700 lwpointiterator_peek(it, &p);
2701 p.x = trim_preserve_decimal_digits(p.x, prec_x);
2702 p.y = trim_preserve_decimal_digits(p.y, prec_y);
2703 if (lwgeom_has_z(geom))
2704 p.z = trim_preserve_decimal_digits(p.z, prec_z);
2705 if (lwgeom_has_m(geom))
2706 p.m = trim_preserve_decimal_digits(p.m, prec_m);
2708 }
2709
2711}
LWPOINTITERATOR * lwpointiterator_create_rw(LWGEOM *g)
Create a new LWPOINTITERATOR over supplied LWGEOM* Supports modification of coordinates during iterat...
Definition lwiterator.c:252
int lwpointiterator_peek(LWPOINTITERATOR *s, POINT4D *p)
Attempts to assigns the next point in the iterator to p.
Definition lwiterator.c:193
void lwpointiterator_destroy(LWPOINTITERATOR *s)
Free all memory associated with the iterator.
Definition lwiterator.c:268
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:224
int lwpointiterator_has_next(LWPOINTITERATOR *s)
Returns LW_TRUE if there is another point available in the iterator.
Definition lwiterator.c:202
static double trim_preserve_decimal_digits(double d, int32_t decimal_digits)
Definition lwgeom.c:2665
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition lwgeom.c:962
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
Definition lwgeom.c:969
double m
Definition liblwgeom.h:414
double x
Definition liblwgeom.h:414
double z
Definition liblwgeom.h:414
double y
Definition liblwgeom.h:414

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: