void test_one_lp(std::string const& caseid, std::string const& wkt_areal, std::string const& wkt_linear, std::size_t expected_count = 0, int expected_point_count = 0, double expected_length = 0, ut_settings const& settings = ut_settings()) { #ifdef BOOST_GEOMETRY_TEST_DEBUG std::cout << caseid << " -- start" << std::endl; #endif Areal areal; bg::read_wkt(wkt_areal, areal); bg::correct(areal); Linear linear; bg::read_wkt(wkt_linear, linear); test_intersection<OutputType, void>(caseid, areal, linear, expected_count, expected_point_count, expected_length, settings); // A linestring reversed should deliver exactly the same. bg::reverse(linear); test_intersection<OutputType, void>(caseid + "_rev", areal, linear, expected_count, expected_point_count, expected_length, settings); #ifdef BOOST_GEOMETRY_TEST_DEBUG std::cout << caseid << " -- end" << std::endl; #endif }
typename bg::default_area_result<G1>::type test_one(std::string const& caseid, std::string const& wkt1, std::string const& wkt2, std::size_t expected_count = 0, int expected_point_count = 0, double expected_length_or_area = 0, ut_settings const& settings = ut_settings()) { return test_one<OutputType, G1, G2>(caseid, wkt1, wkt2, expected_count, 0, expected_point_count, expected_length_or_area, settings); }
typename bg::default_area_result<G1>::type test_intersection(std::string const& caseid, G1 const& g1, G2 const& g2, std::size_t expected_count = 0, int expected_point_count = 0, double expected_length_or_area = 0, ut_settings const& settings = ut_settings()) { return test_intersection<OutputType, CalculationType>( caseid, g1, g2, expected_count, 0, expected_point_count, expected_length_or_area, settings ); }
std::string test_one(std::string const& caseid, std::string const& wkt1, std::string const& wkt2, int expected_count1, int expected_rings_count1, int expected_point_count1, double expected_area1, int expected_count2, int expected_rings_count2, int expected_point_count2, double expected_area2, int expected_count_s, int expected_rings_count_s, int expected_point_count_s, double expected_area_s, ut_settings const& settings = ut_settings()) { G1 g1; bg::read_wkt(wkt1, g1); G2 g2; bg::read_wkt(wkt2, g2); bg::correct(g1); bg::correct(g2); std::string result = test_difference<OutputType>(caseid + "_a", g1, g2, expected_count1, expected_rings_count1, expected_point_count1, expected_area1, false, settings); #ifdef BOOST_GEOMETRY_DEBUG_ASSEMBLE return result; #endif test_difference<OutputType>(caseid + "_b", g2, g1, expected_count2, expected_rings_count2, expected_point_count2, expected_area2, false, settings); if (settings.sym_difference) { test_difference<OutputType>(caseid + "_s", g1, g2, expected_count_s, expected_rings_count_s, expected_point_count_s, expected_area_s, true, settings); } return result; }
std::string test_one(std::string const& caseid, std::string const& wkt1, std::string const& wkt2, int expected_count1, int expected_point_count1, double expected_area1, int expected_count2, int expected_point_count2, double expected_area2, ut_settings const& settings = ut_settings()) { return test_one<OutputType, G1, G2>(caseid, wkt1, wkt2, expected_count1, expected_point_count1, expected_area1, expected_count2, expected_point_count2, expected_area2, expected_count1 + expected_count2, expected_point_count1 >= 0 && expected_point_count2 >= 0 ? (expected_point_count1 + expected_point_count2) : -1, expected_area1 + expected_area2, settings); }
void test_one(std::string const& caseid, std::string const& wkt1, std::string const& wkt2, int expected_count, int expected_hole_count, int expected_point_count, double expected_area, ut_settings const& settings = ut_settings()) { G1 g1; bg::read_wkt(wkt1, g1); G2 g2; bg::read_wkt(wkt2, g2); // Reverse/close if necessary (e.g. G1/G2 are ccw and/or open) bg::correct(g1); bg::correct(g2); test_union<OutputType>(caseid, g1, g2, expected_count, expected_hole_count, expected_point_count, expected_area, settings); }
typename bg::default_area_result<G1>::type test_one(std::string const& caseid, std::string const& wkt1, std::string const& wkt2, std::size_t expected_count = 0, std::size_t expected_holes_count = 0, int expected_point_count = 0, double expected_length_or_area = 0, ut_settings const& settings = ut_settings()) { G1 g1; bg::read_wkt(wkt1, g1); G2 g2; bg::read_wkt(wkt2, g2); // Reverse if necessary bg::correct(g1); bg::correct(g2); return test_intersection<OutputType, void>(caseid, g1, g2, expected_count, expected_holes_count, expected_point_count, expected_length_or_area, settings); }
void test_areal() { typedef typename bg::coordinate_type<Polygon>::type ct; bool const ccw = bg::point_order<Polygon>::value == bg::counterclockwise; bool const open = bg::closure<Polygon>::value == bg::open; test_one<Polygon, Polygon, Polygon>("simplex_with_empty_1", simplex_normal[0], polygon_empty, 0, 0, 0.0); test_one<Polygon, Polygon, Polygon>("simplex_with_empty_2", polygon_empty, simplex_normal[0], 0, 0, 0.0); test_one<Polygon, Polygon, Polygon>("simplex_normal", simplex_normal[0], simplex_normal[1], 1, 7, 5.47363293); test_one<Polygon, Polygon, Polygon>("star_ring", example_star, example_ring, 1, 18, 2.80983); test_one<Polygon, Polygon, Polygon>("star_poly", example_star, example_polygon, 1, 0, // CLN: 23 points, other types: 22 point (one is merged) 2.5020508); test_one<Polygon, Polygon, Polygon>("first_within_second1", first_within_second[0], first_within_second[1], 1, 5, 1.0); test_one<Polygon, Polygon, Polygon>("first_within_second2", first_within_second[1], first_within_second[0], 1, 5, 1.0); test_one<Polygon, Polygon, Polygon>("first_within_hole_of_second", first_within_hole_of_second[0], first_within_hole_of_second[1], 0, 0, 0.0); // Two forming new hole test_one<Polygon, Polygon, Polygon>("new_hole", new_hole[0], new_hole[1], 2, 10, 2.0); // Two identical test_one<Polygon, Polygon, Polygon>("identical", identical[0], identical[1], 1, 5, 1.0); test_one<Polygon, Polygon, Polygon>("intersect_exterior_and_interiors_winded", intersect_exterior_and_interiors_winded[0], intersect_exterior_and_interiors_winded[1], 1, 14, 25.2166667); test_one<Polygon, Polygon, Polygon>("intersect_holes_disjoint", intersect_holes_disjoint[0], intersect_holes_disjoint[1], 1, 15, 18.0); test_one<Polygon, Polygon, Polygon>("intersect_holes_intersect", intersect_holes_intersect[0], intersect_holes_intersect[1], 1, 14, 18.25); test_one<Polygon, Polygon, Polygon>("intersect_holes_intersect_and_disjoint", intersect_holes_intersect_and_disjoint[0], intersect_holes_intersect_and_disjoint[1], 1, 19, 17.25); test_one<Polygon, Polygon, Polygon>("intersect_holes_intersect_and_touch", intersect_holes_intersect_and_touch[0], intersect_holes_intersect_and_touch[1], 1, 23, 17.25); test_one<Polygon, Polygon, Polygon>("intersect_holes_new_ring", intersect_holes_new_ring[0], intersect_holes_new_ring[1], 2, 23, 122.1039); test_one<Polygon, Polygon, Polygon>("winded", winded[0], winded[1], 1, 22, 40.0); test_one<Polygon, Polygon, Polygon>("within_holes_disjoint", within_holes_disjoint[0], within_holes_disjoint[1], 1, 15, 23.0); test_one<Polygon, Polygon, Polygon>("side_side", side_side[0], side_side[1], 0, 0, 0.0); test_one<Polygon, Polygon, Polygon>("two_bends", two_bends[0], two_bends[1], 1, 7, 24.0); test_one<Polygon, Polygon, Polygon>("star_comb_15", star_comb_15[0], star_comb_15[1], 28, 150, 189.952883); test_one<Polygon, Polygon, Polygon>("simplex_normal", simplex_normal[0], simplex_normal[1], 1, 7, 5.47363293); test_one<Polygon, Polygon, Polygon>("distance_zero", distance_zero[0], distance_zero[1], 1, 0 /* f: 4, other: 5 */, 0.29516139, ut_settings(0.01)); test_one<Polygon, Polygon, Polygon>("equal_holes_disjoint", equal_holes_disjoint[0], equal_holes_disjoint[1], 1, 20, 81 - 2 * 3 * 3 - 3 * 7); test_one<Polygon, Polygon, Polygon>("only_hole_intersections1", only_hole_intersections[0], only_hole_intersections[1], 1, 21, 178.090909); test_one<Polygon, Polygon, Polygon>("only_hole_intersection2", only_hole_intersections[0], only_hole_intersections[2], 1, 21, 149.090909); test_one<Polygon, Polygon, Polygon>("fitting", fitting[0], fitting[1], 0, 0, 0); test_one<Polygon, Polygon, Polygon>("crossed", crossed[0], crossed[1], 3, 0, 1.5); test_one<Polygon, Polygon, Polygon>("pie_2_3_23_0", pie_2_3_23_0[0], pie_2_3_23_0[1], 1, 4, 163292.679042133, ut_settings(0.1)); test_one<Polygon, Polygon, Polygon>("isovist", isovist1[0], isovist1[1], 1, 19, 88.19203, ut_settings(if_typed_tt<ct>(0.01, 0.1))); // SQL Server gives: 88.1920416352664 // PostGIS gives: 88.19203677911 test_one<Polygon, Polygon, Polygon>("geos_1", geos_1[0], geos_1[1], 1, -1, 3461.0214843, ut_settings(0.005)); // MSVC 14 reports 3461.025390625 // Expectations: // In most cases: 0 (no intersection) // In some cases: 1.430511474609375e-05 (clang/gcc on Xubuntu using b2) // In some cases: 5.6022983000000002e-05 (powerpc64le-gcc-6-0) test_one<Polygon, Polygon, Polygon>("geos_2", geos_2[0], geos_2[1], 0, 0, 6.0e-5, ut_settings(-1.0)); // -1 denotes: compare with <= #if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS) test_one<Polygon, Polygon, Polygon>("geos_3", geos_3[0], geos_3[1], 0, 0, 0.0); #endif test_one<Polygon, Polygon, Polygon>("geos_4", geos_4[0], geos_4[1], 1, -1, 0.08368849); if ( BOOST_GEOMETRY_CONDITION(! ccw && open) ) { // Pointcount for ttmath/double (both 5) or float (4) // double returns 5 (since method append_no_dups_or_spikes) // but not for ccw/open. Those cases has to be adapted once, anyway, // because for open always one point too much is generated... test_one<Polygon, Polygon, Polygon>("ggl_list_20110306_javier", ggl_list_20110306_javier[0], ggl_list_20110306_javier[1], 1, if_typed<ct, float>(4, 5), 0.6649875, ut_settings(if_typed<ct, float>(1.0, 0.01))); } // SQL Server reports: 0.400390625 // PostGIS reports 0.4 // BG did report 0.4 but is changed to 0.397 // when selecting other IP closer at endpoint or if segment B is smaller than A test_one<Polygon, Polygon, Polygon>("ggl_list_20110307_javier", ggl_list_20110307_javier[0], ggl_list_20110307_javier[1], 1, 4, #if defined(BOOST_GEOMETRY_NO_ROBUSTNESS) 0.40 #else 0.397162651, ut_settings(0.01) #endif ); #if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS) test_one<Polygon, Polygon, Polygon>("ggl_list_20110627_phillip", ggl_list_20110627_phillip[0], ggl_list_20110627_phillip[1], 1, if_typed_tt<ct>(6, 5), 11151.6618); #endif test_one<Polygon, Polygon, Polygon>("ggl_list_20110716_enrico", ggl_list_20110716_enrico[0], ggl_list_20110716_enrico[1], 3, 16, 35723.8506317139); test_one<Polygon, Polygon, Polygon>("ggl_list_20131119_james", ggl_list_20131119_james[0], ggl_list_20131119_james[1], 1, 4, 6.6125873045, ut_settings(0.1)); test_one<Polygon, Polygon, Polygon>("ggl_list_20140223_shalabuda", ggl_list_20140223_shalabuda[0], ggl_list_20140223_shalabuda[1], 1, 4, 3.77106, ut_settings(0.001)); // Mailed to the Boost.Geometry list on 2014/03/21 by [email protected] test_one<Polygon, Polygon, Polygon>("ggl_list_20140321_7415963", ggl_list_20140321_7415963[0], ggl_list_20140321_7415963[1], 0, 0, 0, ut_settings(0.1)); #if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS) test_one<Polygon, Polygon, Polygon>("buffer_rt_f", buffer_rt_f[0], buffer_rt_f[1], 1, 4, 0.00029437899183903937, ut_settings(0.01)); #endif test_one<Polygon, Polygon, Polygon>("buffer_rt_g", buffer_rt_g[0], buffer_rt_g[1], 1, 0, 2.914213562373); #if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS) test_one<Polygon, Polygon, Polygon>("ticket_8254", ticket_8254[0], ticket_8254[1], 1, 4, 3.635930e-08, 0.01); #endif test_one<Polygon, Polygon, Polygon>("ticket_6958", ticket_6958[0], ticket_6958[1], 1, 4, 4.34355e-05, 0.01); #if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS) test_one<Polygon, Polygon, Polygon>("ticket_8652", ticket_8652[0], ticket_8652[1], 1, 4, 0.0003); #endif test_one<Polygon, Polygon, Polygon>("ticket_8310a", ticket_8310a[0], ticket_8310a[1], 1, 5, 0.3843747); test_one<Polygon, Polygon, Polygon>("ticket_8310b", ticket_8310b[0], ticket_8310b[1], 1, 5, 0.3734379); test_one<Polygon, Polygon, Polygon>("ticket_8310c", ticket_8310c[0], ticket_8310c[1], 1, 5, 0.4689541); test_one<Polygon, Polygon, Polygon>("ticket_9081_15", ticket_9081_15[0], ticket_9081_15[1], 1, 4, 0.0068895780745301394); test_one<Polygon, Polygon, Polygon>("ticket_10108_a", ticket_10108_a[0], ticket_10108_a[1], 0, 0, 0.0); #if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS) // msvc 5.6023011e-5 // mingw 5.6022954e-5 test_one<Polygon, Polygon, Polygon>("ticket_10108_b", ticket_10108_b[0], ticket_10108_b[1], 0, 0, 5.6022983e-5); #endif test_one<Polygon, Polygon, Polygon>("ticket_10747_a", ticket_10747_a[0], ticket_10747_a[1], 1, 4, 70368744177664); test_one<Polygon, Polygon, Polygon>("ticket_10747_b", ticket_10747_b[0], ticket_10747_b[1], 1, 4, 7036874417766400); test_one<Polygon, Polygon, Polygon>("ticket_10747_c", ticket_10747_c[0], ticket_10747_c[1], 1, 4, 17592186044416); test_one<Polygon, Polygon, Polygon>("ticket_10747_d", ticket_10747_d[0], ticket_10747_d[1], 1, 4, 703687777321); test_one<Polygon, Polygon, Polygon>("ticket_10747_e", ticket_10747_e[0], ticket_10747_e[1], 1, 4, 7.0368748575710959e-15); test_one<Polygon, Polygon, Polygon>("ticket_11576", ticket_11576[0], ticket_11576[1], 1, 0, 5.585617332907136e-07); #if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS) test_one<Polygon, Polygon, Polygon>("ticket_9563", ticket_9563[0], ticket_9563[1], 1, 8, 129.90381); #endif #if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS) test_one<Polygon, Polygon, Polygon>("buffer_mp1", buffer_mp1[0], buffer_mp1[1], 1, 31, 2.271707796); #endif test_one<Polygon, Polygon, Polygon>("buffer_mp2", buffer_mp2[0], buffer_mp2[1], 1, 29, 0.457126); test_one<Polygon, Polygon, Polygon>("case_58_iet", case_58[0], case_58[2], 2, -1, 1.0 / 3.0); test_one<Polygon, Polygon, Polygon>("case_80", case_80[0], case_80[1], 0, -1, 0.0); test_one<Polygon, Polygon, Polygon>("case_81", case_81[0], case_81[1], 0, -1, 0.0); test_one<Polygon, Polygon, Polygon>("mysql_21964049", mysql_21964049[0], mysql_21964049[1], 0, -1, 0.0); test_one<Polygon, Polygon, Polygon>("mysql_21964465", mysql_21964465[0], mysql_21964465[1], 0, -1, 0.0); test_one<Polygon, Polygon, Polygon>("mysql_21965285_b_inv", mysql_21965285_b_inv[0], mysql_21965285_b_inv[1], 2, -1, 183.71376870369406); return; test_one<Polygon, Polygon, Polygon>( "polygon_pseudo_line", "Polygon((0 0,0 4,4 4,4 0,0 0))", "Polygon((2 -2,2 -1,2 6,2 -2))", 5, 22, 1.1901714); }
void test_all() { typedef bg::model::linestring<P> linestring; typedef bg::model::multi_linestring<linestring> multi_linestring_type; typedef bg::model::polygon<P, Clockwise> polygon; bg::strategy::buffer::join_miter join_miter; bg::strategy::buffer::join_round join_round(100); bg::strategy::buffer::join_round_by_divide join_round_by_divide(4); bg::strategy::buffer::end_flat end_flat; bg::strategy::buffer::end_round end_round(100); bg::strategy::buffer::end_round end_round32(32); bg::strategy::buffer::join_round join_round32(32); // Round joins / round ends test_one<multi_linestring_type, polygon>("simplex", simplex, join_round, end_round, 49.0217, 1.5); test_one<multi_linestring_type, polygon>("two_bends", two_bends, join_round, end_round, 74.73, 1.5); test_one<multi_linestring_type, polygon>("turn_inside", turn_inside, join_round, end_round, 86.3313, 1.5); test_one<multi_linestring_type, polygon>("two_bends_asym", two_bends, join_round, end_round, 58.3395, 1.5, ut_settings(), 0.75); // Round joins / flat ends: test_one<multi_linestring_type, polygon>("simplex", simplex, join_round, end_flat, 38.2623, 1.5); test_one<multi_linestring_type, polygon>("two_bends", two_bends, join_round, end_flat, 64.6217, 1.5); test_one<multi_linestring_type, polygon>("bend_near_start1", bend_near_start1, join_round, end_flat, 202.5910, 9.0); test_one<multi_linestring_type, polygon>("bend_near_start2", bend_near_start2, join_round, end_flat, 231.4988, 9.0); // TODO this should be fixed test_one<multi_linestring_type, polygon>("turn_inside", turn_inside, join_round, end_flat, 99, 1.5); test_one<multi_linestring_type, polygon>("two_bends_asym", two_bends, join_round, end_flat, 52.3793, 1.5, ut_settings(), 0.75); // This one is far from done: // test_one<multi_linestring_type, polygon>("turn_inside_asym_neg", turn_inside, join_round, end_flat, 99, +1.5, ut_settings(), -1.0); // Miter / divide joins, various ends test_one<multi_linestring_type, polygon>("two_bends", two_bends, join_round_by_divide, end_flat, 64.6217, 1.5); test_one<multi_linestring_type, polygon>("two_bends", two_bends, join_miter, end_flat, 65.1834, 1.5); test_one<multi_linestring_type, polygon>("two_bends", two_bends, join_miter, end_round, 75.2917, 1.5); test_one<multi_linestring_type, polygon>("degenerate0", degenerate0, join_round, end_round, 0.0, 3.0); test_one<multi_linestring_type, polygon>("degenerate1", degenerate1, join_round, end_round, 28.2503, 3.0); test_one<multi_linestring_type, polygon>("degenerate2", degenerate2, join_round, end_round, 56.0457, 3.0); test_one<multi_linestring_type, polygon>("degenerate3", degenerate3, join_round, end_round, 80.4531, 3.0); test_one<multi_linestring_type, polygon>("degenerate4", degenerate4, join_round, end_round, 104.3142, 3.0); test_one<multi_linestring_type, polygon>("crossing", crossing, join_round32, end_flat, 2628.4272, 50.0); test_one<multi_linestring_type, polygon>("crossing", crossing, join_round32, end_round32, 9893.764, 50.0); // Cases formly causing a segmentation fault because a generated side was skipped // (The expected area for large distances is about R*R*PI where R is distance) // Note that for large distances the flat ends (not tested here) still give weird effects { // The results can differ between compilers and platforms ut_settings settings(40.0); ut_settings settings10 = settings; settings10.tolerance *= 10.0; test_one<multi_linestring_type, polygon>("mikado1_large", mikado1, join_round32, end_round32, 5455052125.0, 41751.0, settings); test_one<multi_linestring_type, polygon>("mikado1_small", mikado1, join_round32, end_round32, 1057.37, 10.0); test_one<multi_linestring_type, polygon>("mikado1_small", mikado1, join_round32, end_flat, 874.590, 10.0); test_one<multi_linestring_type, polygon>("mikado2_large", mikado2, join_round32, end_round32, 19878812253.0, 79610.0, settings10); test_one<multi_linestring_type, polygon>("mikado2_small", mikado2, join_round32, end_round32, 1082.470, 10.0); test_one<multi_linestring_type, polygon>("mikado2_small", mikado2, join_round32, end_flat, 711.678, 10.0); // BSD 29151950588 // msvc 29151950611 // clang/linux 29151950612 // mingw 29151950711 test_one<multi_linestring_type, polygon>("mikado3_large", mikado3, join_round32, end_round32, 29151950650.0, 96375.0, settings10); test_one<multi_linestring_type, polygon>("mikado3_small", mikado3, join_round32, end_round32, 2533.285, 10.0); test_one<multi_linestring_type, polygon>("mikado3_small", mikado3, join_round32, end_flat, 2136.236, 10.0); test_one<multi_linestring_type, polygon>("mikado4_large", mikado4, join_round32, end_round32, 11212832169.0, 59772.0, settings); test_one<multi_linestring_type, polygon>("mikado4_small", mikado4, join_round32, end_round32, 2103.686, 10.0); test_one<multi_linestring_type, polygon>("mikado4_small", mikado4, join_round32, end_flat, 1930.785, 10.0); } { #if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS) // Coordinates in one linestring vary so much that // length = geometry::math::sqrt(dx * dx + dy * dy); returns a value of inf for length // That geometry is skipped for the buffer // SQL Server reports area 2117753600 (for b) // PostGIS reports 2087335072 (for b) // BG (2017) reports 1063005187 (for a/b) which apparently misses parts // BG (2015) reported 794569660 (for a/b) // BG (earlier) reported 927681870 (for a/b) test_one<multi_linestring_type, polygon>("mysql_2015_04_10a", mysql_2015_04_10a, join_round32, end_round32, ut_settings::ignore_area(), 0.98, ut_settings::assertions_only()); test_one<multi_linestring_type, polygon>("mysql_2015_04_10b", mysql_2015_04_10b, join_round32, end_round32, ut_settings::ignore_area(), 0.98, ut_settings::assertions_only()); #endif // Two other cases with <inf> for length calculation test_one<multi_linestring_type, polygon>("mysql_2015_09_08a", mysql_2015_09_08a, join_round32, end_round32, ut_settings::ignore_area(), 4051744443.0, ut_settings::assertions_only()); test_one<multi_linestring_type, polygon>("mysql_2015_09_08b", mysql_2015_09_08b, join_round32, end_round32, ut_settings::ignore_area(), 2061380362.0, ut_settings::assertions_only()); } // Generates first no interior, then one touching point (no interior), // then one real interior ring, then one complete polygon test_one<multi_linestring_type, polygon>("mysql_23023665_1", mysql_23023665_1, join_round32, end_round32, 1, 1, 186.5504, 1.0); test_one<multi_linestring_type, polygon>("touching1_1", touching1, join_round32, end_round32, 2, 0, 78.70773, 1.0 #if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS) , ut_settings::ignore_validity() // false positive, due to rescaling. As we remove it, it is gone #endif ); test_one<multi_linestring_type, polygon>("touching2_1", touching2, join_round32, end_round32, 1, 1, 107.8991, 1.0); test_one<multi_linestring_type, polygon>("mysql_23023665_1_09", mysql_23023665_1, join_round32, end_round32, 1, 0, 167.8062, 0.9); test_one<multi_linestring_type, polygon>("mysql_23023665_1_11", mysql_23023665_1, join_round32, end_round32, 1, 1, 205.1473, 1.1); test_one<multi_linestring_type, polygon>("mysql_23023665_1_20", mysql_23023665_1, join_round32, end_round32, 1, 1, 368.8422, 2.0); test_one<multi_linestring_type, polygon>("mysql_23023665_1_59", mysql_23023665_1, join_round32, end_round32, 1, 1, 1020.7214, 5.9821); // very small triangle test_one<multi_linestring_type, polygon>("mysql_23023665_1_60", mysql_23023665_1, join_round32, end_round32, 1, 0, 1023.3061, 6.0); // no interior anymore test_one<multi_linestring_type, polygon>("mysql_23023665_1", mysql_23023665_1, join_round32, end_flat, 1, 0, 180.3075, 1.0); test_one<multi_linestring_type, polygon>("mysql_23023665_1_09", mysql_23023665_1, join_round32, end_flat, 1, 0, 162.7494, 0.9); test_one<multi_linestring_type, polygon>("mysql_23023665_1_11", mysql_23023665_1, join_round32, end_flat, 1, 0, 197.7607, 1.1); test_one<multi_linestring_type, polygon>("mysql_23023665_1_20", mysql_23023665_1, join_round32, end_flat, 1, 1, 350.1135, 2.0); #if defined(BOOST_GEOMETRY_NO_ROBUSTNESS) { ut_settings settings(10.0); test_one<multi_linestring_type, polygon>("ticket_13444_1", ticket_13444, join_round32, end_round32, 3, 0, 11801.7832, 1.0, settings); test_one<multi_linestring_type, polygon>("ticket_13444_3", ticket_13444, join_round32, end_round32, 3, 1, 34132.0882, 3.0, settings); test_one<multi_linestring_type, polygon>("ticket_13444_5", ticket_13444, join_round32, end_round32, 2, 1, 50525.1110, 5.0, settings); } #endif }
typename bg::default_area_result<G1>::type test_intersection(std::string const& caseid, G1 const& g1, G2 const& g2, std::size_t expected_count = 0, std::size_t expected_holes_count = 0, int expected_point_count = 0, double expected_length_or_area = 0, ut_settings const& settings = ut_settings()) { if (settings.debug) { std::cout << std::endl << "case " << caseid << std::endl; } typedef typename bg::point_type<G1>::type point_type; typedef typename setop_output_type<OutputType>::type result_type; if (! settings.debug) { // Check _inserter behaviour with stratey typedef bg::intersection_strategies < typename bg::cs_tag<point_type>::type, G1, G2, point_type, typename bg::rescale_policy_type<point_type>::type, CalculationType > strategy; result_type clip; bg::detail::intersection::intersection_insert<OutputType>(g1, g2, std::back_inserter(clip), strategy()); } typename bg::default_area_result<G1>::type length_or_area = 0; // Check normal behaviour result_type intersection_output; bg::intersection(g1, g2, intersection_output); check_result<G1, G2>(intersection_output, caseid, expected_count, expected_holes_count, expected_point_count, expected_length_or_area, settings); // Check variant behaviour intersection_output.clear(); bg::intersection(boost::variant<G1>(g1), g2, intersection_output); check_result<G1, G2>(intersection_output, caseid, expected_count, expected_holes_count, expected_point_count, expected_length_or_area, settings); intersection_output.clear(); bg::intersection(g1, boost::variant<G2>(g2), intersection_output); check_result<G1, G2>(intersection_output, caseid, expected_count, expected_holes_count, expected_point_count, expected_length_or_area, settings); intersection_output.clear(); bg::intersection(boost::variant<G1>(g1), boost::variant<G2>(g2), intersection_output); check_result<G1, G2>(intersection_output, caseid, expected_count, expected_holes_count, expected_point_count, expected_length_or_area, settings); #if defined(TEST_WITH_SVG) { bool const is_line = bg::geometry_id<OutputType>::type::value == 2; typedef typename bg::coordinate_type<G1>::type coordinate_type; bool const ccw = bg::point_order<G1>::value == bg::counterclockwise || bg::point_order<G2>::value == bg::counterclockwise; bool const open = bg::closure<G1>::value == bg::open || bg::closure<G2>::value == bg::open; std::ostringstream filename; filename << "intersection_" << caseid << "_" << string_from_type<coordinate_type>::name() << string_from_type<CalculationType>::name() << (ccw ? "_ccw" : "") << (open ? "_open" : "") #if defined(BOOST_GEOMETRY_NO_ROBUSTNESS) << "_no_rob" #endif << ".svg"; std::ofstream svg(filename.str().c_str()); bg::svg_mapper<point_type> mapper(svg, 500, 500); mapper.add(g1); mapper.add(g2); mapper.map(g1, is_line ? "opacity:0.6;stroke:rgb(0,255,0);stroke-width:5" : "fill-opacity:0.5;fill:rgb(153,204,0);" "stroke:rgb(153,204,0);stroke-width:3"); mapper.map(g2, "fill-opacity:0.3;fill:rgb(51,51,153);" "stroke:rgb(51,51,153);stroke-width:3"); for (typename result_type::const_iterator it = intersection_output.begin(); it != intersection_output.end(); ++it) { mapper.map(*it, "fill-opacity:0.2;stroke-opacity:0.4;fill:rgb(255,0,0);" "stroke:rgb(255,0,255);stroke-width:8"); } } #endif if (settings.debug) { std::cout << "end case " << caseid << std::endl; } return length_or_area; }