From 4b78a1e1fa322aa9c90c42dd6c3a593d77cead31 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Tue, 10 Feb 2015 15:50:11 +0200 Subject: [PATCH 01/14] [test][algorithms][set operations L/L] add suport for equality testing with a given tolerance --- .../test_set_ops_linear_linear.hpp | 85 +++++++++++++++---- 1 file changed, 67 insertions(+), 18 deletions(-) diff --git a/test/algorithms/set_operations/test_set_ops_linear_linear.hpp b/test/algorithms/set_operations/test_set_ops_linear_linear.hpp index c208f1b74..0ed1d8ac2 100644 --- a/test/algorithms/set_operations/test_set_ops_linear_linear.hpp +++ b/test/algorithms/set_operations/test_set_ops_linear_linear.hpp @@ -72,6 +72,22 @@ struct ls_equal }; +template +struct pt_equal +{ + double m_tolerence; + + pt_equal(double tolerence) : m_tolerence(tolerence) {} + + bool operator()(Point1 const& point1, Point2 const& point2) const + { + // allow for some tolerence in testing equality of points + return std::abs(bg::get<0>(point1) - bg::get<0>(point2)) < m_tolerence + && std::abs(bg::get<1>(point1) - bg::get<1>(point2)) < m_tolerence; + } +}; + + template struct multilinestring_equals { @@ -79,21 +95,33 @@ struct multilinestring_equals struct unique { typedef typename boost::range_value::type Linestring; + typedef typename bg::point_type::type point_type; typedef ls_equal linestring_equal; + typedef pt_equal point_equal; - void operator()(MultiLinestring& mls) + template + void apply_to_range(Range& range, EqualTo const& equal_to) { - mls.erase(std::unique(boost::begin(mls), - boost::end(mls), - linestring_equal()), - boost::end(mls)); + range.erase(std::unique(boost::begin(range), boost::end(range), + equal_to), + boost::end(range)); + } + + void operator()(MultiLinestring& mls, double tolerance) + { + for (typename boost::range_iterator::type it + = boost::begin(mls); it != boost::end(mls); ++it) + { + apply_to_range(*it, point_equal(tolerance)); + } + apply_to_range(mls, linestring_equal()); } }; template struct unique { - void operator()(MultiLinestring&) + void operator()(MultiLinestring&, double) { } }; @@ -101,7 +129,8 @@ struct multilinestring_equals template static inline bool apply(MultiLinestring1 const& multilinestring1, - MultiLinestring2 const& multilinestring2) + MultiLinestring2 const& multilinestring2, + double tolerance) { typedef typename boost::range_iterator < @@ -129,14 +158,27 @@ struct multilinestring_equals typedef ls_less linestring_less; + typedef pt_equal + < + typename boost::range_value + < + typename boost::range_value::type + >::type, + typename boost::range_value + < + typename boost::range_value::type + >::type + > point_equal; + + MultiLinestring1 mls1 = multilinestring1; MultiLinestring2 mls2 = multilinestring2; std::sort(boost::begin(mls1), boost::end(mls1), linestring_less()); std::sort(boost::begin(mls2), boost::end(mls2), linestring_less()); - unique()(mls1); - unique()(mls2); + unique()(mls1, tolerance); + unique()(mls2, tolerance); if ( boost::size(mls1) != boost::size(mls2) ) { @@ -155,7 +197,7 @@ struct multilinestring_equals point2_iterator pit2 = boost::begin(*it2); for (; pit1 != boost::end(*it1); ++pit1, ++pit2) { - if ( !bg::equals(*pit1, *pit2) ) + if (! point_equal(tolerance)(*pit1, *pit2)) { return false; } @@ -209,31 +251,37 @@ private: template static inline bool apply_base(MultiLinestring1 const& multilinestring1, - MultiLinestring2 const& multilinestring2) + MultiLinestring2 const& multilinestring2, + double tolerance) { typedef multilinestring_equals mls_equals; - if ( mls_equals::apply(multilinestring1, multilinestring2) ) + if ( mls_equals::apply(multilinestring1, multilinestring2, tolerance) ) { return true; } MultiLinestring1 reverse_multilinestring1 = multilinestring1; bg::reverse(reverse_multilinestring1); - if ( mls_equals::apply(reverse_multilinestring1, multilinestring2) ) + if ( mls_equals::apply(reverse_multilinestring1, + multilinestring2, + tolerance) ) { return true; } MultiLinestring2 reverse_multilinestring2 = multilinestring2; bg::reverse(reverse_multilinestring2); - if ( mls_equals::apply(multilinestring1, reverse_multilinestring2) ) + if ( mls_equals::apply(multilinestring1, + reverse_multilinestring2, + tolerance) ) { return true; } return mls_equals::apply(reverse_multilinestring1, - reverse_multilinestring2); + reverse_multilinestring2, + tolerance); } @@ -241,7 +289,8 @@ private: public: template static inline bool apply(MultiLinestring1 const& multilinestring1, - MultiLinestring2 const& multilinestring2) + MultiLinestring2 const& multilinestring2, + double tolerance) { #ifndef BOOST_GEOMETRY_ALLOW_ONE_POINT_LINESTRINGS MultiLinestring1 converted_multilinestring1; @@ -251,9 +300,9 @@ public: convert_isolated_points_to_segments (multilinestring2, std::back_inserter(converted_multilinestring2)); return apply_base(converted_multilinestring1, - converted_multilinestring2); + converted_multilinestring2, tolerance); #else - return apply_base(multilinestring1, multilinestring2); + return apply_base(multilinestring1, multilinestring2, tolerance); #endif } }; From 70475d0bbda997c540d5ed1ccff7e139dd7ac69f Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Tue, 10 Feb 2015 15:50:56 +0200 Subject: [PATCH 02/14] [test][algorithms][difference L/L] add support for testing with tolerance --- .../test_difference_linear_linear.hpp | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/test/algorithms/set_operations/difference/test_difference_linear_linear.hpp b/test/algorithms/set_operations/difference/test_difference_linear_linear.hpp index daa037151..a10aa6a86 100644 --- a/test/algorithms/set_operations/difference/test_difference_linear_linear.hpp +++ b/test/algorithms/set_operations/difference/test_difference_linear_linear.hpp @@ -10,6 +10,8 @@ #ifndef BOOST_GEOMETRY_TEST_DIFFERENCE_LINEAR_LINEAR_HPP #define BOOST_GEOMETRY_TEST_DIFFERENCE_LINEAR_LINEAR_HPP +#include + #include #include "../test_set_ops_linear_linear.hpp" #include @@ -34,6 +36,7 @@ private: Geometry2 const& geometry2, MultiLineString const& mls_diff, std::string const& case_id, + double tolerance, bool test_vector_and_deque = true, bool reverse_output_for_checking = false) { @@ -55,8 +58,9 @@ private: bg::reverse(mls_output); } - BOOST_CHECK_MESSAGE( equals::apply(mls_diff, mls_output), - "difference L/L: " << bg::wkt(geometry1) + BOOST_CHECK_MESSAGE( equals::apply(mls_diff, mls_output, tolerance), + "case id: " << case_id + << ", difference L/L: " << bg::wkt(geometry1) << " " << bg::wkt(geometry2) << " -> Expected: " << bg::wkt(mls_diff) << " computed: " << bg::wkt(mls_output) ); @@ -75,11 +79,15 @@ private: bg::difference(geometry1, geometry2, ls_vector_output); bg::difference(geometry1, geometry2, ls_deque_output); - BOOST_CHECK(multilinestring_equals::apply(mls_diff, - ls_vector_output)); + BOOST_CHECK(multilinestring_equals + < + false + >::apply(mls_diff, ls_vector_output, tolerance)); - BOOST_CHECK(multilinestring_equals::apply(mls_diff, - ls_deque_output)); + BOOST_CHECK(multilinestring_equals + < + false + >::apply(mls_diff, ls_deque_output, tolerance)); #ifdef BOOST_GEOMETRY_TEST_DEBUG std::cout << "Done!" << std::endl << std::endl; @@ -103,7 +111,9 @@ public: static inline void apply(Geometry1 const& geometry1, Geometry2 const& geometry2, MultiLineString const& mls_diff, - std::string const& case_id) + std::string const& case_id, + double tolerance + = std::numeric_limits::epsilon()) { #ifdef BOOST_GEOMETRY_TEST_DEBUG std::cout << "test case: " << case_id << std::endl; @@ -128,10 +138,10 @@ public: #endif test_get_turns_ll_invariance<>::apply(rg1, geometry2); - base_test(geometry1, geometry2, mls_diff, case_id); - base_test(geometry1, rg2, mls_diff, case_id, false); - base_test(rg1, geometry2, mls_diff, case_id, false, true); - base_test(rg1, rg2, mls_diff, case_id, false, true); + base_test(geometry1, geometry2, mls_diff, case_id, tolerance); + base_test(geometry1, rg2, mls_diff, case_id, tolerance, false); + base_test(rg1, geometry2, mls_diff, case_id, tolerance, false, true); + base_test(rg1, rg2, mls_diff, case_id, tolerance, false, true); #ifdef BOOST_GEOMETRY_TEST_DEBUG std::cout << std::endl; From 87d714b26395bf99a88c80e0b515ad7dbf7f26ff Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Tue, 10 Feb 2015 15:51:31 +0200 Subject: [PATCH 03/14] [test][algorithms][difference L/L] add more test cases, most guarded by macro because they are currently failing due to rounding errors --- .../difference/difference_linear_linear.cpp | 117 +++++++++++++++++- 1 file changed, 114 insertions(+), 3 deletions(-) diff --git a/test/algorithms/set_operations/difference/difference_linear_linear.cpp b/test/algorithms/set_operations/difference/difference_linear_linear.cpp index 214c6abba..a38af3a49 100644 --- a/test/algorithms/set_operations/difference/difference_linear_linear.cpp +++ b/test/algorithms/set_operations/difference/difference_linear_linear.cpp @@ -510,7 +510,7 @@ BOOST_AUTO_TEST_CASE( test_difference_linestring_linestring ) 1.7441860465116283 1.9302325581395348,\ -0.7692307692307692 2.6483516483516487,\ -2 3,-1.0071942446043165 5.316546762589928)"), - from_wkt("MULTILINESTRING()"), + from_wkt("MULTILINESTRING((8 5,5 1,-2 3,1 10))"), "lldf30a" ); @@ -520,7 +520,10 @@ BOOST_AUTO_TEST_CASE( test_difference_linestring_linestring ) -0.7692307692307692 2.6483516483516487,\ -2 3,-1.0071942446043165 5.316546762589928)"), from_wkt("LINESTRING(8 5,5 1,-2 3,1 10)"), - from_wkt("MULTILINESTRING()"), + from_wkt("MULTILINESTRING((1.9375 1.875,\ + 1.7441860465116283 1.9302325581395348,\ + -0.7692307692307692 2.6483516483516487,\ + -2 3,-1.0071942446043165 5.316546762589928))"), "lldf30b" ); @@ -531,10 +534,84 @@ BOOST_AUTO_TEST_CASE( test_difference_linestring_linestring ) 1.7441860465116283 1.9302325581395348,\ -0.7692307692307692 2.6483516483516487,\ -2 3,-1.0071942446043165 5.316546762589928)"), - from_wkt("MULTILINESTRING()"), + from_wkt("MULTILINESTRING((5 -8,-7 -6,-3 6,-3 1,-5 4,-1 0,8 5,\ + 5 1,-2 3,1 10,8 5,6 2,7 4))"), + "lldf30c" ); #endif + + tester::apply + (from_wkt("LINESTRING(8 1, 4 .4)"), + from_wkt("LINESTRING(0 -.2, 8 1)"), + from_wkt("MULTILINESTRING()"), + "lldf31s" + ); + +#ifdef GEOMETRY_TEST_INCLUDE_FAILING_TESTS + tester::apply + (from_wkt("LINESTRING(8 1, 4 .4,2 8)"), + from_wkt("LINESTRING(0 -.2, 8 1)"), + from_wkt("MULTILINESTRING((4 .4,2 8))"), + "lldf31x" + ); + + tester::apply + (from_wkt("LINESTRING(2 8,4 .4,8 1)"), + from_wkt("LINESTRING(0 -.2, 8 1)"), + from_wkt("MULTILINESTRING((2 8,4 .4))"), + "lldf31x-r" + ); + + tester::apply + (from_wkt("LINESTRING(0 5, 8 1, 4 .4, 2 8)"), + from_wkt("LINESTRING(0 -.2, 8 1, -.5 7)"), + from_wkt("MULTILINESTRING((0 5,8 1),(4 .4,2 8))"), + "lldf31y", + 1e-10 + ); + + tester::apply + (from_wkt("LINESTRING(0 -.2, 8 1, -.5 7)"), + from_wkt("LINESTRING(0 5, 8 1, 4 .4, 2 8)"), + from_wkt("MULTILINESTRING((0 -.2,4 .4),(8 1,-.5 7))"), + "lldf31y-r", + 1e-10 + ); + + tester::apply + (from_wkt("LINESTRING(0 5, 8 1, 4 .4, 2 8)"), + from_wkt("LINESTRING(0 -.2, 8 1, -.5 7, 6 +.2)"), + from_wkt("MULTILINESTRING((0 5,8 1),(4 .4,2 8))"), + "lldf31y+", + 1e-10 + ); +#endif + +#ifdef GEOMETRY_TEST_INCLUDE_FAILING_TESTS + tester::apply + (from_wkt("LINESTRING(10.0002 2,9 -1032.34324, .3 8, 0 5, 8 1, 4 .4, 2 8)"), + from_wkt("LINESTRING(0 -.2, 8 1, -.5 7, 6 +.2)"), + from_wkt("MULTILINESTRING((10.0002 2,9 -1032.34324,.3 8,0 5,8 1),(4 .4,2 8))"), + "lldf31z", + 1e-10 + ); + + tester::apply + (from_wkt("LINESTRING(0 -.2, 8 1, -.5 7, 6 +.2)"), + from_wkt("LINESTRING(10.0002 2,9 -1032.34324, .3 8, 0 5, 8 1, 4 .4, 2 8)"), + from_wkt("MULTILINESTRING((0 -.2,4 .4),(8 1,-.5 7,6 .2))"), + "lldf31z-r", + 1e-10 + ); + + tester::apply + (from_wkt("LINESTRING(0 0, 8 1, -.5 7)"), + from_wkt("LINESTRING(0 5, 8 1, 4 .5, 2 8)"), + from_wkt("MULTILINESTRING((0 0,4 .5),(8 1,-.5 7))"), + "lldf32" + ); +#endif } @@ -1079,6 +1156,40 @@ BOOST_AUTO_TEST_CASE( test_difference_multilinestring_multilinestring ) from_wkt("MULTILINESTRING((0 0,10 0))"), "mlmldf19" ); + +#ifdef GEOMETRY_TEST_INCLUDE_FAILING_TESTS + tester::apply + (from_wkt("MULTILINESTRING((1 5, -4.3 -.1), (0 6, 8.6 6, 189.7654 5, 1 3, 6 3, 3 5, 6 2.232432, 0 4), (-6 5, 1 2.232432), (3 -1032.34324, 9 0, 189.7654 1, -1.4 3, 3 189.7654, +.3 10.0002, 1 5, 6 3, 5 1, 9 1, 10.0002 -1032.34324, -0.7654 0, 5 3, 3 4), (2.232432 2.232432, 8.6 +.4, 0.0 2.232432, 4 0, -8.8 10.0002), (1 0, 6 6, 7 2, -0 8.4), (-0.7654 3, +.6 8, 4 -1032.34324, 1 6, 0 4), (0 7, 2 1, 8 -7, 7 -.7, -1032.34324 9), (5 0, 10.0002 4, 8 7, 3 3, -8.1 5))"), + from_wkt("MULTILINESTRING((5 10.0002, 2 7, -0.7654 0, 5 3), (0 -0.7654, 4 10.0002, 4 +.1, -.8 3, -.1 8, 10.0002 2, +.9 -1032.34324))"), + from_wkt("MULTILINESTRING((1 5,-4.3 -0.1),(0 6,8.6 6,189.7654 5,1 3,6 3,3 5,6 2.232432,0 4),(-6 5,1 2.232432),(5 3,3 4),(3 -1032.34324,9 0,189.7654 1,-1.4 3,3 189.7654,0.3 10.0002,1 5,6 3,5 1,9 1,10.0002 -1032.34324,-0.7654 0),(2.232432 2.232432,8.6 0.4,0 2.232432,4 0,-8.8 10.0002),(1 0,6 6,7 2,-0 8.4),(-0.7654 3,0.6 8,4 -1032.34324,1 6,0 4),(0 7,2 1,8 -7,7 -0.7,-1032.34324 9),(5 0,10.0002 4,8 7,3 3,-8.1 5))"), + "mlmldf24", + 1e-10 + ); + + tester::apply + (from_wkt("MULTILINESTRING((5 10.0002, 2 7, -0.7654 0, 5 3), (0 -0.7654, 4 10.0002, 4 +.1, -.8 3, -.1 8, 10.0002 2, +.9 -1032.34324))"), + from_wkt("MULTILINESTRING((1 5, -4.3 -.1), (0 6, 8.6 6, 189.7654 5, 1 3, 6 3, 3 5, 6 2.232432, 0 4), (-6 5, 1 2.232432), (3 -1032.34324, 9 0, 189.7654 1, -1.4 3, 3 189.7654, +.3 10.0002, 1 5, 6 3, 5 1, 9 1, 10.0002 -1032.34324, -0.7654 0, 5 3, 3 4), (2.232432 2.232432, 8.6 +.4, 0.0 2.232432, 4 0, -8.8 10.0002), (1 0, 6 6, 7 2, -0 8.4), (-0.7654 3, +.6 8, 4 -1032.34324, 1 6, 0 4), (0 7, 2 1, 8 -7, 7 -.7, -1032.34324 9), (5 0, 10.0002 4, 8 7, 3 3, -8.1 5))"), + from_wkt("MULTILINESTRING((5 10.0002,2 7,-0.7654 8.88178e-16),(0 -0.7654,4 10.0002,4 0.1,-0.8 3,-0.1 8,10.0002 2,0.9 -1032.34324))"), + "mlmldf24-r", + 1e-10 + ); + + tester::apply + (from_wkt("MULTILINESTRING((-.4 2, 2.232432 3, 6 9, 8 189.7654, -1032.34324 5.4, 2.232432 9), (-1032.34324 3, 8 -1.6), (0 -.2, 8 1, -.5 7, 6 +.2))"), + from_wkt("MULTILINESTRING((-8 1, 4.8 6, 2 +.5), (10.0002 2,9 -1032.34324, .3 8, 0 5, 8 1, 4 .4, 2 8), (6 7, +.1 7, 0 -.5))"), + from_wkt("MULTILINESTRING((-0.4 2,2.232432 3,6 9,8 189.7654,-1032.34324 5.4,2.232432 9),(-1032.34324 3,8 -1.6),(0 -0.2,4 0.4),(8 1,-0.5 7,6 0.2))"), + "mlmldf25", + 1e-10 + ); + + tester::apply + (from_wkt("MULTILINESTRING((-8 1, 4.8 6, 2 +.5), (10.0002 2,9 -1032.34324, .3 8, 0 5, 8 1, 4 .4, 2 8), (6 7, +.1 7, 0 -.5))"), + from_wkt("MULTILINESTRING((-.4 2, 2.232432 3, 6 9, 8 189.7654, -1032.34324 5.4, 2.232432 9), (-1032.34324 3, 8 -1.6), (0 -.2, 8 1, -.5 7, 6 +.2))"), + from_wkt("MULTILINESTRING((-8 1,4.8 6,2 0.5),(10.0002 2,9 -1032.34324,0.3 8,0 5,8 1),(4 0.4,2 8),(6 7,0.1 7,0 -0.5))"), + "mlmldf25-r", + 1e-10 + ); +#endif } From e131358c9ef0471e3b94ec80ea7bf4fba72716cd Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Tue, 10 Feb 2015 16:04:12 +0200 Subject: [PATCH 04/14] [test][algorithms][union L/L] add support for checking equality with tolerance --- .../union/test_union_linear_linear.hpp | 38 ++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/test/algorithms/set_operations/union/test_union_linear_linear.hpp b/test/algorithms/set_operations/union/test_union_linear_linear.hpp index 2fd16fbfb..b92c537a3 100644 --- a/test/algorithms/set_operations/union/test_union_linear_linear.hpp +++ b/test/algorithms/set_operations/union/test_union_linear_linear.hpp @@ -35,6 +35,7 @@ private: MultiLineString const& mls_union1, MultiLineString const& mls_union2, std::string const& case_id, + double tolerance, bool test_vector_and_deque = false) { static bool vector_deque_already_tested = false; @@ -50,8 +51,9 @@ private: bg::union_(geometry1, geometry2, mls_output); - BOOST_CHECK_MESSAGE( equals::apply(mls_union1, mls_output), - "union L/L: " << bg::wkt(geometry1) + BOOST_CHECK_MESSAGE( equals::apply(mls_union1, mls_output, tolerance), + "case id: " << case_id + << ", union L/L: " << bg::wkt(geometry1) << " " << bg::wkt(geometry2) << " -> Expected: " << bg::wkt(mls_union1) << " computed: " << bg::wkt(mls_output) ); @@ -82,11 +84,15 @@ private: bg::union_(geometry1, geometry2, ls_vector_output); bg::union_(geometry1, geometry2, ls_deque_output); - BOOST_CHECK(multilinestring_equals::apply(mls_union1, - ls_vector_output)); + BOOST_CHECK(multilinestring_equals + < + false + >::apply(mls_union1, ls_vector_output, tolerance)); - BOOST_CHECK(multilinestring_equals::apply(mls_union1, - ls_deque_output)); + BOOST_CHECK(multilinestring_equals + < + false + >::apply(mls_union1, ls_deque_output, tolerance)); #ifdef BOOST_GEOMETRY_TEST_DEBUG std::cout << "Done!" << std::endl << std::endl; @@ -98,8 +104,9 @@ private: bg::clear(mls_output); bg::union_(geometry2, geometry1, mls_output); - BOOST_CHECK_MESSAGE( equals::apply(mls_union2, mls_output), - "union L/L: " << bg::wkt(geometry2) + BOOST_CHECK_MESSAGE( equals::apply(mls_union2, mls_output, tolerance), + "case id: " << case_id + << ", union L/L: " << bg::wkt(geometry2) << " " << bg::wkt(geometry1) << " -> Expected: " << bg::wkt(mls_union2) << " computed: " << bg::wkt(mls_output) ); @@ -123,7 +130,9 @@ public: Geometry2 const& geometry2, MultiLineString const& mls_union1, MultiLineString const& mls_union2, - std::string const& case_id) + std::string const& case_id, + double tolerance + = std::numeric_limits::epsilon()) { #ifdef BOOST_GEOMETRY_TEST_DEBUG std::cout << "test case: " << case_id << std::endl; @@ -146,10 +155,11 @@ public: #endif test_get_turns_ll_invariance<>::apply(rg1, geometry2); - base_test(geometry1, geometry2, mls_union1, mls_union2, case_id, true); + base_test(geometry1, geometry2, mls_union1, mls_union2, + case_id, tolerance, true); // base_test(geometry1, rg2, mls_sym_diff); // base_test(rg1, geometry2, mls_sym_diff); - base_test(rg1, rg2, mls_union1, mls_union2, case_id); + base_test(rg1, rg2, mls_union1, mls_union2, case_id, tolerance); #ifdef BOOST_GEOMETRY_TEST_DEBUG std::cout << std::endl; @@ -161,9 +171,11 @@ public: static inline void apply(Geometry1 const& geometry1, Geometry2 const& geometry2, MultiLineString const& mls_union, - std::string const& case_id) + std::string const& case_id, + double tolerance + = std::numeric_limits::epsilon()) { - apply(geometry1, geometry2, mls_union, mls_union, case_id); + apply(geometry1, geometry2, mls_union, mls_union, case_id, tolerance); } }; From a4988e34a365a3bf156cfa624e664329283107ed Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Tue, 10 Feb 2015 16:13:11 +0200 Subject: [PATCH 05/14] [test][algorithms][union L/L] add missing include --- .../set_operations/union/test_union_linear_linear.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/algorithms/set_operations/union/test_union_linear_linear.hpp b/test/algorithms/set_operations/union/test_union_linear_linear.hpp index b92c537a3..a36e3298b 100644 --- a/test/algorithms/set_operations/union/test_union_linear_linear.hpp +++ b/test/algorithms/set_operations/union/test_union_linear_linear.hpp @@ -10,6 +10,8 @@ #ifndef BOOST_GEOMETRY_TEST_UNION_LINEAR_LINEAR_HPP #define BOOST_GEOMETRY_TEST_UNION_LINEAR_LINEAR_HPP +#include + #include #include "../test_set_ops_linear_linear.hpp" #include From 4ae803e734ed680396fa01e47a0617f68725ee52 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Tue, 10 Feb 2015 17:08:08 +0200 Subject: [PATCH 06/14] [test][algorithms][sym_difference L/L] add support for checking equality with a tolerance --- .../test_sym_difference_linear_linear.hpp | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/test/algorithms/set_operations/sym_difference/test_sym_difference_linear_linear.hpp b/test/algorithms/set_operations/sym_difference/test_sym_difference_linear_linear.hpp index 69c82403e..2cf6917a8 100644 --- a/test/algorithms/set_operations/sym_difference/test_sym_difference_linear_linear.hpp +++ b/test/algorithms/set_operations/sym_difference/test_sym_difference_linear_linear.hpp @@ -10,6 +10,8 @@ #ifndef BOOST_GEOMETRY_TEST_SYM_DIFFERENCE_LINEAR_LINEAR_HPP #define BOOST_GEOMETRY_TEST_SYM_DIFFERENCE_LINEAR_LINEAR_HPP +#include + #include #include "../test_set_ops_linear_linear.hpp" #include @@ -34,6 +36,7 @@ private: Geometry2 const& geometry2, MultiLineString const& mls_sym_diff, std::string const& case_id, + double tolerance, bool test_vector_and_deque = false) { static bool vector_deque_already_tested = false; @@ -49,8 +52,9 @@ private: bg::sym_difference(geometry1, geometry2, mls_output); - BOOST_CHECK_MESSAGE( equals::apply(mls_sym_diff, mls_output), - "sym diff L/L: " << bg::wkt(geometry1) + BOOST_CHECK_MESSAGE( equals::apply(mls_sym_diff, mls_output, tolerance), + "case id: " << case_id + << ", sym diff L/L: " << bg::wkt(geometry1) << " " << bg::wkt(geometry2) << " -> Expected: " << bg::wkt(mls_sym_diff) << " computed: " << bg::wkt(mls_output) ); @@ -82,11 +86,15 @@ private: bg::sym_difference(geometry1, geometry2, ls_vector_output); bg::sym_difference(geometry1, geometry2, ls_deque_output); - BOOST_CHECK(multilinestring_equals::apply(mls_sym_diff, - ls_vector_output)); + BOOST_CHECK(multilinestring_equals + < + false + >::apply(mls_sym_diff, ls_vector_output, tolerance)); - BOOST_CHECK(multilinestring_equals::apply(mls_sym_diff, - ls_deque_output)); + BOOST_CHECK(multilinestring_equals + < + false + >::apply(mls_sym_diff, ls_deque_output, tolerance)); #ifdef BOOST_GEOMETRY_TEST_DEBUG std::cout << "Done!" << std::endl << std::endl; @@ -98,8 +106,9 @@ private: bg::clear(mls_output); bg::sym_difference(geometry2, geometry1, mls_output); - BOOST_CHECK_MESSAGE( equals::apply(mls_sym_diff, mls_output), - "sym diff L/L: " << bg::wkt(geometry2) + BOOST_CHECK_MESSAGE( equals::apply(mls_sym_diff, mls_output, tolerance), + "case id: " << case_id + << ", sym diff L/L: " << bg::wkt(geometry2) << " " << bg::wkt(geometry1) << " -> Expected: " << bg::wkt(mls_sym_diff) << " computed: " << bg::wkt(mls_output) ); @@ -122,7 +131,9 @@ public: static inline void apply(Geometry1 const& geometry1, Geometry2 const& geometry2, MultiLineString const& mls_sym_diff, - std::string const& case_id) + std::string const& case_id, + double tolerance + = std::numeric_limits::epsilon()) { #ifdef BOOST_GEOMETRY_TEST_DEBUG std::cout << "test case: " << case_id << std::endl; @@ -147,10 +158,10 @@ public: #endif test_get_turns_ll_invariance<>::apply(rg1, geometry2); - base_test(geometry1, geometry2, mls_sym_diff, case_id, true); + base_test(geometry1, geometry2, mls_sym_diff, case_id, tolerance, true); // base_test(geometry1, rg2, mls_sym_diff); // base_test(rg1, geometry2, mls_sym_diff); - base_test(rg1, rg2, mls_sym_diff, case_id); + base_test(rg1, rg2, mls_sym_diff, case_id, tolerance); #ifdef BOOST_GEOMETRY_TEST_DEBUG std::cout << std::endl; From bcb52c4f47a8259710a5bba157f0fc3c514da889 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Tue, 10 Feb 2015 17:10:47 +0200 Subject: [PATCH 07/14] [test][algorithms][set operations L/L] update copyright year --- .../set_operations/difference/difference_linear_linear.cpp | 2 +- .../set_operations/difference/test_difference_linear_linear.hpp | 2 +- .../sym_difference/test_sym_difference_linear_linear.hpp | 2 +- .../set_operations/union/test_union_linear_linear.hpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/algorithms/set_operations/difference/difference_linear_linear.cpp b/test/algorithms/set_operations/difference/difference_linear_linear.cpp index a38af3a49..b1ae1a21b 100644 --- a/test/algorithms/set_operations/difference/difference_linear_linear.cpp +++ b/test/algorithms/set_operations/difference/difference_linear_linear.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html diff --git a/test/algorithms/set_operations/difference/test_difference_linear_linear.hpp b/test/algorithms/set_operations/difference/test_difference_linear_linear.hpp index a10aa6a86..cbfd9fa5d 100644 --- a/test/algorithms/set_operations/difference/test_difference_linear_linear.hpp +++ b/test/algorithms/set_operations/difference/test_difference_linear_linear.hpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html diff --git a/test/algorithms/set_operations/sym_difference/test_sym_difference_linear_linear.hpp b/test/algorithms/set_operations/sym_difference/test_sym_difference_linear_linear.hpp index 2cf6917a8..3676fd9a2 100644 --- a/test/algorithms/set_operations/sym_difference/test_sym_difference_linear_linear.hpp +++ b/test/algorithms/set_operations/sym_difference/test_sym_difference_linear_linear.hpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html diff --git a/test/algorithms/set_operations/union/test_union_linear_linear.hpp b/test/algorithms/set_operations/union/test_union_linear_linear.hpp index a36e3298b..1b6dda37c 100644 --- a/test/algorithms/set_operations/union/test_union_linear_linear.hpp +++ b/test/algorithms/set_operations/union/test_union_linear_linear.hpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html From b39342db0200f7c78f54c0aae61a1eb268101458 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Tue, 10 Feb 2015 17:13:47 +0200 Subject: [PATCH 08/14] [test][algorithms][sym_difference L/L] enable disabled test that now works correctly; update copyright year; --- .../sym_difference/sym_difference_linear_linear.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/test/algorithms/set_operations/sym_difference/sym_difference_linear_linear.cpp b/test/algorithms/set_operations/sym_difference/sym_difference_linear_linear.cpp index bc72e1037..7530a36eb 100644 --- a/test/algorithms/set_operations/sym_difference/sym_difference_linear_linear.cpp +++ b/test/algorithms/set_operations/sym_difference/sym_difference_linear_linear.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015 Oracle and/or its affiliates. // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html @@ -787,9 +787,6 @@ BOOST_AUTO_TEST_CASE( test_sym_difference_multilinestring_multilinestring ) "mlmlsdf05" ); -#ifdef GEOMETRY_TEST_INCLUDE_FAILING_TESTS - // the following produces an assertion failure in line 483 of - // get_turn_info_ll tester::apply (from_wkt("MULTILINESTRING((0 0,10 0,20 1),(1 0,7 0),\ (10 10,20 10,30 20))"), @@ -802,7 +799,6 @@ BOOST_AUTO_TEST_CASE( test_sym_difference_multilinestring_multilinestring ) (10 20,15 10),(20 10,25 10,30 15))"), "mlmlsdf06" ); -#endif tester::apply (from_wkt("MULTILINESTRING((0 0,10 0,20 10),(1 0,7 0),\ From b0b40ffa261d06c8e5a1cd8910766787dd9f1c9d Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Tue, 10 Feb 2015 17:14:34 +0200 Subject: [PATCH 09/14] [test][algorithms][set operations L/L] update copyright year --- test/algorithms/set_operations/test_set_ops_linear_linear.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/algorithms/set_operations/test_set_ops_linear_linear.hpp b/test/algorithms/set_operations/test_set_ops_linear_linear.hpp index 0ed1d8ac2..831759312 100644 --- a/test/algorithms/set_operations/test_set_ops_linear_linear.hpp +++ b/test/algorithms/set_operations/test_set_ops_linear_linear.hpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html From 34eef73263e6543220cb9df425050b55e9663898 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Tue, 10 Feb 2015 17:24:28 +0200 Subject: [PATCH 10/14] [test][algorithms][sym_difference L/L] update disabled (failing example) --- .../sym_difference_linear_linear.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/test/algorithms/set_operations/sym_difference/sym_difference_linear_linear.cpp b/test/algorithms/set_operations/sym_difference/sym_difference_linear_linear.cpp index 7530a36eb..edda825e8 100644 --- a/test/algorithms/set_operations/sym_difference/sym_difference_linear_linear.cpp +++ b/test/algorithms/set_operations/sym_difference/sym_difference_linear_linear.cpp @@ -636,20 +636,14 @@ BOOST_AUTO_TEST_CASE( test_sym_difference_linestring_multilinestring ) (-1032.34324 4,1 5,9 7,3 9,0.2 5,1 -0.3),\ (1 0.9,1 6,1 -0.6,2.232432 -0.7654,0.9 3,1 5,\ -0.7654 9,3 0.1,9 0,-6 8,-0.7 8,0 1,-1032.34324 0))"), - /* - from_wkt("MULTILINESTRING((-0.7654 2,2 5),\ - (1 -0.3,0.2 5,3 9,9 7,1 5,-1032.34 4),\ - (-1032.34 0,0 1,-0.7 8,-6 8,9 0,3 0.1,\ - -0.7654 9,1 5,0.9 3,2.23243 -0.7654,1 -0.6),\ - (-0.7654 3,2 5,1 189.765,1 6),\ - (1 -0.6,1 -1.1,4 2,1 5))"), - */ - from_wkt("MULTILINESTRING((1 5,4 2,1 -1.1,1 -0.6),\ - (1 6,1 189.7654,2 5,-0.7654 3),(2 5,-0.7654 2),\ + from_wkt("MULTILINESTRING((2 5,-0.7654 2),\ (-1032.34324 4,1 5,9 7,3 9,0.2 5,1 -0.3),\ (1 -0.6,2.232432 -0.7654,0.9 3,1 5,-0.7654 9,\ - 3 0.1,9 0,-6 8,-0.7 8,0 1,-1032.34324 0))"), - "lmlsdf19" + 3 0.1,9 0,-6 8,-0.7 8,0 1,-1032.34324 0),\ + (1 5,4 2,1 -1.1,1 -0.6),\ + (1 6,1 189.7654,2 5,-0.7654 3))"), + "lmlsdf19", + 1e-10 ); #endif } From e4ea5defa31140a9fffdd37486050247afe04c2e Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Tue, 10 Feb 2015 23:36:12 +0200 Subject: [PATCH 11/14] [test][algorithms][intersection L/L] add support for checking equality within a specified tolerance --- .../test_intersection_linear_linear.hpp | 52 ++++++++++++------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/test/algorithms/set_operations/intersection/test_intersection_linear_linear.hpp b/test/algorithms/set_operations/intersection/test_intersection_linear_linear.hpp index bc378f932..8e9254040 100644 --- a/test/algorithms/set_operations/intersection/test_intersection_linear_linear.hpp +++ b/test/algorithms/set_operations/intersection/test_intersection_linear_linear.hpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html @@ -10,6 +10,8 @@ #ifndef BOOST_GEOMETRY_TEST_INTERSECTION_LINEAR_LINEAR_HPP #define BOOST_GEOMETRY_TEST_INTERSECTION_LINEAR_LINEAR_HPP +#include + #include #include #include "../test_set_ops_linear_linear.hpp" @@ -36,6 +38,7 @@ private: MultiLineString const& mls_int1, MultiLineString const& mls_int2, std::string const& case_id, + double tolerance, bool test_vector_and_deque = false) { static bool vector_deque_already_tested = false; @@ -51,9 +54,10 @@ private: bg::intersection(geometry1, geometry2, mls_output); - BOOST_CHECK_MESSAGE( equals::apply(mls_int1, mls_output) - || equals::apply(mls_int2, mls_output), - "intersection L/L: " << bg::wkt(geometry1) + BOOST_CHECK_MESSAGE( equals::apply(mls_int1, mls_output, tolerance) + || equals::apply(mls_int2, mls_output, tolerance), + "case id: " << case_id + << ", intersection L/L: " << bg::wkt(geometry1) << " " << bg::wkt(geometry2) << " -> Expected: " << bg::wkt(mls_int1) << " or: " << bg::wkt(mls_int2) @@ -84,11 +88,15 @@ private: bg::intersection(geometry1, geometry2, ls_vector_output); bg::intersection(geometry1, geometry2, ls_deque_output); - BOOST_CHECK(multilinestring_equals::apply(mls_int1, - ls_vector_output)); + BOOST_CHECK(multilinestring_equals + < + false + >::apply(mls_int1, ls_vector_output, tolerance)); - BOOST_CHECK(multilinestring_equals::apply(mls_int1, - ls_deque_output)); + BOOST_CHECK(multilinestring_equals + < + false + >::apply(mls_int1, ls_deque_output, tolerance)); #ifdef BOOST_GEOMETRY_TEST_DEBUG std::cout << "Done!" << std::endl << std::endl; @@ -100,9 +108,10 @@ private: bg::clear(mls_output); bg::intersection(geometry2, geometry1, mls_output); - BOOST_CHECK_MESSAGE( equals::apply(mls_int1, mls_output) - || equals::apply(mls_int2, mls_output), - "intersection L/L: " << bg::wkt(geometry1) + BOOST_CHECK_MESSAGE( equals::apply(mls_int1, mls_output, tolerance) + || equals::apply(mls_int2, mls_output, tolerance), + "case id: " << case_id + << ", intersection L/L: " << bg::wkt(geometry1) << " " << bg::wkt(geometry2) << " -> Expected: " << bg::wkt(mls_int1) << " or: " << bg::wkt(mls_int2) @@ -121,10 +130,10 @@ private: #endif } +#ifdef BOOST_GEOMETRY_TEST_DEBUG static inline void base_test_all(Geometry1 const& geometry1, Geometry2 const& geometry2) { - //typedef typename boost::range_value::type LineString; typedef typename bg::point_type::type Point; typedef bg::model::multi_point multi_point; @@ -136,7 +145,6 @@ private: bg::intersection(geometry2, geometry1, mls21_output); bg::intersection(geometry2, geometry1, mp21_output); -#ifdef BOOST_GEOMETRY_TEST_DEBUG std::cout << "************************************" << std::endl; std::cout << "Geometry #1: " << bg::wkt(geometry1) << std::endl; std::cout << "Geometry #2: " << bg::wkt(geometry2) << std::endl; @@ -153,8 +161,12 @@ private: std::cout << "************************************" << std::endl; std::cout << std::endl; std::cout << std::endl; -#endif } +#else + static inline void base_test_all(Geometry1 const&, Geometry2 const&) + { + } +#endif public: @@ -162,7 +174,9 @@ public: Geometry2 const& geometry2, MultiLineString const& mls_int1, MultiLineString const& mls_int2, - std::string const& case_id) + std::string const& case_id, + double tolerance + = std::numeric_limits::epsilon()) { #ifdef BOOST_GEOMETRY_TEST_DEBUG std::cout << "test case: " << case_id << std::endl; @@ -188,7 +202,7 @@ public: test_get_turns_ll_invariance<>::apply(rg1, geometry2); - base_test(geometry1, geometry2, mls_int1, mls_int2, case_id); + base_test(geometry1, geometry2, mls_int1, mls_int2, case_id, tolerance); // base_test(rg1, rg2, mls_int1, mls_int2); base_test_all(geometry1, geometry2); @@ -203,9 +217,11 @@ public: static inline void apply(Geometry1 const& geometry1, Geometry2 const& geometry2, MultiLineString const& mls_int, - std::string const& case_id) + std::string const& case_id, + double tolerance + = std::numeric_limits::epsilon()) { - apply(geometry1, geometry2, mls_int, mls_int, case_id); + apply(geometry1, geometry2, mls_int, mls_int, case_id, tolerance); } }; From fe44edfce392423e053e96d14cce1f151050d76f Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Tue, 10 Feb 2015 23:37:34 +0200 Subject: [PATCH 12/14] [test][algorithms][intersection L/L] add one more test case --- .../intersection_linear_linear.cpp | 76 ++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-) diff --git a/test/algorithms/set_operations/intersection/intersection_linear_linear.cpp b/test/algorithms/set_operations/intersection/intersection_linear_linear.cpp index d4cb22a73..2e020120c 100644 --- a/test/algorithms/set_operations/intersection/intersection_linear_linear.cpp +++ b/test/algorithms/set_operations/intersection/intersection_linear_linear.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html @@ -1267,6 +1267,80 @@ BOOST_AUTO_TEST_CASE( test_intersection_ml_ml_degenerate ) #endif "mlmli20e" ); + + tester::apply + (from_wkt("MULTILINESTRING((1 5, -4.3 -.1), (0 6, 8.6 6, 189.7654 5, 1 3, 6 3, 3 5, 6 2.232432, 0 4), (-6 5, 1 2.232432), (3 -1032.34324, 9 0, 189.7654 1, -1.4 3, 3 189.7654, +.3 10.0002, 1 5, 6 3, 5 1, 9 1, 10.0002 -1032.34324, -0.7654 0, 5 3, 3 4), (2.232432 2.232432, 8.6 +.4, 0.0 2.232432, 4 0, -8.8 10.0002), (1 0, 6 6, 7 2, -0 8.4), (-0.7654 3, +.6 8, 4 -1032.34324, 1 6, 0 4), (0 7, 2 1, 8 -7, 7 -.7, -1032.34324 9), (5 0, 10.0002 4, 8 7, 3 3, -8.1 5))"), + from_wkt("MULTILINESTRING((5 10.0002, 2 7, -0.7654 0, 5 3), (0 -0.7654, 4 10.0002, 4 +.1, -.8 3, -.1 8, 10.0002 2, +.9 -1032.34324))"), + from_wkt("MULTILINESTRING((-0.756651 3.30964),(1.60494 6),\ + (2.51371 6),(3.26673 6),(4 6),(8.18862 3.07616),\ + (4 3.03179),(1.40063 3.00424),(1.39905 3),\ + (4 3),(5 3),(4 4.33333),(4 4.07748),\ + (4.41962 2.698),(4 2.82162),(1.59592 3.52985),\ + (0.729883 3.78498),(-0.532243 2.83823),\ + (0.235887 2.53454),(7.08745 -329.0674155),\ + (9.98265 0.00543606),(8.49103 2.89652),\ + (4.87386 2.93436),(4 2.9435),(1.38821 2.97083)\ + (0.412281 2.98104),(-0.789427 2.99361),\ + (0.641699 7.5594),(1.18124 4.9275),\ + (1.99437 4.60225),(4 3.8),(9.09826 -100.515944),\ + (5.06428 -559.024344),\ + (4 3.5),(3.06464 1.99294),(4 1.72377),\ + (4 1.38014),(2.50083 1.69957),(1.03214 2.01251),\ + (0.72677 2.07758),(0.10749 2.20953),\ + (0.0954852 2.17914),(0.92255 1.71755),\ + (1.70073 1.28324),(3.43534 0.441146),\ + (2.09493 1.48836),(1.12031 2.2498),\ + (0.358522 2.84496),(-0.705343 3.67612),\ + (2.06005 1.27206),(2.3516 1.62191),(4 3.6),\ + (5.09496 4.91395),(6.47672 4.09311),(4 4.74286),\ + (2.54193 6.07595),(1.87562 6.68515),\ + (1.43457 7.08839),(0.502294 7.64221),\ + (0.601362 7.58336),(0.614728 3.49349),\ + (0.619143 2.1426),(0.623165 0.911787),\ + (0.623783 0.722855),(3.16036 -775.427199),\ + (3.23365 -767.0972558),(1.01466 0.926246),\ + (1.01183 1.90535),(1.01168 1.95744),\ + (1.00439 4.47984),(0.91526 4.25422),\ + (1.36441 2.90677),(1.8713 1.38609),\ + (1.87531 1.37408),(0.0484053 -0.635122),\ + (8.5655 2.85228),(5.26567 4.81254),(4 3.8),\ + (1.4995 3.27036),(0.591231 3.43401),\ + (-0.706503 3.66784),\ + (-0.7654 8.88178e-16,-0.7654 0,5 3))"), + from_wkt("MULTILINESTRING((1.87562 6.68515),(1.60494 6),\ + (1.18124 4.9275),(1.00439 4.47984),(0.91526 4.25422),\ + (0.729883 3.78498),(0.614728 3.49349),\ + (0.591231 3.43401),(0.412281 2.98104),\ + (0.358522 2.84496),(0.235887 2.53454),\ + (0.10749 2.20953),(0.0954852 2.17914),\ + (5 3),(0.0484053 -0.635122),(0.535994 0.677175),\ + (0.623165 0.911787),(0.92255 1.71755),\ + (1.01168 1.95744),(1.03214 2.01251),\ + (1.12031 2.2498),(1.36441 2.90677),\ + (1.38821 2.97083),(1.39905 3),(1.40063 3.00424),\ + (1.4995 3.27036),(1.59592 3.52985),\ + (1.99437 4.60225),(2.51371 6),(2.54193 6.07595),\ + (4 6),(4 4.74286),(4 4.33333),(4 4.07748),(4 3.8),\ + (4 3.8),(4 3.6),(4 3.5),(4 3.03179),(4 3),\ + (4 2.9435),(4 2.82162),(4 2.47965),(4 1.72377),\ + (4 1.38014),(3.43534 0.441146),(2.06005 1.27206),\ + (1.88383 1.37852),(1.8713 1.38609),\ + (1.01183 1.90535),(0.72677 2.07758),\ + (0.619143 2.1426),(-0.532243 2.83823),\ + (-0.789427 2.99361),(-0.756651 3.30964),\ + (-0.706503 3.66784),(-0.705343 3.67612),\ + (0.502294 7.64221),(0.601362 7.58336),\ + (0.641699 7.5594),(1.43457 7.08839),\ + (3.26673 6),(5.09496 4.91395),(5.26567 4.81254),\ + (6.47672 4.09311),(8.18862 3.07616),\ + (8.49103 2.89652),(8.5655 2.85228),\ + (9.98265 0.00543606),(9.09826 -100.515944),\ + (7.08745 -329.0674155),(5.06428 -559.024344),\ + (3.23365 -767.0972558),(3.16036 -775.427199),\ + (-0.7654 8.88178e-16,-0.7654 0,5 3))"), + "mlmli21", + 1e-5 + ); } #endif // BOOST_GEOMETRY_TEST_NO_DEGENERATE From b4c34417b0c1667dd9ffd8549acea57f488170f9 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Tue, 10 Feb 2015 23:49:17 +0200 Subject: [PATCH 13/14] [test][algorithms][intersection L/L] add result when omitting isolated intersection points --- .../intersection/intersection_linear_linear.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/algorithms/set_operations/intersection/intersection_linear_linear.cpp b/test/algorithms/set_operations/intersection/intersection_linear_linear.cpp index 2e020120c..790dae8bd 100644 --- a/test/algorithms/set_operations/intersection/intersection_linear_linear.cpp +++ b/test/algorithms/set_operations/intersection/intersection_linear_linear.cpp @@ -1271,6 +1271,9 @@ BOOST_AUTO_TEST_CASE( test_intersection_ml_ml_degenerate ) tester::apply (from_wkt("MULTILINESTRING((1 5, -4.3 -.1), (0 6, 8.6 6, 189.7654 5, 1 3, 6 3, 3 5, 6 2.232432, 0 4), (-6 5, 1 2.232432), (3 -1032.34324, 9 0, 189.7654 1, -1.4 3, 3 189.7654, +.3 10.0002, 1 5, 6 3, 5 1, 9 1, 10.0002 -1032.34324, -0.7654 0, 5 3, 3 4), (2.232432 2.232432, 8.6 +.4, 0.0 2.232432, 4 0, -8.8 10.0002), (1 0, 6 6, 7 2, -0 8.4), (-0.7654 3, +.6 8, 4 -1032.34324, 1 6, 0 4), (0 7, 2 1, 8 -7, 7 -.7, -1032.34324 9), (5 0, 10.0002 4, 8 7, 3 3, -8.1 5))"), from_wkt("MULTILINESTRING((5 10.0002, 2 7, -0.7654 0, 5 3), (0 -0.7654, 4 10.0002, 4 +.1, -.8 3, -.1 8, 10.0002 2, +.9 -1032.34324))"), +#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS + from_wkt("MULTILINESTRING((-0.7654 8.88178e-16,-0.7654 0,5 3))"), +#else from_wkt("MULTILINESTRING((-0.756651 3.30964),(1.60494 6),\ (2.51371 6),(3.26673 6),(4 6),(8.18862 3.07616),\ (4 3.03179),(1.40063 3.00424),(1.39905 3),\ @@ -1338,6 +1341,7 @@ BOOST_AUTO_TEST_CASE( test_intersection_ml_ml_degenerate ) (7.08745 -329.0674155),(5.06428 -559.024344),\ (3.23365 -767.0972558),(3.16036 -775.427199),\ (-0.7654 8.88178e-16,-0.7654 0,5 3))"), +#endif "mlmli21", 1e-5 ); From b7ccd1f03e36980d39c78fe84b76a72d682dbba7 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Wed, 11 Feb 2015 00:22:07 +0200 Subject: [PATCH 14/14] [test][algorithms][set operations L/L] replace absoute tolerance by relative tolerance --- .../intersection_linear_linear.cpp | 2 +- .../test_set_ops_linear_linear.hpp | 21 ++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/test/algorithms/set_operations/intersection/intersection_linear_linear.cpp b/test/algorithms/set_operations/intersection/intersection_linear_linear.cpp index 790dae8bd..0102edc5c 100644 --- a/test/algorithms/set_operations/intersection/intersection_linear_linear.cpp +++ b/test/algorithms/set_operations/intersection/intersection_linear_linear.cpp @@ -1343,7 +1343,7 @@ BOOST_AUTO_TEST_CASE( test_intersection_ml_ml_degenerate ) (-0.7654 8.88178e-16,-0.7654 0,5 3))"), #endif "mlmli21", - 1e-5 + 1e-4 ); } #endif // BOOST_GEOMETRY_TEST_NO_DEGENERATE diff --git a/test/algorithms/set_operations/test_set_ops_linear_linear.hpp b/test/algorithms/set_operations/test_set_ops_linear_linear.hpp index 831759312..884b5028a 100644 --- a/test/algorithms/set_operations/test_set_ops_linear_linear.hpp +++ b/test/algorithms/set_operations/test_set_ops_linear_linear.hpp @@ -73,17 +73,32 @@ struct ls_equal template -struct pt_equal +class pt_equal { +private: double m_tolerence; + template + static inline T const& get_max(T const& a, T const& b, T const& c) + { + return (std::max)((std::max)(a, b), c); + } + + template + static inline bool check_close(T const& a, T const& b, T const& tol) + { + return (a == b) + || (std::abs(a - b) <= tol * get_max(std::abs(a), std::abs(b), 1.0)); + } + +public: pt_equal(double tolerence) : m_tolerence(tolerence) {} bool operator()(Point1 const& point1, Point2 const& point2) const { // allow for some tolerence in testing equality of points - return std::abs(bg::get<0>(point1) - bg::get<0>(point2)) < m_tolerence - && std::abs(bg::get<1>(point1) - bg::get<1>(point2)) < m_tolerence; + return check_close(bg::get<0>(point1), bg::get<0>(point2), m_tolerence) + && check_close(bg::get<1>(point1), bg::get<1>(point2), m_tolerence); } };