1383{
1386 LWPOINT* expected_result = NULL;
1390
1393
1394 if (expected != NULL)
1395 {
1398 }
1399 if (result != NULL)
1400 {
1402 }
1403
1404 if (result != NULL && expected != NULL)
1405 {
1409
1411 {
1413 {
1414 passed &= fabs(actual_pt.
x - expected_pt.
x) < tolerance;
1415 passed &= fabs(actual_pt.
y - expected_pt.
y) < tolerance;
1416 passed &= (!
lwgeom_has_z((
LWGEOM*) expected_result) || fabs(actual_pt.
z - expected_pt.
z) < tolerance);
1417 passed &= (!
lwgeom_has_m((
LWGEOM*) expected_result) || fabs(actual_pt.
m - expected_pt.
m) < tolerance);
1418 }
1419 else
1420 {
1421
1422
1423 uint32_t npoints = 1;
1428
1429 passed = distance_result <= (1.0 + tolerance) * distance_expected;
1430 if (!passed)
1431 {
1432 printf("Diff: Got %.10f Expected %.10f\n", distance_result, distance_expected);
1433 }
1435 }
1436 }
1437
1438 if (!passed)
1439 {
1440 printf("median_test input %s (parsed %s) expected %s got %s\n",
1444 }
1445
1446 }
1447 else if (result == NULL && expected == NULL)
1448 {
1450 }
1451 else if (result != NULL && expected == NULL)
1452 {
1455 }
1456 else if (result == NULL && expected != NULL)
1457 {
1461 }
1462
1463 CU_ASSERT_TRUE(passed);
1464
1468}
static double test_weighted_distance(const POINT4D *curr, const POINT4D *points, uint32_t npoints)
void cu_error_msg_reset()
char cu_error_msg[MAX_CUNIT_ERROR_LENGTH+1]
int lwpoint_getPoint4d_p(const LWPOINT *point, POINT4D *out)
void lwpoint_free(LWPOINT *pt)
void lwgeom_free(LWGEOM *geom)
#define LW_PARSER_CHECK_NONE
char * lwgeom_to_ewkt(const LWGEOM *lwgeom)
Return an alloced string.
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
LWPOINT * lwgeom_median(const LWGEOM *g, double tol, uint32_t maxiter, char fail_if_not_converged)
LWMPOINT * lwgeom_as_lwmpoint(const LWGEOM *lwgeom)
#define LW_TRUE
Return types for functions with status returns.
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
POINT4D * lwmpoint_extract_points_4d(const LWMPOINT *g, uint32_t *npoints, int *input_empty)
#define FP_TOLERANCE
Floating point comparators.
static LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)