PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ test_median_robustness()

static void test_median_robustness ( void  )
static

Definition at line 1038 of file cu_algorithm.c.

References do_median_test().

Referenced by algorithms_suite_setup().

1039 {
1040  /* A simple implementation of Weiszfeld's algorithm will fail if the median is equal
1041  * to any one of the inputs, during any iteration of the algorithm.
1042  *
1043  * Because the algorithm uses the centroid as a starting point, this situation will
1044  * occur in the test case below.
1045  */
1046  do_median_test("MULTIPOINT ((0 -1), (0 0), (0 1))", "POINT (0 0)");
1047 
1048  /* Same as above but 3D, and shifter */
1049  do_median_test("MULTIPOINT ((1 -1 3), (1 0 2), (2 1 1))", "POINT (1 0 2)");
1050 
1051  /* Starting point is duplicated */
1052  do_median_test("MULTIPOINT ((0 -1), (0 0), (0 0), (0 1))", "POINT (0 0)");
1053 
1054  /* Cube */
1055  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))",
1056  "POINT (15 15 15)");
1057 
1058  /* Some edge cases */
1059  do_median_test("MULTIPOINT EMPTY", "POINT EMPTY");
1060  do_median_test("MULTIPOINT (EMPTY)", "POINT EMPTY");
1061  do_median_test("POINT (7 6)", "POINT (7 6)");
1062  do_median_test("POINT (7 6 2)", "POINT (7 6 2)");
1063  do_median_test("MULTIPOINT ((7 6 2), EMPTY)", "POINT (7 6 2)");
1064 }
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: