PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ do_median_test()

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

Definition at line 1022 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().

1023 {
1025  LWPOINT* expected_result = lwgeom_as_lwpoint(lwgeom_from_wkt(expected, LW_PARSER_CHECK_NONE));
1026  POINT3DZ actual_pt;
1027  POINT3DZ expected_pt;
1028 
1029  LWPOINT* result = lwgeom_median(g, FP_TOLERANCE / 10.0, 1000, LW_TRUE);
1030  int passed = LW_TRUE;
1031 
1032  lwpoint_getPoint3dz_p(result, &actual_pt);
1033  lwpoint_getPoint3dz_p(expected_result, &expected_pt);
1034 
1035  passed = passed && lwgeom_is_empty((LWGEOM*) expected_result) == lwgeom_is_empty((LWGEOM*) result);
1036  passed = passed && (lwgeom_has_z((LWGEOM*) expected_result) == lwgeom_has_z((LWGEOM*) result));
1037 
1038  if (!lwgeom_is_empty((LWGEOM*) result))
1039  {
1040  passed = passed && FP_EQUALS(actual_pt.x, expected_pt.x);
1041  passed = passed && FP_EQUALS(actual_pt.y, expected_pt.y);
1042  passed = passed && (!lwgeom_has_z((LWGEOM*) expected_result) || FP_EQUALS(actual_pt.z, expected_pt.z));
1043  }
1044 
1045  if (!passed)
1046  printf("median_test expected %s got %s\n", lwgeom_to_ewkt((LWGEOM*) expected_result), lwgeom_to_ewkt((LWGEOM*) result));
1047 
1048  CU_ASSERT_TRUE(passed);
1049 
1050  lwgeom_free(g);
1051  lwpoint_free(expected_result);
1052  lwpoint_free(result);
1053 }
double z
Definition: liblwgeom.h:334
double y
Definition: liblwgeom.h:334
double x
Definition: liblwgeom.h:334
char * lwgeom_to_ewkt(const LWGEOM *lwgeom)
Return an alloced string.
Definition: lwgeom.c:518
void lwpoint_free(LWPOINT *pt)
Definition: lwpoint.c:213
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1099
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:129
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition: lwgeom.c:885
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2013
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
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:1346
Here is the call graph for this function:
Here is the caller graph for this function: