PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ test_trim_bits()

static void test_trim_bits ( void  )
static

Definition at line 1454 of file cu_algorithm.c.

1455 {
1457  POINT4D pt;
1458  LWLINE *line;
1459  int precision;
1460  uint32_t i;
1461 
1462  pt.x = 1.2345678901234;
1463  pt.y = 2.3456789012345;
1464  pt.z = 3.4567890123456;
1465  pt.m = 4.5678901234567;
1466 
1467  ptarray_insert_point(pta, &pt, 0);
1468 
1469  pt.x *= 3;
1470  pt.y *= 3;
1471  pt.y *= 3;
1472  pt.z *= 3;
1473 
1474  ptarray_insert_point(pta, &pt, 1);
1475 
1476  line = lwline_construct(0, NULL, pta);
1477 
1478  for (precision = -15; precision <= 15; precision++)
1479  {
1480  LWLINE *line2 = (LWLINE*) lwgeom_clone_deep((LWGEOM*) line);
1482 
1483  for (i = 0; i < line->points->npoints; i++)
1484  {
1485  POINT4D pt1 = getPoint4d(line->points, i);
1486  POINT4D pt2 = getPoint4d(line2->points, i);
1487 
1488  CU_ASSERT_DOUBLE_EQUAL(pt1.x, pt2.x, pow(10, -1*precision));
1489  CU_ASSERT_DOUBLE_EQUAL(pt1.y, pt2.y, pow(10, -1*precision));
1490  CU_ASSERT_DOUBLE_EQUAL(pt1.z, pt2.z, pow(10, -1*precision));
1491  CU_ASSERT_DOUBLE_EQUAL(pt1.m, pt2.m, pow(10, -1*precision));
1492  }
1493 
1494  lwline_free(line2);
1495  }
1496 
1497  lwline_free(line);
1498 }
static uint8_t precision
Definition: cu_in_twkb.c:25
POINT4D getPoint4d(const POINTARRAY *pa, uint32_t n)
Definition: lwgeom_api.c:106
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:2518
LWGEOM * lwgeom_clone_deep(const LWGEOM *lwgeom)
Deep clone an LWGEOM, everything is copied.
Definition: lwgeom.c:520
int ptarray_insert_point(POINTARRAY *pa, const POINT4D *p, uint32_t where)
Insert a point into an existing POINTARRAY.
Definition: ptarray.c:96
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition: ptarray.c:70
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwline.c:42
void lwline_free(LWLINE *line)
Definition: lwline.c:76
POINTARRAY * points
Definition: liblwgeom.h:425
double m
Definition: liblwgeom.h:355
double x
Definition: liblwgeom.h:355
double z
Definition: liblwgeom.h:355
double y
Definition: liblwgeom.h:355
uint32_t npoints
Definition: liblwgeom.h:374
unsigned int uint32_t
Definition: uthash.h:78

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: