]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/geometry/test/algorithms/set_operations/intersection/intersection_multi.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / geometry / test / algorithms / set_operations / intersection / intersection_multi.cpp
index 2e46408cacd8bcd9a4021dc7f61c720c5677de80..f982cbca9104bb3154a8bbe5cfcaa1b245ab1a71 100644 (file)
 
 #include <boost/geometry/io/wkt/read.hpp>
 
+#define TEST_INTERSECTION(caseid, clips, points, area) \
+    (test_one<Polygon, MultiPolygon, MultiPolygon>) \
+    ( #caseid, caseid[0], caseid[1], clips, points, area)
+
+#define TEST_INTERSECTION_IGNORE(caseid, clips, points, area) \
+    { ut_settings ignore_validity; ignore_validity.test_validity = false; \
+    (test_one<Polygon, MultiPolygon, MultiPolygon>) \
+    ( #caseid, caseid[0], caseid[1], clips, points, area, ignore_validity); }
+
 template <typename Ring, typename Polygon, typename MultiPolygon>
 void test_areal()
 {
-    ut_settings ignore_validity;
-    ignore_validity.test_validity = false;
-
     test_one<Polygon, MultiPolygon, MultiPolygon>("simplex_multi",
         case_multi_simplex[0], case_multi_simplex[1],
         2, 12, 6.42);
@@ -102,15 +108,13 @@ void test_areal()
         3, 14, 2.85);
     test_one<Polygon, MultiPolygon, MultiPolygon>("case_72_multi_inv_b",
         case_72_multi[1], case_72_multi[2],
-        3, 16, 6.15,
-        ignore_validity);
+        3, 16, 6.15);
     test_one<Polygon, MultiPolygon, MultiPolygon>("case_77_multi",
         case_77_multi[0], case_77_multi[1],
         5, 33, 9.0);
     test_one<Polygon, MultiPolygon, MultiPolygon>("case_78_multi",
         case_78_multi[0], case_78_multi[1],
-        1, 16, 22.0,
-        ignore_validity);
+        1, 16, 22.0);
     test_one<Polygon, MultiPolygon, MultiPolygon>("case_101_multi",
         case_101_multi[0], case_101_multi[1],
         4, 22, 4.75);
@@ -119,8 +123,7 @@ void test_areal()
         3, 26, 19.75);
     test_one<Polygon, MultiPolygon, MultiPolygon>("case_102_multi_inv_b",
         case_102_multi[1], case_102_multi[2],
-        3, 25, 3.75,
-        ignore_validity);
+        6, 25, 3.75);
     test_one<Polygon, MultiPolygon, MultiPolygon>("case_107_multi",
         case_107_multi[0], case_107_multi[1],
         2, 10, 1.5);
@@ -129,30 +132,65 @@ void test_areal()
         3, 13, 3.0);
 
 #ifdef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS
-    // One intersection is missing (by rescaling)
-    test_one<Polygon, MultiPolygon, MultiPolygon>("case_108_multi",
-        case_108_multi[0], case_108_multi[1],
-        5, 33, 7.5,
-        ignore_validity);
+    {
+        ut_settings ignore_validity; ignore_validity.test_validity = false;
+
+        // One intersection is missing (by rescaling)
+        test_one<Polygon, MultiPolygon, MultiPolygon>("case_108_multi",
+            case_108_multi[0], case_108_multi[1],
+            5, 33, 7.5,
+            ignore_validity);
+    }
+#endif
+
+    TEST_INTERSECTION(case_123_multi, 3, 13, 1.875);
+    TEST_INTERSECTION(case_124_multi, 2, 13, 2.0625);
+    TEST_INTERSECTION(case_125_multi, 3, 17, 2.1);
+#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
+    TEST_INTERSECTION(case_126_multi, 5, 27, 9.0);
+#else
+    TEST_INTERSECTION_IGNORE(case_126_multi, 3, 23, 9.0);
+#endif
+    TEST_INTERSECTION(case_127_multi, 3, 19, 24.0);
+    TEST_INTERSECTION(case_128_multi, 2, 26, 75.5);
+    TEST_INTERSECTION(case_129_multi, 1, 20, 20.5);
+    TEST_INTERSECTION(case_130_multi, 2, 30, 39.0);
+
+    TEST_INTERSECTION(case_133_multi, 2, 23, 40.625);
+    TEST_INTERSECTION(case_134_multi, 1, 23, 42.0);
+    TEST_INTERSECTION(case_135_multi, 1, 17, 7.0);
+    TEST_INTERSECTION(case_136_multi, 1, 17, 6.5);
+    TEST_INTERSECTION(case_137_multi, 1, 17, 6.5);
+
+    TEST_INTERSECTION(case_138_multi, 2, 23, 40.4);
+    TEST_INTERSECTION(case_139_multi, 2, 23, 40.546875);
+    TEST_INTERSECTION(case_140_multi, 2, 23, 40.546875);
+
+    // TODO: isolated region with multiple connection should be handled
+    // differently
+    TEST_INTERSECTION_IGNORE(case_141_multi, 2, -1, 74.5);
+
+#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
+    TEST_INTERSECTION(case_recursive_boxes_1, 10, 97, 47.0);
+#else
+    TEST_INTERSECTION_IGNORE(case_recursive_boxes_1, 8, 97, 47.0);
 #endif
-    test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_1",
-        case_recursive_boxes_1[0], case_recursive_boxes_1[1],
-        8, 97, 47.0,
-        ignore_validity);
+
     test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_2",
         case_recursive_boxes_2[0], case_recursive_boxes_2[1],
-        1, 50, 90.0, // Area from SQL Server
-        ignore_validity);
+        1, 50, 90.0); // Area from SQL Server
     test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_3",
         case_recursive_boxes_3[0], case_recursive_boxes_3[1],
         19, 87, 12.5); // Area from SQL Server
 
-    test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_4",
-        case_recursive_boxes_4[0], case_recursive_boxes_4[1],
-        8, 174, 67.0, // Area from SQL Server
-        ignore_validity);
+#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
+    TEST_INTERSECTION_IGNORE(case_recursive_boxes_4, 13, 169, 67.0);
+#else
+    TEST_INTERSECTION_IGNORE(case_recursive_boxes_4, 8, 178, 67.0);
+#endif
 
     // Fixed by replacing handle_tangencies in less_by_segment_ratio sort order
+    // Should contain 6 output polygons
     test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_6",
         case_recursive_boxes_6[0], case_recursive_boxes_6[1],
         6, 47, 19.0);
@@ -242,12 +280,10 @@ void test_areal()
         3, 0, 2.0);
     test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_34",
         case_recursive_boxes_34[0], case_recursive_boxes_34[1],
-        2, 0, 17.25,
-        ignore_validity);
+        2, 0, 17.25);
     test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_35",
         case_recursive_boxes_35[0], case_recursive_boxes_35[1],
-        1, 0, 20.0,
-        ignore_validity);
+        2, 0, 20.0);
     test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_36",
         case_recursive_boxes_36[0], case_recursive_boxes_36[1],
         1, 0, 0.5);
@@ -255,6 +291,71 @@ void test_areal()
         case_recursive_boxes_37[0], case_recursive_boxes_37[1],
         2, 0, 1.0);
 
+    TEST_INTERSECTION(case_recursive_boxes_39, 3, 0, 3.0);
+    TEST_INTERSECTION(case_recursive_boxes_40, 1, 0, 1.0);
+    TEST_INTERSECTION(case_recursive_boxes_41, 1, 0, 23.5);
+    TEST_INTERSECTION(case_recursive_boxes_42, 1, 29, 95.0);
+    TEST_INTERSECTION(case_recursive_boxes_43, 2, 0, 22.5);
+    TEST_INTERSECTION(case_recursive_boxes_44, 2, 0, 3.0);
+    TEST_INTERSECTION(case_recursive_boxes_45, 7, 0, 12.0);
+    TEST_INTERSECTION(case_recursive_boxes_46, 6, -1, 7.0);
+    TEST_INTERSECTION(case_recursive_boxes_47, 1, 5, 1.0);
+    TEST_INTERSECTION(case_recursive_boxes_48, 1, 5, 1.0);
+    TEST_INTERSECTION(case_recursive_boxes_49, 7, 57, 20.0);
+    TEST_INTERSECTION(case_recursive_boxes_50, 9, 71, 26.0);
+    TEST_INTERSECTION(case_recursive_boxes_51, 14, 79, 19.0);
+    TEST_INTERSECTION(case_recursive_boxes_52, 8, -1, 22.0);
+    TEST_INTERSECTION(case_recursive_boxes_53, 1, -1, 19.75);
+    TEST_INTERSECTION(case_recursive_boxes_54, 3, -1, 10.0);
+    TEST_INTERSECTION(case_recursive_boxes_55, 5, -1, 2.25);
+    TEST_INTERSECTION(case_recursive_boxes_56, 1, -1, 0.5);
+    TEST_INTERSECTION(case_recursive_boxes_57, 10, -1, 9.5);
+    TEST_INTERSECTION(case_recursive_boxes_58, 1, -1, 0.25);
+    TEST_INTERSECTION(case_recursive_boxes_59, 8, -1, 8.25);
+    TEST_INTERSECTION(case_recursive_boxes_60, 8, -1, 10.0);
+    TEST_INTERSECTION(case_recursive_boxes_61, 2, -1, 20.0);
+    TEST_INTERSECTION(case_recursive_boxes_62, 9, -1, 10.5);
+
+    TEST_INTERSECTION(case_recursive_boxes_63, 11, -1, 5.75);
+#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
+    TEST_INTERSECTION(case_recursive_boxes_64, 5, -1, 17.25);
+#else
+    TEST_INTERSECTION_IGNORE(case_recursive_boxes_64, 4, -1, 17.25);
+#endif
+    TEST_INTERSECTION(case_recursive_boxes_65, 3, -1, 17.25);
+
+#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
+    TEST_INTERSECTION(case_recursive_boxes_66, 4, -1, 16.0);
+#else
+    TEST_INTERSECTION_IGNORE(case_recursive_boxes_66, 2, -1, 16.0);
+#endif
+
+    TEST_INTERSECTION(case_recursive_boxes_67, 5, -1, 2.5);
+    TEST_INTERSECTION(case_recursive_boxes_68, 8, -1, 9.5);
+    TEST_INTERSECTION(case_recursive_boxes_69, 6, -1, 3.25);
+#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
+    TEST_INTERSECTION(case_recursive_boxes_70, 6, -1, 18.5);
+#else
+    // Misses a necessary self-turn and therefore a ring
+    TEST_INTERSECTION_IGNORE(case_recursive_boxes_70, 3, -1, 18.0);
+#endif
+
+    TEST_INTERSECTION(case_recursive_boxes_71, 3, -1, 1.75);
+    TEST_INTERSECTION(case_recursive_boxes_72, 8, -1, 4.5);
+    TEST_INTERSECTION(case_recursive_boxes_73, 3, -1, 18.5);
+#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
+    TEST_INTERSECTION(case_recursive_boxes_74, 3, -1, 20.25);
+#else
+    TEST_INTERSECTION_IGNORE(case_recursive_boxes_74, 2, -1, 20.25);
+#endif
+
+    TEST_INTERSECTION(case_recursive_boxes_75, 5, -1, 16.75);
+    TEST_INTERSECTION(case_recursive_boxes_76, 2, -1, 18.25);
+    TEST_INTERSECTION(case_recursive_boxes_77, 5, -1, 3.5);
+    TEST_INTERSECTION(case_recursive_boxes_78, 9, -1, 8.0);
+    TEST_INTERSECTION(case_recursive_boxes_79, 5, -1, 9.0);
+    TEST_INTERSECTION(case_recursive_boxes_80, 1, -1, 0.25);
+
     test_one<Polygon, MultiPolygon, MultiPolygon>("ggl_list_20120915_h2_a",
         ggl_list_20120915_h2[0], ggl_list_20120915_h2[1],
         2, 10, 6.0); // Area from SQL Server
@@ -278,14 +379,19 @@ void test_areal()
 
     );
 
+    TEST_INTERSECTION(ticket_12503, 2, 13, 17.375);
+
     test_one<Polygon, MultiPolygon, MultiPolygon>("mysql_23023665_7",
         mysql_23023665_7[0], mysql_23023665_7[1],
         2, 11, 9.80505786783);
 
-    test_one<Polygon, MultiPolygon, MultiPolygon>("mysql_23023665_12",
-        mysql_23023665_12[0], mysql_23023665_12[1],
-        1, -1, 11.812440191387557,
-        ignore_validity);
+#ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS
+    TEST_INTERSECTION(mysql_23023665_12, 2, 0, 11.812440191387557);
+#else
+    TEST_INTERSECTION_IGNORE(mysql_23023665_12, 1, -1, 11.812440191387557);
+#endif
+
+    TEST_INTERSECTION(mysql_regression_1_65_2017_08_31, 2, -1, 29.9022122);
 }
 
 template <typename Polygon, typename MultiPolygon, typename Box>