1407{
1410 LWPOINT* expected_result = NULL;
1414
1417
1418 if (expected != NULL)
1419 {
1422 }
1424 {
1426 }
1427
1428 if (
result != NULL && expected != NULL)
1429 {
1433
1435 {
1437 {
1438 passed &= fabs(actual_pt.
x - expected_pt.
x) < tolerance;
1439 passed &= fabs(actual_pt.
y - expected_pt.
y) < tolerance;
1440 passed &= (!
lwgeom_has_z((
LWGEOM*) expected_result) || fabs(actual_pt.
z - expected_pt.
z) < tolerance);
1441 passed &= (!
lwgeom_has_m((
LWGEOM*) expected_result) || fabs(actual_pt.
m - expected_pt.
m) < tolerance);
1442 }
1443 else
1444 {
1445
1446
1447 uint32_t npoints = 1;
1452
1453 passed = distance_result <= (1.0 + tolerance) * distance_expected;
1454 if (!passed)
1455 {
1456 printf("Diff: Got %.10f Expected %.10f\n", distance_result, distance_expected);
1457 }
1459 }
1460 }
1461
1462 if (!passed)
1463 {
1464 printf("median_test input %s (parsed %s) expected %s got %s\n",
1468 }
1469
1470 }
1471 else if (
result == NULL && expected == NULL)
1472 {
1474 }
1475 else if (
result != NULL && expected == NULL)
1476 {
1479 }
1480 else if (
result == NULL && expected != NULL)
1481 {
1485 }
1486
1487 CU_ASSERT_TRUE(passed);
1488
1492}
static double test_weighted_distance(const POINT4D *curr, const POINT4D *points, uint32_t npoints)
char result[OUT_DOUBLE_BUFFER_SIZE]
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 allocated 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)