PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ test_trim_bits()

static void test_trim_bits ( void  )
static

Definition at line 1770 of file cu_algorithm.c.

1771 {
1773  POINT4D pt;
1774  LWLINE *line;
1775  int precision;
1776  uint32_t i;
1777 
1778  pt.x = 1.2345678901234;
1779  pt.y = 2.3456789012345;
1780  pt.z = 3.4567890123456;
1781  pt.m = 4.5678901234567;
1782 
1783  ptarray_insert_point(pta, &pt, 0);
1784 
1785  pt.x *= 3;
1786  pt.y *= 3;
1787  pt.y *= 3;
1788  pt.z *= 3;
1789 
1790  ptarray_insert_point(pta, &pt, 1);
1791 
1792  line = lwline_construct(0, NULL, pta);
1793 
1794  for (precision = -15; precision <= 15; precision++)
1795  {
1796  LWLINE *line2 = (LWLINE*) lwgeom_clone_deep((LWGEOM*) line);
1798 
1799  for (i = 0; i < line->points->npoints; i++)
1800  {
1801  POINT4D pt1 = getPoint4d(line->points, i);
1802  POINT4D pt2 = getPoint4d(line2->points, i);
1803 
1804  CU_ASSERT_DOUBLE_EQUAL(pt1.x, pt2.x, pow(10, -1*precision));
1805  CU_ASSERT_DOUBLE_EQUAL(pt1.y, pt2.y, pow(10, -1*precision));
1806  CU_ASSERT_DOUBLE_EQUAL(pt1.z, pt2.z, pow(10, -1*precision));
1807  CU_ASSERT_DOUBLE_EQUAL(pt1.m, pt2.m, pow(10, -1*precision));
1808  }
1809 
1810  lwline_free(line2);
1811  }
1812 
1813  lwline_free(line);
1814 }
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:2539
LWGEOM * lwgeom_clone_deep(const LWGEOM *lwgeom)
Deep clone an LWGEOM, everything is copied.
Definition: lwgeom.c:529
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
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition: ptarray.c:59
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:93
void lwline_free(LWLINE *line)
Definition: lwline.c:67
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: