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

◆ test_trim_bits()

static void test_trim_bits ( void  )
static

Definition at line 1769 of file cu_algorithm.c.

1770{
1772 POINT4D pt;
1773 LWLINE *line;
1774 int precision;
1775 uint32_t i;
1776
1777 pt.x = 1.2345678901234;
1778 pt.y = 2.3456789012345;
1779 pt.z = 3.4567890123456;
1780 pt.m = 4.5678901234567;
1781
1782 ptarray_insert_point(pta, &pt, 0);
1783
1784 pt.x *= 3;
1785 pt.y *= 3;
1786 pt.y *= 3;
1787 pt.z *= 3;
1788
1789 ptarray_insert_point(pta, &pt, 1);
1790
1791 line = lwline_construct(0, NULL, pta);
1792
1793 for (precision = -15; precision <= 15; precision++)
1794 {
1795 LWLINE *line2 = (LWLINE*) lwgeom_clone_deep((LWGEOM*) line);
1797
1798 for (i = 0; i < line->points->npoints; i++)
1799 {
1800 POINT4D pt1 = getPoint4d(line->points, i);
1801 POINT4D pt2 = getPoint4d(line2->points, i);
1802
1803 CU_ASSERT_DOUBLE_EQUAL(pt1.x, pt2.x, pow(10, -1*precision));
1804 CU_ASSERT_DOUBLE_EQUAL(pt1.y, pt2.y, pow(10, -1*precision));
1805 CU_ASSERT_DOUBLE_EQUAL(pt1.z, pt2.z, pow(10, -1*precision));
1806 CU_ASSERT_DOUBLE_EQUAL(pt1.m, pt2.m, pow(10, -1*precision));
1807 }
1808
1809 lwline_free(line2);
1810 }
1811
1812 lwline_free(line);
1813}
static uint8_t precision
Definition cu_in_twkb.c:25
POINT4D getPoint4d(const POINTARRAY *pa, uint32_t n)
Definition lwgeom_api.c:107
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.
Definition lwgeom.c:2693
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition ptarray.c:59
LWLINE * lwline_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
Definition lwline.c:42
int ptarray_insert_point(POINTARRAY *pa, const POINT4D *p, uint32_t where)
Insert a point into an existing POINTARRAY.
Definition ptarray.c:85
#define LW_TRUE
Return types for functions with status returns.
Definition liblwgeom.h:93
void lwline_free(LWLINE *line)
Definition lwline.c:67
LWGEOM * lwgeom_clone_deep(const LWGEOM *lwgeom)
Deep clone an LWGEOM, everything is copied.
Definition lwgeom.c:557
POINTARRAY * points
Definition liblwgeom.h:483
double m
Definition liblwgeom.h:414
double x
Definition liblwgeom.h:414
double z
Definition liblwgeom.h:414
double y
Definition liblwgeom.h:414
uint32_t npoints
Definition liblwgeom.h:427

References getPoint4d(), LW_TRUE, lwgeom_clone_deep(), lwgeom_trim_bits_in_place(), lwline_construct(), lwline_free(), POINT4D::m, POINTARRAY::npoints, LWLINE::points, precision, ptarray_construct_empty(), ptarray_insert_point(), POINT4D::x, POINT4D::y, and POINT4D::z.

Referenced by algorithms_suite_setup().

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