PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ test_median_robustness()

static void test_median_robustness ( void  )
static

Definition at line 1055 of file cu_algorithm.c.

References do_median_test().

Referenced by algorithms_suite_setup().

1056 {
1057  /* A simple implementation of Weiszfeld's algorithm will fail if the median is equal
1058  * to any one of the inputs, during any iteration of the algorithm.
1059  *
1060  * Because the algorithm uses the centroid as a starting point, this situation will
1061  * occur in the test case below.
1062  */
1063  do_median_test("MULTIPOINT ((0 -1), (0 0), (0 1))", "POINT (0 0)");
1064 
1065  /* Same as above but 3D, and shifter */
1066  do_median_test("MULTIPOINT ((1 -1 3), (1 0 2), (2 1 1))", "POINT (1 0 2)");
1067 
1068  /* Starting point is duplicated */
1069  do_median_test("MULTIPOINT ((0 -1), (0 0), (0 0), (0 1))", "POINT (0 0)");
1070 
1071  /* Cube */
1072  do_median_test("MULTIPOINT ((10 10 10), (10 20 10), (20 10 10), (20 20 10), (10 10 20), (10 20 20), (20 10 20), (20 20 20))",
1073  "POINT (15 15 15)");
1074 
1075  /* Some edge cases */
1076  do_median_test("MULTIPOINT EMPTY", "POINT EMPTY");
1077  do_median_test("MULTIPOINT (EMPTY)", "POINT EMPTY");
1078  do_median_test("POINT (7 6)", "POINT (7 6)");
1079  do_median_test("POINT (7 6 2)", "POINT (7 6 2)");
1080  do_median_test("MULTIPOINT ((7 6 2), EMPTY)", "POINT (7 6 2)");
1081 }
static void do_median_test(char *input, char *expected)
Here is the call graph for this function:
Here is the caller graph for this function: