Merge pull request #214 from mkaravel/fix/set_ops_ll_add_test_cases_and_tolerance

Fix/set ops ll add test cases and tolerance
This commit is contained in:
Adam Wulkiewicz
2015-02-11 14:06:11 +01:00
8 changed files with 391 additions and 97 deletions

View File

@@ -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
@@ -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<ML>("MULTILINESTRING()"),
from_wkt<ML>("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<L>("LINESTRING(8 5,5 1,-2 3,1 10)"),
from_wkt<ML>("MULTILINESTRING()"),
from_wkt<ML>("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<ML>("MULTILINESTRING()"),
from_wkt<ML>("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<L>("LINESTRING(8 1, 4 .4)"),
from_wkt<L>("LINESTRING(0 -.2, 8 1)"),
from_wkt<ML>("MULTILINESTRING()"),
"lldf31s"
);
#ifdef GEOMETRY_TEST_INCLUDE_FAILING_TESTS
tester::apply
(from_wkt<L>("LINESTRING(8 1, 4 .4,2 8)"),
from_wkt<L>("LINESTRING(0 -.2, 8 1)"),
from_wkt<ML>("MULTILINESTRING((4 .4,2 8))"),
"lldf31x"
);
tester::apply
(from_wkt<L>("LINESTRING(2 8,4 .4,8 1)"),
from_wkt<L>("LINESTRING(0 -.2, 8 1)"),
from_wkt<ML>("MULTILINESTRING((2 8,4 .4))"),
"lldf31x-r"
);
tester::apply
(from_wkt<L>("LINESTRING(0 5, 8 1, 4 .4, 2 8)"),
from_wkt<L>("LINESTRING(0 -.2, 8 1, -.5 7)"),
from_wkt<ML>("MULTILINESTRING((0 5,8 1),(4 .4,2 8))"),
"lldf31y",
1e-10
);
tester::apply
(from_wkt<L>("LINESTRING(0 -.2, 8 1, -.5 7)"),
from_wkt<L>("LINESTRING(0 5, 8 1, 4 .4, 2 8)"),
from_wkt<ML>("MULTILINESTRING((0 -.2,4 .4),(8 1,-.5 7))"),
"lldf31y-r",
1e-10
);
tester::apply
(from_wkt<L>("LINESTRING(0 5, 8 1, 4 .4, 2 8)"),
from_wkt<L>("LINESTRING(0 -.2, 8 1, -.5 7, 6 +.2)"),
from_wkt<ML>("MULTILINESTRING((0 5,8 1),(4 .4,2 8))"),
"lldf31y+",
1e-10
);
#endif
#ifdef GEOMETRY_TEST_INCLUDE_FAILING_TESTS
tester::apply
(from_wkt<L>("LINESTRING(10.0002 2,9 -1032.34324, .3 8, 0 5, 8 1, 4 .4, 2 8)"),
from_wkt<L>("LINESTRING(0 -.2, 8 1, -.5 7, 6 +.2)"),
from_wkt<ML>("MULTILINESTRING((10.0002 2,9 -1032.34324,.3 8,0 5,8 1),(4 .4,2 8))"),
"lldf31z",
1e-10
);
tester::apply
(from_wkt<L>("LINESTRING(0 -.2, 8 1, -.5 7, 6 +.2)"),
from_wkt<L>("LINESTRING(10.0002 2,9 -1032.34324, .3 8, 0 5, 8 1, 4 .4, 2 8)"),
from_wkt<ML>("MULTILINESTRING((0 -.2,4 .4),(8 1,-.5 7,6 .2))"),
"lldf31z-r",
1e-10
);
tester::apply
(from_wkt<L>("LINESTRING(0 0, 8 1, -.5 7)"),
from_wkt<L>("LINESTRING(0 5, 8 1, 4 .5, 2 8)"),
from_wkt<ML>("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<ML>("MULTILINESTRING((0 0,10 0))"),
"mlmldf19"
);
#ifdef GEOMETRY_TEST_INCLUDE_FAILING_TESTS
tester::apply
(from_wkt<ML>("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<ML>("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<ML>("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<ML>("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<ML>("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<ML>("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<ML>("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<ML>("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<ML>("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<ML>("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<ML>("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<ML>("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
}

View File

@@ -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_DIFFERENCE_LINEAR_LINEAR_HPP
#define BOOST_GEOMETRY_TEST_DIFFERENCE_LINEAR_LINEAR_HPP
#include <limits>
#include <boost/geometry/geometry.hpp>
#include "../test_set_ops_linear_linear.hpp"
#include <from_wkt.hpp>
@@ -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<false>::apply(mls_diff,
ls_vector_output));
BOOST_CHECK(multilinestring_equals
<
false
>::apply(mls_diff, ls_vector_output, tolerance));
BOOST_CHECK(multilinestring_equals<false>::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<double>::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;

View File

@@ -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,84 @@ BOOST_AUTO_TEST_CASE( test_intersection_ml_ml_degenerate )
#endif
"mlmli20e"
);
tester::apply
(from_wkt<ML>("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<ML>("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<ML>("MULTILINESTRING((-0.7654 8.88178e-16,-0.7654 0,5 3))"),
#else
from_wkt<ML>("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<ML>("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))"),
#endif
"mlmli21",
1e-4
);
}
#endif // BOOST_GEOMETRY_TEST_NO_DEGENERATE

View File

@@ -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 <limits>
#include <boost/geometry/multi/geometries/multi_point.hpp>
#include <boost/geometry/geometry.hpp>
#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<false>::apply(mls_int1,
ls_vector_output));
BOOST_CHECK(multilinestring_equals
<
false
>::apply(mls_int1, ls_vector_output, tolerance));
BOOST_CHECK(multilinestring_equals<false>::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<MultiLineString>::type LineString;
typedef typename bg::point_type<MultiLineString>::type Point;
typedef bg::model::multi_point<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<double>::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<double>::epsilon())
{
apply(geometry1, geometry2, mls_int, mls_int, case_id);
apply(geometry1, geometry2, mls_int, mls_int, case_id, tolerance);
}
};

View File

@@ -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
@@ -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<ML>("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<ML>("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<ML>("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
}
@@ -787,9 +781,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<ML>("MULTILINESTRING((0 0,10 0,20 1),(1 0,7 0),\
(10 10,20 10,30 20))"),
@@ -802,7 +793,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<ML>("MULTILINESTRING((0 0,10 0,20 10),(1 0,7 0),\

View File

@@ -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_SYM_DIFFERENCE_LINEAR_LINEAR_HPP
#define BOOST_GEOMETRY_TEST_SYM_DIFFERENCE_LINEAR_LINEAR_HPP
#include <limits>
#include <boost/geometry/geometry.hpp>
#include "../test_set_ops_linear_linear.hpp"
#include <from_wkt.hpp>
@@ -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<false>::apply(mls_sym_diff,
ls_vector_output));
BOOST_CHECK(multilinestring_equals
<
false
>::apply(mls_sym_diff, ls_vector_output, tolerance));
BOOST_CHECK(multilinestring_equals<false>::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<double>::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;

View File

@@ -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
@@ -72,6 +72,37 @@ struct ls_equal
};
template <typename Point1, typename Point2>
class pt_equal
{
private:
double m_tolerence;
template <typename T>
static inline T const& get_max(T const& a, T const& b, T const& c)
{
return (std::max)((std::max)(a, b), c);
}
template <typename T>
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 check_close(bg::get<0>(point1), bg::get<0>(point2), m_tolerence)
&& check_close(bg::get<1>(point1), bg::get<1>(point2), m_tolerence);
}
};
template <bool EnableUnique = false>
struct multilinestring_equals
{
@@ -79,21 +110,33 @@ struct multilinestring_equals
struct unique
{
typedef typename boost::range_value<MultiLinestring>::type Linestring;
typedef typename bg::point_type<MultiLinestring>::type point_type;
typedef ls_equal<Linestring, Linestring> linestring_equal;
typedef pt_equal<point_type, point_type> point_equal;
void operator()(MultiLinestring& mls)
template <typename Range, typename EqualTo>
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<MultiLinestring>::type it
= boost::begin(mls); it != boost::end(mls); ++it)
{
apply_to_range(*it, point_equal(tolerance));
}
apply_to_range(mls, linestring_equal());
}
};
template <typename MultiLinestring>
struct unique<MultiLinestring, false>
{
void operator()(MultiLinestring&)
void operator()(MultiLinestring&, double)
{
}
};
@@ -101,7 +144,8 @@ struct multilinestring_equals
template <typename MultiLinestring1, typename MultiLinestring2>
static inline
bool apply(MultiLinestring1 const& multilinestring1,
MultiLinestring2 const& multilinestring2)
MultiLinestring2 const& multilinestring2,
double tolerance)
{
typedef typename boost::range_iterator
<
@@ -129,14 +173,27 @@ struct multilinestring_equals
typedef ls_less<Linestring1, Linestring2> linestring_less;
typedef pt_equal
<
typename boost::range_value
<
typename boost::range_value<MultiLinestring1>::type
>::type,
typename boost::range_value
<
typename boost::range_value<MultiLinestring2>::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<MultiLinestring1, EnableUnique>()(mls1);
unique<MultiLinestring2, EnableUnique>()(mls2);
unique<MultiLinestring1, EnableUnique>()(mls1, tolerance);
unique<MultiLinestring2, EnableUnique>()(mls2, tolerance);
if ( boost::size(mls1) != boost::size(mls2) )
{
@@ -155,7 +212,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 +266,37 @@ private:
template <typename MultiLinestring1, typename MultiLinestring2>
static inline bool apply_base(MultiLinestring1 const& multilinestring1,
MultiLinestring2 const& multilinestring2)
MultiLinestring2 const& multilinestring2,
double tolerance)
{
typedef multilinestring_equals<true> 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 +304,8 @@ private:
public:
template <typename MultiLinestring1, typename MultiLinestring2>
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 +315,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
}
};

View File

@@ -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_UNION_LINEAR_LINEAR_HPP
#define BOOST_GEOMETRY_TEST_UNION_LINEAR_LINEAR_HPP
#include <limits>
#include <boost/geometry/geometry.hpp>
#include "../test_set_ops_linear_linear.hpp"
#include <from_wkt.hpp>
@@ -35,6 +37,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 +53,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 +86,15 @@ private:
bg::union_(geometry1, geometry2, ls_vector_output);
bg::union_(geometry1, geometry2, ls_deque_output);
BOOST_CHECK(multilinestring_equals<false>::apply(mls_union1,
ls_vector_output));
BOOST_CHECK(multilinestring_equals
<
false
>::apply(mls_union1, ls_vector_output, tolerance));
BOOST_CHECK(multilinestring_equals<false>::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 +106,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 +132,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<double>::epsilon())
{
#ifdef BOOST_GEOMETRY_TEST_DEBUG
std::cout << "test case: " << case_id << std::endl;
@@ -146,10 +157,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 +173,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<double>::epsilon())
{
apply(geometry1, geometry2, mls_union, mls_union, case_id);
apply(geometry1, geometry2, mls_union, mls_union, case_id, tolerance);
}
};