PostGIS  3.1.6dev-r@@SVN_REVISION@@

◆ test_trim_bits()

static void test_trim_bits ( void  )
static

Definition at line 1750 of file cu_algorithm.c.

1751 {
1753  POINT4D pt;
1754  LWLINE *line;
1755  int precision;
1756  uint32_t i;
1757 
1758  pt.x = 1.2345678901234;
1759  pt.y = 2.3456789012345;
1760  pt.z = 3.4567890123456;
1761  pt.m = 4.5678901234567;
1762 
1763  ptarray_insert_point(pta, &pt, 0);
1764 
1765  pt.x *= 3;
1766  pt.y *= 3;
1767  pt.y *= 3;
1768  pt.z *= 3;
1769 
1770  ptarray_insert_point(pta, &pt, 1);
1771 
1772  line = lwline_construct(0, NULL, pta);
1773 
1774  for (precision = -15; precision <= 15; precision++)
1775  {
1776  LWLINE *line2 = (LWLINE*) lwgeom_clone_deep((LWGEOM*) line);
1778 
1779  for (i = 0; i < line->points->npoints; i++)
1780  {
1781  POINT4D pt1 = getPoint4d(line->points, i);
1782  POINT4D pt2 = getPoint4d(line2->points, i);
1783 
1784  CU_ASSERT_DOUBLE_EQUAL(pt1.x, pt2.x, pow(10, -1*precision));
1785  CU_ASSERT_DOUBLE_EQUAL(pt1.y, pt2.y, pow(10, -1*precision));
1786  CU_ASSERT_DOUBLE_EQUAL(pt1.z, pt2.z, pow(10, -1*precision));
1787  CU_ASSERT_DOUBLE_EQUAL(pt1.m, pt2.m, pow(10, -1*precision));
1788  }
1789 
1790  lwline_free(line2);
1791  }
1792 
1793  lwline_free(line);
1794 }
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:2519
LWGEOM * lwgeom_clone_deep(const LWGEOM *lwgeom)
Deep clone an LWGEOM, everything is copied.
Definition: lwgeom.c:512
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:107
void lwline_free(LWLINE *line)
Definition: lwline.c:67
POINTARRAY * points
Definition: liblwgeom.h:497
double m
Definition: liblwgeom.h:428
double x
Definition: liblwgeom.h:428
double z
Definition: liblwgeom.h:428
double y
Definition: liblwgeom.h:428
uint32_t npoints
Definition: liblwgeom.h:441

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: