[geometry] unit test update (especially in union) for fix of several robustness issues in cart_intersect and get_turn_info found by testing buffer algorithm

[SVN r77989]
This commit is contained in:
Barend Gehrels 2012-04-15 11:47:08 +00:00
parent 2aed65855f
commit 2373c321e5
3 changed files with 79 additions and 11 deletions

View File

@ -616,7 +616,36 @@ static std::string buffer_rt_l[2] =
"POLYGON((5.0 1.0,5.0 2.0,5.0 4.4142135623730958,6.7071067811865479 2.7071067811865475,7.7071067811865479 1.7071067811865475,9.4142135623730958 0.00,7.0 0.0,6.0 0.0,5.0 0.0,5.0 1.0))"
};
static std::string buffer_rt_m1[2] =
{
"POLYGON((3.0 2.0,3.0 3.0,3.0 5.4142135623730940,4.7071067811865479 3.7071067811865475,5.7071067811865479 2.7071067811865475,7.4142135623730940 1.0,5.0 1.0,4.0 1.0,3.0 1.0,3.0 2.0))",
"POLYGON((0.29289321881345254 2.7071067811865475,1.2928932188134525 3.7071067811865475,3.0 5.4142135623730949,3.0 3.0,3.0 2.0,3.0 1.0,2.0 1.0,1.0 1.0,-1.4142135623730949 1.0,0.29289321881345254 2.7071067811865475))"
};
static std::string buffer_rt_m2[2] =
{
"POLYGON((-0.70710678118654746 3.7071067811865475,0.29289321881345254 4.7071067811865479,2.0 6.4142135623730967,2.0 4.0,2.0 3.0,2.0 2.0,1.0 2.0,0.00 2.0,-2.4142135623730949 2.0,-0.70710678118654746 3.7071067811865475))",
"POLYGON((2.2928932188134525 6.7071067811865479,3.2928932188134525 7.7071067811865479,5.0 9.4142135623730958,5.0 7.0,5.0 6.0,5.0 6.0,5.0 5.0,5.0 4.0,4.0 4.0,3.0 4.0,2.0 4.0,2.0 5.0,2.0 6.0,2.0 6.4142135623730958,2.2928932188134525 6.7071067811865479))"
};
static std::string buffer_rt_n[2] =
{
"POLYGON((-0.70710678118654746 0.70710678118654746,0.29289321881345254 1.7071067811865475,2.0 3.4142135623730949,2.0 1.0,2.0 0.0,2.0 -1.0,1.0 -1.0,0.00 -1.0,-2.4142135623730949 -1.0,-0.70710678118654746 0.70710678118654746))",
"POLYGON((2.2928932188134525 3.7071067811865475,3.2928932188134525 4.7071067811865479,5.0 6.4142135623730958,5.0 4.0,5.0 3.0,5.0 2.0,4.0 2.0,3.0 2.0,0.58578643762690574 2.0,2.2928932188134525 3.7071067811865475))"
};
static std::string buffer_rt_q[2] =
{
"POLYGON((6.0 6.0,7.0 6.0,9.4142135623730958 6.0,7.7071067811865479 4.2928932188134521,6.7071067811865479 3.2928932188134525,6.4142135623730949 3.0,6.0 3.0,5.0 3.0,4.0 3.0,4.0 4.0,4.0 5.0,4.0 6.0,5.0 6.0,6.0 6.0))",
"POLYGON((3.0 2.0,3.0 3.0,3.0 4.0,4.0 4.0,5.0 4.0,7.4142135623730958 4.0,5.7071067811865479 2.2928932188134525,4.7071067811865479 1.2928932188134525,3.0 -0.41421356237309581,3.0 2.0))"
};
static std::string buffer_rt_r[2] =
{
"POLYGON((3.7071067811865475 0.29289321881345254,2.7071067811865475 -0.70710678118654746,2.0 -1.4142135623730949,1.2928932188134525 -0.70710678118654746,0.29289321881345254 0.29289321881345254,-0.41421356237309492 1.0,0.29289321881345254 1.7071067811865475,1.2928932188134525 2.7071067811865475,2.0000000000000004 3.4142135623730954,2.7071067811865475 2.7071067811865475,3.7071067811865475 1.7071067811865475,4.4142135623730958 1.0000000000000004,3.7071067811865475 0.29289321881345254))",
"POLYGON((5.7071067811865479 2.2928932188134525,4.7071067811865479 1.2928932188134525,4.4142135623730958 1.0,4.0 1.0,3.0 1.0,1.3819660112501053 1.0,2.1055728090000843 2.4472135954999579,3.1055728090000843 4.4472135954999583,3.7260485282911020 5.6881650340819956,4.7071067811865479 4.7071067811865479,5.7071067811865479 3.7071067811865475,6.4142135623730958 3.0,5.7071067811865479 2.2928932188134525))"
};

View File

@ -38,7 +38,7 @@
template <typename OutputType, typename G1, typename G2>
void test_union(std::string const& caseid, G1 const& g1, G2 const& g2,
std::size_t expected_count, std::size_t expected_hole_count,
std::size_t expected_point_count, double expected_area,
int expected_point_count, double expected_area,
double percentage)
{
typedef typename bg::coordinate_type<G1>::type coordinate_type;
@ -90,13 +90,15 @@ void test_union(std::string const& caseid, G1 const& g1, G2 const& g2,
<< std::endl;
***/
BOOST_CHECK_MESSAGE(std::size_t(n) == expected_point_count,
"union: " << caseid
<< " #points expected: " << expected_point_count
<< " detected: " << n
<< " type: " << string_from_type<coordinate_type>::name()
);
if (expected_point_count >= 0)
{
BOOST_CHECK_MESSAGE(n == expected_point_count,
"union: " << caseid
<< " #points expected: " << expected_point_count
<< " detected: " << n
<< " type: " << string_from_type<coordinate_type>::name()
);
}
BOOST_CHECK_EQUAL(clip.size(), expected_count);
BOOST_CHECK_EQUAL(holes, expected_hole_count);
@ -149,7 +151,7 @@ void test_union(std::string const& caseid, G1 const& g1, G2 const& g2,
template <typename OutputType, typename G1, typename G2>
void test_one(std::string const& caseid, std::string const& wkt1, std::string const& wkt2,
std::size_t expected_count, std::size_t expected_hole_count,
std::size_t expected_point_count, double expected_area,
int expected_point_count, double expected_area,
double percentage = 0.001)
{
G1 g1;

View File

@ -235,12 +235,15 @@ void test_areal()
test_one<Polygon, Polygon, Polygon>("ggl_list_20110716_enrico",
ggl_list_20110716_enrico[0], ggl_list_20110716_enrico[1],
1, 1,
if_typed<ct, double>(18, 17),
if_typed<ct, double>(18, if_typed<ct, float>(15, 17)),
129904.197692871);
test_one<Polygon, Polygon, Polygon>("ggl_list_20110820_christophe",
ggl_list_20110820_christophe[0], ggl_list_20110820_christophe[1],
1, 0, 8, 67.3550722317627);
if_typed<ct, float>(2, 1),
0,
if_typed_tt<ct>(9, 8),
67.3550722317627);
#ifdef TEST_ISOVIST
@ -290,6 +293,36 @@ void test_areal()
1, 0, 13, 13.6569);
test_one<Polygon, Polygon, Polygon>("buffer_rt_i_rev", buffer_rt_i[1], buffer_rt_i[0],
1, 0, 13, 13.6569);
test_one<Polygon, Polygon, Polygon>("buffer_rt_j", buffer_rt_j[0], buffer_rt_j[1],
1, 0, -1, 16.5711);
test_one<Polygon, Polygon, Polygon>("buffer_rt_j_rev", buffer_rt_j[1], buffer_rt_j[0],
1, 0, -1, 16.5711);
test_one<Polygon, Polygon, Polygon>("buffer_rt_l", buffer_rt_l[0], buffer_rt_l[1],
1, 0, -1, 19.3995);
test_one<Polygon, Polygon, Polygon>("buffer_rt_l_rev", buffer_rt_l[1], buffer_rt_l[0],
1, 0, -1, 19.3995);
test_one<Polygon, Polygon, Polygon>("buffer_rt_m1", buffer_rt_m1[0], buffer_rt_m1[1],
1, 0, if_typed_tt<ct>(14, 13), 19.4852);
test_one<Polygon, Polygon, Polygon>("buffer_rt_m1_rev", buffer_rt_m1[1], buffer_rt_m1[0],
1, 0, if_typed_tt<ct>(14, 13), 19.4852);
test_one<Polygon, Polygon, Polygon>("buffer_rt_m2", buffer_rt_m2[0], buffer_rt_m2[1],
1, 0, if_typed_tt<ct>(20, 19), 21.4853);
test_one<Polygon, Polygon, Polygon>("buffer_rt_m2_rev", buffer_rt_m2[1], buffer_rt_m2[0],
1, 0, if_typed_tt<ct>(20, 19), 21.4853);
test_one<Polygon, Polygon, Polygon>("buffer_rt_q", buffer_rt_q[0], buffer_rt_q[1],
1, 0, if_typed<ct, float>(18, 17), 18.5710);
test_one<Polygon, Polygon, Polygon>("buffer_rt_q_rev", buffer_rt_q[1], buffer_rt_q[0],
1, 0, if_typed<ct, float>(18, 17), 18.5710);
test_one<Polygon, Polygon, Polygon>("buffer_rt_r", buffer_rt_r[0], buffer_rt_r[1],
1, 0, if_typed<ct, float>(19, 20), 21.07612);
test_one<Polygon, Polygon, Polygon>("buffer_rt_r_rev", buffer_rt_r[1], buffer_rt_r[0],
1, 0, if_typed_tt<ct>(20, 19), 21.07612);
}
template <typename P>
@ -353,6 +386,10 @@ void test_all()
int test_main(int, char* [])
{
test_all<bg::model::d2::point_xy<double> >();
#if defined(HAVE_TTMATH)
std::cout << "Testing TTMATH" << std::endl;
test_all<bg::model::d2::point_xy<ttmath_big> >();
#endif
#if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE)
test_all<bg::model::d2::point_xy<float> >();