PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ do_median_test()

static void do_median_test ( char *  input,
char *  expected 
)
static

Definition at line 1005 of file cu_algorithm.c.

References FP_EQUALS, FP_TOLERANCE, LW_PARSER_CHECK_NONE, LW_TRUE, lwgeom_as_lwpoint(), lwgeom_free(), lwgeom_from_wkt(), lwgeom_has_z(), lwgeom_is_empty(), lwgeom_median(), lwgeom_to_ewkt(), lwpoint_free(), lwpoint_getPoint3dz_p(), POINT3DZ::x, POINT3DZ::y, and POINT3DZ::z.

Referenced by test_median_robustness().

1006 {
1008  LWPOINT* expected_result = lwgeom_as_lwpoint(lwgeom_from_wkt(expected, LW_PARSER_CHECK_NONE));
1009  POINT3DZ actual_pt;
1010  POINT3DZ expected_pt;
1011 
1012  LWPOINT* result = lwgeom_median(g, FP_TOLERANCE / 10.0, 1000, LW_TRUE);
1013  int passed = LW_TRUE;
1014 
1015  lwpoint_getPoint3dz_p(result, &actual_pt);
1016  lwpoint_getPoint3dz_p(expected_result, &expected_pt);
1017 
1018  passed = passed && lwgeom_is_empty((LWGEOM*) expected_result) == lwgeom_is_empty((LWGEOM*) result);
1019  passed = passed && (lwgeom_has_z((LWGEOM*) expected_result) == lwgeom_has_z((LWGEOM*) result));
1020 
1021  if (!lwgeom_is_empty((LWGEOM*) result))
1022  {
1023  passed = passed && FP_EQUALS(actual_pt.x, expected_pt.x);
1024  passed = passed && FP_EQUALS(actual_pt.y, expected_pt.y);
1025  passed = passed && (!lwgeom_has_z((LWGEOM*) expected_result) || FP_EQUALS(actual_pt.z, expected_pt.z));
1026  }
1027 
1028  if (!passed)
1029  printf("median_test expected %s got %s\n", lwgeom_to_ewkt((LWGEOM*) expected_result), lwgeom_to_ewkt((LWGEOM*) result));
1030 
1031  CU_ASSERT_TRUE(passed);
1032 
1033  lwgeom_free(g);
1034  lwpoint_free(expected_result);
1035  lwpoint_free(result);
1036 }
double z
Definition: liblwgeom.h:333
double y
Definition: liblwgeom.h:333
double x
Definition: liblwgeom.h:333
char * lwgeom_to_ewkt(const LWGEOM *lwgeom)
Return an alloced string.
Definition: lwgeom.c:482
void lwpoint_free(LWPOINT *pt)
Definition: lwpoint.c:195
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1063
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:904
LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
Definition: lwgeom.c:93
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition: lwgeom.c:849
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:1985
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:75
int lwpoint_getPoint3dz_p(const LWPOINT *point, POINT3DZ *out)
Definition: lwpoint.c:47
#define FP_TOLERANCE
Floating point comparators.
#define FP_EQUALS(A, B)
LWPOINT * lwgeom_median(const LWGEOM *g, double tol, uint32_t maxiter, char fail_if_not_converged)
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
Definition: lwgeom.c:1310
Here is the call graph for this function:
Here is the caller graph for this function: