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

◆ test_trim_bits()

static void test_trim_bits ( void  )
static

Definition at line 1745 of file cu_algorithm.c.

1746{
1748 POINT4D pt;
1749 LWLINE *line;
1750 int precision;
1751 uint32_t i;
1752
1753 pt.x = 1.2345678901234;
1754 pt.y = 2.3456789012345;
1755 pt.z = 3.4567890123456;
1756 pt.m = 4.5678901234567;
1757
1758 ptarray_insert_point(pta, &pt, 0);
1759
1760 pt.x *= 3;
1761 pt.y *= 3;
1762 pt.y *= 3;
1763 pt.z *= 3;
1764
1765 ptarray_insert_point(pta, &pt, 1);
1766
1767 line = lwline_construct(0, NULL, pta);
1768
1769 for (precision = -15; precision <= 15; precision++)
1770 {
1771 LWLINE *line2 = (LWLINE*) lwgeom_clone_deep((LWGEOM*) line);
1773
1774 for (i = 0; i < line->points->npoints; i++)
1775 {
1776 POINT4D pt1 = getPoint4d(line->points, i);
1777 POINT4D pt2 = getPoint4d(line2->points, i);
1778
1779 CU_ASSERT_DOUBLE_EQUAL(pt1.x, pt2.x, pow(10, -1*precision));
1780 CU_ASSERT_DOUBLE_EQUAL(pt1.y, pt2.y, pow(10, -1*precision));
1781 CU_ASSERT_DOUBLE_EQUAL(pt1.z, pt2.z, pow(10, -1*precision));
1782 CU_ASSERT_DOUBLE_EQUAL(pt1.m, pt2.m, pow(10, -1*precision));
1783 }
1784
1785 lwline_free(line2);
1786 }
1787
1788 lwline_free(line);
1789}
static uint8_t precision
Definition cu_in_twkb.c:25
POINT4D getPoint4d(const POINTARRAY *pa, uint32_t n)
Definition lwgeom_api.c:108
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:2508
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:107
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:511
POINTARRAY * points
Definition liblwgeom.h:469
double m
Definition liblwgeom.h:400
double x
Definition liblwgeom.h:400
double z
Definition liblwgeom.h:400
double y
Definition liblwgeom.h:400
uint32_t npoints
Definition liblwgeom.h:413

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: