summaryrefslogtreecommitdiff
path: root/libs/geometry/test
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2016-10-06 10:33:54 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2016-10-06 10:36:09 +0900
commitd9ec475d945d3035377a0d89ed42e382d8988891 (patch)
tree34aff2cee4b209906243ab5499d61f3edee2982f /libs/geometry/test
parent71d216b90256936a9638f325af9bc69d720e75de (diff)
downloadboost-d9ec475d945d3035377a0d89ed42e382d8988891.tar.gz
boost-d9ec475d945d3035377a0d89ed42e382d8988891.tar.bz2
boost-d9ec475d945d3035377a0d89ed42e382d8988891.zip
Imported Upstream version 1.60.0
Change-Id: Ie709530d6d5841088ceaba025cbe175a4ef43050 Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'libs/geometry/test')
-rw-r--r--libs/geometry/test/algorithms/buffer/buffer_linestring.cpp10
-rw-r--r--libs/geometry/test/algorithms/buffer/buffer_multi_linestring.cpp18
-rw-r--r--libs/geometry/test/algorithms/buffer/buffer_polygon.cpp6
-rw-r--r--libs/geometry/test/algorithms/buffer/test_buffer_svg.hpp2
-rw-r--r--libs/geometry/test/algorithms/centroid.cpp16
-rw-r--r--libs/geometry/test/algorithms/centroid_multi.cpp55
-rw-r--r--libs/geometry/test/algorithms/distance/distance_pointlike_linear.cpp13
-rw-r--r--libs/geometry/test/algorithms/is_simple.cpp26
-rw-r--r--libs/geometry/test/algorithms/is_valid.cpp201
-rw-r--r--libs/geometry/test/algorithms/num_geometries_multi.cpp4
-rw-r--r--libs/geometry/test/algorithms/num_interior_rings_multi.cpp4
-rw-r--r--libs/geometry/test/algorithms/num_points_multi.cpp4
-rw-r--r--libs/geometry/test/algorithms/overlay/Jamfile.v24
-rw-r--r--libs/geometry/test/algorithms/overlay/enrich_intersection_points.cpp3
-rw-r--r--libs/geometry/test/algorithms/overlay/get_turns.cpp2
-rw-r--r--libs/geometry/test/algorithms/overlay/get_turns_linear_linear.cpp19
-rw-r--r--libs/geometry/test/algorithms/overlay/multi_overlay_cases.hpp75
-rw-r--r--libs/geometry/test/algorithms/overlay/overlay_cases.hpp81
-rw-r--r--libs/geometry/test/algorithms/overlay/self_intersection_points.cpp4
-rw-r--r--libs/geometry/test/algorithms/overlay/traverse.cpp501
-rw-r--r--libs/geometry/test/algorithms/overlay/traverse_ccw.cpp6
-rw-r--r--libs/geometry/test/algorithms/overlay/traverse_gmp.cpp3
-rw-r--r--libs/geometry/test/algorithms/overlay/traverse_multi.cpp25
-rw-r--r--libs/geometry/test/algorithms/relational_operations/covered_by.cpp10
-rw-r--r--libs/geometry/test/algorithms/relational_operations/disjoint/disjoint_point_box_geometry.cpp5
-rw-r--r--libs/geometry/test/algorithms/relational_operations/intersects/intersects_box_geometry.cpp24
-rw-r--r--libs/geometry/test/algorithms/relational_operations/nan_cases.hpp130
-rw-r--r--libs/geometry/test/algorithms/relational_operations/overlaps/overlaps_areal.cpp8
-rw-r--r--libs/geometry/test/algorithms/relational_operations/overlaps/overlaps_box.cpp1
-rw-r--r--libs/geometry/test/algorithms/relational_operations/overlaps/test_overlaps.hpp33
-rw-r--r--libs/geometry/test/algorithms/relational_operations/relate/relate_areal_areal.cpp19
-rw-r--r--libs/geometry/test/algorithms/relational_operations/relate/relate_linear_areal.cpp19
-rw-r--r--libs/geometry/test/algorithms/relational_operations/relate/relate_pointlike_geometry.cpp32
-rw-r--r--libs/geometry/test/algorithms/relational_operations/touches/test_touches.hpp12
-rw-r--r--libs/geometry/test/algorithms/relational_operations/touches/touches.cpp14
-rw-r--r--libs/geometry/test/algorithms/relational_operations/touches/touches_box.cpp3
-rw-r--r--libs/geometry/test/algorithms/relational_operations/within/within.cpp4
-rw-r--r--libs/geometry/test/algorithms/set_operations/difference/Jamfile.v210
-rw-r--r--libs/geometry/test/algorithms/set_operations/difference/difference.cpp353
-rw-r--r--libs/geometry/test/algorithms/set_operations/difference/difference_areal_linear.cpp234
-rw-r--r--libs/geometry/test/algorithms/set_operations/difference/difference_linear_linear.cpp4
-rw-r--r--libs/geometry/test/algorithms/set_operations/difference/difference_multi.cpp129
-rw-r--r--libs/geometry/test/algorithms/set_operations/difference/difference_multi_areal_linear.cpp87
-rw-r--r--libs/geometry/test/algorithms/set_operations/difference/test_difference.hpp170
-rw-r--r--libs/geometry/test/algorithms/set_operations/difference/test_difference_linear_linear.hpp1
-rw-r--r--libs/geometry/test/algorithms/set_operations/intersection/intersection.cpp118
-rw-r--r--libs/geometry/test/algorithms/set_operations/intersection/intersection_multi.cpp44
-rw-r--r--libs/geometry/test/algorithms/set_operations/intersection/test_intersection.hpp6
-rw-r--r--libs/geometry/test/algorithms/set_operations/sym_difference/sym_difference_areal_areal.cpp5
-rw-r--r--libs/geometry/test/algorithms/set_operations/union/test_union.hpp43
-rw-r--r--libs/geometry/test/algorithms/set_operations/union/union.cpp62
-rw-r--r--libs/geometry/test/algorithms/set_operations/union/union_multi.cpp62
-rw-r--r--libs/geometry/test/algorithms/test_centroid.hpp16
-rw-r--r--libs/geometry/test/arithmetic/Jamfile.v22
-rw-r--r--libs/geometry/test/arithmetic/general.cpp (renamed from libs/geometry/test/arithmetic/arithmetic.cpp)0
-rw-r--r--libs/geometry/test/geometries/Jamfile.v22
-rw-r--r--libs/geometry/test/geometries/initialization.cpp (renamed from libs/geometry/test/geometries/geometries.cpp)0
-rw-r--r--libs/geometry/test/iterators/ever_circling_iterator.cpp12
-rw-r--r--libs/geometry/test/views/Jamfile.v217
59 files changed, 1995 insertions, 778 deletions
diff --git a/libs/geometry/test/algorithms/buffer/buffer_linestring.cpp b/libs/geometry/test/algorithms/buffer/buffer_linestring.cpp
index 3f36735933..87fed599ad 100644
--- a/libs/geometry/test/algorithms/buffer/buffer_linestring.cpp
+++ b/libs/geometry/test/algorithms/buffer/buffer_linestring.cpp
@@ -93,6 +93,10 @@ static std::string const mysql_report_2015_06_11 = "LINESTRING("
"-162.7456296900030000 11.7183989853218000, 115.6208648232840000 "
"51.0941612539320000, -48.7772321835054000 50.4339743128205000)";
+static std::string const mysql_report_2015_09_08a = "LINESTRING(1 1, 2 1, 1.765258e+308 4, -1 1, 10 4)";
+static std::string const mysql_report_2015_09_08b = "LINESTRING(2199023255556 16777218, 32770 8194, 1.417733e+308 7.823620e+307, -8 -9, 2147483649 20)";
+static std::string const mysql_report_2015_09_08c = "LINESTRING(-5 -8, 2 8, 2.160023e+307 1.937208e+307, -4 -3, -5 -4, 8796093022208 281474976710653)";
+
template <bool Clockwise, typename P>
void test_all()
{
@@ -270,6 +274,12 @@ void test_all()
mysql_report_2015_06_11, join_round32, end_round32,
27862.733459829971,
5.9518403867035365);
+
+#if defined(BOOST_GEOMETRY_BUFFER_INCLUDE_FAILING_TESTS)
+ test_one<linestring, polygon>("mysql_report_2015_09_08a", mysql_report_2015_09_08a, join_round32, end_round32, 0.0, 1.0);
+ test_one<linestring, polygon>("mysql_report_2015_09_08b", mysql_report_2015_09_08b, join_round32, end_round32, 0.0, 1099511627778.0);
+ test_one<linestring, polygon>("mysql_report_2015_09_08c", mysql_report_2015_09_08c, join_round32, end_round32, 0.0, 0xbe);
+#endif
}
template <bool Clockwise, typename P>
diff --git a/libs/geometry/test/algorithms/buffer/buffer_multi_linestring.cpp b/libs/geometry/test/algorithms/buffer/buffer_multi_linestring.cpp
index 11b1915479..6501d131ad 100644
--- a/libs/geometry/test/algorithms/buffer/buffer_multi_linestring.cpp
+++ b/libs/geometry/test/algorithms/buffer/buffer_multi_linestring.cpp
@@ -32,6 +32,9 @@ static std::string const mikado4 = "MULTILINESTRING((-15 2,-15 -17,-6 11,-1.9358
static std::string const mysql_2015_04_10a = "MULTILINESTRING((-58 19, 61 88),(1.922421e+307 1.520384e+308, 15 42, 89 -93,-89 -22),(-63 -5, -262141 -536870908, -3 87, 77 -69))";
static std::string const mysql_2015_04_10b = "MULTILINESTRING((-58 19, 61 88), (-63 -5, -262141 -536870908, -3 87, 77 -69))";
+static std::string const mysql_2015_09_08a = "MULTILINESTRING((7 -4, -3 -5), (72057594037927936 15, 72057594037927940 70368744177660, 32771 36028797018963964, 8589934589 2305843009213693953, 7 2, 9.300367e+307 9.649737e+307, -4092 -274877906946, 5 10, -3 4))";
+static std::string const mysql_2015_09_08b = "MULTILINESTRING((-9 -10, 0 -1, 5 -10, -6 7, -7 7, 5.041061e+307 9.926906e+307, 6.870356e+307 1.064454e+307, 35184372088830 288230376151711743, 183673728842483250000000000000000000000.000000 244323751784861950000000000000000000000.000000), (-23530 -7131, -6 1, 1 1, 2 -6, 32766 -4194302, -4 -6), (134217725 0, 50336782742294697000000000000000000000.000000 36696596077212901000000000000000000000.000000, 7434 16486, 3.025467e+307 8.926790e+307), (2147483646 67108868, 71328904281592545000000000000000000000.000000 225041650340452780000000000000000000000.000000, -7 4, 1.667154e+307 3.990414e+307))";
+
template <bool Clockwise, typename P>
void test_all()
{
@@ -96,7 +99,7 @@ void test_all()
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, 79610.0, same_distance, true, mikado_tolerance);
+ test_one<multi_linestring_type, polygon>("mikado2_large", mikado2, join_round32, end_round32, 19878812253, 79610.0, same_distance, true, 10 * mikado_tolerance);
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);
@@ -104,7 +107,7 @@ void test_all()
// msvc 29151950611
// clang/linux 29151950612
// mingw 29151950711
- test_one<multi_linestring_type, polygon>("mikado3_large", mikado3, join_round32, end_round32, 29151950650, 96375.0, same_distance, true, 3 * mikado_tolerance);
+ test_one<multi_linestring_type, polygon>("mikado3_large", mikado3, join_round32, end_round32, 29151950650, 96375.0, same_distance, true, 10 * mikado_tolerance);
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);
@@ -125,6 +128,17 @@ void test_all()
test_one<multi_linestring_type, polygon>("mysql_2015_04_10a", mysql_2015_04_10a, join_round32, end_round32, 1063005187.214, 0.98);
test_one<multi_linestring_type, polygon>("mysql_2015_04_10b", mysql_2015_04_10b, join_round32, end_round32, 1063005187.214, 0.98);
#endif
+
+ // Two other cases with inf for length calculation (tolerance quite high
+ // because the output area is quite high and varies between gcc/clang)
+ test_one<multi_linestring_type, polygon>("mysql_2015_09_08a",
+ mysql_2015_09_08a, join_round32, end_round32,
+ 5.12436196736438764e+19, 4051744443.0,
+ same_distance, true, 1.0e12);
+ test_one<multi_linestring_type, polygon>("mysql_2015_09_08b",
+ mysql_2015_09_08b, join_round32, end_round32,
+ 1.32832149026508268e+19, 2061380362.0,
+ same_distance, true, 1.0e12);
}
diff --git a/libs/geometry/test/algorithms/buffer/buffer_polygon.cpp b/libs/geometry/test/algorithms/buffer/buffer_polygon.cpp
index 8db5c2cbd7..31a91d024b 100644
--- a/libs/geometry/test/algorithms/buffer/buffer_polygon.cpp
+++ b/libs/geometry/test/algorithms/buffer/buffer_polygon.cpp
@@ -570,7 +570,8 @@ void test_all()
test_one<polygon_type, polygon_type>("mysql_report_2015_07_05_1", mysql_report_2015_07_05_1,
join_round32, end_round32, 2.07548405999982264e+19, 6);
test_one<polygon_type, polygon_type>("mysql_report_2015_07_05_2", mysql_report_2015_07_05_2,
- join_round32, end_round32, 9.48681585720922691e+23, 549755813889);
+ join_round32, end_round32, 9.48681585720922691e+23, 549755813889,
+ same_distance, true, high_tolerance);
test_one<polygon_type, polygon_type>("mysql_report_2015_07_05_3", mysql_report_2015_07_05_3,
join_round32, end_round32, 6.10005339242509925e+22, 49316,
same_distance, false, high_tolerance);
@@ -578,7 +579,8 @@ void test_all()
join_round32, end_round32, 4.25405937213774089e+23, 1479986,
same_distance, false, high_tolerance);
test_one<polygon_type, polygon_type>("mysql_report_2015_07_05_5", mysql_report_2015_07_05_5,
- join_round32, end_round32, 644489321051.62439, 38141);
+ join_round32, end_round32, 644489321051.62439, 38141,
+ same_distance, false, 10000.0);
}
}
diff --git a/libs/geometry/test/algorithms/buffer/test_buffer_svg.hpp b/libs/geometry/test/algorithms/buffer/test_buffer_svg.hpp
index 82a04583ea..4940f6b24f 100644
--- a/libs/geometry/test/algorithms/buffer/test_buffer_svg.hpp
+++ b/libs/geometry/test/algorithms/buffer/test_buffer_svg.hpp
@@ -131,6 +131,8 @@ private :
color = 'b';
is_good = false;
break;
+ default:
+ ; // to avoid "enumeration value not handled" warning
}
if (!it->selectable_start)
{
diff --git a/libs/geometry/test/algorithms/centroid.cpp b/libs/geometry/test/algorithms/centroid.cpp
index 4ffeb45f9e..8f7399230b 100644
--- a/libs/geometry/test/algorithms/centroid.cpp
+++ b/libs/geometry/test/algorithms/centroid.cpp
@@ -175,6 +175,21 @@ void test_exceptions()
test_centroid_exception<bg::model::linestring<P> >();
test_centroid_exception<bg::model::polygon<P> >();
test_centroid_exception<bg::model::ring<P> >();
+
+ // Empty exterior ring
+ test_centroid_exception<bg::model::polygon<P> >(
+ "POLYGON((), ())");
+ test_centroid_exception<bg::model::polygon<P> >(
+ "POLYGON((), (0 0, 1 0, 1 1, 0 1, 0 0))");
+}
+
+template <typename P>
+void test_empty()
+{
+ // Empty interior ring
+ test_centroid<bg::model::polygon<P> >(
+ "POLYGON((0 0, 1 0, 1 1, 0 1, 0 0), ())",
+ 0.5, 0.5);
}
void test_large_integers()
@@ -255,6 +270,7 @@ int test_main(int, char* [])
test_large_doubles();
test_exceptions<bg::model::d2::point_xy<double> >();
+ test_empty<bg::model::d2::point_xy<double> >();
return 0;
}
diff --git a/libs/geometry/test/algorithms/centroid_multi.cpp b/libs/geometry/test/algorithms/centroid_multi.cpp
index c98b3f164e..5f250116e2 100644
--- a/libs/geometry/test/algorithms/centroid_multi.cpp
+++ b/libs/geometry/test/algorithms/centroid_multi.cpp
@@ -115,6 +115,58 @@ void test_2d(bool is_integer = false)
424530.6059719588, 4527519.619367547);
}
+template <typename P>
+void test_exceptions()
+{
+ using namespace bg::model;
+ typedef multi_polygon<polygon<P> > multi_polygon;
+ typedef multi_linestring<linestring<P> > multi_linestring;
+
+ // Empty multi-polygon
+ test_centroid_exception<multi_polygon>("MULTIPOLYGON()");
+ test_centroid_exception<multi_polygon>("MULTIPOLYGON(())");
+ test_centroid_exception<multi_polygon>("MULTIPOLYGON((), ())");
+ test_centroid_exception<multi_polygon>("MULTIPOLYGON((()), ())");
+ test_centroid_exception<multi_polygon>("MULTIPOLYGON(((), ()))");
+
+ // Empty multi-linestring
+ test_centroid_exception<multi_linestring>("MULTILINESTRING()");
+ test_centroid_exception<multi_linestring>("MULTILINESTRING(())");
+ test_centroid_exception<multi_linestring>("MULTILINESTRING((), ())");
+}
+
+template <typename P>
+void test_empty()
+{
+ using namespace bg::model;
+ typedef multi_polygon<polygon<P> > multi_polygon;
+ typedef multi_linestring<linestring<P> > multi_linestring;
+
+ // Multi-linestring with empty linestring
+ test_centroid<multi_linestring>(
+ "MULTILINESTRING((), (0 0))",
+ 0.0, 0.0);
+ test_centroid<multi_linestring>(
+ "MULTILINESTRING((0 0, 1 0), ())",
+ 0.5, 0.0);
+
+ // Multi-polygon with empty polygon
+ test_centroid<multi_polygon>(
+ "MULTIPOLYGON((()), ((0 0)))",
+ 0.0, 0.0);
+ test_centroid<multi_polygon>(
+ "MULTIPOLYGON(((0 0, 1 0, 1 1, 0 1, 0 0)), (()))",
+ 0.5, 0.5);
+
+ // Multi-polygon with empty interior ring
+ test_centroid<multi_polygon>(
+ "MULTIPOLYGON(((0 0, 1 0, 1 1, 0 1, 0 0), ()))",
+ 0.5, 0.5);
+ test_centroid<multi_polygon>(
+ "MULTIPOLYGON((()), ((0 0, 1 0, 1 1, 0 1, 0 0), ()))",
+ 0.5, 0.5);
+}
+
int test_main(int, char* [])
@@ -129,5 +181,8 @@ int test_main(int, char* [])
test_2d<bg::model::d2::point_xy<ttmath_big> >();
#endif
+ test_exceptions<bg::model::d2::point_xy<double> >();
+ test_empty<bg::model::d2::point_xy<double> >();
+
return 0;
}
diff --git a/libs/geometry/test/algorithms/distance/distance_pointlike_linear.cpp b/libs/geometry/test/algorithms/distance/distance_pointlike_linear.cpp
index ad22bf120d..3ab390bde2 100644
--- a/libs/geometry/test/algorithms/distance/distance_pointlike_linear.cpp
+++ b/libs/geometry/test/algorithms/distance/distance_pointlike_linear.cpp
@@ -226,6 +226,19 @@ void test_distance_multipoint_multilinestring(Strategy const& strategy)
tester::apply("multipoint(0 0,1 0,0 1,1 1)",
"multilinestring((4 4,5 5),(),(3 3))",
sqrt(8.0), 8, strategy);
+
+ // 21890717 - assertion failure in distance(Pt, Box)
+ {
+ multi_point_type mpt;
+ bg::read_wkt("multipoint(1 1,1 1,1 1,1 1,1 1,1 1,1 1,1 1,1 1)", mpt);
+ multi_linestring_type mls;
+ linestring_type ls;
+ point_type pt(std::numeric_limits<double>::quiet_NaN(), 1.0);
+ ls.push_back(pt);
+ ls.push_back(pt);
+ mls.push_back(ls);
+ bg::distance(mpt, mls);
+ }
}
//===========================================================================
diff --git a/libs/geometry/test/algorithms/is_simple.cpp b/libs/geometry/test/algorithms/is_simple.cpp
index f73d6309c3..17cbb4b7c5 100644
--- a/libs/geometry/test/algorithms/is_simple.cpp
+++ b/libs/geometry/test/algorithms/is_simple.cpp
@@ -64,14 +64,15 @@ typedef bg::model::box<point_type> box_type;
template <typename Geometry>
-void test_simple(Geometry const& geometry, bool expected_result)
+void test_simple(Geometry const& geometry, bool expected_result,
+ bool check_validity = true)
{
#ifdef BOOST_GEOMETRY_TEST_DEBUG
std::cout << "=======" << std::endl;
#endif
bool simple = bg::is_simple(geometry);
- BOOST_ASSERT( bg::is_valid(geometry) );
+ BOOST_ASSERT( ! check_validity || bg::is_valid(geometry) );
BOOST_CHECK_MESSAGE( simple == expected_result,
"Expected: " << expected_result
<< " detected: " << simple
@@ -122,6 +123,9 @@ BOOST_AUTO_TEST_CASE( test_is_simple_multipoint )
test_simple(from_wkt<G>("MULTIPOINT(0 0)"), true);
test_simple(from_wkt<G>("MULTIPOINT(0 0,1 0,1 1,0 1)"), true);
test_simple(from_wkt<G>("MULTIPOINT(0 0,1 0,1 1,1 0,0 1)"), false);
+
+ // empty multipoint
+ test_simple(from_wkt<G>("MULTIPOINT()"), true);
}
BOOST_AUTO_TEST_CASE( test_is_simple_segment )
@@ -191,6 +195,11 @@ BOOST_AUTO_TEST_CASE( test_is_simple_linestring )
false);
test_simple(from_wkt<G>("LINESTRING(10 3,10 5,4 1,4 6,10 8,4 1)"),
false);
+
+ // empty linestring
+ // the simplicity result is irrelevant since an empty linestring
+ // is considered as invalid
+ test_simple(from_wkt<G>("LINESTRING()"), false, false);
}
BOOST_AUTO_TEST_CASE( test_is_simple_multilinestring )
@@ -271,6 +280,9 @@ BOOST_AUTO_TEST_CASE( test_is_simple_multilinestring )
false);
test_simple(from_wkt<G>("MULTILINESTRING((10 3,10 5,4 1,4 6,10 8,4 1))"),
false);
+
+ // empty multilinestring
+ test_simple(from_wkt<G>("MULTILINESTRING()"), true);
}
BOOST_AUTO_TEST_CASE( test_is_simple_areal )
@@ -295,6 +307,14 @@ BOOST_AUTO_TEST_CASE( test_is_simple_areal )
false);
test_simple(from_wkt<mpl>("MULTIPOLYGON(((0 0,1 0,1 1,1 1)),((10 0,20 0,20 0,20 10,10 10)))"),
false);
+
+ // empty polygon
+ // the simplicity result is irrelevant since an empty polygon
+ // is considered as invalid
+ test_simple(from_wkt<o_ccw_p>("POLYGON(())"), false, false);
+
+ // empty multipolygon
+ test_simple(from_wkt<mpl>("MULTIPOLYGON()"), true);
}
BOOST_AUTO_TEST_CASE( test_geometry_with_NaN_coordinates )
@@ -315,7 +335,7 @@ BOOST_AUTO_TEST_CASE( test_geometry_with_NaN_coordinates )
multi_linestring_type mls;
bg::intersection(ls1, ls2, mls);
- test_simple(mls, true);
+ test_simple(mls, true, false);
}
BOOST_AUTO_TEST_CASE( test_is_simple_variant )
diff --git a/libs/geometry/test/algorithms/is_valid.cpp b/libs/geometry/test/algorithms/is_valid.cpp
index 7ec61eece8..6d2360ec1a 100644
--- a/libs/geometry/test/algorithms/is_valid.cpp
+++ b/libs/geometry/test/algorithms/is_valid.cpp
@@ -13,12 +13,15 @@
#define BOOST_TEST_MODULE test_is_valid
#endif
+#include <limits>
#include <iostream>
#include <boost/test/included/unit_test.hpp>
#include "test_is_valid.hpp"
+#include <boost/geometry/core/coordinate_type.hpp>
+
#include <boost/geometry/algorithms/correct.hpp>
#include <boost/geometry/algorithms/intersection.hpp>
#include <boost/geometry/algorithms/reverse.hpp>
@@ -713,6 +716,67 @@ inline void test_open_polygons()
0.7808688094430304 -0.6246950475544243,\
0.7808688094430304 -0.6246950475544243))",
AllowDuplicates);
+
+
+ // MySQL report on Sep 30, 2015
+ test::apply
+ ("pg077",
+ "POLYGON((72.8714768817168 -167.0048853643874,9274.40641550926 3433.5957427942167,-58.09039811390054 187.50989457746405,-81.09039811390053 179.50989457746405,-207.99999999999997 135.36742435621204,-208 1,-208 0,-208 -276.9111154485375,49.8714768817168 -176.0048853643874))",
+ true);
+
+ test::apply("pg077-simplified",
+ "POLYGON((-200 0,-207.99999999999997 135.36742435621204,-208 1,-208 0,-208 -276.9111154485375))",
+ true);
+
+ test::apply
+ ("pg078",
+ "POLYGON((0 10,-10 0,0 0,10 0))",
+ true);
+
+ test::apply
+ ("pg078spike1",
+ "POLYGON((0 10,-10 0,0 0,-10 0,10 0))",
+ false);
+
+ test::apply
+ ("pg078spike2",
+ "POLYGON((0 10,-10 0,0 0,-8 0,10 0))",
+ false);
+
+ test::apply
+ ("pg078spike3",
+ "POLYGON((0 10,-10 0,0 0,-11 0,10 0))",
+ false);
+
+ test::apply
+ ("pg078reversed",
+ "POLYGON((0 10,10 0,0 0,-10 0))",
+ false);
+
+ test::apply
+ ("pg079",
+ "POLYGON((10 0,0 10,0 0,0 -10))",
+ true);
+
+ test::apply
+ ("pg079spike1",
+ "POLYGON((10 0,0 10,0 0,0 10,0 -10))",
+ false);
+
+ test::apply
+ ("pg079spike2",
+ "POLYGON((10 0,0 10,0 0,0 8,0 -10))",
+ false);
+
+ test::apply
+ ("pg079spike3",
+ "POLYGON((10 0,0 10,0 0,0 11,0 -10))",
+ false);
+
+ test::apply
+ ("pg079reversed",
+ "POLYGON((10 0,0 -10,0 0,0 10))",
+ false);
}
template <typename Point>
@@ -1115,7 +1179,138 @@ BOOST_AUTO_TEST_CASE( test_is_valid_multipolygon )
test_open_multipolygons<point_type, do_not_allow_duplicates>();
}
-BOOST_AUTO_TEST_CASE( test_geometry_with_NaN_coordinates )
+
+template <typename CoordinateType, typename Geometry>
+inline void check_one(Geometry const& geometry)
+{
+ bool const is_fp = boost::is_floating_point<CoordinateType>::value;
+
+ bg::validity_failure_type failure;
+ bool validity = bg::is_valid(geometry, failure);
+ if (BOOST_GEOMETRY_CONDITION(is_fp))
+ {
+ BOOST_CHECK(! validity);
+ BOOST_CHECK(failure == bg::failure_invalid_coordinate);
+ }
+ else
+ {
+ BOOST_CHECK(failure == bg::no_failure
+ || failure != bg::failure_invalid_coordinate);
+ }
+}
+
+template <typename P, typename CoordinateType>
+inline void test_with_invalid_coordinate(CoordinateType invalid_value)
+{
+ typedef bg::model::segment<P> segment_t;
+ typedef bg::model::box<P> box_t;
+ typedef bg::model::linestring<P> linestring_t;
+ typedef bg::model::ring<P> ring_t; // cw, closed
+ typedef bg::model::polygon<P> polygon_t; // cw, closed
+ typedef bg::model::multi_point<P> multi_point_t;
+ typedef bg::model::multi_linestring<linestring_t> multi_linestring_t;
+ typedef bg::model::multi_polygon<polygon_t> multi_polygon_t;
+
+ typedef typename bg::coordinate_type<P>::type coord_t;
+
+ std::string wkt_point = "POINT(1 1)";
+ std::string wkt_segment = "LINESTRING(1 1,10 20)";
+ std::string wkt_box = "BOX(1 1,10 20)";
+ std::string wkt_linestring = "LINESTRING(1 1,2 3,4 -5)";
+ std::string wkt_ring = "POLYGON((1 1,2 2,2 1,1 1))";
+ std::string wkt_polygon = "POLYGON((1 1,1 200,200 200,200 1,1 1),(50 50,50 51,49 50,50 50))";
+ std::string wkt_multipoint = "MULTIPOINT(1 1,2 3,4 -5,-5 2)";
+ std::string wkt_multilinestring =
+ "MULTILINESTRING((1 1,2 3,4 -5),(-4 -2,-8 9))";
+ std::string wkt_multipolygon = "MULTIPOLYGON(((1 1,1 200,200 200,200 1,1 1),(50 50,50 51,49 50,50 50)),((500 500,550 550,550 500,500 500)))";
+
+ {
+ P p;
+ bg::read_wkt(wkt_point, p);
+ BOOST_CHECK(bg::is_valid(p));
+ bg::set<1>(p, invalid_value);
+ check_one<coord_t>(p);
+ }
+ {
+ segment_t s;
+ bg::read_wkt(wkt_segment, s);
+ BOOST_CHECK(bg::is_valid(s));
+ bg::set<1, 1>(s, invalid_value);
+ check_one<coord_t>(s);
+ }
+ {
+ box_t b;
+ bg::read_wkt(wkt_box, b);
+ BOOST_CHECK(bg::is_valid(b));
+ bg::set<1, 0>(b, invalid_value);
+ check_one<coord_t>(b);
+ }
+ {
+ linestring_t ls;
+ bg::read_wkt(wkt_linestring, ls);
+ BOOST_CHECK(bg::is_valid(ls));
+ bg::set<1>(ls[1], invalid_value);
+ check_one<coord_t>(ls);
+ }
+ {
+ ring_t r;
+ bg::read_wkt(wkt_ring, r);
+ BOOST_CHECK(bg::is_valid(r));
+ bg::set<0>(r[1], invalid_value);
+ check_one<coord_t>(r);
+ }
+ {
+ polygon_t pgn;
+ bg::read_wkt(wkt_polygon, pgn);
+ BOOST_CHECK(bg::is_valid(pgn));
+ bg::set<0>(bg::interior_rings(pgn)[0][1], invalid_value);
+ check_one<coord_t>(pgn);
+ }
+ {
+ multi_point_t mp;
+ bg::read_wkt(wkt_multipoint, mp);
+ BOOST_CHECK(bg::is_valid(mp));
+ bg::set<0>(mp[2], invalid_value);
+ check_one<coord_t>(mp);
+ }
+ {
+ multi_linestring_t mls;
+ bg::read_wkt(wkt_multilinestring, mls);
+ BOOST_CHECK(bg::is_valid(mls));
+ bg::set<0>(mls[1][1], invalid_value);
+ check_one<coord_t>(mls);
+ }
+ {
+ multi_polygon_t mpgn;
+ bg::read_wkt(wkt_multipolygon, mpgn);
+ BOOST_CHECK(bg::is_valid(mpgn));
+ bg::set<0>(bg::exterior_ring(mpgn[1])[1], invalid_value);
+ check_one<coord_t>(mpgn);
+ }
+}
+
+template <typename P>
+inline void test_with_invalid_coordinate()
+{
+ typedef typename bg::coordinate_type<P>::type coord_t;
+
+ coord_t const q_nan = std::numeric_limits<coord_t>::quiet_NaN();
+ coord_t const inf = std::numeric_limits<coord_t>::infinity();
+
+ test_with_invalid_coordinate<P, coord_t>(q_nan);
+ test_with_invalid_coordinate<P, coord_t>(inf);
+}
+
+BOOST_AUTO_TEST_CASE( test_geometries_with_invalid_coordinates )
+{
+ typedef point_type fp_point_type;
+ typedef bg::model::point<int, 2, bg::cs::cartesian> int_point_type;
+
+ test_with_invalid_coordinate<fp_point_type>();
+ test_with_invalid_coordinate<int_point_type>();
+}
+
+BOOST_AUTO_TEST_CASE( test_with_NaN_coordinates )
{
#ifdef BOOST_GEOMETRY_TEST_DEBUG
std::cout << std::endl << std::endl;
@@ -1139,12 +1334,12 @@ BOOST_AUTO_TEST_CASE( test_geometry_with_NaN_coordinates )
test_valid
<
tester_allow_spikes, multi_linestring_type
- >::apply("mls-NaN", mls, true);
+ >::apply("mls-NaN", mls, false);
test_valid
<
tester_disallow_spikes, multi_linestring_type
- >::apply("mls-NaN", mls, true);
+ >::apply("mls-NaN", mls, false);
}
BOOST_AUTO_TEST_CASE( test_is_valid_variant )
diff --git a/libs/geometry/test/algorithms/num_geometries_multi.cpp b/libs/geometry/test/algorithms/num_geometries_multi.cpp
index 292e06ea93..9c18a96188 100644
--- a/libs/geometry/test/algorithms/num_geometries_multi.cpp
+++ b/libs/geometry/test/algorithms/num_geometries_multi.cpp
@@ -15,11 +15,11 @@
#include <boost/geometry/geometries/point_xy.hpp>
template <typename Geometry>
-void test_geometry(std::string const& wkt, int expected)
+void test_geometry(std::string const& wkt, std::size_t expected)
{
Geometry geometry;
bg::read_wkt(wkt, geometry);
- int detected = bg::num_geometries(geometry);
+ std::size_t detected = bg::num_geometries(geometry);
BOOST_CHECK_MESSAGE(detected == expected,
"num_geometries: " << wkt
<< " -> Expected: " << expected
diff --git a/libs/geometry/test/algorithms/num_interior_rings_multi.cpp b/libs/geometry/test/algorithms/num_interior_rings_multi.cpp
index 2f9991fe9d..2ad958d810 100644
--- a/libs/geometry/test/algorithms/num_interior_rings_multi.cpp
+++ b/libs/geometry/test/algorithms/num_interior_rings_multi.cpp
@@ -15,11 +15,11 @@
#include <boost/geometry/geometries/point_xy.hpp>
template <typename Geometry>
-void test_geometry(std::string const& wkt, int expected)
+void test_geometry(std::string const& wkt, std::size_t expected)
{
Geometry geometry;
bg::read_wkt(wkt, geometry);
- int detected = bg::num_interior_rings(geometry);
+ std::size_t detected = bg::num_interior_rings(geometry);
BOOST_CHECK_MESSAGE(detected == expected,
"num_interior_rings: " << wkt
<< " -> Expected: " << expected
diff --git a/libs/geometry/test/algorithms/num_points_multi.cpp b/libs/geometry/test/algorithms/num_points_multi.cpp
index 68b814e321..dd96bf3a47 100644
--- a/libs/geometry/test/algorithms/num_points_multi.cpp
+++ b/libs/geometry/test/algorithms/num_points_multi.cpp
@@ -21,9 +21,9 @@
template <typename Geometry>
-void check_geometry(Geometry const& geometry, std::string const& wkt, int expected)
+void check_geometry(Geometry const& geometry, std::string const& wkt, std::size_t expected)
{
- int detected = bg::num_points(geometry);
+ std::size_t detected = bg::num_points(geometry);
BOOST_CHECK_MESSAGE(detected == expected,
"num_points: " << wkt
<< " -> Expected: " << expected
diff --git a/libs/geometry/test/algorithms/overlay/Jamfile.v2 b/libs/geometry/test/algorithms/overlay/Jamfile.v2
index a062f32b43..d1c05438fa 100644
--- a/libs/geometry/test/algorithms/overlay/Jamfile.v2
+++ b/libs/geometry/test/algorithms/overlay/Jamfile.v2
@@ -24,10 +24,8 @@ test-suite boost-geometry-algorithms-overlay
[ run relative_order.cpp : : : : algorithms_relative_order ]
[ run select_rings.cpp : : : : algorithms_select_rings ]
[ run self_intersection_points.cpp : : : : algorithms_self_intersection_points ]
- [ run traverse.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE
- : algorithms_traverse ]
+ [ run traverse.cpp : : : : algorithms_traverse ]
[ run traverse_ccw.cpp : : : : algorithms_traverse_ccw ]
[ run traverse_multi.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE
- <define>BOOST_GEOMETRY_RESCALE_TO_ROBUST
: algorithms_traverse_multi ]
;
diff --git a/libs/geometry/test/algorithms/overlay/enrich_intersection_points.cpp b/libs/geometry/test/algorithms/overlay/enrich_intersection_points.cpp
index 5c37a4be5d..c0078a9e19 100644
--- a/libs/geometry/test/algorithms/overlay/enrich_intersection_points.cpp
+++ b/libs/geometry/test/algorithms/overlay/enrich_intersection_points.cpp
@@ -12,6 +12,8 @@
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
+#error This unit test is not updated for several years
+
#include <iostream>
#include <geometry_test_common.hpp>
@@ -26,7 +28,6 @@
#define GEOMETRY_TEST_OVERLAY_NOT_REVERSED
-#include <overlay_common.hpp>
#include <boost/algorithm/string/replace.hpp>
diff --git a/libs/geometry/test/algorithms/overlay/get_turns.cpp b/libs/geometry/test/algorithms/overlay/get_turns.cpp
index 90cc082771..4efea8e419 100644
--- a/libs/geometry/test/algorithms/overlay/get_turns.cpp
+++ b/libs/geometry/test/algorithms/overlay/get_turns.cpp
@@ -44,7 +44,7 @@
// To test that "get_turns" can be called using additional information
template <typename Point, typename SegmentRatio>
-struct my_turn_op : public bg::detail::overlay::turn_operation<SegmentRatio>
+struct my_turn_op : public bg::detail::overlay::turn_operation<Point, SegmentRatio>
{
};
diff --git a/libs/geometry/test/algorithms/overlay/get_turns_linear_linear.cpp b/libs/geometry/test/algorithms/overlay/get_turns_linear_linear.cpp
index cc7003f8eb..1db5ade851 100644
--- a/libs/geometry/test/algorithms/overlay/get_turns_linear_linear.cpp
+++ b/libs/geometry/test/algorithms/overlay/get_turns_linear_linear.cpp
@@ -285,6 +285,10 @@ void test_all()
"LINESTRING(2 8,4 0.4,8 1,0 5)",
expected("iuu++")("mui=+")("tiu+="));
+#if ! ( defined(BOOST_CLANG) && defined(BOOST_GEOMETRY_COMPILER_MODE_RELEASE) )
+
+ // In clang/release mode this testcase gives other results
+
// assertion failure in 1.57
// FAILING - no assertion failure but the result is not very good
test_geometry<ls, ls>("LINESTRING(-2305843009213693956 4611686018427387906, -33 -92, 78 83)",
@@ -293,6 +297,9 @@ void test_all()
test_geometry<ls, ls>("LINESTRING(31 -97, -46 57, -20 -4)",
"LINESTRING(-2305843009213693956 4611686018427387906, -33 -92, 78 83)",
expected("")(""));
+
+#endif
+
}
// In 1.57 the results of those combinations was different for MinGW
@@ -511,6 +518,18 @@ void test_all()
test_geometry<mls, mls>("MULTILINESTRING((0 0,10 0))",
"MULTILINESTRING((2 0,0 0,-1 -1))",
expected("tiu+=")("mui=+"));
+
+ // parts of boundaries taken from union A/A buffer_mp1
+ if ( BOOST_GEOMETRY_CONDITION((boost::is_same<T, double>::value)) )
+ {
+ test_geometry<ls, ls>("LINESTRING(6.95629520146761 5.415823381635526,6.989043790736545 5.209056926535316,7 5,6.989043790736547 4.790943073464693,6.956295201467611 4.584176618364482)",
+ "LINESTRING(7.415823381635519 5.043704798532389,7.209056926535308 5.010956209263453,7.000000000000001 5,6.790943073464693 5.010956209263453,6.584176618364483 5.043704798532389)",
+ expected("tuu++"));
+ // the above should give the same result as this:
+ test_geometry<ls, ls>("LINESTRING(6.95629520146761 5.415823381635526,6.989043790736545 5.209056926535316,7 5,6.989043790736547 4.790943073464693,6.956295201467611 4.584176618364482)",
+ "LINESTRING(7.415823381635519 5.043704798532389,7.209056926535308 5.010956209263453,7 5,6.790943073464693 5.010956209263453,6.584176618364483 5.043704798532389)",
+ expected("tuu++"));
+ }
}
int test_main(int, char* [])
diff --git a/libs/geometry/test/algorithms/overlay/multi_overlay_cases.hpp b/libs/geometry/test/algorithms/overlay/multi_overlay_cases.hpp
index c44b17adb5..0d0ce1421b 100644
--- a/libs/geometry/test/algorithms/overlay/multi_overlay_cases.hpp
+++ b/libs/geometry/test/algorithms/overlay/multi_overlay_cases.hpp
@@ -12,10 +12,14 @@
#include <string>
+// See powerpoint doc/other/test_cases/overlay_cases.ppt
+// Note that there are some duplicates with single (80 and on)
-static std::string case_multi_simplex[2] = {
- "MULTIPOLYGON(((0 1,2 5,5 3,0 1)),((1 1,5 2,5 0,1 1)))",
- "MULTIPOLYGON(((3 0,0 3,4 5,3 0)))" };
+static std::string case_multi_simplex[2] =
+{
+ "MULTIPOLYGON(((0 1,2 5,5 3,0 1)),((1 1,5 2,5 0,1 1)))",
+ "MULTIPOLYGON(((3 0,0 3,4 5,3 0)))"
+};
// To mix multi/single
static std::string case_single_simplex = "POLYGON((3 0,0 3,4 5,3 0))";
@@ -32,6 +36,22 @@ static std::string case_multi_2[2] =
"MULTIPOLYGON(((14 4,8 8,15 10,14 4)),((15 3,18 9,20 2,15 3)),((5 5,4 7,7 7,5 5)))"
};
+// Case 58, same as case_58 IET (single) but here the second polygon is inverted
+// To check behaviour of difference, but in an intersection operation
+static std::string case_58_multi[8] =
+{
+ /* a */ "MULTIPOLYGON(((3 3,3 4,4 4,4 3,3 3)))",
+ /* b */ "MULTIPOLYGON(((0 2,0 5,4 4,5 0,0 2),(4 4,1 4,1 3,4 4),(4 4,2 3,2 2,4 4),(4 4,3 2,4 2,4 4)))",
+ /* a inv */ "MULTIPOLYGON(((-1 -1,-1 6,6 6,6 -1,-1 -1),(3 3,4 3,4 4,3 4,3 3)))",
+ /* b inv */ "MULTIPOLYGON(((6 6,6 0,5 0,4 4,0 5,0 6,6 6)),((4 4,1 3,1 4,4 4)),((4 4,2 2,2 3,4 4)),((4 4,4 2,3 2,4 4)))",
+
+ // simpler versions of b
+ /* b */ "MULTIPOLYGON(((0 2,0 5,4 4,5 0,0 2),(4 4,1 4,1 3,4 4)))",
+ /* b */ "MULTIPOLYGON(((0 2,0 5,4 4,5 0,0 2),(4 4,3 2,4 2,4 4)))",
+ /* b */ "MULTIPOLYGON(((0 2,0 5,4 4,5 0,0 2),(4 4,2 3,2 2,4 4)))",
+ /* b */ "MULTIPOLYGON(((0 2,0 5,4 4,5 0,0 2),(4 4,2 3,2 2,4 4),(4 4,3 2,4 2,4 4)))",
+};
+
static std::string case_61_multi[2] =
{
// extracted from recursive boxes
@@ -380,6 +400,20 @@ static std::string case_recursive_boxes_4[2] =
"MULTIPOLYGON(((1 0,2 1,2 0,1 0)),((7 9,7 10,8 10,7 9)),((1 0,0 0,0 3,1 3,2 2,2 3,1 3,1 4,2 4,2 5,1 4,0 4,0 8,1 7,1 6,2 7,1 7,1 9,0 9,0 10,7 10,6 9,6.5 8.5,7 9,8 9,9 8,8 8,9 7,9 6,10 7,10 5,9 5,9 4,10 5,10 0,7 0,8 1,7 1,6 0,3 0,3 1,1 1,1 0),(5 1,5.5 0.5,6 1,6 2,6.5 1.5,7 2,8 2,8 4,7 3,6 3,6 2,5 2,6 1,5 1),(4 4,5 4,5 5,4 4),(4 6,4 7,3 7,2 6,3 6,3 7,4 6),(6 5,6.5 4.5,7 5,6 5,7 6,7 7,6 7,6 5),(3.5 7.5,4 8,4 9,3 8,3.5 7.5)),((9 8,9 9,8 9,9 10,10 10,10 8,9 8)))"
};
+static std::string case_recursive_boxes_5[2] =
+{
+ // Occurs after refactoring uu / handle_touch (not yet integrated)
+ "MULTIPOLYGON(((0 9,0 10,1 10,1 9,0 9)),((9 0,9 1,10 1,10 0,9 0)),((5 6,5 7,6 7,6 6,7 6,7 4,6 4,6 5,5 5,5 6)),((5 3,7 3,7 2,4 2,4 3,5 3)),((5 8,5 9,7 9,7 8,5 8)),((4 0,1 0,1 1,5 1,5 0,4 0)),((3 5,3 4,4 4,4 3,2 3,2 2,1 2,1 3,0 3,0 4,2 4,2 5,1 5,1 6,4 6,4 5,3 5)),((0 2,1 2,1 1,0 1,0 2)),((4 10,4 7,1 7,1 6,0 6,0 8,1 8,1 9,2 9,2 10,4 10)),((9 4,9 3,8 3,8 5,9 5,9 4)),((7 2,8 2,8 0,7 0,7 2)),((8 7,10 7,10 6,7 6,7 8,8 8,8 7)))",
+ "MULTIPOLYGON(((2 3,2 4,3 4,3 3,2 3)),((1 5,1 6,2 6,2 5,1 5)),((2 1,2 2,3 2,3 1,2 1)),((8 1,9 1,9 0,8 0,8 1)),((9 7,10 7,10 6,9 6,9 7)),((1 4,1 3,0 3,0 5,1 5,1 4)),((7 6,7 7,8 7,8 6,7 6)),((7 1,7 2,8 2,8 1,7 1)),((6 2,6 3,7 3,7 2,6 2)),((6 8,6 9,7 9,7 8,6 8)),((5 0,3 0,3 1,4 1,4 2,6 2,6 1,7 1,7 0,5 0)),((5 5,5 6,6 6,6 5,8 5,8 6,9 6,9 4,8 4,8 3,7 3,7 4,6 4,6 3,5 3,5 4,3 4,3 6,2 6,2 8,3 8,3 7,5 7,5 6,4 6,4 5,5 5)),((1 1,2 1,2 0,1 0,1 1)),((1 3,2 3,2 2,1 2,1 3)),((3 10,4 10,4 9,2 9,2 8,0 8,0 10,3 10)),((10 3,10 1,9 1,9 2,8 2,8 3,9 3,9 4,10 4,10 3)),((9 9,10 9,10 8,9 8,9 7,8 7,8 10,9 10,9 9)))"
+};
+
+static std::string case_recursive_boxes_6[2] =
+{
+ // Recent regression
+ "MULTIPOLYGON(((2 2,1.5 1.5,2 1,1 1,2 0,0 0,0 3,1 3,1 4,2 4,2 5,5 5,5 0,2 0,2 2,3 1,3 2,3.5 1.5,4 2,2 2)),((1 5,2 5,0 3,0 5,1 5)))",
+ "MULTIPOLYGON(((2 1,2 2,1 2,2 3,1 3,1 4,0 4,0 5,5 5,5 2,4 2,4 3,3 3,4 2,3 2,3 1,2 1)),((2 0,0 0,0 3,1 3,1 2,3 0,2 0)),((4 0,3 0,3 1,4 2,4 1,5 1,5 0,4 0)))"
+};
+
static std::string pie_21_7_21_0_3[2] =
{
"MULTIPOLYGON(((2500 2500,2500 3875,2855 3828,3187 3690,3472 3472,3690 3187,3828 2855,3875 2500,3828 2144,3690 1812,3472 1527,3187 1309,2855 1171,2499 1125,2144 1171,1812 1309,1527 1527,1309 1812,1171 2144,1125 2499,1171 2855,1309 3187,2500 2500)))",
@@ -454,5 +488,40 @@ static std::string ticket_9081[2] =
"MULTIPOLYGON(((0.2099392122251989 0.492066865490789,0.1124301889095737 0.5124668111209448,0.3306914939102383 0.6126684490171914,0.2099392122251989 0.492066865490789)),((0.5885369465145437 0.6478961722242873,0.5342320718598281 0.6686303269145104,0.5619623880692838 0.7033299168703926,0.5945761233023867 0.6823532655194001,0.5885369465145437 0.6478961722242873)),((0.5570738195183501 0.6001870087680015,0.5429714753344335 0.6231021858940831,0.5880357506342242 0.6450365518134291,0.5838690879677763 0.6212632646137447,0.568218114394707 0.5970364466647042,0.5570738195183501 0.6001870087680015)),((0.5498478321815098 0.5029279381860542,0.608691671498764 0.5163121433149205,0.5636607291345047 0.5894838094559455,0.8595233008819849 0.8301950132755517,0.8285440738598029 0.8412277162756114,0.9591357158116398 0.9011810663167211,0.8572649311807611 0.3566393017365032,0.5965816668471951 0.4111770689940296,0.5498478321815098 0.5029279381860542)),((0.3984249865018206 0.4526335964808558,0.3621206996557855 0.4602288471829723,0.4183516736935784 0.4730187483833363,0.4099611282054451 0.4644351568071601,0.3984249865018206 0.4526335964808558)))"
};
+// Integer, ccw, open
+static std::string ticket_10661[3] =
+ {
+ /* A */ "MULTIPOLYGON(((1701 985,3501 985,3501 2785,1701 2785,1701 985)))",
+ /* B */ "MULTIPOLYGON(((1698 1860,1698 1122,2598 1392,3492 1842,3492 32706,2598 2340,1698 1860)))",
+ /* C=A-B, */
+ /* D */ "MULTIPOLYGON(((1698 2772,1698 1860,2598 2340,3492 2412,3492 32743,1698 2772)))"
+ // Reported problem was: validity of difference C-D
+ };
+
+// Integer, ccw, open
+static std::string ticket_10803[2] =
+ {
+ "MULTIPOLYGON(((3174 1374,3174 2886,1374 2886,1374 2139,3174 1374)))",
+ "MULTIPOLYGON(((1374 1092,1734 1092,3174 2526,3174 2886,1374 2886,1374 1092)))"
+ };
+
+// Integer, ccw, open
+static std::string ticket_11674[2] =
+ {
+ "MULTIPOLYGON(((529 3217,529 998,5337 998,5337 1834,5070 2000,5337 2072,5337 3475,529 3475,529 3312,1734 2054,2934 1670,3230 1690,2934 1400,1734 1784,529 3217),(4140 2582,5071 2001,4140 1754,3231 1691,4140 2582)))",
+ "MULTIPOLYGON(((528 3218,528 2498,1734 1406,2556 1522,1734 1784,528 3218)),((4610 2288,5340 1178,5340 1832,4609 2289,4140 3002,2934 1574,2555 1521,2934 1400,4140 2582,4610 2288)))",
+ };
+
+static std::string bug_21155501[2] =
+ {
+ "MULTIPOLYGON(((-8.3935546875 27.449790329784214,4.9658203125 18.729501999072138,11.8212890625 23.563987128451217,9.7119140625 25.48295117535531,9.8876953125 31.728167146023935,8.3056640625 32.99023555965106,8.5693359375 37.16031654673677,-1.8896484375 35.60371874069731,-0.5712890625 32.02670629333614,-8.9208984375 29.458731185355344,-8.3935546875 27.449790329784214)))",
+ "MULTIPOLYGON(((4.9658203125 18.729501999072138,-3.4868710311820115 24.246968623627644,8.3589904332912 33.833614418115445,8.3056640625 32.99023555965106,9.8876953125 31.728167146023935,9.7119140625 25.48295117535531,11.8212890625 23.563987128451217,4.9658203125 18.729501999072138)),((-3.88714525609152 24.508246314579743,-8.3935546875 27.449790329784214,-8.9208984375 29.458731185355344,-0.5712890625 32.02670629333614,-1.8896484375 35.60371874069731,8.5693359375 37.16031654673677,8.362166569827938 33.883846345901595,-3.88714525609152 24.508246314579743)))",
+ };
+
+static std::string mysql_21965285_b[2] =
+ {
+ "MULTIPOLYGON(((3 0, -19 -19, -7 3, -2 10, 15 0, 3 0)))",
+ "MULTIPOLYGON(((1 1, 3 0, 19 -8, -4 -3, 1 1)),((3 0, -2 7, -3 16, 1 19, 8 12, 3 0)))"
+ };
#endif // BOOST_GEOMETRY_TEST_MULTI_OVERLAY_CASES_HPP
diff --git a/libs/geometry/test/algorithms/overlay/overlay_cases.hpp b/libs/geometry/test/algorithms/overlay/overlay_cases.hpp
index 1a28e0c067..5a829dd266 100644
--- a/libs/geometry/test/algorithms/overlay/overlay_cases.hpp
+++ b/libs/geometry/test/algorithms/overlay/overlay_cases.hpp
@@ -18,7 +18,7 @@
#include <string>
-// See powerpoint
+// For case 1..79, See powerpoint doc/other/test_cases/overlay_cases.ppt
static std::string case_1[2] = {
"POLYGON((0 1,2 5,5 3,0 1))",
@@ -310,7 +310,7 @@ static std::string case_58[3] = {
"POLYGON((3 3,3 4,4 4,4 3,3 3))",
// ST: self-tangent
"POLYGON((0 2,0 5,4 4,1 4,1 3,4 4,2 3,2 2,4 4,3 2,4 2,4 4,5 0,0 2))",
- // IET: inner/ext tangency
+ // IET: inner/ext tangency (the correct version)
"POLYGON((0 2,0 5,4 4,5 0,0 2),(4 4,1 4,1 3,4 4),(4 4,2 3,2 2,4 4),(4 4,3 2,4 2,4 4))"
};
@@ -348,11 +348,25 @@ static std::string case_72[2] = {
"POLYGON((0 0,1 4,3 3,4 1,0 0))"
};
+// 73..78: multi
+
static std::string case_79[2] = {
"POLYGON((0 0,0 5,5 5,5 3,2 3,2 2,5 2,5 0,0 0))",
"POLYGON((0 0,0 5,5 5,5 0,2 0,2 2,1 2,1 0,0 0))"
};
+// Two colocations of interior/exterior ring
+static std::string case_80[2] = {
+ "POLYGON((0 5,5 10,10 5,5 0,0 5),(10 5,4 6,5 4,10 5))",
+ "POLYGON((10 0,10 10,20 10,20 0,10 0),(10 5,15 3,18 8,10 5))"
+ };
+
+// Interior ring touches other ring in the middle
+static std::string case_81[2] = {
+ "POLYGON((0 0,0 10,10 10,10 0,0 0),(10 4,2 7,5 1,10 4))",
+ "POLYGON((10 0,10 10,20 10,20 0,10 0),(10 6,15 3,18 8,10 6))"
+ };
+
static std::string case_many_situations[2] = {
"POLYGON((2 6,2 14,10 18,18 14,18 6,16 5,14 4,12 3,10 2,8 3,6 4,4 5,2 6))",
"POLYGON((2 6,2 7,2 8,2 9,2 10,2 11,2 12,1 14"
@@ -864,4 +878,67 @@ static std::string ticket_11121[2] =
"POLYGON((-7901 -1485,-7901 529,-7901 529,15802 544,15802 -1485,-7901 -1485))"
};
+
+static std::string ticket_11725[2] =
+ {
+ "POLYGON((0 0, 0 1, 3 1, 3 0, 0 0))",
+ "POLYGON((0 1, 0 3, 3 3, 3 1, 2 2, 1 2 , 1 1, 0 1))"
+ };
+
+static std::string ticket_11725_2[2] =
+ {
+ "POLYGON((0 0, 0 3, 3 3, 3 0, 0 0))",
+ "POLYGON((3 1, 1 1, 1 2, 2 2, 3 1))",
+ };
+
+// Integer, ccw, open
+static std::string ticket_11676[2] =
+ {
+ "POLYGON((1920 1660,1920 1462,3720 1462,3720 3262,1920 3262,1920 1959,2218 2189,1920 1660),(3718 1561,3360 2233,3718 1957,3718 1561),(2818 2653,2218 2189,2818 3253,3360 2233,2818 2653))",
+ "POLYGON((1918 2155,1918 1957,2818 2653,3718 1957,3718 2154,2818 3055,1918 2155))",
+ };
+
+static std::string mysql_21964079_1[2] =
+ {
+ "POLYGON((7 3,0 10,0 -6,9 -5, 7 7, 7 3), (0 8, 2 3, 2 -2, 0 8))",
+ "POLYGON((0 8,-8 14,-11 18,-19 11, -3 1, 0 8))"
+ };
+
+static std::string mysql_21964079_2[2] =
+ {
+ "POLYGON((0 0,0 10,10 10,10 0,0 0), (0 8, 4 4, 4 6, 0 8))",
+ "POLYGON((0 8,-8 8,-10 4,0 8))"
+ };
+
+static std::string mysql_21964049[2] =
+ {
+ "POLYGON((7 0,10 -3,7 1,7 0))",
+ "POLYGON((7 4,-14 10,7 -17,7 4),(7 1,0 3,-2 4,7 1))"
+ };
+
+static std::string mysql_21964465[2] =
+ {
+ "POLYGON((0 0,0 10,10 10,10 0, 0 0), (0 8, 4 4, 4 6, 0 8))",
+ "POLYGON((0 8,-8 8,-2 2,0 8))",
+ };
+
+static std::string mysql_21977775[2] =
+ {
+ "POLYGON((8 6, 5 7, -1 4, -8 -7, 0 -17, 8 6), (3 6, 5 5, 0 -2, 3 6))",
+ "POLYGON((3 3, -17 11, -8 -3, 3 3))",
+ };
+
+static std::string mysql_21965285[2] =
+ {
+ "POLYGON((7 3, 0 10, 0 -6, 9 -5, 7 7, 7 3), (0 8, 2 3, 2 -2, 0 8))",
+ "POLYGON((0 6, 0 8, -14 13, 0 6))",
+ };
+
+static std::string mysql_21965285_b_inv[2] =
+ {
+ "POLYGON((3 0, -19 -19, -7 3, -2 10, 15 0, 3 0))",
+ "POLYGON((-20 -20,-20 20,20 20,20 -20,-20 -20),(1 1, -4 -3, 19 -8, 3 0, 1 1),(3 0, 8 12, 1 19, -3 16, -2 7, 3 0))"
+ };
+
+
#endif // BOOST_GEOMETRY_TEST_OVERLAY_CASES_HPP
diff --git a/libs/geometry/test/algorithms/overlay/self_intersection_points.cpp b/libs/geometry/test/algorithms/overlay/self_intersection_points.cpp
index 9825018bfd..d6471ff04d 100644
--- a/libs/geometry/test/algorithms/overlay/self_intersection_points.cpp
+++ b/libs/geometry/test/algorithms/overlay/self_intersection_points.cpp
@@ -44,7 +44,7 @@
template <typename Geometry>
static void test_self_intersection_points(std::string const& case_id,
- int expected_count,
+ std::size_t expected_count,
Geometry const& geometry,
bool check_has_intersections,
double /*precision*/ = 0.001)
@@ -84,7 +84,7 @@ static void test_self_intersection_points(std::string const& case_id,
x += bg::get<0>(turn.point);
y += bg::get<1>(turn.point);
}
- int n = boost::size(turns);
+ std::size_t n = boost::size(turns);
if (n > 0)
{
x /= n;
diff --git a/libs/geometry/test/algorithms/overlay/traverse.cpp b/libs/geometry/test/algorithms/overlay/traverse.cpp
index 7aef1789be..cf079dc22e 100644
--- a/libs/geometry/test/algorithms/overlay/traverse.cpp
+++ b/libs/geometry/test/algorithms/overlay/traverse.cpp
@@ -46,6 +46,7 @@
#include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
#include <boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp>
+#include <boost/geometry/algorithms/detail/overlay/overlay_type.hpp>
#include <boost/geometry/algorithms/detail/overlay/traverse.hpp>
#include <boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp>
@@ -68,9 +69,16 @@
#include <algorithms/overlay/overlay_cases.hpp>
-static inline std::string operation(int d)
+template <bg::overlay_type Op>
+static inline std::string operation()
{
- return d == 1 ? "union" : "intersection";
+ switch(Op)
+ {
+ case bg::overlay_union : return "union";
+ case bg::overlay_intersection : return "intersection";
+ case bg::overlay_difference : return "difference";
+ }
+ return "unknown";
}
@@ -80,7 +88,7 @@ namespace detail
template
<
typename G1, typename G2,
- bg::detail::overlay::operation_type Direction,
+ bg::overlay_type OverlayType,
bool Reverse1, bool Reverse2
>
struct test_traverse
@@ -159,28 +167,30 @@ struct test_traverse
> turn_info;
std::vector<turn_info> turns;
+ bg::detail::overlay::operation_type const op =
+ OverlayType == bg::overlay_union
+ ? bg::detail::overlay::operation_union
+ : bg::detail::overlay::operation_intersection;
+
bg::detail::get_turns::no_interrupt_policy policy;
bg::get_turns<Reverse1, Reverse2, bg::detail::overlay::assign_null_policy>(g1, g2, rescale_policy, turns, policy);
- bg::enrich_intersection_points<Reverse1, Reverse2>(turns,
- Direction == 1 ? bg::detail::overlay::operation_union
- : bg::detail::overlay::operation_intersection,
+ bg::enrich_intersection_points<Reverse1, Reverse2, OverlayType>(turns, op,
g1, g2, rescale_policy, side_strategy_type());
typedef bg::model::ring<typename bg::point_type<G2>::type> ring_type;
typedef std::vector<ring_type> out_vector;
out_vector v;
-
bg::detail::overlay::traverse
<
Reverse1, Reverse2,
G1, G2
- >::apply(g1, g2, Direction, rescale_policy, turns, v);
+ >::apply(g1, g2, op, rescale_policy, turns, v);
// Check number of resulting rings
BOOST_CHECK_MESSAGE(expected_count == boost::size(v),
"traverse: " << id
- << " (" << operation(Direction) << ")"
+ << " (" << operation<OverlayType>() << ")"
<< " #shapes expected: " << expected_count
<< " detected: " << boost::size(v)
<< " type: " << string_from_type
@@ -200,7 +210,7 @@ struct test_traverse
#if defined(TEST_WITH_SVG)
{
std::ostringstream filename;
- filename << "traverse_" << operation(Direction)
+ filename << "traverse_" << operation<OverlayType>()
<< "_" << id
<< "_" << string_from_type<typename bg::coordinate_type<G1>::type>::name()
<< ".svg";
@@ -257,6 +267,10 @@ struct test_traverse
style = "fill:rgb(92,92,92);font-family:Arial;font-size:6px";
lineheight = 6;
}
+ else if (turn.colocated)
+ {
+ style = "fill:rgb(255,0,0);font-family:Arial;font-size:8px";
+ }
//if (! turn.is_discarded() && ! turn.blocked() && ! turn.both(bg::detail::overlay::operation_union))
//if (! turn.discarded)
@@ -357,7 +371,7 @@ struct test_traverse
template
<
typename G1, typename G2,
- bg::detail::overlay::operation_type Direction,
+ bg::overlay_type OverlayType,
bool Reverse1 = false,
bool Reverse2 = false
>
@@ -365,7 +379,7 @@ struct test_traverse
{
typedef detail::test_traverse
<
- G1, G2, Direction, Reverse1, Reverse2
+ G1, G2, OverlayType, Reverse1, Reverse2
> detail_test_traverse;
inline static void apply(std::string const& id, std::size_t expected_count, double expected_area,
@@ -418,299 +432,306 @@ struct test_traverse
template <typename T>
void test_all(bool test_self_tangencies = true, bool test_mixed = false)
{
- using namespace bg::detail::overlay;
-
typedef bg::model::point<T, 2, bg::cs::cartesian> P;
typedef bg::model::polygon<P> polygon;
//typedef bg::model::box<P> box;
+ typedef test_traverse
+ <
+ polygon, polygon, bg::overlay_intersection
+ > test_traverse_intersection;
+ typedef test_traverse
+ <
+ polygon, polygon, bg::overlay_union
+ > test_traverse_union;
+
// 1-6
- test_traverse<polygon, polygon, operation_intersection>::apply("1", 1, 5.4736, case_1[0], case_1[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("2", 1, 12.0545, case_2[0], case_2[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("3", 1, 5, case_3[0], case_3[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("4", 1, 10.2212, case_4[0], case_4[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("5", 2, 12.8155, case_5[0], case_5[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("6", 1, 4.5, case_6[0], case_6[1]);
+ test_traverse_intersection::apply("1", 1, 5.4736, case_1[0], case_1[1]);
+ test_traverse_intersection::apply("2", 1, 12.0545, case_2[0], case_2[1]);
+ test_traverse_intersection::apply("3", 1, 5, case_3[0], case_3[1]);
+ test_traverse_intersection::apply("4", 1, 10.2212, case_4[0], case_4[1]);
+ test_traverse_intersection::apply("5", 2, 12.8155, case_5[0], case_5[1]);
+ test_traverse_intersection::apply("6", 1, 4.5, case_6[0], case_6[1]);
// 7-12
- test_traverse<polygon, polygon, operation_intersection>::apply("7", 0, 0, case_7[0], case_7[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("8", 0, 0, case_8[0], case_8[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("9", 0, 0, case_9[0], case_9[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("10", 0, 0, case_10[0], case_10[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("11", 1, 1, case_11[0], case_11[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("12", 2, 0.63333, case_12[0], case_12[1]);
+ test_traverse_intersection::apply("7", 0, 0, case_7[0], case_7[1]);
+ test_traverse_intersection::apply("8", 0, 0, case_8[0], case_8[1]);
+ test_traverse_intersection::apply("9", 0, 0, case_9[0], case_9[1]);
+ test_traverse_intersection::apply("10", 0, 0, case_10[0], case_10[1]);
+ test_traverse_intersection::apply("11", 1, 1, case_11[0], case_11[1]);
+ test_traverse_intersection::apply("12", 2, 0.63333, case_12[0], case_12[1]);
// 13-18
- test_traverse<polygon, polygon, operation_intersection>::apply("13", 0, 0, case_13[0], case_13[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("14", 0, 0, case_14[0], case_14[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("15", 0, 0, case_15[0], case_15[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("16", 0, 0, case_16[0], case_16[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("17", 1, 2, case_17[0], case_17[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("18", 1, 2, case_18[0], case_18[1]);
+ test_traverse_intersection::apply("13", 0, 0, case_13[0], case_13[1]);
+ test_traverse_intersection::apply("14", 0, 0, case_14[0], case_14[1]);
+ test_traverse_intersection::apply("15", 0, 0, case_15[0], case_15[1]);
+ test_traverse_intersection::apply("16", 0, 0, case_16[0], case_16[1]);
+ test_traverse_intersection::apply("17", 1, 2, case_17[0], case_17[1]);
+ test_traverse_intersection::apply("18", 1, 2, case_18[0], case_18[1]);
// 19-24
- test_traverse<polygon, polygon, operation_intersection>::apply("19", 0, 0, case_19[0], case_19[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("20", 1, 5.5, case_20[0], case_20[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("21", 0, 0, case_21[0], case_21[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("22", 0, 0, case_22[0], case_22[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("23", 1, 1.4, case_23[0], case_23[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("24", 1, 1.0, case_24[0], case_24[1]);
+ test_traverse_intersection::apply("19", 0, 0, case_19[0], case_19[1]);
+ test_traverse_intersection::apply("20", 1, 5.5, case_20[0], case_20[1]);
+ test_traverse_intersection::apply("21", 0, 0, case_21[0], case_21[1]);
+ test_traverse_intersection::apply("22", 0, 0, case_22[0], case_22[1]);
+ test_traverse_intersection::apply("23", 1, 1.4, case_23[0], case_23[1]);
+ test_traverse_intersection::apply("24", 1, 1.0, case_24[0], case_24[1]);
// 25-30
- test_traverse<polygon, polygon, operation_intersection>::apply("25", 0, 0, case_25[0], case_25[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("26", 0, 0, case_26[0], case_26[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("27", 1, 0.9545454, case_27[0], case_27[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("28", 1, 0.9545454, case_28[0], case_28[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("29", 1, 1.4, case_29[0], case_29[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("30", 1, 0.5, case_30[0], case_30[1]);
+ test_traverse_intersection::apply("25", 0, 0, case_25[0], case_25[1]);
+ test_traverse_intersection::apply("26", 0, 0, case_26[0], case_26[1]);
+ test_traverse_intersection::apply("27", 1, 0.9545454, case_27[0], case_27[1]);
+ test_traverse_intersection::apply("28", 1, 0.9545454, case_28[0], case_28[1]);
+ test_traverse_intersection::apply("29", 1, 1.4, case_29[0], case_29[1]);
+ test_traverse_intersection::apply("30", 1, 0.5, case_30[0], case_30[1]);
// 31-36
- test_traverse<polygon, polygon, operation_intersection>::apply("31", 0, 0, case_31[0], case_31[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("32", 0, 0, case_32[0], case_32[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("33", 0, 0, case_33[0], case_33[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("34", 1, 0.5, case_34[0], case_34[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("35", 1, 1.0, case_35[0], case_35[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("36", 1, 1.625, case_36[0], case_36[1]);
+ test_traverse_intersection::apply("31", 0, 0, case_31[0], case_31[1]);
+ test_traverse_intersection::apply("32", 0, 0, case_32[0], case_32[1]);
+ test_traverse_intersection::apply("33", 0, 0, case_33[0], case_33[1]);
+ test_traverse_intersection::apply("34", 1, 0.5, case_34[0], case_34[1]);
+ test_traverse_intersection::apply("35", 1, 1.0, case_35[0], case_35[1]);
+ test_traverse_intersection::apply("36", 1, 1.625, case_36[0], case_36[1]);
// 37-42
- test_traverse<polygon, polygon, operation_intersection>::apply("37", 2, 0.666666, case_37[0], case_37[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("38", 2, 0.971429, case_38[0], case_38[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("39", 1, 24, case_39[0], case_39[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("40", 0, 0, case_40[0], case_40[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("41", 1, 5, case_41[0], case_41[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("42", 1, 5, case_42[0], case_42[1]);
+ test_traverse_intersection::apply("37", 2, 0.666666, case_37[0], case_37[1]);
+ test_traverse_intersection::apply("38", 2, 0.971429, case_38[0], case_38[1]);
+ test_traverse_intersection::apply("39", 1, 24, case_39[0], case_39[1]);
+ test_traverse_intersection::apply("40", 0, 0, case_40[0], case_40[1]);
+ test_traverse_intersection::apply("41", 1, 5, case_41[0], case_41[1]);
+ test_traverse_intersection::apply("42", 1, 5, case_42[0], case_42[1]);
// 43-48 - invalid polygons
- //test_traverse<polygon, polygon, operation_intersection>::apply("43", 2, 0.75, case_43[0], case_43[1]);
- //test_traverse<polygon, polygon, operation_intersection>::apply("44", 1, 44, case_44[0], case_44[1]);
- //test_traverse<polygon, polygon, operation_intersection>::apply("45", 1, 45, case_45[0], case_45[1]);
- //test_traverse<polygon, polygon, operation_intersection>::apply("46", 1, 46, case_46[0], case_46[1]);
- //test_traverse<polygon, polygon, operation_intersection>::apply("47", 1, 47, case_47[0], case_47[1]);
+ //test_traverse_intersection::apply("43", 2, 0.75, case_43[0], case_43[1]);
+ //test_traverse_intersection::apply("44", 1, 44, case_44[0], case_44[1]);
+ //test_traverse_intersection::apply("45", 1, 45, case_45[0], case_45[1]);
+ //test_traverse_intersection::apply("46", 1, 46, case_46[0], case_46[1]);
+ //test_traverse_intersection::apply("47", 1, 47, case_47[0], case_47[1]);
// 49-54
- test_traverse<polygon, polygon, operation_intersection>::apply("50", 0, 0, case_50[0], case_50[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("51", 0, 0, case_51[0], case_51[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("52", 1, 10.5, case_52[0], case_52[1]);
+ test_traverse_intersection::apply("50", 0, 0, case_50[0], case_50[1]);
+ test_traverse_intersection::apply("51", 0, 0, case_51[0], case_51[1]);
+ test_traverse_intersection::apply("52", 1, 10.5, case_52[0], case_52[1]);
if (test_self_tangencies)
{
- test_traverse<polygon, polygon, operation_intersection>::apply("53_st", 0, 0, case_53[0], case_53[1]);
+ test_traverse_intersection::apply("53_st", 0, 0, case_53[0], case_53[1]);
}
- test_traverse<polygon, polygon, operation_intersection>::apply("53_iet", 0, 0, case_53[0], case_53[2]);
+ test_traverse_intersection::apply("53_iet", 0, 0, case_53[0], case_53[2]);
- test_traverse<polygon, polygon, operation_intersection>::apply("54_iet_iet", 1, 2, case_54[1], case_54[3]);
+ test_traverse_intersection::apply("54_iet_iet", 1, 2, case_54[1], case_54[3]);
if (test_self_tangencies)
{
- test_traverse<polygon, polygon, operation_intersection>::apply("54_st_iet", 1, 2, case_54[0], case_54[3]);
- test_traverse<polygon, polygon, operation_intersection>::apply("54_iet_st", 1, 2, case_54[1], case_54[2]);
- test_traverse<polygon, polygon, operation_intersection>::apply("54_st_st", 1, 2, case_54[0], case_54[2]);
+ test_traverse_intersection::apply("54_st_iet", 1, 2, case_54[0], case_54[3]);
+ test_traverse_intersection::apply("54_iet_st", 1, 2, case_54[1], case_54[2]);
+ test_traverse_intersection::apply("54_st_st", 1, 2, case_54[0], case_54[2]);
}
if (test_self_tangencies)
{
// 55-60
- test_traverse<polygon, polygon, operation_intersection>::apply("55_st_st", 1, 2, case_55[0], case_55[2]);
+ test_traverse_intersection::apply("55_st_st", 1, 2, case_55[0], case_55[2]);
}
- test_traverse<polygon, polygon, operation_intersection>::apply("55_st_iet", 1, 2, case_55[0], case_55[3]);
- test_traverse<polygon, polygon, operation_intersection>::apply("55_iet_st", 1, 2, case_55[1], case_55[2]);
+ test_traverse_intersection::apply("55_st_iet", 1, 2, case_55[0], case_55[3]);
+ test_traverse_intersection::apply("55_iet_st", 1, 2, case_55[1], case_55[2]);
if (test_self_tangencies)
{
- test_traverse<polygon, polygon, operation_intersection>::apply("56", 2, 4.5, case_56[0], case_56[1]);
+ test_traverse_intersection::apply("56", 2, 4.5, case_56[0], case_56[1]);
}
- test_traverse<polygon, polygon, operation_intersection>::apply("55_iet_iet", 1, 2, case_55[1], case_55[3]);
- test_traverse<polygon, polygon, operation_intersection>::apply("57", 2, 5.9705882, case_57[0], case_57[1]);
+ test_traverse_intersection::apply("55_iet_iet", 1, 2, case_55[1], case_55[3]);
+ test_traverse_intersection::apply("57", 2, 5.9705882, case_57[0], case_57[1]);
if (test_self_tangencies)
{
- test_traverse<polygon, polygon, operation_intersection>::apply("58_st",
+ test_traverse_intersection::apply("58_st",
2, 0.333333, case_58[0], case_58[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("59_st",
+ test_traverse_intersection::apply("59_st",
2, 1.5416667, case_59[0], case_59[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("60_st",
+ test_traverse_intersection::apply("60_st",
3, 2, case_60[0], case_60[1]);
}
- test_traverse<polygon, polygon, operation_intersection>::apply("58_iet",
+ test_traverse_intersection::apply("58_iet",
2, 0.333333, case_58[0], case_58[2]);
- test_traverse<polygon, polygon, operation_intersection>::apply("59_iet",
+ test_traverse_intersection::apply("59_iet",
2, 1.5416667, case_59[0], case_59[2]);
- test_traverse<polygon, polygon, operation_intersection>::apply("60_iet",
+ test_traverse_intersection::apply("60_iet",
3, 2, case_60[0], case_60[2]);
- test_traverse<polygon, polygon, operation_intersection>::apply("61_st",
+ test_traverse_intersection::apply("61_st",
0, 0, case_61[0], case_61[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("70",
+ test_traverse_intersection::apply("70",
2, 4, case_70[0], case_70[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("71",
+ test_traverse_intersection::apply("71",
2, 2, case_71[0], case_71[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("72",
+ test_traverse_intersection::apply("72",
3, 2.85, case_72[0], case_72[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("79",
+ test_traverse_intersection::apply("79",
2, 20, case_79[0], case_79[1]);
// other
// pies (went wrong when not all cases where implemented, especially some collinear (opposite) cases
- test_traverse<polygon, polygon, operation_intersection>::apply("pie_16_4_12",
+ test_traverse_intersection::apply("pie_16_4_12",
1, 491866.5, pie_16_4_12[0], pie_16_4_12[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("pie_23_21_12_500",
+ test_traverse_intersection::apply("pie_23_21_12_500",
2, 2363199.3313, pie_23_21_12_500[0], pie_23_21_12_500[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("pie_23_23_3_2000",
+ test_traverse_intersection::apply("pie_23_23_3_2000",
2, 1867779.9349, pie_23_23_3_2000[0], pie_23_23_3_2000[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("pie_23_16_16",
+ test_traverse_intersection::apply("pie_23_16_16",
2, 2128893.9555, pie_23_16_16[0], pie_23_16_16[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("pie_16_2_15_0",
+ test_traverse_intersection::apply("pie_16_2_15_0",
0, 0, pie_16_2_15_0[0], pie_16_2_15_0[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("pie_4_13_15",
+ test_traverse_intersection::apply("pie_4_13_15",
1, 490887.06678, pie_4_13_15[0], pie_4_13_15[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("pie_20_20_7_100",
+ test_traverse_intersection::apply("pie_20_20_7_100",
2, 2183372.2718, pie_20_20_7_100[0], pie_20_20_7_100[1]);
// 1-6
- test_traverse<polygon, polygon, operation_union>::apply("1", 1, 11.5264, case_1[0], case_1[1]);
- test_traverse<polygon, polygon, operation_union>::apply("2", 1, 17.9455, case_2[0], case_2[1]);
- test_traverse<polygon, polygon, operation_union>::apply("3", 1, 9, case_3[0], case_3[1]);
- test_traverse<polygon, polygon, operation_union>::apply("4", 3, 17.7788, case_4[0], case_4[1]);
- test_traverse<polygon, polygon, operation_union>::apply("5", 2, 18.4345, case_5[0], case_5[1]);
- test_traverse<polygon, polygon, operation_union>::apply("6", 1, 9, case_6[0], case_6[1]);
+ test_traverse_union::apply("1", 1, 11.5264, case_1[0], case_1[1]);
+ test_traverse_union::apply("2", 1, 17.9455, case_2[0], case_2[1]);
+ test_traverse_union::apply("3", 1, 9, case_3[0], case_3[1]);
+ test_traverse_union::apply("4", 3, 17.7788, case_4[0], case_4[1]);
+ test_traverse_union::apply("5", 2, 18.4345, case_5[0], case_5[1]);
+ test_traverse_union::apply("6", 1, 9, case_6[0], case_6[1]);
// 7-12
- test_traverse<polygon, polygon, operation_union>::apply("7", 1, 9, case_7[0], case_7[1]);
- test_traverse<polygon, polygon, operation_union>::apply("8", 1, 12, case_8[0], case_8[1]);
- test_traverse<polygon, polygon, operation_union>::apply("9", 0, 0 /*UU 2, 11*/, case_9[0], case_9[1]);
- test_traverse<polygon, polygon, operation_union>::apply("10", 1, 9, case_10[0], case_10[1]);
- test_traverse<polygon, polygon, operation_union>::apply("11", 1, 8, case_11[0], case_11[1]);
- test_traverse<polygon, polygon, operation_union>::apply("12", 2, 8.36667, case_12[0], case_12[1]);
+ test_traverse_union::apply("7", 1, 9, case_7[0], case_7[1]);
+ test_traverse_union::apply("8", 1, 12, case_8[0], case_8[1]);
+ test_traverse_union::apply("9", 0, 0 /*UU 2, 11*/, case_9[0], case_9[1]);
+ test_traverse_union::apply("10", 1, 9, case_10[0], case_10[1]);
+ test_traverse_union::apply("11", 1, 8, case_11[0], case_11[1]);
+ test_traverse_union::apply("12", 2, 8.36667, case_12[0], case_12[1]);
// 13-18
- test_traverse<polygon, polygon, operation_union>::apply("13", 1, 4, case_13[0], case_13[1]);
- test_traverse<polygon, polygon, operation_union>::apply("14", 1, 12, case_14[0], case_14[1]);
- test_traverse<polygon, polygon, operation_union>::apply("15", 1, 12, case_15[0], case_15[1]);
- test_traverse<polygon, polygon, operation_union>::apply("16", 1, 9, case_16[0], case_16[1]);
- test_traverse<polygon, polygon, operation_union>::apply("17", 1, 8, case_17[0], case_17[1]);
- test_traverse<polygon, polygon, operation_union>::apply("18", 1, 8, case_18[0], case_18[1]);
+ test_traverse_union::apply("13", 1, 4, case_13[0], case_13[1]);
+ test_traverse_union::apply("14", 1, 12, case_14[0], case_14[1]);
+ test_traverse_union::apply("15", 1, 12, case_15[0], case_15[1]);
+ test_traverse_union::apply("16", 1, 9, case_16[0], case_16[1]);
+ test_traverse_union::apply("17", 1, 8, case_17[0], case_17[1]);
+ test_traverse_union::apply("18", 1, 8, case_18[0], case_18[1]);
// 19-24
- test_traverse<polygon, polygon, operation_union>::apply("19", 1, 10, case_19[0], case_19[1]);
- test_traverse<polygon, polygon, operation_union>::apply("20", 1, 5.5, case_20[0], case_20[1]);
- test_traverse<polygon, polygon, operation_union>::apply("21", 0, 0, case_21[0], case_21[1]);
- test_traverse<polygon, polygon, operation_union>::apply("22", 0, 0 /*UU 2, 9.5*/, case_22[0], case_22[1]);
- test_traverse<polygon, polygon, operation_union>::apply("23", 1, 6.1, case_23[0], case_23[1]);
- test_traverse<polygon, polygon, operation_union>::apply("24", 1, 5.5, case_24[0], case_24[1]);
+ test_traverse_union::apply("19", 1, 10, case_19[0], case_19[1]);
+ test_traverse_union::apply("20", 1, 5.5, case_20[0], case_20[1]);
+ test_traverse_union::apply("21", 0, 0, case_21[0], case_21[1]);
+ test_traverse_union::apply("22", 0, 0 /*UU 2, 9.5*/, case_22[0], case_22[1]);
+ test_traverse_union::apply("23", 1, 6.1, case_23[0], case_23[1]);
+ test_traverse_union::apply("24", 1, 5.5, case_24[0], case_24[1]);
// 25-30
- test_traverse<polygon, polygon, operation_union>::apply("25", 0, 0 /*UU 2, 7*/, case_25[0], case_25[1]);
- test_traverse<polygon, polygon, operation_union>::apply("26", 0, 0 /*UU 2, 7.5 */, case_26[0], case_26[1]);
- test_traverse<polygon, polygon, operation_union>::apply("27", 1, 8.04545, case_27[0], case_27[1]);
- test_traverse<polygon, polygon, operation_union>::apply("28", 1, 10.04545, case_28[0], case_28[1]);
- test_traverse<polygon, polygon, operation_union>::apply("29", 1, 8.1, case_29[0], case_29[1]);
- test_traverse<polygon, polygon, operation_union>::apply("30", 1, 6.5, case_30[0], case_30[1]);
+ test_traverse_union::apply("25", 0, 0 /*UU 2, 7*/, case_25[0], case_25[1]);
+ test_traverse_union::apply("26", 0, 0 /*UU 2, 7.5 */, case_26[0], case_26[1]);
+ test_traverse_union::apply("27", 1, 8.04545, case_27[0], case_27[1]);
+ test_traverse_union::apply("28", 1, 10.04545, case_28[0], case_28[1]);
+ test_traverse_union::apply("29", 1, 8.1, case_29[0], case_29[1]);
+ test_traverse_union::apply("30", 1, 6.5, case_30[0], case_30[1]);
// 31-36
- test_traverse<polygon, polygon, operation_union>::apply("31", 0, 0 /*UU 2, 4.5 */, case_31[0], case_31[1]);
- test_traverse<polygon, polygon, operation_union>::apply("32", 0, 0 /*UU 2, 4.5 */, case_32[0], case_32[1]);
- test_traverse<polygon, polygon, operation_union>::apply("33", 0, 0 /*UU 2, 4.5 */, case_33[0], case_33[1]);
- test_traverse<polygon, polygon, operation_union>::apply("34", 1, 6.0, case_34[0], case_34[1]);
- test_traverse<polygon, polygon, operation_union>::apply("35", 1, 10.5, case_35[0], case_35[1]);
- test_traverse<polygon, polygon, operation_union>::apply("36", 1 /*UU 2*/, 14.375, case_36[0], case_36[1]);
+ test_traverse_union::apply("31", 0, 0 /*UU 2, 4.5 */, case_31[0], case_31[1]);
+ test_traverse_union::apply("32", 0, 0 /*UU 2, 4.5 */, case_32[0], case_32[1]);
+ test_traverse_union::apply("33", 0, 0 /*UU 2, 4.5 */, case_33[0], case_33[1]);
+ test_traverse_union::apply("34", 1, 6.0, case_34[0], case_34[1]);
+ test_traverse_union::apply("35", 1, 10.5, case_35[0], case_35[1]);
+ test_traverse_union::apply("36", 1 /*UU 2*/, 14.375, case_36[0], case_36[1]);
// 37-42
- test_traverse<polygon, polygon, operation_union>::apply("37", 1, 7.33333, case_37[0], case_37[1]);
- test_traverse<polygon, polygon, operation_union>::apply("38", 1, 9.52857, case_38[0], case_38[1]);
- test_traverse<polygon, polygon, operation_union>::apply("39", 1, 40.0, case_39[0], case_39[1]);
- test_traverse<polygon, polygon, operation_union>::apply("40", 0, 0 /*UU 2, 11 */, case_40[0], case_40[1]);
- test_traverse<polygon, polygon, operation_union>::apply("41", 1, 5, case_41[0], case_41[1]);
- test_traverse<polygon, polygon, operation_union>::apply("42", 1, 5, case_42[0], case_42[1]);
+ test_traverse_union::apply("37", 1, 7.33333, case_37[0], case_37[1]);
+ test_traverse_union::apply("38", 1, 9.52857, case_38[0], case_38[1]);
+ test_traverse_union::apply("39", 1, 40.0, case_39[0], case_39[1]);
+ test_traverse_union::apply("40", 0, 0 /*UU 2, 11 */, case_40[0], case_40[1]);
+ test_traverse_union::apply("41", 1, 5, case_41[0], case_41[1]);
+ test_traverse_union::apply("42", 1, 5, case_42[0], case_42[1]);
// 43-48
- //test_traverse<polygon, polygon, operation_union>::apply("43", 3, 8.1875, case_43[0], case_43[1]);
- //test_traverse<polygon, polygon, operation_union>::apply("44", 1, 44, case_44[0], case_44[1]);
- //test_traverse<polygon, polygon, operation_union>::apply("45", 1, 45, case_45[0], case_45[1]);
- //test_traverse<polygon, polygon, operation_union>::apply("46", 1, 46, case_46[0], case_46[1]);
- //test_traverse<polygon, polygon, operation_union>::apply("47", 1, 47, case_47[0], case_47[1]);
+ //test_traverse_union::apply("43", 3, 8.1875, case_43[0], case_43[1]);
+ //test_traverse_union::apply("44", 1, 44, case_44[0], case_44[1]);
+ //test_traverse_union::apply("45", 1, 45, case_45[0], case_45[1]);
+ //test_traverse_union::apply("46", 1, 46, case_46[0], case_46[1]);
+ //test_traverse_union::apply("47", 1, 47, case_47[0], case_47[1]);
// 49-54
- test_traverse<polygon, polygon, operation_union>::apply("50", 1, 25, case_50[0], case_50[1]);
- test_traverse<polygon, polygon, operation_union>::apply("51", 0, 0, case_51[0], case_51[1]);
- test_traverse<polygon, polygon, operation_union>::apply("52", 1, 15.5, case_52[0], case_52[1]);
+ test_traverse_union::apply("50", 1, 25, case_50[0], case_50[1]);
+ test_traverse_union::apply("51", 0, 0, case_51[0], case_51[1]);
+ test_traverse_union::apply("52", 1, 15.5, case_52[0], case_52[1]);
if (test_self_tangencies)
{
- test_traverse<polygon, polygon, operation_union>::apply("53_st", 2, 16, case_53[0], case_53[1]);
+ test_traverse_union::apply("53_st", 2, 16, case_53[0], case_53[1]);
}
- test_traverse<polygon, polygon, operation_union>::apply("53_iet",
+ test_traverse_union::apply("53_iet",
2, 16, case_53[0], case_53[2]);
if (test_self_tangencies)
{
- test_traverse<polygon, polygon, operation_union>::apply("54_st_st", 2, 20, case_54[0], case_54[2]);
- test_traverse<polygon, polygon, operation_union>::apply("54_st_iet", 2, 20, case_54[0], case_54[3]);
- test_traverse<polygon, polygon, operation_union>::apply("54_iet_st", 2, 20, case_54[1], case_54[2]);
+ test_traverse_union::apply("54_st_st", 2, 20, case_54[0], case_54[2]);
+ test_traverse_union::apply("54_st_iet", 2, 20, case_54[0], case_54[3]);
+ test_traverse_union::apply("54_iet_st", 2, 20, case_54[1], case_54[2]);
}
- test_traverse<polygon, polygon, operation_union>::apply("54_iet_iet", 2, 20, case_54[1], case_54[3]);
+ test_traverse_union::apply("54_iet_iet", 2, 20, case_54[1], case_54[3]);
if (test_mixed)
{
- test_traverse<polygon, polygon, operation_union>::apply("55_st_iet", 2, 18, case_55[0], case_55[3]);
- test_traverse<polygon, polygon, operation_union>::apply("55_iet_st", 2, 18, case_55[1], case_55[2]);
+ test_traverse_union::apply("55_st_iet", 2, 18, case_55[0], case_55[3]);
+ test_traverse_union::apply("55_iet_st", 2, 18, case_55[1], case_55[2]);
// moved to mixed
- test_traverse<polygon, polygon, operation_union>::apply("55_iet_iet", 3, 18, case_55[1], case_55[3]);
+ test_traverse_union::apply("55_iet_iet", 3, 18, case_55[1], case_55[3]);
}
// 55-60
if (test_self_tangencies)
{
// 55 with both input polygons having self tangencies (st_st) generates 1 correct shape
- test_traverse<polygon, polygon, operation_union>::apply("55_st_st", 1, 18, case_55[0], case_55[2]);
+ test_traverse_union::apply("55_st_st", 1, 18, case_55[0], case_55[2]);
// 55 with one of them self-tangency, other int/ext ring tangency generate 2 correct shapes
- test_traverse<polygon, polygon, operation_union>::apply("56", 2, 14, case_56[0], case_56[1]);
+ test_traverse_union::apply("56", 2, 14, case_56[0], case_56[1]);
}
- test_traverse<polygon, polygon, operation_union>::apply("57", 1, 14.029412, case_57[0], case_57[1]);
+ test_traverse_union::apply("57", 1, 14.029412, case_57[0], case_57[1]);
if (test_self_tangencies)
{
- test_traverse<polygon, polygon, operation_union>::apply("58_st",
+ test_traverse_union::apply("58_st",
4, 12.16666, case_58[0], case_58[1]);
- test_traverse<polygon, polygon, operation_union>::apply("59_st",
+ test_traverse_union::apply("59_st",
2, 17.208333, case_59[0], case_59[1]);
- test_traverse<polygon, polygon, operation_union>::apply("60_st",
+ test_traverse_union::apply("60_st",
3, 19, case_60[0], case_60[1]);
}
- test_traverse<polygon, polygon, operation_union>::apply("58_iet",
+ test_traverse_union::apply("58_iet",
4, 12.16666, case_58[0], case_58[2]);
- test_traverse<polygon, polygon, operation_union>::apply("59_iet",
+ test_traverse_union::apply("59_iet",
1, -3.791666, // 2, 17.208333), outer ring (ii/ix) is done by ASSEMBLE
case_59[0], case_59[2]);
- test_traverse<polygon, polygon, operation_union>::apply("60_iet",
+ test_traverse_union::apply("60_iet",
3, 19, case_60[0], case_60[2]);
- test_traverse<polygon, polygon, operation_union>::apply("61_st",
+ test_traverse_union::apply("61_st",
1, 4, case_61[0], case_61[1]);
- test_traverse<polygon, polygon, operation_union>::apply("70",
+ test_traverse_union::apply("70",
1, 9, case_70[0], case_70[1]);
- test_traverse<polygon, polygon, operation_union>::apply("71",
+ test_traverse_union::apply("71",
2, 9, case_71[0], case_71[1]);
- test_traverse<polygon, polygon, operation_union>::apply("72",
+ test_traverse_union::apply("72",
1, 10.65, case_72[0], case_72[1]);
// other
- test_traverse<polygon, polygon, operation_union>::apply("box_poly5",
+ test_traverse_union::apply("box_poly5",
2, 4.7191,
"POLYGON((1.5 1.5, 1.5 2.5, 4.5 2.5, 4.5 1.5, 1.5 1.5))",
"POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 2.5,4.5 2.5,4.5 2.3,5.0 2.3,5.0 2.1,4.5 2.1,4.5 1.9,4.0 1.9,4.5 1.2,4.9 0.8,2.9 0.7,2 1.3))");
- test_traverse<polygon, polygon, operation_intersection>::apply("collinear_overlaps",
+ test_traverse_intersection::apply("collinear_overlaps",
1, 24,
collinear_overlaps[0], collinear_overlaps[1]);
- test_traverse<polygon, polygon, operation_union>::apply("collinear_overlaps",
+ test_traverse_union::apply("collinear_overlaps",
1, 50,
collinear_overlaps[0], collinear_overlaps[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("many_situations", 1, 184, case_many_situations[0], case_many_situations[1]);
- test_traverse<polygon, polygon, operation_union>::apply("many_situations",
+ test_traverse_intersection::apply("many_situations", 1, 184, case_many_situations[0], case_many_situations[1]);
+ test_traverse_union::apply("many_situations",
1, 207, case_many_situations[0], case_many_situations[1]);
@@ -718,25 +739,25 @@ void test_all(bool test_self_tangencies = true, bool test_mixed = false)
// This all went wrong in the past
// (when not all cases (get_turns) where implemented,
// especially important are some collinear (opposite) cases)
- test_traverse<polygon, polygon, operation_union>::apply("pie_16_4_12",
+ test_traverse_union::apply("pie_16_4_12",
1, 3669665.5, pie_16_4_12[0], pie_16_4_12[1]);
- test_traverse<polygon, polygon, operation_union>::apply("pie_23_21_12_500",
+ test_traverse_union::apply("pie_23_21_12_500",
1, 6295516.7185, pie_23_21_12_500[0], pie_23_21_12_500[1]);
- test_traverse<polygon, polygon, operation_union>::apply("pie_23_23_3_2000",
+ test_traverse_union::apply("pie_23_23_3_2000",
1, 7118735.0530, pie_23_23_3_2000[0], pie_23_23_3_2000[1]);
- test_traverse<polygon, polygon, operation_union>::apply("pie_23_16_16",
+ test_traverse_union::apply("pie_23_16_16",
1, 5710474.5406, pie_23_16_16[0], pie_23_16_16[1]);
- test_traverse<polygon, polygon, operation_union>::apply("pie_16_2_15_0",
+ test_traverse_union::apply("pie_16_2_15_0",
1, 3833641.5, pie_16_2_15_0[0], pie_16_2_15_0[1]);
- test_traverse<polygon, polygon, operation_union>::apply("pie_4_13_15",
+ test_traverse_union::apply("pie_4_13_15",
1, 2208122.43322, pie_4_13_15[0], pie_4_13_15[1]);
- test_traverse<polygon, polygon, operation_union>::apply("pie_20_20_7_100",
+ test_traverse_union::apply("pie_20_20_7_100",
1, 5577158.72823, pie_20_20_7_100[0], pie_20_20_7_100[1]);
/*
if (test_not_valid)
{
- test_traverse<polygon, polygon, operation_union>::apply("pie_5_12_12_0_7s",
+ test_traverse_union::apply("pie_5_12_12_0_7s",
1, 3271710.48516, pie_5_12_12_0_7s[0], pie_5_12_12_0_7s[1]);
}
*/
@@ -747,7 +768,7 @@ void test_all(bool test_self_tangencies = true, bool test_mixed = false)
static const double float_might_deviate_more = is_float ? 0.1 : 0.001; // In some cases up to 1 promille permitted
// GCC: does not everywhere handle float correctly (in our algorithms)
- bool const is_float_on_non_msvc =
+ static bool const is_float_on_non_msvc =
#if defined(_MSC_VER)
false;
#else
@@ -763,30 +784,30 @@ void test_all(bool test_self_tangencies = true, bool test_mixed = false)
// ("hv" means "high volume")
{
double deviation = is_float ? 0.01 : 0.001;
- test_traverse<polygon, polygon, operation_union>::apply("hv1", 1, 1624.508688461573, hv_1[0], hv_1[1], deviation);
- test_traverse<polygon, polygon, operation_intersection>::apply("hv1", 1, 1622.7200125123809, hv_1[0], hv_1[1], deviation);
+ test_traverse_union::apply("hv1", 1, 1624.508688461573, hv_1[0], hv_1[1], deviation);
+ test_traverse_intersection::apply("hv1", 1, 1622.7200125123809, hv_1[0], hv_1[1], deviation);
- test_traverse<polygon, polygon, operation_union>::apply("hv2", 1, 1622.9193392726836, hv_2[0], hv_2[1], deviation);
- test_traverse<polygon, polygon, operation_intersection>::apply("hv2", 1, 1622.1733591429329, hv_2[0], hv_2[1], deviation);
+ test_traverse_union::apply("hv2", 1, 1622.9193392726836, hv_2[0], hv_2[1], deviation);
+ test_traverse_intersection::apply("hv2", 1, 1622.1733591429329, hv_2[0], hv_2[1], deviation);
- test_traverse<polygon, polygon, operation_union>::apply("hv3", 1, 1624.22079205664, hv_3[0], hv_3[1], deviation);
- test_traverse<polygon, polygon, operation_intersection>::apply("hv3", 1, 1623.8265057282042, hv_3[0], hv_3[1], deviation);
+ test_traverse_union::apply("hv3", 1, 1624.22079205664, hv_3[0], hv_3[1], deviation);
+ test_traverse_intersection::apply("hv3", 1, 1623.8265057282042, hv_3[0], hv_3[1], deviation);
if ( BOOST_GEOMETRY_CONDITION(! is_float) )
{
- test_traverse<polygon, polygon, operation_union>::apply("hv4", 1, 1626.5146964146334, hv_4[0], hv_4[1], deviation);
- test_traverse<polygon, polygon, operation_intersection>::apply("hv4", 1, 1626.2580370864305, hv_4[0], hv_4[1], deviation);
- test_traverse<polygon, polygon, operation_union>::apply("hv5", 1, 1624.2158307261871, hv_5[0], hv_5[1], deviation);
- test_traverse<polygon, polygon, operation_intersection>::apply("hv5", 1, 1623.4506071521519, hv_5[0], hv_5[1], deviation);
+ test_traverse_union::apply("hv4", 1, 1626.5146964146334, hv_4[0], hv_4[1], deviation);
+ test_traverse_intersection::apply("hv4", 1, 1626.2580370864305, hv_4[0], hv_4[1], deviation);
+ test_traverse_union::apply("hv5", 1, 1624.2158307261871, hv_5[0], hv_5[1], deviation);
+ test_traverse_intersection::apply("hv5", 1, 1623.4506071521519, hv_5[0], hv_5[1], deviation);
// Case 2009-12-07
- test_traverse<polygon, polygon, operation_intersection>::apply("hv6", 1, 1604.6318757402121, hv_6[0], hv_6[1], deviation);
- test_traverse<polygon, polygon, operation_union>::apply("hv6", 1, 1790.091872401327, hv_6[0], hv_6[1], deviation);
+ test_traverse_intersection::apply("hv6", 1, 1604.6318757402121, hv_6[0], hv_6[1], deviation);
+ test_traverse_union::apply("hv6", 1, 1790.091872401327, hv_6[0], hv_6[1], deviation);
// Case 2009-12-08, needing sorting on side in enrich_intersection_points
- test_traverse<polygon, polygon, operation_union>::apply("hv7", 1, 1624.5779453641017, hv_7[0], hv_7[1], deviation);
- test_traverse<polygon, polygon, operation_intersection>::apply("hv7", 1, 1623.6936420295772, hv_7[0], hv_7[1], deviation);
+ test_traverse_union::apply("hv7", 1, 1624.5779453641017, hv_7[0], hv_7[1], deviation);
+ test_traverse_intersection::apply("hv7", 1, 1623.6936420295772, hv_7[0], hv_7[1], deviation);
}
}
@@ -799,24 +820,24 @@ void test_all(bool test_self_tangencies = true, bool test_mixed = false)
// Solved now (by sorting on sides in those cases)
if ( BOOST_GEOMETRY_CONDITION(! is_float_on_non_msvc) )
{
- test_traverse<polygon, polygon, operation_intersection>::apply("dz_1",
+ test_traverse_intersection::apply("dz_1",
2, 16.887537949472005, dz_1[0], dz_1[1]);
- test_traverse<polygon, polygon, operation_union>::apply("dz_1",
+ test_traverse_union::apply("dz_1",
3, 1444.2621305732864, dz_1[0], dz_1[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("dz_2",
+ test_traverse_intersection::apply("dz_2",
2, 68.678921274288541, dz_2[0], dz_2[1]);
- test_traverse<polygon, polygon, operation_union>::apply("dz_2",
+ test_traverse_union::apply("dz_2",
1, 1505.4202304878663, dz_2[0], dz_2[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("dz_3",
+ test_traverse_intersection::apply("dz_3",
5, 192.49316937645651, dz_3[0], dz_3[1]);
- test_traverse<polygon, polygon, operation_union>::apply("dz_3",
+ test_traverse_union::apply("dz_3",
5, 1446.496005965641, dz_3[0], dz_3[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("dz_4",
+ test_traverse_intersection::apply("dz_4",
1, 473.59423868207693, dz_4[0], dz_4[1]);
- test_traverse<polygon, polygon, operation_union>::apply("dz_4",
+ test_traverse_union::apply("dz_4",
1, 1871.6125138873476, dz_4[0], dz_4[1]);
}
@@ -824,21 +845,21 @@ void test_all(bool test_self_tangencies = true, bool test_mixed = false)
// SNL (Subsidiestelsel Natuur & Landschap - verAANnen)
- test_traverse<polygon, polygon, operation_intersection>::apply("snl-1",
+ test_traverse_intersection::apply("snl-1",
2, 286.996062095888,
snl_1[0], snl_1[1],
float_might_deviate_more);
- test_traverse<polygon, polygon, operation_union>::apply("snl-1",
+ test_traverse_union::apply("snl-1",
2, 51997.5408506132,
snl_1[0], snl_1[1],
float_might_deviate_more);
{
- test_traverse<polygon, polygon, operation_intersection>::apply("isov",
+ test_traverse_intersection::apply("isov",
1, 88.1920, isovist[0], isovist[1],
float_might_deviate_more);
- test_traverse<polygon, polygon, operation_union>::apply("isov",
+ test_traverse_union::apply("isov",
1, 313.3604, isovist[0], isovist[1],
float_might_deviate_more);
}
@@ -859,59 +880,59 @@ void test_all(bool test_self_tangencies = true, bool test_mixed = false)
// ttmath can form a very small intersection triangle
// (which is even not accomplished by SQL Server/PostGIS)
std::string const caseid = "ggl_list_20110820_christophe";
- test_traverse<polygon, polygon, operation_intersection>::apply(caseid,
+ test_traverse_intersection::apply(caseid,
expected_count, expected,
ggl_list_20110820_christophe[0], ggl_list_20110820_christophe[1]);
- test_traverse<polygon, polygon, operation_union>::apply(caseid,
+ test_traverse_union::apply(caseid,
1, 67.3550722317627,
ggl_list_20110820_christophe[0], ggl_list_20110820_christophe[1]);
*/
}
- test_traverse<polygon, polygon, operation_union>::apply("buffer_rt_f",
+ test_traverse_union::apply("buffer_rt_f",
1, 4.60853,
buffer_rt_f[0], buffer_rt_f[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("buffer_rt_f",
+ test_traverse_intersection::apply("buffer_rt_f",
1, 0.0002943725152286,
buffer_rt_f[0], buffer_rt_f[1], 0.01);
- test_traverse<polygon, polygon, operation_union>::apply("buffer_rt_g",
+ test_traverse_union::apply("buffer_rt_g",
1, 16.571,
buffer_rt_g[0], buffer_rt_g[1]);
- test_traverse<polygon, polygon, operation_union>::apply("buffer_rt_g_boxes1",
+ test_traverse_union::apply("buffer_rt_g_boxes1",
1, 20,
buffer_rt_g_boxes[0], buffer_rt_g_boxes[1]);
- test_traverse<polygon, polygon, operation_union>::apply("buffer_rt_g_boxes2",
+ test_traverse_union::apply("buffer_rt_g_boxes2",
1, 24,
buffer_rt_g_boxes[0], buffer_rt_g_boxes[2]);
- test_traverse<polygon, polygon, operation_union>::apply("buffer_rt_g_boxes3",
+ test_traverse_union::apply("buffer_rt_g_boxes3",
1, 28,
buffer_rt_g_boxes[0], buffer_rt_g_boxes[3]);
- test_traverse<polygon, polygon, operation_union>::apply("buffer_rt_g_boxes43",
+ test_traverse_union::apply("buffer_rt_g_boxes43",
1, 30,
buffer_rt_g_boxes[4], buffer_rt_g_boxes[3]);
- test_traverse<polygon, polygon, operation_union>::apply("buffer_rt_l",
+ test_traverse_union::apply("buffer_rt_l",
1, 19.3995, buffer_rt_l[0], buffer_rt_l[1]);
- test_traverse<polygon, polygon, operation_union>::apply("buffer_mp2",
+ test_traverse_union::apply("buffer_mp2",
1, 36.7535642, buffer_mp2[0], buffer_mp2[1], 0.01);
- test_traverse<polygon, polygon, operation_union>::apply("collinear_opposite_rr",
+ test_traverse_union::apply("collinear_opposite_rr",
1, 6.41, collinear_opposite_right[0], collinear_opposite_right[1]);
- test_traverse<polygon, polygon, operation_union>::apply("collinear_opposite_ll",
+ test_traverse_union::apply("collinear_opposite_ll",
1, 11.75, collinear_opposite_left[0], collinear_opposite_left[1]);
- test_traverse<polygon, polygon, operation_union>::apply("collinear_opposite_ss",
+ test_traverse_union::apply("collinear_opposite_ss",
1, 6, collinear_opposite_straight[0], collinear_opposite_straight[1]);
- test_traverse<polygon, polygon, operation_union>::apply("collinear_opposite_lr",
+ test_traverse_union::apply("collinear_opposite_lr",
1, 8.66, collinear_opposite_left[0], collinear_opposite_right[1]);
- test_traverse<polygon, polygon, operation_union>::apply("collinear_opposite_rl",
+ test_traverse_union::apply("collinear_opposite_rl",
1, 9, collinear_opposite_right[0], collinear_opposite_left[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply("ticket_7462", 1, 0.220582, ticket_7462[0], ticket_7462[1]);
+ test_traverse_intersection::apply("ticket_7462", 1, 0.220582, ticket_7462[0], ticket_7462[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply
+ test_traverse_intersection::apply
("ticket_9081_15", 1, 0.006889578,
ticket_9081_15[0], ticket_9081_15[1]);
@@ -919,37 +940,45 @@ void test_all(bool test_self_tangencies = true, bool test_mixed = false)
{
// NOTE: currently throws (normally)
std::string caseid = "ggl_list_20120229_volker";
- test_traverse<polygon, polygon, operation_union>::apply(caseid,
+ test_traverse_union::apply(caseid,
1, 99,
ggl_list_20120229_volker[0], ggl_list_20120229_volker[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply(caseid,
+ test_traverse_intersection::apply(caseid,
1, 99,
ggl_list_20120229_volker[0], ggl_list_20120229_volker[1]);
caseid = "ggl_list_20120229_volker_2";
- test_traverse<polygon, polygon, operation_union>::apply(caseid,
+ test_traverse_union::apply(caseid,
1, 99,
ggl_list_20120229_volker[2], ggl_list_20120229_volker[1]);
- test_traverse<polygon, polygon, operation_intersection>::apply(caseid,
+ test_traverse_intersection::apply(caseid,
1, 99,
ggl_list_20120229_volker[2], ggl_list_20120229_volker[1]);
}
#endif
}
+#if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE)
template <typename T>
void test_open()
{
- using namespace bg::detail::overlay;
-
typedef bg::model::polygon
<
bg::model::point<T, 2, bg::cs::cartesian>,
true, false
> polygon;
- test_traverse<polygon, polygon, operation_intersection>::apply("open_1", 1, 5.4736,
+ typedef test_traverse
+ <
+ polygon, polygon, bg::overlay_intersection
+ > test_traverse_intersection;
+ typedef test_traverse
+ <
+ polygon, polygon, bg::overlay_union
+ > test_traverse_union;
+
+ test_traverse_intersection::apply("open_1", 1, 5.4736,
open_case_1[0], open_case_1[1]);
- test_traverse<polygon, polygon, operation_union>::apply("open_1", 1, 11.5264,
+ test_traverse_union::apply("open_1", 1, 11.5264,
open_case_1[0], open_case_1[1]);
}
@@ -957,20 +986,18 @@ void test_open()
template <typename T>
void test_ccw()
{
- using namespace bg::detail::overlay;
-
typedef bg::model::polygon
<
bg::model::point<T, 2, bg::cs::cartesian>,
false, true
> polygon;
- test_traverse<polygon, polygon, operation_intersection, true, true>::apply("ccw_1", 1, 5.4736,
+ test_traverse<polygon, polygon, bg::overlay_intersection, true, true>::apply("ccw_1", 1, 5.4736,
ccw_case_1[0], ccw_case_1[1]);
- test_traverse<polygon, polygon, operation_union, true, true>::apply("ccw_1", 1, 11.5264,
+ test_traverse<polygon, polygon, bg::overlay_union, true, true>::apply("ccw_1", 1, 11.5264,
ccw_case_1[0], ccw_case_1[1]);
}
-
+#endif
int test_main(int, char* [])
diff --git a/libs/geometry/test/algorithms/overlay/traverse_ccw.cpp b/libs/geometry/test/algorithms/overlay/traverse_ccw.cpp
index 55d2d58945..c3d5d20688 100644
--- a/libs/geometry/test/algorithms/overlay/traverse_ccw.cpp
+++ b/libs/geometry/test/algorithms/overlay/traverse_ccw.cpp
@@ -71,7 +71,11 @@ intersect(Geometry1 const& g1, Geometry2 const& g2, std::string const& name,
bg::detail::overlay::assign_null_policy
>(g1, g2, rescale_policy, turns, policy);
- bg::enrich_intersection_points<rev<Geometry1>::value, rev<Geometry2>::value >(turns, bg::detail::overlay::operation_intersection,
+ bg::enrich_intersection_points
+ <
+ rev<Geometry1>::value, rev<Geometry2>::value,
+ bg::overlay_intersection
+ >(turns, bg::detail::overlay::operation_intersection,
g1, g2, rescale_policy, side_strategy_type());
typedef bg::model::ring<typename bg::point_type<Geometry1>::type> ring_type;
diff --git a/libs/geometry/test/algorithms/overlay/traverse_gmp.cpp b/libs/geometry/test/algorithms/overlay/traverse_gmp.cpp
index b3db22cce4..335e8ce34b 100644
--- a/libs/geometry/test/algorithms/overlay/traverse_gmp.cpp
+++ b/libs/geometry/test/algorithms/overlay/traverse_gmp.cpp
@@ -12,6 +12,9 @@
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
+#error This unit test is not updated for several years
+
+
#if defined(_MSC_VER)
#pragma warning( disable : 4244 )
#pragma warning( disable : 4267 )
diff --git a/libs/geometry/test/algorithms/overlay/traverse_multi.cpp b/libs/geometry/test/algorithms/overlay/traverse_multi.cpp
index d600ce9cbc..4f4645211f 100644
--- a/libs/geometry/test/algorithms/overlay/traverse_multi.cpp
+++ b/libs/geometry/test/algorithms/overlay/traverse_multi.cpp
@@ -37,17 +37,15 @@
template <typename MultiPolygon, bool Reverse>
void test_geometries()
{
- namespace ov = bg::detail::overlay;
-
typedef test_traverse
<
MultiPolygon, MultiPolygon,
- ov::operation_intersection, Reverse, Reverse
+ bg::overlay_intersection, Reverse, Reverse
> test_traverse_intersection;
typedef test_traverse
<
MultiPolygon, MultiPolygon,
- ov::operation_union, Reverse, Reverse
+ bg::overlay_union, Reverse, Reverse
> test_traverse_union;
// Intersections:
@@ -59,6 +57,25 @@ void test_geometries()
test_traverse_intersection::apply
(
+ "case_58_multi_b4", 1, 12.666666667,
+ case_58_multi[4], case_58_multi[2]
+ );
+
+#ifdef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS
+ test_traverse_intersection::apply
+ (
+ "case_58_multi_b5", 1, 1,
+ case_58_multi[5], case_58_multi[2]
+ );
+#endif
+ test_traverse_intersection::apply
+ (
+ "case_58_multi_b6", 1, 13.25,
+ case_58_multi[6], case_58_multi[2]
+ );
+
+ test_traverse_intersection::apply
+ (
"case_65_multi", 1, 1,
case_65_multi[0], case_65_multi[1]
);
diff --git a/libs/geometry/test/algorithms/relational_operations/covered_by.cpp b/libs/geometry/test/algorithms/relational_operations/covered_by.cpp
index 15031487a3..351efaad83 100644
--- a/libs/geometry/test/algorithms/relational_operations/covered_by.cpp
+++ b/libs/geometry/test/algorithms/relational_operations/covered_by.cpp
@@ -1,7 +1,12 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
-// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
-// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland.
+// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland.
+
+// This file was modified by Oracle on 2015.
+// Modifications copyright (c) 2015 Oracle and/or its affiliates.
+
+// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@@ -145,6 +150,7 @@ int test_main( int , char* [] )
#if defined(HAVE_TTMATH)
test_all<bg::model::d2::point_xy<ttmath_big> >();
+ test_eps<bg::model::d2::point_xy<ttmath_big> >();
//test_spherical<bg::model::point<ttmath_big, 2, bg::cs::spherical_equatorial<bg::degree> > >();
#endif
diff --git a/libs/geometry/test/algorithms/relational_operations/disjoint/disjoint_point_box_geometry.cpp b/libs/geometry/test/algorithms/relational_operations/disjoint/disjoint_point_box_geometry.cpp
index f1de2de0e3..37fb8b15ad 100644
--- a/libs/geometry/test/algorithms/relational_operations/disjoint/disjoint_point_box_geometry.cpp
+++ b/libs/geometry/test/algorithms/relational_operations/disjoint/disjoint_point_box_geometry.cpp
@@ -111,9 +111,11 @@ void test_3d()
}
+
int test_main(int, char* [])
{
test_all<bg::model::d2::point_xy<float> >();
+
test_all<bg::model::d2::point_xy<double> >();
#ifdef HAVE_TTMATH
@@ -121,7 +123,6 @@ int test_main(int, char* [])
#endif
test_3d<bg::model::point<double, 3, bg::cs::cartesian> >();
-
-
+
return 0;
}
diff --git a/libs/geometry/test/algorithms/relational_operations/intersects/intersects_box_geometry.cpp b/libs/geometry/test/algorithms/relational_operations/intersects/intersects_box_geometry.cpp
index 50a3324363..7c40efc3c7 100644
--- a/libs/geometry/test/algorithms/relational_operations/intersects/intersects_box_geometry.cpp
+++ b/libs/geometry/test/algorithms/relational_operations/intersects/intersects_box_geometry.cpp
@@ -80,6 +80,30 @@ void test_additional()
"LINESTRING(1 2)",
"BOX(0 0,3 5)",
true);
+
+ // http://stackoverflow.com/questions/32457920/boost-rtree-of-box-gives-wrong-intersection-with-segment
+ // http://lists.boost.org/geometry/2015/09/3476.php
+ // For now disabled by default even though it works properly on MSVC14
+ // it's probable that the result depends on the compiler
+#ifdef BOOST_GEOMETRY_ENABLE_FAILING_TESTS
+ test_geometry<bg::model::segment<P>, bg::model::box<P> >(
+ "SEGMENT(12 0,20 10)",
+ "BOX(0 0,10 10)",
+ false);
+ test_geometry<bg::model::segment<P>, bg::model::box<P> >(
+ "SEGMENT(2 0,8 6)",
+ "BOX(0 0,10 10)",
+ true);
+ test_geometry<bg::model::segment<P>, bg::model::box<P> >(
+ "SEGMENT(2 0,18 8)",
+ "BOX(0 0,10 10)",
+ true);
+ typedef bg::model::point<typename bg::coordinate_type<P>::type, 3, bg::cs::cartesian> point3d_t;
+ test_geometry<bg::model::segment<point3d_t>, bg::model::box<point3d_t> >(
+ "SEGMENT(2 1 0,2 1 10)",
+ "BOX(0 0 0,10 0 10)",
+ false);
+#endif
}
diff --git a/libs/geometry/test/algorithms/relational_operations/nan_cases.hpp b/libs/geometry/test/algorithms/relational_operations/nan_cases.hpp
new file mode 100644
index 0000000000..d6acbd6c98
--- /dev/null
+++ b/libs/geometry/test/algorithms/relational_operations/nan_cases.hpp
@@ -0,0 +1,130 @@
+// Boost.Geometry
+
+// Copyright (c) 2015 Oracle and/or its affiliates.
+
+// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <geometry_test_common.hpp>
+
+#include <boost/geometry/geometries/geometries.hpp>
+#include <boost/geometry/geometries/point_xy.hpp>
+
+#include <boost/range/value_type.hpp>
+#include <boost/type_traits/is_same.hpp>
+
+template <typename Container>
+struct pusher
+ : public Container
+{
+ typedef typename Container::value_type value_type;
+ pusher(value_type const& val)
+ {
+ this->push_back(val);
+ }
+
+ pusher & operator()(value_type const& val)
+ {
+ this->push_back(val);
+ return *this;
+ }
+};
+
+template <typename Geometry,
+ typename Tag = typename bg::tag<Geometry>::type,
+ typename Coord = typename bg::coordinate_type<Geometry>::type>
+struct nan_case_generator
+{
+ static void apply(Geometry & , std::string & )
+ {}
+};
+
+template <typename Geometry>
+struct nan_case_generator<Geometry, bg::multi_linestring_tag, double>
+{
+ static void apply(Geometry & geometry, std::string & wkt)
+ {
+ typedef typename boost::range_value<Geometry>::type ls;
+ typedef typename bg::point_type<Geometry>::type P;
+ typedef typename bg::coordinate_type<Geometry>::type coord_t;
+ coord_t nan = std::numeric_limits<coord_t>::quiet_NaN();
+
+ wkt = "MULTILINESTRING((3.1e+307 1,-nan -nan),(3.1e+307 1,-nan -nan),(3.1e+307 1,5.1e+307 6e+307,nan nan),(-nan -nan,nan nan),(-nan -nan,-1 -3.97843,-1 3.28571,-1 47.6364),(3 78.5455,3 2),(nan nan,3 12.9689),(3 -2,-nan -nan),(3 2,3 12.9689,3 78.5455),(-1 4.29497e+09,-1 7,-nan -nan),(9 5,-nan -nan),(-nan -nan,9 60.8755,9 124.909),(nan nan,1 6.87195e+10,-nan -nan),(nan nan,4 86.2727,4 20.9533),(4 -5,-nan -nan),(4 -5,-nan -nan),(4 -5,-nan -nan),(4 -5,1.1e+308 2.1e+307,nan nan),(-nan -nan,-1 -8),(-nan -nan,-9 -4))";
+
+ typedef pusher<Geometry> ml;
+ typedef pusher<ls> l;
+ geometry = ml(l(P(3.1e+307, 1))(P(-nan, -nan)))
+ (l(P(3.1e+307, 1))(P(-nan, -nan)))
+ (l(P(3.1e+307, 1))(P(5.1e+307, 6e+307))(P(nan, nan)))
+ (l(P(-nan, -nan))(P(nan, nan)))
+ (l(P(-nan, -nan))(P(-1, -3.97843))(P(-1, 3.28571))(P(-1, 47.6364)))
+ (l(P(3, 78.5455))(P(3, 2)))
+ (l(P(nan, nan))(P(3, 12.9689)))
+ (l(P(3, -2))(P(-nan, -nan)))
+ (l(P(3, 2))(P(3, 12.9689))(P(3, 78.5455)))
+ (l(P(-1, 4.29497e+09))(P(-1, 7))(P(-nan, -nan)))
+ (l(P(9, 5))(P(-nan, -nan)))
+ (l(P(-nan, -nan))(P(9, 60.8755))(P(9, 124.909)))
+ (l(P(nan, nan))(P(1, 6.87195e+10))(P(-nan, -nan)))
+ (l(P(nan, nan))(P(4, 86.2727))(P(4, 20.9533)))
+ (l(P(4, -5))(P(-nan, -nan)))
+ (l(P(4, -5))(P(-nan, -nan)))
+ (l(P(4, -5))(P(-nan, -nan)))
+ (l(P(4, -5))(P(1.1e+308, 2.1e+307))(P(nan, nan)))
+ (l(P(-nan, -nan))(P(-1, -8)))
+ (l(P(-nan, -nan))(P(-9, -4)));
+ }
+};
+
+template <typename Geometry>
+struct nan_case_generator<Geometry, bg::multi_point_tag, double>
+{
+ static void apply(Geometry & geometry, std::string & wkt)
+ {
+ typedef typename bg::point_type<Geometry>::type P;
+ typedef typename bg::coordinate_type<Geometry>::type coord_t;
+ coord_t nan = std::numeric_limits<coord_t>::quiet_NaN();
+
+ wkt = "MULTIPOINT((3.1e+307 1),(-nan -nan),(3.1e+307 1),(-nan -nan),(3.1e+307 1),(5.1e+307 6e+307),(nan nan),(-nan -nan),(nan nan),(-nan -nan),(-1 -3.97843),(-1 3.28571),(-1 47.6364),(3 78.5455),(3 2),(nan nan),(3 12.9689),(3 -2),(-nan -nan),(3 2),(3 12.9689),(3 78.5455),(-1 4.29497e+09),(-1 7),(-nan -nan),(9 5),(-nan -nan),(-nan -nan),(9 60.8755),(9 124.909),(nan nan),(1 6.87195e+10),(-nan -nan),(nan nan),(4 86.2727),(4 20.9533),(4 -5),(-nan -nan),(4 -5),(-nan -nan),(4 -5),(-nan -nan),(4 -5),(1.1e+308 2.1e+307),(nan nan),(-nan -nan),(-1 -8),(-nan -nan),(-9 -4))";
+
+ typedef pusher<Geometry> mp;
+ geometry = mp(P(3.1e+307, 1))(P(-nan, -nan))
+ (P(3.1e+307, 1))(P(-nan, -nan))
+ (P(3.1e+307, 1))(P(5.1e+307, 6e+307))(P(nan, nan))
+ (P(-nan, -nan))(P(nan, nan))
+ (P(-nan, -nan))(P(-1, -3.97843))(P(-1, 3.28571))(P(-1, 47.6364))
+ (P(3, 78.5455))(P(3, 2))
+ (P(nan, nan))(P(3, 12.9689))
+ (P(3, -2))(P(-nan, -nan))
+ (P(3, 2))(P(3, 12.9689))(P(3, 78.5455))
+ (P(-1, 4.29497e+09))(P(-1, 7))(P(-nan, -nan))
+ (P(9, 5))(P(-nan, -nan))
+ (P(-nan, -nan))(P(9, 60.8755))(P(9, 124.909))
+ (P(nan, nan))(P(1, 6.87195e+10))(P(-nan, -nan))
+ (P(nan, nan))(P(4, 86.2727))(P(4, 20.9533))
+ (P(4, -5))(P(-nan, -nan))
+ (P(4, -5))(P(-nan, -nan))
+ (P(4, -5))(P(-nan, -nan))
+ (P(4, -5))(P(1.1e+308, 2.1e+307))(P(nan, nan))
+ (P(-nan, -nan))(P(-1, -8))
+ (P(-nan, -nan))(P(-9, -4));
+ }
+};
+
+template <typename Geometry>
+void nan_case(Geometry & geometry, std::string & wkt)
+{
+ nan_case_generator<Geometry>::apply(geometry, wkt);
+}
+
+template <typename Geometry>
+struct is_nan_case_supported
+{
+ typedef typename bg::coordinate_type<Geometry>::type coord_t;
+
+ static const bool value = boost::is_same<coord_t, double>::value
+ && std::numeric_limits<coord_t>::has_quiet_NaN;
+}; \ No newline at end of file
diff --git a/libs/geometry/test/algorithms/relational_operations/overlaps/overlaps_areal.cpp b/libs/geometry/test/algorithms/relational_operations/overlaps/overlaps_areal.cpp
index c41da0639e..c7361f2035 100644
--- a/libs/geometry/test/algorithms/relational_operations/overlaps/overlaps_areal.cpp
+++ b/libs/geometry/test/algorithms/relational_operations/overlaps/overlaps_areal.cpp
@@ -44,6 +44,14 @@ void test_aa()
test_geometry<mpoly, poly>("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
"POLYGON((0 0,0 10,10 10,10 0,0 0))",
false);
+
+ // mysql 21872795
+ test_geometry<poly, poly>("POLYGON((2 2,2 8,8 8,8 2,2 2))",
+ "POLYGON((0 0,0 10,10 10,10 0,0 0),(8 8,4 6,4 4,8 8))",
+ true);
+ test_geometry<poly, poly>("POLYGON((2 2,2 8,8 8,8 2,2 2))",
+ "POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 4,4 6,2 2))",
+ true);
}
template <typename P>
diff --git a/libs/geometry/test/algorithms/relational_operations/overlaps/overlaps_box.cpp b/libs/geometry/test/algorithms/relational_operations/overlaps/overlaps_box.cpp
index c80ff6de4c..b58cfa967e 100644
--- a/libs/geometry/test/algorithms/relational_operations/overlaps/overlaps_box.cpp
+++ b/libs/geometry/test/algorithms/relational_operations/overlaps/overlaps_box.cpp
@@ -43,6 +43,7 @@ void test_3d()
test_geometry<bg::model::box<P>, bg::model::box<P> >("BOX(1 1 1, 3 3 3)", "BOX(4 4 4,6 6 6)", false);
}
+
template <typename P>
void test_2d()
{
diff --git a/libs/geometry/test/algorithms/relational_operations/overlaps/test_overlaps.hpp b/libs/geometry/test/algorithms/relational_operations/overlaps/test_overlaps.hpp
index 862fe73891..c631ae715c 100644
--- a/libs/geometry/test/algorithms/relational_operations/overlaps/test_overlaps.hpp
+++ b/libs/geometry/test/algorithms/relational_operations/overlaps/test_overlaps.hpp
@@ -2,6 +2,12 @@
// Unit Test
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// This file was modified by Oracle on 2015.
+// Modifications copyright (c) 2015 Oracle and/or its affiliates.
+
+// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
+
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
@@ -22,15 +28,12 @@
template <typename Geometry1, typename Geometry2>
-void test_geometry(std::string const& wkt1,
- std::string const& wkt2, bool expected)
+void test_geometry(Geometry1 const& geometry1,
+ Geometry2 const& geometry2,
+ std::string const& wkt1,
+ std::string const& wkt2,
+ bool expected)
{
- Geometry1 geometry1;
- Geometry2 geometry2;
-
- bg::read_wkt(wkt1, geometry1);
- bg::read_wkt(wkt2, geometry2);
-
bool detected = bg::overlaps(geometry1, geometry2);
BOOST_CHECK_MESSAGE(detected == expected,
@@ -48,5 +51,19 @@ void test_geometry(std::string const& wkt1,
<< " detected: " << detected);
}
+template <typename Geometry1, typename Geometry2>
+void test_geometry(std::string const& wkt1,
+ std::string const& wkt2,
+ bool expected)
+{
+ Geometry1 geometry1;
+ Geometry2 geometry2;
+
+ bg::read_wkt(wkt1, geometry1);
+ bg::read_wkt(wkt2, geometry2);
+
+ test_geometry(geometry1, geometry2, wkt1, wkt2, expected);
+}
+
#endif
diff --git a/libs/geometry/test/algorithms/relational_operations/relate/relate_areal_areal.cpp b/libs/geometry/test/algorithms/relational_operations/relate/relate_areal_areal.cpp
index 9a2b41aafc..81ced941e1 100644
--- a/libs/geometry/test/algorithms/relational_operations/relate/relate_areal_areal.cpp
+++ b/libs/geometry/test/algorithms/relational_operations/relate/relate_areal_areal.cpp
@@ -343,6 +343,25 @@ void test_polygon_polygon()
"POLYGON((1 1,1 2,2 2,2 1,1 1))",
"****F****");*/
}
+
+ // mysql 21872795 (overlaps)
+ test_geometry<poly, poly>("POLYGON((2 2,2 8,8 8,8 2,2 2))",
+ "POLYGON((0 0,0 10,10 10,10 0,0 0),(8 8,4 6,4 4,8 8))",
+ "21210F212");
+ test_geometry<poly, poly>("POLYGON((2 2,2 8,8 8,8 2,2 2))",
+ "POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 4,4 6,2 2))",
+ "21210F212");
+ // mysql 21873343 (touches)
+ test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0), (0 8, 8 5, 8 8, 0 8))",
+ "POLYGON((0 8,-8 5,-8 8,0 8))",
+ "FF2F01212");
+ test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0), (0 6, 6 3, 6 6, 0 6))",
+ "POLYGON((0 6,-6 3,-6 6,0 6))",
+ "FF2F01212");
+ // similar but touching from the inside of the hole
+ test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0), (0 8, 8 5, 8 8, 0 8))",
+ "POLYGON((0 8,7 7, 7 6,0 8))",
+ "FF2F01212");
}
template <typename P>
diff --git a/libs/geometry/test/algorithms/relational_operations/relate/relate_linear_areal.cpp b/libs/geometry/test/algorithms/relational_operations/relate/relate_linear_areal.cpp
index fbd399f015..a53e388fa1 100644
--- a/libs/geometry/test/algorithms/relational_operations/relate/relate_linear_areal.cpp
+++ b/libs/geometry/test/algorithms/relational_operations/relate/relate_linear_areal.cpp
@@ -12,6 +12,7 @@
// http://www.boost.org/LICENSE_1_0.txt)
#include "test_relate.hpp"
+#include "../nan_cases.hpp"
//TEST
//#include <to_svg.hpp>
@@ -381,6 +382,7 @@ void test_multi_linestring_polygon()
typedef bg::model::linestring<P> ls;
typedef bg::model::multi_linestring<ls> mls;
typedef bg::model::polygon<P> poly;
+ typedef typename bg::coordinate_type<P>::type coord_t;
test_geometry<mls, poly>("MULTILINESTRING((11 11, 20 20),(5 7, 4 1))",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 2,4 4,2 4,2 2))",
@@ -390,7 +392,7 @@ void test_multi_linestring_polygon()
"1F10F0212");
if ( BOOST_GEOMETRY_CONDITION((
- boost::is_same<typename bg::coordinate_type<P>::type, double>::value )) )
+ boost::is_same<coord_t, double>::value )) )
{
// assertion failure in 1.57
test_geometry<mls, poly>("MULTILINESTRING((-0.59322033898305082 -8.0508474576271194,-2.882352941176471 -7.7647058823529411,-2.8823529411764706 -7.7647058823529411,-3.7361111111111112 -6.5694444444444446,-3.4404145077720205 -5.766839378238342,-4.1864406779661012 -3.6779661016949152,-7.5252525252525251 -5.5858585858585865,-7.5862068965517242 -5.1896551724137936,-4.47887323943662 -2.859154929577465,-4.5789473684210531 -2.5789473684210527,-3 -1,-2.9310344827586206 -0.86206896551724144,-3.1764705882352944 -0.70588235294117663,-4.7401960784313726 -2.1274509803921577,-5.3255813953488369 -0.48837209302325502,-4.7872340425531918 0.31914893617021284,-5.8571428571428577 1.0000000000000007,-5.3255813953488369 -0.48837209302325502,-5.9473684210526319 -1.4210526315789465,-8 2,-7.7333333333333334 2.1939393939393939,-8.8294573643410867 2.891472868217055,-8.8556701030927822 3.061855670103093,-7.5999999999999996 3.6000000000000001,-7.7999999999999998 3.7999999999999998,-7.75 3.7916666666666665,-7.5471698113207548 3.6226415094339623,-7.3200000000000003 3.7200000000000002,-3.473684210526315 3.0789473684210527,-3.2549019607843133 3.2156862745098036,-2.9999999999999982 3.1428571428571423,-3.1733333333333325 3.2666666666666666,-2.9180327868852456 3.4262295081967209,-2.8723404255319145 3.1063829787234041,-2.1111111111111112 2.8888888888888888,-2.1428571428571428 2.8571428571428572,-1.8433734939759043 2.8072289156626509,-1.8396226415094346 2.8113207547169816,-1.6486486486486487 2.756756756756757,-1.76510067114094 2.8926174496644301,-0.53846153846153855 4.2307692307692308,1.8148148148148147 5.4074074074074074,1.588235294117647 2.2352941176470589,1.819672131147541 2.1967213114754101,2 4,2 2.1666666666666665,2.3538461538461544 2.1076923076923078,2 1.6875000000000004,2 -2,1.2173913043478262 -3.8260869565217392,1.7375886524822697 1.3758865248226959,1.5073170731707317 1.1024390243902444,1.1428571428571428 -4,-0.59322033898305082 -8.0508474576271194),(1.666666666666667 1.5999999999999988,1.5675675675675675 1.8378378378378377,1.4374999999999991 1.8750000000000002,1.0487804878048776 2.3414634146341466,0.46666666666666712 2.6060606060606055,0.086956521739131043 2.2608695652173911,1.4374999999999991 1.8750000000000002,1.666666666666667 1.5999999999999988))",
@@ -422,6 +424,21 @@ void test_multi_linestring_polygon()
test_geometry<mls, poly>("MULTILINESTRING((3 10, 1 5, 1 10, 3 4, 7 8, 6 10, 10 2))",
"POLYGON((0 0,0 10,10 10,10 0,0 0))",
"10FF0F212");
+
+ // mysql bug
+ // assertion failure in relate->boundary_checker->std::equal_range with msvc
+ if (BOOST_GEOMETRY_CONDITION(is_nan_case_supported<mls>::value))
+ {
+ mls g1;
+ std::string wkt1;
+ nan_case(g1, wkt1);
+
+ std::string wkt2 = "POLYGON((1.1e+308 1.2e+308,-1 -9,1 1e+12,1.1e+308 7.8e+307,1.1e+308 1.2e+308),(3 2,1 1,8e+307 1e+308,3 2),(258 2049,1 -3,1 1,-6 9,258 2049))";
+ poly g2;
+ bg::read_wkt(wkt2, g2);
+
+ check_geometry(g1, g2, wkt1, wkt2, "*********");
+ }
}
template <typename P>
diff --git a/libs/geometry/test/algorithms/relational_operations/relate/relate_pointlike_geometry.cpp b/libs/geometry/test/algorithms/relational_operations/relate/relate_pointlike_geometry.cpp
index 95a4158651..d06c6b7cb0 100644
--- a/libs/geometry/test/algorithms/relational_operations/relate/relate_pointlike_geometry.cpp
+++ b/libs/geometry/test/algorithms/relational_operations/relate/relate_pointlike_geometry.cpp
@@ -12,6 +12,7 @@
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
#include "test_relate.hpp"
+#include "../nan_cases.hpp"
//TEST
//#include <to_svg.hpp>
@@ -47,6 +48,16 @@ void test_multipoint_multipoint()
//typedef bg::model::d2::point_xy<float> ptf;
//typedef bg::model::multi_point<ptf> mptf;
//test_geometry<mptf, mpt>("MULTIPOINT(0 0)", "MULTIPOINT(0 0)", "0FFFFFFF2");
+
+ // assertion failure in relate->boundary_checker->std::equal_range with msvc
+ if (BOOST_GEOMETRY_CONDITION(is_nan_case_supported<mpt>::value))
+ {
+ mpt g;
+ std::string wkt;
+ nan_case(g, wkt);
+
+ check_geometry(g, g, wkt, wkt, "*********");
+ }
}
template <typename P>
@@ -78,6 +89,27 @@ void test_point_multilinestring()
test_geometry<P, mls>("POINT(0 0)", "MULTILINESTRING((0 0,5 0),(0 0,0 5,5 0),(0 0,-5 0),(0 0,0 -5,-5 0))", "0FFFFF1F2");
test_geometry<P, mls>("POINT(5 0)", "MULTILINESTRING((0 0,5 0),(0 0,0 5,5 0),(0 0,-5 0),(0 0,0 -5,-5 0))", "0FFFFF1F2");
test_geometry<P, mls>("POINT(1 0)", "MULTILINESTRING((0 0,5 0),(0 0,0 5,5 0),(0 0,-5 0),(0 0,0 -5,-5 0))", "0FFFFF1F2");
+
+ // assertion failure in relate->boundary_checker->std::equal_range with msvc
+ if (BOOST_GEOMETRY_CONDITION(is_nan_case_supported<mls>::value))
+ {
+ // on the boundary
+ std::string wkt0 = "POINT(3.1e+307 1)";
+ P g0;
+ bg::read_wkt(wkt0, g0);
+
+ // disjoint
+ std::string wkt1 = "POINT(1.1e+308 1.2e+308)";
+ P g1;
+ bg::read_wkt(wkt1, g1);
+
+ mls g2;
+ std::string wkt2;
+ nan_case(g2, wkt2);
+
+ check_geometry(g0, g2, wkt0, wkt2, "*********");
+ check_geometry(g1, g2, wkt1, wkt2, "*********");
+ }
}
template <typename P>
diff --git a/libs/geometry/test/algorithms/relational_operations/touches/test_touches.hpp b/libs/geometry/test/algorithms/relational_operations/touches/test_touches.hpp
index 60df672c5a..2bc0db86df 100644
--- a/libs/geometry/test/algorithms/relational_operations/touches/test_touches.hpp
+++ b/libs/geometry/test/algorithms/relational_operations/touches/test_touches.hpp
@@ -1,10 +1,12 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Unit Test
-// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
-// This file was modified by Oracle on 2013.
-// Modifications copyright (c) 2013, Oracle and/or its affiliates.
+// This file was modified by Oracle on 2013, 2015.
+// Modifications copyright (c) 2013, 2015 Oracle and/or its affiliates.
+
+// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@@ -43,8 +45,8 @@ void check_touches(Geometry1 const& geometry1,
detected = bg::touches(geometry2, geometry1);
BOOST_CHECK_MESSAGE(detected == expected,
- "touches: " << wkt2
- << " with " << wkt1
+ "touches: " << wkt1
+ << " with " << wkt2
<< " -> Expected: " << expected
<< " detected: " << detected);
}
diff --git a/libs/geometry/test/algorithms/relational_operations/touches/touches.cpp b/libs/geometry/test/algorithms/relational_operations/touches/touches.cpp
index 88a0cc2695..536250ceee 100644
--- a/libs/geometry/test/algorithms/relational_operations/touches/touches.cpp
+++ b/libs/geometry/test/algorithms/relational_operations/touches/touches.cpp
@@ -118,6 +118,20 @@ void test_all()
true
);
+ // mysql 21873343
+ test_touches<polygon, polygon>
+ (
+ "POLYGON((0 0,0 10,10 10,10 0,0 0), (0 8, 8 5, 8 8, 0 8))",
+ "POLYGON((0 8,-8 5,-8 8,0 8))",
+ true
+ );
+ test_touches<polygon, polygon>
+ (
+ "POLYGON((0 0,0 10,10 10,10 0,0 0), (0 6, 6 3, 6 6, 0 6))",
+ "POLYGON((0 6,-6 3,-6 6,0 6))",
+ true
+ );
+
// Point-Polygon
test_touches<P, ring>("POINT(40 50)", "POLYGON((40 40,40 60,60 60,60 40,40 40))", true);
test_touches<P, polygon>("POINT(40 50)", "POLYGON((40 40,40 60,60 60,60 40,40 40))", true);
diff --git a/libs/geometry/test/algorithms/relational_operations/touches/touches_box.cpp b/libs/geometry/test/algorithms/relational_operations/touches/touches_box.cpp
index 4e8b932f11..7325bc2c2f 100644
--- a/libs/geometry/test/algorithms/relational_operations/touches/touches_box.cpp
+++ b/libs/geometry/test/algorithms/relational_operations/touches/touches_box.cpp
@@ -2,7 +2,7 @@
//
// Copyright (c) 2012-2015 Barend Gehrels, Amsterdam, the Netherlands.
-// This file was modified by Oracle on 2013, 2014. 2015.
+// This file was modified by Oracle on 2013, 2014, 2015.
// Modifications copyright (c) 2013-2015, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
@@ -42,6 +42,7 @@ void test_box_3d()
true);
}
+
int test_main( int , char* [] )
{
test_all<bg::model::d2::point_xy<double> >();
diff --git a/libs/geometry/test/algorithms/relational_operations/within/within.cpp b/libs/geometry/test/algorithms/relational_operations/within/within.cpp
index c8999e4db5..11e86b46d3 100644
--- a/libs/geometry/test/algorithms/relational_operations/within/within.cpp
+++ b/libs/geometry/test/algorithms/relational_operations/within/within.cpp
@@ -6,12 +6,12 @@
// This file was modified by Oracle on 2014, 2015.
// Modifications copyright (c) 2014-2015 Oracle and/or its affiliates.
+// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
+
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
-
#include "test_within.hpp"
diff --git a/libs/geometry/test/algorithms/set_operations/difference/Jamfile.v2 b/libs/geometry/test/algorithms/set_operations/difference/Jamfile.v2
index b00e397d00..8dcae0e25d 100644
--- a/libs/geometry/test/algorithms/set_operations/difference/Jamfile.v2
+++ b/libs/geometry/test/algorithms/set_operations/difference/Jamfile.v2
@@ -16,13 +16,15 @@
test-suite boost-geometry-algorithms-difference
:
- [ run difference.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE
+ [ run difference.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE
: algorithms_difference ]
[ run difference_linear_linear.cpp : : : : algorithms_difference_linear_linear ]
+ [ run difference_areal_linear.cpp : : : : algorithms_difference_areal_linear ]
[ run difference_pl_l.cpp : : : : algorithms_difference_pl_l ]
[ run difference_pl_pl.cpp : : : : algorithms_difference_pl_pl ]
- [ run difference_multi.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE
+ [ run difference_multi.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE
: algorithms_difference_multi ]
- [ run difference_multi_spike.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE
- : algorithms_difference_multi_spike ]
+ [ run difference_multi_areal_linear.cpp : : : : algorithms_difference_multi_areal_linear ]
+ [ run difference_multi_spike.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE
+ : algorithms_difference_multi_spike ]
;
diff --git a/libs/geometry/test/algorithms/set_operations/difference/difference.cpp b/libs/geometry/test/algorithms/set_operations/difference/difference.cpp
index 1e6a23c2ab..7865c704b6 100644
--- a/libs/geometry/test/algorithms/set_operations/difference/difference.cpp
+++ b/libs/geometry/test/algorithms/set_operations/difference/difference.cpp
@@ -7,6 +7,7 @@
// Modifications copyright (c) 2015, Oracle and/or its affiliates.
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
+// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@@ -39,176 +40,15 @@
#endif
-
-template <typename Polygon, typename LineString>
-void test_areal_linear()
-{
- std::string const poly_simplex = "POLYGON((1 1,1 3,3 3,3 1,1 1))";
- test_one_lp<LineString, LineString, Polygon>("simplex", "LINESTRING(0 2,4 2)", poly_simplex, 2, 4, 2.0);
- test_one_lp<LineString, LineString, Polygon>("case2", "LINESTRING(0 1,4 3)", poly_simplex, 2, 4, sqrt(5.0));
- test_one_lp<LineString, LineString, Polygon>("case3", "LINESTRING(0 1,1 2,3 2,4 3,6 3,7 4)", "POLYGON((2 0,2 5,5 5,5 0,2 0))", 2, 6, 2.0 + 2.0 * sqrt(2.0));
- test_one_lp<LineString, LineString, Polygon>("case4", "LINESTRING(1 1,3 2,1 3)", "POLYGON((0 0,0 4,2 4,2 0,0 0))", 1, 3, sqrt(5.0));
-
- test_one_lp<LineString, LineString, Polygon>("case5", "LINESTRING(0 1,3 4)", poly_simplex, 2, 4, 2.0 * sqrt(2.0));
- test_one_lp<LineString, LineString, Polygon>("case6", "LINESTRING(1 1,10 3)", "POLYGON((2 0,2 4,3 4,3 1,4 1,4 3,5 3,5 1,6 1,6 3,7 3,7 1,8 1,8 3,9 3,9 0,2 0))", 5, 10,
- // Pieces are 1 x 2/9:
- 5.0 * sqrt(1.0 + 4.0/81.0));
-
-
- test_one_lp<LineString, LineString, Polygon>("case7", "LINESTRING(1.5 1.5,2.5 2.5)", poly_simplex, 0, 0, 0.0);
- test_one_lp<LineString, LineString, Polygon>("case8", "LINESTRING(1 0,2 0)", poly_simplex, 1, 2, 1.0);
-
- std::string const poly_9 = "POLYGON((1 1,1 4,4 4,4 1,1 1))";
- test_one_lp<LineString, LineString, Polygon>("case9", "LINESTRING(0 1,1 2,2 2)", poly_9, 1, 2, sqrt(2.0));
- test_one_lp<LineString, LineString, Polygon>("case10", "LINESTRING(0 1,1 2,0 2)", poly_9, 1, 3, 1.0 + sqrt(2.0));
- test_one_lp<LineString, LineString, Polygon>("case11", "LINESTRING(2 2,4 2,3 3)", poly_9, 0, 0, 0.0);
- test_one_lp<LineString, LineString, Polygon>("case12", "LINESTRING(2 3,4 4,5 6)", poly_9, 1, 2, sqrt(5.0));
-
- test_one_lp<LineString, LineString, Polygon>("case13", "LINESTRING(3 2,4 4,2 3)", poly_9, 0, 0, 0.0);
- test_one_lp<LineString, LineString, Polygon>("case14", "LINESTRING(5 6,4 4,6 5)", poly_9, 1, 3, 2.0 * sqrt(5.0));
-
- test_one_lp<LineString, LineString, Polygon>("case15", "LINESTRING(0 2,1 2,1 3,0 3)", poly_9, 2, 4, 2.0);
- test_one_lp<LineString, LineString, Polygon>("case16", "LINESTRING(2 2,1 2,1 3,2 3)", poly_9, 0, 0, 0.0);
-
- std::string const angly = "LINESTRING(2 2,2 1,4 1,4 2,5 2,5 3,4 3,4 4,5 4,3 6,3 5,2 5,2 6,0 4)";
- test_one_lp<LineString, LineString, Polygon>("case17", angly, "POLYGON((1 1,1 5,4 5,4 1,1 1))", 3, 11, 6.0 + 4.0 * sqrt(2.0));
- test_one_lp<LineString, LineString, Polygon>("case18", angly, "POLYGON((1 1,1 5,5 5,5 1,1 1))", 2, 6, 2.0 + 3.0 * sqrt(2.0));
- test_one_lp<LineString, LineString, Polygon>("case19", "LINESTRING(1 2,1 3,0 3)", poly_9, 1, 2, 1.0);
- test_one_lp<LineString, LineString, Polygon>("case20", "LINESTRING(1 2,1 3,2 3)", poly_9, 0, 0, 0.0);
-
- // PROPERTIES CHANGED BY switch_to_integer
- // TODO test_one_lp<LineString, LineString, Polygon>("case21", "LINESTRING(1 2,1 4,4 4,4 1,2 1,2 2)", poly_9, 0, 0, 0.0);
-
- // More collinear (opposite) cases
- test_one_lp<LineString, LineString, Polygon>("case22", "LINESTRING(4 1,4 4,7 4)", poly_9, 1, 2, 3.0);
- test_one_lp<LineString, LineString, Polygon>("case23", "LINESTRING(4 0,4 4,7 4)", poly_9, 2, 4, 4.0);
- test_one_lp<LineString, LineString, Polygon>("case24", "LINESTRING(4 1,4 5,7 5)", poly_9, 1, 3, 4.0);
- test_one_lp<LineString, LineString, Polygon>("case25", "LINESTRING(4 0,4 5,7 5)", poly_9, 2, 5, 5.0);
- test_one_lp<LineString, LineString, Polygon>("case26", "LINESTRING(4 0,4 3,4 5,7 5)", poly_9, 2, 5, 5.0);
- test_one_lp<LineString, LineString, Polygon>("case27", "LINESTRING(4 4,4 5,5 5)", poly_9, 1, 3, 2.0);
-}
-
-template <typename CoordinateType>
-void test_ticket_10658(std::string const& wkt_out)
-{
- typedef bg::model::point<CoordinateType, 2, bg::cs::cartesian> point_type;
- typedef bg::model::polygon
- <
- point_type, /*ClockWise*/false, /*Closed*/false
- > polygon_type;
- typedef bg::model::multi_polygon<polygon_type> multipolygon_type;
-
- polygon_type polygon1;
- bg::read_wkt(ticket_10658[0], polygon1);
- polygon_type polygon2;
- bg::read_wkt(ticket_10658[1], polygon2);
-
- multipolygon_type multipolygon_out;
- bg::sym_difference(polygon1, polygon2, multipolygon_out);
- std::stringstream stream;
- stream << bg::wkt(multipolygon_out);
-
- BOOST_CHECK_EQUAL(stream.str(), wkt_out);
-}
-
-template <typename CoordinateType>
-void test_ticket_10835(std::string const& wkt_out1, std::string const& wkt_out2)
-{
- typedef bg::model::point<CoordinateType, 2, bg::cs::cartesian> point_type;
- typedef bg::model::linestring<point_type> linestring_type;
- typedef bg::model::multi_linestring<linestring_type> multilinestring_type;
- typedef bg::model::polygon
- <
- point_type, /*ClockWise*/false, /*Closed*/false
- > polygon_type;
-
- multilinestring_type multilinestring;
- bg::read_wkt(ticket_10835[0], multilinestring);
- polygon_type polygon1;
- bg::read_wkt(ticket_10835[1], polygon1);
- polygon_type polygon2;
- bg::read_wkt(ticket_10835[2], polygon2);
-
- multilinestring_type multilinestringOut1;
- bg::difference(multilinestring, polygon1, multilinestringOut1);
- std::stringstream stream;
- stream << bg::wkt(multilinestringOut1);
-
- BOOST_CHECK_EQUAL(stream.str(), wkt_out1);
-
- multilinestring_type multilinestringOut2;
- bg::difference(multilinestringOut1, polygon2, multilinestringOut2);
- stream.str("");
- stream.clear();
- stream << bg::wkt(multilinestringOut2);
-
- BOOST_CHECK_EQUAL(stream.str(), wkt_out2);
-}
-
-template <typename CoordinateType>
-void test_ticket_11121()
-{
- typedef bg::model::point<CoordinateType,2,bg::cs::cartesian> point_type;
- typedef bg::model::polygon
- <
- point_type, /*ClockWise*/false, /*Closed*/false
- > polygon_type;
- typedef bg::model::multi_polygon<polygon_type> multipolygon_type;
-
- polygon_type polygon1;
- bg::read_wkt(ticket_11121[0], polygon1);
- polygon_type polygon2;
- bg::read_wkt(ticket_11121[1], polygon2);
-
- multipolygon_type diff12, diff21, sym_diff;
- bg::difference(polygon1, polygon2, diff12);
- bg::difference(polygon2, polygon1, diff21);
- bg::sym_difference(polygon1, polygon2, sym_diff);
-
- BOOST_CHECK(bg::is_valid(diff12));
- BOOST_CHECK(bg::is_valid(diff21));
- BOOST_CHECK(bg::is_valid(sym_diff));
-}
-
-template <typename CoordinateType>
-void test_bug21155501()
-{
- typedef bg::model::point<CoordinateType,2,bg::cs::cartesian> point_type;
- typedef bg::model::polygon
- <
- point_type, /*ClockWise*/false, /*Closed*/false
- > polygon_type;
- typedef bg::model::multi_polygon<polygon_type> multipolygon_type;
-
- polygon_type g1;
- bg::read_wkt("POLYGON((-8.3935546875 27.449790329784214,4.9658203125 18.729501999072138,11.8212890625 23.563987128451217,9.7119140625 25.48295117535531,9.8876953125 31.728167146023935,8.3056640625 32.99023555965106,8.5693359375 37.16031654673677,-1.8896484375 35.60371874069731,-0.5712890625 32.02670629333614,-8.9208984375 29.458731185355344,-8.3935546875 27.449790329784214))", g1);
- multipolygon_type g2;
- bg::read_wkt("MULTIPOLYGON(((4.9658203125 18.729501999072138,-3.4868710311820115 24.246968623627644,8.3589904332912 33.833614418115445,8.3056640625 32.99023555965106,9.8876953125 31.728167146023935,9.7119140625 25.48295117535531,11.8212890625 23.563987128451217,4.9658203125 18.729501999072138)),((-3.88714525609152 24.508246314579743,-8.3935546875 27.449790329784214,-8.9208984375 29.458731185355344,-0.5712890625 32.02670629333614,-1.8896484375 35.60371874069731,8.5693359375 37.16031654673677,8.362166569827938 33.883846345901595,-3.88714525609152 24.508246314579743)))", g2);
- bg::correct(g1);
- bg::correct(g2);
-
- multipolygon_type diff12, diff21, sym_diff;
- bg::difference(g1, g2, diff12);
- bg::difference(g2, g1, diff21);
- bg::sym_difference(g1, g2, sym_diff);
-
- BOOST_CHECK(bg::is_valid(diff12));
- BOOST_CHECK(bg::is_valid(diff21));
- BOOST_CHECK(bg::is_valid(sym_diff));
-}
-
template <typename P>
void test_all()
{
typedef bg::model::box<P> box;
typedef bg::model::polygon<P> polygon;
- typedef bg::model::linestring<P> linestring;
typedef bg::model::ring<P> ring;
typedef typename bg::coordinate_type<P>::type ct;
- test_areal_linear<polygon, linestring>();
-
test_one<polygon, polygon, polygon>("simplex_normal",
simplex_normal[0], simplex_normal[1],
3, 12, 2.52636706856656,
@@ -258,7 +98,7 @@ void test_all()
distance_zero[0], distance_zero[1],
-1, -1, 8.7048386,
-1, -1, 0.0098387,
- 0.001);
+ tolerance(0.001));
test_one<polygon, polygon, polygon>("equal_holes_disjoint",
equal_holes_disjoint[0], equal_holes_disjoint[1],
@@ -309,7 +149,8 @@ void test_all()
test_one<polygon, polygon, polygon>("intersect_holes_new_ring",
intersect_holes_new_ring[0], intersect_holes_new_ring[1],
3, 15, 9.8961,
- 4, 25, 121.8961, 0.01);
+ 4, 25, 121.8961,
+ tolerance(0.01));
test_one<polygon, polygon, polygon>("first_within_hole_of_second",
first_within_hole_of_second[0], first_within_hole_of_second[1],
@@ -336,6 +177,29 @@ void test_all()
8, 36, 2.43452380952381,
7, 33, 3.18452380952381);
+#ifdef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS
+ // Fails, a-b is partly generated, b-a does not have any output
+ // It failed already in 1.59
+ test_one<polygon, polygon, polygon>("case_58_iet",
+ case_58[0], case_58[2],
+ 3, 12, 0.6666666667,
+ 1, -1, 11.1666666667);
+#endif
+
+ test_one<polygon, polygon, polygon>("case_80",
+ case_80[0], case_80[1],
+ 1, 9, 44.5,
+ 1, 10, 84.5);
+
+#ifdef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS
+ // Fails, holes are not subtracted
+ test_one<polygon, polygon, polygon>("case_81",
+ case_81[0], case_81[1],
+ 1, 8, 80.5,
+ 1, 8, 83.0,
+ 1, 12, 80.5 + 83.0);
+#endif
+
test_one<polygon, polygon, polygon>("winded",
winded[0], winded[1],
3, 37, 61,
@@ -386,15 +250,15 @@ void test_all()
-1, -1, 0.279132,
-1, -1, 224.8892,
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
- 0.1);
+ tolerance(0.1));
#else
- 0.001);
+ tolerance(0.001));
#endif
// SQL Server gives: 0.279121891701124 and 224.889211358929
// PostGIS gives: 0.279121991127244 and 224.889205853156
// No robustness gives: 0.279121991127106 and 224.825363749290
-#ifdef GEOMETRY_TEST_INCLUDE_FAILING_TESTS
+#ifdef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS
test_one<polygon, polygon, polygon>("geos_1",
geos_1[0], geos_1[1],
21, -1, 0.31640625,
@@ -414,7 +278,7 @@ void test_all()
geos_2[0], geos_2[1],
1, -1, 138.6923828,
1, -1, 211.859375,
- 0.01); // MSVC 14 expects 138.69214 and 211.85913
+ tolerance(0.01)); // MSVC 14 expects 138.69214 and 211.85913
test_one<polygon, polygon, polygon>("geos_3",
geos_3[0], geos_3[1],
@@ -438,7 +302,7 @@ void test_all()
ggl_list_20110307_javier[0], ggl_list_20110307_javier[1],
1, if_typed<ct, float>(14, 13), 16815.6,
1, 4, 3200.4,
- 0.01);
+ tolerance(0.01));
if ( BOOST_GEOMETRY_CONDITION((! boost::is_same<ct, float>::value)) )
{
@@ -459,7 +323,8 @@ void test_all()
test_one<polygon, polygon, polygon>("ggl_list_20120717_volker",
ggl_list_20120717_volker[0], ggl_list_20120717_volker[1],
1, 11, 3370866.2295081965,
- 1, 5, 384.2295081964694, 0.01);
+ 1, 5, 384.2295081964694,
+ tolerance(0.01));
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
// 2011-07-02 / 2014-06-19
@@ -474,7 +339,7 @@ void test_all()
if_typed_tt<ct>(1, 1), -1,
if_typed_tt<ct>(0.0000000000001105367, 0.000125137888971949),
1, -1, 3577.40960816756,
- 0.01
+ tolerance(0.01)
);
#endif
@@ -564,19 +429,6 @@ void test_all()
// Multi/box (should be moved to multi)
{
- /* Tested with SQL Geometry:
- with viewy as (select geometry::STGeomFromText(
- 'MULTIPOLYGON(((0 1,2 5,5 3,0 1)),((1 1,5 2,5 0,1 1)))',0) as p,
- geometry::STGeomFromText(
- 'POLYGON((2 2,2 4,4 4,4 2,2 2))',0) as q)
-
- select
- p.STDifference(q).STArea(),p.STDifference(q).STNumGeometries(),p.STDifference(q) as p_min_q,
- q.STDifference(p).STArea(),q.STDifference(p).STNumGeometries(),q.STDifference(p) as q_min_p,
- p.STSymDifference(q).STArea(),q.STSymDifference(p) as p_xor_q
- from viewy
-
- */
typedef bg::model::multi_polygon<polygon> mp;
static std::string const clip = "POLYGON((2 2,4 4))";
@@ -599,140 +451,81 @@ void test_all()
5, 22, 1.1901714,
5, 27, 1.6701714);
***/
-}
-
-/*******
-// To be moved to another file
-template <typename T>
-void test_difference_parcel_precision()
-{
- typedef bg::model::d2::point_xy<T> point_type;
- typedef bg::model::polygon<point_type> polygon_type;
- typedef bg::model::linestring<point_type> linestring_type;
- typedef std::vector<boost::uint8_t> byte_vector;
- polygon_type parcel, buffer;
-
- {
- byte_vector wkb;
- bg::hex2wkb("0103000000010000001A00000023DBF97EE316064146B6F3FDD32513415A643BDFD216064175931804E225134196438B6C52150641C976BE9F34261341F6285C8F06150641022B871641261341F853E3A5D3140641E17A14AE50261341B81E85EBFB120641A4703D8A142713414E6210584D120641AC1C5A64602713414E621058431106414E621058C9271341A01A2FDD1B11064121B07268D8271341F4FDD478571006411904560ECF271341448B6CE7DD0F06418195438BC1271341F6285C8F6A0F06413BDF4F0DA72713410E2DB29D360F06416F1283C091271341E5D022DB070F0641F6285C0F7227134160E5D022DA0E06416F1283404F271341448B6CE7D30E0641F853E3A52427134154E3A59BE60E06411904568E07271341643BDF4F0C0F0641D7A3703DFC2613414A0C022B100F064125068115FB26134191ED7C3F310F0641B6F3FDD4F42613414C378941F11006414A0C022BA0261341EC51B81ECC1206413BDF4F0D40261341022B87167514064125068115F1251341B4C876BE8C160641C74B37897F25134121B07268C6160641508D976E7525134123DBF97EE316064146B6F3FDD3251341", std::back_inserter(wkb));
- bg::read_wkb(wkb.begin(), wkb.end(), parcel);
- }
- {
- byte_vector wkb;
- bg::hex2wkb("01030000000100000083000000000032FCD716064100009E998F25134100000706D81606410040A4998F2513410000DA0FD816064100C0E6998F2513410000A819D81606410080659A8F25134100806A23D816064100C0209B8F25134100801E2DD81606410080189C8F2513410000BE36D816064100404D9D8F25134100004540D816064100C0BE9E8F2513410000AF49D816064100806DA08F2513410000F752D8160641008059A28F2513410000195CD816064100C082A48F25134100800F65D81606410080E9A68F2513410000D66DD816064100408EA98F25134100006876D816064100C070AC8F2513410000C17ED8160641000091AF8F2513410080DC86D816064100C0EFB28F25134100009E8ED816064100C081B68F2513410080EC95D816064100803ABA8F2513410080C79CD8160641000018BE8F25134100002FA3D8160641008017C28F251341008022A9D8160641000037C68F2513410080A1AED8160641000074CA8F2513410000ACB3D81606410040CCCE8F251341000042B8D816064100403DD38F251341000062BCD81606410000C5D78F25134100000DC0D8160641000061DC8F251341000042C3D816064100000FE18F251341000001C6D81606410080CCE58F251341008049C8D8160641004097EA8F25134100001BCAD816064100006DEF8F251341008075CBD816064100804BF48F251341008058CCD8160641004030F98F2513410000C4CCD8160641000019FE8F2513410080B7CCD81606410080030390251341008032CCD81606410000ED0790251341000035CBD81606410000D40C902513410080BEC9D81606410040B511902513410000CFC7D816064100408F1690251341008065C5D816064100005F1B90251341008082C2D81606410080222090251341000025BFD81606410080D7249025134100004DBBD816064100807B29902513410080FAB6D816064100800C2E9025134100002DB2D816064100C08732902513410080E3ACD81606410000EB369025134100801EA7D81606410000343B902513410000DEA0D81606410080603F902513410080209AD816064100406E43902513410080209AC015064100406E43302613410080FC92C015064100004F473026134100008B8BC01506410040F64A302613410000D083C015064100C0634E302613410000D17BC0150641008097513026134100009273C015064100409154302613410000186BC015064100C050573026134100806762C01506410000D6593026134100808559C01506410000215C3026134100007650C01506410000315E3026134100003E47C015064100800660302613410000E23DC01506410000A1613026134100006734C015064100800063302613410080D12AC015064100C024643026134100002621C015064100800D653026134100006917C015064100C0BA653026134100809F0DC015064100402C66302613410000CE03C015064100006266302613410000F9F9BF15064100C05B6630261341000026F0BF1506410040196630261341000058E6BF15064100809A6530261341008095DCBF1506410040DF64302613410080E1D2BF1506410080E76330261341000042C9BF15064100C0B262302613410000BBBFBF1506410040416130261341000051B6BF1506410080925F30261341000009ADBF1506410080A65D302613410000E7A3BF15064100407D5B302613410080F09ABF150641008016593026134100002A92BF15064100C071563026134100009889BF15064100408F533026134100003F81BF15064100006F503026134100802379BF1506410040104D3026134100006271BF15064100407E49302613410080136ABF1506410080C5453026134100803863BF1506410000E841302613410000D15CBF1506410080E83D302613410080DD56BF1506410000C9393026134100805E51BF15064100008C35302613410000544CBF15064100C03331302613410000BE47BF15064100C0C22C3026134100009E43BF15064100003B28302613410000F33FBF15064100009F23302613410000BE3CBF1506410000F11E302613410000FF39BF1506410080331A302613410080B637BF15064100C06815302613410000E535BF150641000093103026134100808A34BF1506410080B40B302613410080A733BF15064100C0CF063026134100003C33BF1506410000E7013026134100804833BF1506410080FCFC2F2613410080CD33BF150641000013F82F2613410000CB34BF15064100002CF32F26134100804136BF15064100C04AEE2F26134100003138BF15064100C070E92F26134100809A3ABF1506410000A1E42F26134100807D3DBF1506410080DDDF2F2613410000DB40BF150641008028DB2F2613410000B344BF150641008084D62F26134100800549BF1506410080F3D12F2613410000D34DBF150641004078CD2F26134100801C53BF150641000015C92F2613410080E158BF1506410000CCC42F2613410000225FBF15064100809FC02F2613410080DF65BF15064100C091BC2F2613410080DF65D716064100C091BC8F2513410080036DD71606410000B1B88F25134100007574D716064100C009B58F2513410000307CD716064100409CB18F25134100002F84D7160641008068AE8F25134100006E8CD716064100C06EAB8F2513410000E894D71606410040AFA88F2513410080989DD716064100002AA68F25134100807AA6D71606410000DFA38F25134100008AAFD71606410000CFA18F2513410000C2B8D71606410080F99F8F25134100001EC2D716064100005F9E8F251341000099CBD71606410080FF9C8F25134100802ED5D71606410040DB9B8F2513410000DADED71606410080F29A8F251341000097E8D71606410040459A8F251341008060F2D716064100C0D3998F251341000032FCD716064100009E998F251341", std::back_inserter(wkb));
- bg::read_wkb(wkb.begin(), wkb.end(), buffer);
- }
- bg::correct(parcel);
- bg::correct(buffer);
-
- std::vector<polygon_type> pieces;
- bg::difference(parcel, buffer, pieces);
-
- std::vector<polygon_type> filled_out;
- bg::difference(parcel, pieces.back(), filled_out);
-
-#if defined(TEST_OUTPUT)
- std::cout << bg::area(parcel) << std::endl;
- std::cout << bg::area(buffer) << std::endl;
- std::cout << pieces.size() << std::endl;
- std::cout << bg::area(pieces.front()) << std::endl;
- std::cout << filled_out.size() << std::endl;
- std::cout << std::setprecision(16) << bg::wkt(filled_out.front()) << std::endl;
- std::cout << bg::wkt(filled_out.front()) << std::endl;
- std::cout << bg::area(filled_out.front()) << std::endl;
- std::cout << bg::perimeter(filled_out.front()) << std::endl;
+#ifdef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS
+ test_one<polygon, polygon, polygon>("ticket_11725_2",
+ ticket_11725_2[0], ticket_11725_2[1],
+ 2, -1, 7.5, 0, -1, 0.0);
+ test_one<polygon, polygon, polygon>("mysql_21977775",
+ mysql_21977775[0], mysql_21977775[1],
+ 2, -1, 160.856568913, 2, -1, 92.3565689126);
#endif
-#if defined(TEST_WITH_SVG)
- {
- linestring_type cut_line;
- bg::read_wkt("linestring(180955 313700,180920 313740)", cut_line);
-
- std::ostringstream filename;
- filename << "difference_precision_"
- << string_from_type<T>::name()
- << ".svg";
-
- std::ofstream svg(filename.str().c_str());
-
- bg::svg_mapper<point_type> mapper(svg, 500, 500);
-
- mapper.add(cut_line);
-
- //mapper.map(parcel, "fill-opacity:0.5;fill:rgb(153,204,0);stroke:rgb(153,204,0);stroke-width:3");
- mapper.map(pieces.front(), "fill-opacity:0.5;fill:rgb(153,204,0);stroke:rgb(153,204,0);stroke-width:1");
- mapper.map(pieces.back(), "fill-opacity:0.5;fill:rgb(153,204,0);stroke:rgb(153,204,0);stroke-width:1");
- mapper.map(filled_out.front(), "fill-opacity:0.3;fill:rgb(51,51,153);stroke:rgb(51,51,153);stroke-width:3");
-
- mapper.map(cut_line, "opacity:0.8;fill:none;stroke:rgb(255,128,0);stroke-width:5;stroke-dasharray:1,7;stroke-linecap:round");
- //mapper.map(cut_line, "opacity:0.8;fill:none;stroke:rgb(255,128,0);stroke-width:2");
- }
-#endif
+ test_one<polygon, polygon, polygon>("mysql_21965285",
+ mysql_21965285[0], mysql_21965285[1],
+ 1, -1, 92.0,
+ 1, -1, 14.0,
+ 1, -1, 92.0 + 14.0);
}
-*****/
-template <typename P, bool clockwise, bool closed>
+// Test cases for integer coordinates / ccw / open
+template <typename Point, bool ClockWise, bool Closed>
void test_specific()
{
- typedef bg::model::polygon<P, clockwise, closed> polygon;
+ typedef bg::model::polygon<Point, ClockWise, Closed> polygon;
+
+ ut_settings settings;
+ settings.test_validity = true;
test_one<polygon, polygon, polygon>("ggl_list_20120717_volker",
ggl_list_20120717_volker[0], ggl_list_20120717_volker[1],
1, 11, 3371540,
1, 4, 385,
1, 16, 3371540 + 385,
- 0.001);
+ settings);
test_one<polygon, polygon, polygon>("ticket_10658",
ticket_10658[0], ticket_10658[1],
1, 6, 1510434,
- 0, 0, 0);
+ 0, 0, 0,
+ settings);
test_one<polygon, polygon, polygon>("ticket_11121",
ticket_11121[0], ticket_11121[1],
2, 8, 489763.5,
- 1, 4, 6731652.0);
+ 1, 4, 6731652.0,
+ settings);
+
+ {
+ ut_settings settings;
+#ifdef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS
+ settings.test_validity = true;
+#endif
+
+ // Generates spikes, both a-b and b-a
+ test_one<polygon, polygon, polygon>("ticket_11676",
+ ticket_11676[0], ticket_11676[1],
+ 1, 18, 2537992.5,
+ 2, 11, 294963.5,
+ 2, -1, 2537992.5 + 294963.5,
+ settings);
+ }
}
int test_main(int, char* [])
{
- //test_difference_parcel_precision<float>();
- //test_difference_parcel_precision<double>();
-
test_all<bg::model::d2::point_xy<double> >();
test_specific<bg::model::d2::point_xy<int>, false, false>();
- test_ticket_10658<int>
- ("MULTIPOLYGON(((516 2484,516 1608,1308 1932,2094 2466,2094 3150,1308 3066,516 2484)))");
-
- test_ticket_10658<double>
- ("MULTIPOLYGON(((516 2484,516 1608,1308 1932,2094 2466,2094 3150,1308 3066,516 2484)))");
-
- test_ticket_10835<int>
- ("MULTILINESTRING((5239 2113,5233 2114),(4794 2205,1020 2986))",
- "MULTILINESTRING((5239 2113,5233 2114),(4794 2205,1460 2895))");
-
- test_ticket_10835<double>
- ("MULTILINESTRING((5239 2113,5232.52 2114.34),(4794.39 2205,1020 2986))",
- "MULTILINESTRING((5239 2113,5232.52 2114.34),(4794.39 2205,1459.78 2895))");
-
- test_ticket_11121<int>();
-
-#ifdef BOOST_GEOMETRY_TEST_ENABLE_FAILING
- test_bug21155501<double>();
-#endif
-
#if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE)
test_all<bg::model::d2::point_xy<float> >();
#ifdef HAVE_TTMATH
std::cout << "Testing TTMATH" << std::endl;
test_all<bg::model::d2::point_xy<ttmath_big> >();
- //test_difference_parcel_precision<ttmath_big>();
#endif
#endif
diff --git a/libs/geometry/test/algorithms/set_operations/difference/difference_areal_linear.cpp b/libs/geometry/test/algorithms/set_operations/difference/difference_areal_linear.cpp
new file mode 100644
index 0000000000..c6001f11bd
--- /dev/null
+++ b/libs/geometry/test/algorithms/set_operations/difference/difference_areal_linear.cpp
@@ -0,0 +1,234 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// Unit Test
+
+// Copyright (c) 2010-2015 Barend Gehrels, Amsterdam, the Netherlands.
+
+// This file was modified by Oracle on 2015.
+// Modifications copyright (c) 2015, Oracle and/or its affiliates.
+
+// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
+// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <iomanip>
+#include <iostream>
+#include <sstream>
+#include <string>
+
+// If defined, tests are run without rescaling-to-integer or robustness policy
+// Test which would fail then are disabled automatically
+// #define BOOST_GEOMETRY_NO_ROBUSTNESS
+
+#include <boost/geometry/algorithms/correct.hpp>
+#include <boost/geometry/algorithms/is_valid.hpp>
+
+#include <boost/geometry/io/wkt/wkt.hpp>
+
+#include <boost/geometry/geometries/point_xy.hpp>
+
+#include "test_difference.hpp"
+#include <algorithms/test_overlay.hpp>
+#include <algorithms/overlay/overlay_cases.hpp>
+#include <algorithms/overlay/multi_overlay_cases.hpp>
+
+
+#ifdef HAVE_TTMATH
+# include <boost/geometry/extensions/contrib/ttmath_stub.hpp>
+#endif
+
+template <typename CoordinateType>
+void test_ticket_10835(std::string const& wkt_out1, std::string const& wkt_out2)
+{
+ typedef bg::model::point<CoordinateType, 2, bg::cs::cartesian> point_type;
+ typedef bg::model::linestring<point_type> linestring_type;
+ typedef bg::model::multi_linestring<linestring_type> multilinestring_type;
+ typedef bg::model::polygon
+ <
+ point_type, /*ClockWise*/false, /*Closed*/false
+ > polygon_type;
+
+ multilinestring_type multilinestring;
+ bg::read_wkt(ticket_10835[0], multilinestring);
+ polygon_type polygon1;
+ bg::read_wkt(ticket_10835[1], polygon1);
+ polygon_type polygon2;
+ bg::read_wkt(ticket_10835[2], polygon2);
+
+ multilinestring_type multilinestringOut1;
+ bg::difference(multilinestring, polygon1, multilinestringOut1);
+ std::stringstream stream;
+ stream << bg::wkt(multilinestringOut1);
+
+ BOOST_CHECK_EQUAL(stream.str(), wkt_out1);
+
+ multilinestring_type multilinestringOut2;
+ bg::difference(multilinestringOut1, polygon2, multilinestringOut2);
+ stream.str("");
+ stream.clear();
+ stream << bg::wkt(multilinestringOut2);
+
+ BOOST_CHECK_EQUAL(stream.str(), wkt_out2);
+}
+
+
+template <typename Polygon, typename LineString>
+void test_areal_linear()
+{
+ typedef typename bg::point_type<Polygon>::type point;
+ typedef typename bg::coordinate_type<point>::type ct;
+
+ std::string const poly_simplex = "POLYGON((1 1,1 3,3 3,3 1,1 1))";
+ test_one_lp<LineString, LineString, Polygon>("simplex", "LINESTRING(0 2,4 2)", poly_simplex, 2, 4, 2.0);
+ test_one_lp<LineString, LineString, Polygon>("case2", "LINESTRING(0 1,4 3)", poly_simplex, 2, 4, sqrt(5.0));
+ test_one_lp<LineString, LineString, Polygon>("case3", "LINESTRING(0 1,1 2,3 2,4 3,6 3,7 4)", "POLYGON((2 0,2 5,5 5,5 0,2 0))", 2, 6, 2.0 + 2.0 * sqrt(2.0));
+ test_one_lp<LineString, LineString, Polygon>("case4", "LINESTRING(1 1,3 2,1 3)", "POLYGON((0 0,0 4,2 4,2 0,0 0))", 1, 3, sqrt(5.0));
+
+ test_one_lp<LineString, LineString, Polygon>("case5", "LINESTRING(0 1,3 4)", poly_simplex, 2, 4, 2.0 * sqrt(2.0));
+ test_one_lp<LineString, LineString, Polygon>("case6", "LINESTRING(1 1,10 3)", "POLYGON((2 0,2 4,3 4,3 1,4 1,4 3,5 3,5 1,6 1,6 3,7 3,7 1,8 1,8 3,9 3,9 0,2 0))", 5, 10,
+ // Pieces are 1 x 2/9:
+ 5.0 * sqrt(1.0 + 4.0/81.0));
+
+
+ test_one_lp<LineString, LineString, Polygon>("case7", "LINESTRING(1.5 1.5,2.5 2.5)", poly_simplex, 0, 0, 0.0);
+ test_one_lp<LineString, LineString, Polygon>("case8", "LINESTRING(1 0,2 0)", poly_simplex, 1, 2, 1.0);
+
+ std::string const poly_9 = "POLYGON((1 1,1 4,4 4,4 1,1 1))";
+ test_one_lp<LineString, LineString, Polygon>("case9", "LINESTRING(0 1,1 2,2 2)", poly_9, 1, 2, sqrt(2.0));
+ test_one_lp<LineString, LineString, Polygon>("case10", "LINESTRING(0 1,1 2,0 2)", poly_9, 1, 3, 1.0 + sqrt(2.0));
+ test_one_lp<LineString, LineString, Polygon>("case11", "LINESTRING(2 2,4 2,3 3)", poly_9, 0, 0, 0.0);
+ test_one_lp<LineString, LineString, Polygon>("case12", "LINESTRING(2 3,4 4,5 6)", poly_9, 1, 2, sqrt(5.0));
+
+ test_one_lp<LineString, LineString, Polygon>("case13", "LINESTRING(3 2,4 4,2 3)", poly_9, 0, 0, 0.0);
+ test_one_lp<LineString, LineString, Polygon>("case14", "LINESTRING(5 6,4 4,6 5)", poly_9, 1, 3, 2.0 * sqrt(5.0));
+
+ test_one_lp<LineString, LineString, Polygon>("case15", "LINESTRING(0 2,1 2,1 3,0 3)", poly_9, 2, 4, 2.0);
+ test_one_lp<LineString, LineString, Polygon>("case16", "LINESTRING(2 2,1 2,1 3,2 3)", poly_9, 0, 0, 0.0);
+
+ std::string const angly = "LINESTRING(2 2,2 1,4 1,4 2,5 2,5 3,4 3,4 4,5 4,3 6,3 5,2 5,2 6,0 4)";
+ test_one_lp<LineString, LineString, Polygon>("case17", angly, "POLYGON((1 1,1 5,4 5,4 1,1 1))", 3, 11, 6.0 + 4.0 * sqrt(2.0));
+ test_one_lp<LineString, LineString, Polygon>("case18", angly, "POLYGON((1 1,1 5,5 5,5 1,1 1))", 2, 6, 2.0 + 3.0 * sqrt(2.0));
+ test_one_lp<LineString, LineString, Polygon>("case19", "LINESTRING(1 2,1 3,0 3)", poly_9, 1, 2, 1.0);
+ test_one_lp<LineString, LineString, Polygon>("case20", "LINESTRING(1 2,1 3,2 3)", poly_9, 0, 0, 0.0);
+
+ // PROPERTIES CHANGED BY switch_to_integer
+ // TODO test_one_lp<LineString, LineString, Polygon>("case21", "LINESTRING(1 2,1 4,4 4,4 1,2 1,2 2)", poly_9, 0, 0, 0.0);
+
+ // More collinear (opposite) cases
+ test_one_lp<LineString, LineString, Polygon>("case22", "LINESTRING(4 1,4 4,7 4)", poly_9, 1, 2, 3.0);
+ test_one_lp<LineString, LineString, Polygon>("case23", "LINESTRING(4 0,4 4,7 4)", poly_9, 2, 4, 4.0);
+ test_one_lp<LineString, LineString, Polygon>("case24", "LINESTRING(4 1,4 5,7 5)", poly_9, 1, 3, 4.0);
+ test_one_lp<LineString, LineString, Polygon>("case25", "LINESTRING(4 0,4 5,7 5)", poly_9, 2, 5, 5.0);
+ test_one_lp<LineString, LineString, Polygon>("case26", "LINESTRING(4 0,4 3,4 5,7 5)", poly_9, 2, 5, 5.0);
+ test_one_lp<LineString, LineString, Polygon>("case27", "LINESTRING(4 4,4 5,5 5)", poly_9, 1, 3, 2.0);
+
+ if (BOOST_GEOMETRY_CONDITION( (! boost::is_same<ct, float>::value)) )
+ {
+ // Fails for float
+ test_one_lp<LineString, LineString, Polygon>("case28",
+ "LINESTRING(-1.3 0,-15 0,-1.3 0)",
+ "POLYGON((2 3,-9 -7,12 -13,2 3))",
+ 1, 3, 27.4);
+ }
+
+ test_one_lp<LineString, LineString, Polygon>("case29",
+ "LINESTRING(5 5,-10 5,5 5)",
+ "POLYGON((0 0,0 10,10 10,10 0,0 0))",
+ 1, 3, 20);
+
+ test_one_lp<LineString, LineString, Polygon>("case29a",
+ "LINESTRING(1 1,5 5,-10 5,5 5,6 6)",
+ "POLYGON((0 0,0 10,10 10,10 0,0 0))",
+ 1, 3, 20);
+
+ test_one_lp<LineString, LineString, Polygon>("case30",
+ "LINESTRING(-10 5,5 5,-10 5)",
+ "POLYGON((0 0,0 10,10 10,10 0,0 0))",
+ 2, 4, 20);
+
+ test_one_lp<LineString, LineString, Polygon>("case30a",
+ "LINESTRING(-20 10,-10 5,5 5,-10 5,-20 -10)",
+ "POLYGON((0 0,0 10,10 10,10 0,0 0))",
+ 2, 6, 49.208096);
+
+ test_one_lp<LineString, LineString, Polygon>("case31",
+ "LINESTRING(0 5,5 5,0 5)",
+ "POLYGON((0 0,0 10,10 10,10 0,0 0))",
+ 0, 0, 0);
+
+ test_one_lp<LineString, LineString, Polygon>("case31",
+ "LINESTRING(0 5,5 5,1 1,9 1,5 5,0 5)",
+ "POLYGON((0 0,0 10,10 10,10 0,0 0))",
+ 0, 0, 0);
+
+ test_one_lp<LineString, LineString, Polygon>("case32",
+ "LINESTRING(5 5,0 5,5 5)",
+ "POLYGON((0 0,0 10,10 10,10 0,0 0))",
+ 0, 0, 0);
+
+ test_one_lp<LineString, LineString, Polygon>("case32a",
+ "LINESTRING(-10 10,5 5,0 5,5 5,20 10)",
+ "POLYGON((0 0,0 10,10 10,10 0,0 0))",
+ 2, 4, 21.081851);
+
+ test_one_lp<LineString, LineString, Polygon>("case33",
+ "LINESTRING(-5 5,0 5,-5 5)",
+ "POLYGON((0 0,0 10,10 10,10 0,0 0))",
+ 1, 3, 10);
+
+ test_one_lp<LineString, LineString, Polygon>("case33a",
+ "LINESTRING(-10 10,-5 5,0 5,-5 5,-10 -10)",
+ "POLYGON((0 0,0 10,10 10,10 0,0 0))",
+ 1, 5, 32.882456);
+
+ test_one_lp<LineString, LineString, Polygon>("case33b",
+ "LINESTRING(0 5,-5 5,0 5)",
+ "POLYGON((0 0,0 10,10 10,10 0,0 0))",
+ 1, 3, 10);
+
+ test_one_lp<LineString, LineString, Polygon>("case34",
+ "LINESTRING(5 5,0 5,5 5,5 4,0 4,5 4)",
+ "POLYGON((0 0,0 10,10 10,10 0,0 0))",
+ 0, 0, 0);
+
+ test_one_lp<LineString, LineString, Polygon>("case35",
+ "LINESTRING(5 5,0 5,5 5,5 4,0 4,5 3)",
+ "POLYGON((0 0,0 10,10 10,10 0,0 0))",
+ 0, 0, 0);
+
+ test_one_lp<LineString, LineString, Polygon>("case36",
+ "LINESTRING(-1 -1,10 10)",
+ "POLYGON((5 5,15 15,15 5,5 5))",
+ 1, 2, 6 * std::sqrt(2.0));
+}
+
+template <typename P>
+void test_all()
+{
+ typedef bg::model::polygon<P> polygon;
+ typedef bg::model::linestring<P> linestring;
+
+ test_areal_linear<polygon, linestring>();
+}
+
+
+int test_main(int, char* [])
+{
+ test_all<bg::model::d2::point_xy<double> >();
+
+ test_ticket_10835<int>
+ ("MULTILINESTRING((5239 2113,5233 2114),(4794 2205,1020 2986))",
+ "MULTILINESTRING((5239 2113,5233 2114),(4794 2205,1460 2895))");
+
+ test_ticket_10835<double>
+ ("MULTILINESTRING((5239 2113,5232.52 2114.34),(4794.39 2205,1020 2986))",
+ "MULTILINESTRING((5239 2113,5232.52 2114.34),(4794.39 2205,1459.78 2895))");
+
+#if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE)
+ test_all<bg::model::d2::point_xy<float> >();
+#endif
+
+ return 0;
+}
diff --git a/libs/geometry/test/algorithms/set_operations/difference/difference_linear_linear.cpp b/libs/geometry/test/algorithms/set_operations/difference/difference_linear_linear.cpp
index e081666582..701ec46124 100644
--- a/libs/geometry/test/algorithms/set_operations/difference/difference_linear_linear.cpp
+++ b/libs/geometry/test/algorithms/set_operations/difference/difference_linear_linear.cpp
@@ -553,7 +553,7 @@ BOOST_AUTO_TEST_CASE( test_difference_linestring_linestring )
from_wkt<L>("LINESTRING(0 -.2, 8 1)"),
from_wkt<ML>("MULTILINESTRING((4 .4,2 8))"),
"lldf31x",
- 4.0 * std::numeric_limits<double>::epsilon()
+ 1e-10
);
tester::apply
@@ -561,7 +561,7 @@ BOOST_AUTO_TEST_CASE( test_difference_linestring_linestring )
from_wkt<L>("LINESTRING(0 -.2, 8 1)"),
from_wkt<ML>("MULTILINESTRING((2 8,4 .4))"),
"lldf31x-r",
- 4.0 * std::numeric_limits<double>::epsilon()
+ 1e-10
);
tester::apply
diff --git a/libs/geometry/test/algorithms/set_operations/difference/difference_multi.cpp b/libs/geometry/test/algorithms/set_operations/difference/difference_multi.cpp
index eb5ae6f79a..3d032deff2 100644
--- a/libs/geometry/test/algorithms/set_operations/difference/difference_multi.cpp
+++ b/libs/geometry/test/algorithms/set_operations/difference/difference_multi.cpp
@@ -33,7 +33,6 @@
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/multi_point.hpp>
-#include <boost/geometry/geometries/multi_linestring.hpp>
#include <boost/geometry/geometries/multi_polygon.hpp>
#include <boost/geometry/io/wkt/read.hpp>
@@ -106,23 +105,6 @@ void test_areal()
ggl_list_20111025_vd[2], ggl_list_20111025_vd[3],
1, 4, 8.0, 1, 4, 12.5);
- // Second case
- // This can be tested with this SQL for SQL-Server
- /*
- with viewy as (select geometry::STGeomFromText(
- 'POLYGON((5 0,5 4,8 4,8 0,5 0))',0) as p,
- geometry::STGeomFromText(
- 'MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)),((4 0,4 2,6 2,6 0,4 0)))',0) as q)
- select
- p.STDifference(q).STArea(),p.STDifference(q).STNumGeometries(),p.STDifference(q) as p_min_q,
- q.STDifference(p).STArea(),q.STDifference(p).STNumGeometries(),q.STDifference(p) as q_min_p,
- p.STSymDifference(q).STArea(),q.STSymDifference(p) as p_xor_q
- from viewy
-
- Outputting:
- 10, 1, <WKB>, 6, 2, <WKB>, 16, <WKB>
- */
-
test_one<Polygon, Polygon, MultiPolygon>("ggl_list_20111025_vd_2",
ggl_list_20111025_vd_2[0], ggl_list_20111025_vd_2[1],
1, 7, 10.0, 2, 10, 6.0);
@@ -137,16 +119,33 @@ void test_areal()
test_one<Polygon, MultiPolygon, MultiPolygon>("ggl_list_20120221_volker",
ggl_list_20120221_volker[0], ggl_list_20120221_volker[1],
2, 12, 7962.66, 1, 18, 2775258.93,
- 0.001);
+ tolerance(0.001));
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
test_one<Polygon, MultiPolygon, MultiPolygon>("ticket_9081",
ticket_9081[0], ticket_9081[1],
2, 28, 0.0907392476356186, 4, 25, 0.126018011439877,
4, 42, 0.0907392476356186 + 0.126018011439877,
- 0.001);
+ tolerance(0.001));
#endif
+ {
+ // Bug 21155501
+
+ // POSTGIS areas: 3.75893745345145, 2.5810000723917e-15
+
+ ut_settings settings;
+#ifdef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS
+ settings.test_validity = true;
+#endif
+ test_one<Polygon, MultiPolygon, MultiPolygon>("bug_21155501",
+ bug_21155501[0], bug_21155501[1],
+ 1, 9, 3.758937,
+ 0, 0, 0.0,
+ settings);
+
+ }
+
/* TODO: fix
test_one<Polygon, MultiPolygon, MultiPolygon>("case_101_multi",
case_101_multi[0], case_101_multi[1],
@@ -170,47 +169,75 @@ void test_areal()
case_recursive_boxes_3[0], case_recursive_boxes_3[1],
1, 1, 1, 1, 1, 1);
*/
-}
-template <typename MultiPolygon, typename MultiLineString>
-void test_areal_linear()
-{
- typedef typename boost::range_value<MultiPolygon>::type Polygon;
- typedef typename boost::range_value<MultiLineString>::type LineString;
- typedef typename bg::point_type<Polygon>::type Point;
- typedef bg::model::ring<Point> Ring;
-
- test_one_lp<LineString, LineString, MultiPolygon>("case_mp_ls_1", "LINESTRING(2 0,2 5)", case_multi_simplex[0], 2, 4, 1.30);
- test_one_lp<LineString, MultiLineString, Polygon>("case_p_mls_1", "MULTILINESTRING((2 0,2 5),(3 0,3 5))", case_single_simplex, 3, 6, 2.5);
- test_one_lp<LineString, MultiLineString, MultiPolygon>("case_mp_mls_1", "MULTILINESTRING((2 0,2 5),(3 0,3 5))", case_multi_simplex[0], 5, 10, 3.1666667);
- test_one_lp<LineString, MultiLineString, Ring>("case_r_mls_1", "MULTILINESTRING((2 0,2 5),(3 0,3 5))", case_single_simplex, 3, 6, 2.5);
-
- // Collinear cases, with multiple turn points at the same location
- test_one_lp<LineString, LineString, MultiPolygon>("case_mp_ls_2a", "LINESTRING(1 0,1 1,2 1,2 0)", "MULTIPOLYGON(((0 0,0 1,1 1,1 0,0 0)),((1 1,1 2,2 2,2 1,1 1)))", 1, 2, 1.0);
- test_one_lp<LineString, LineString, MultiPolygon>("case_mp_ls_2b", "LINESTRING(1 0,1 1,2 1,2 0)", "MULTIPOLYGON(((1 1,1 2,2 2,2 1,1 1)),((0 0,0 1,1 1,1 0,0 0)))", 1, 2, 1.0);
-
- test_one_lp<LineString, LineString, MultiPolygon>("case_mp_ls_3",
- "LINESTRING(6 6,6 7,7 7,7 6,8 6,8 7,9 7,9 6)",
- "MULTIPOLYGON(((5 7,5 8,6 8,6 7,5 7)),((6 6,6 7,7 7,7 6,6 6)),((8 8,9 8,9 7,8 7,7 7,7 8,8 8)))", 2, 5, 3.0);
-
- return;
-
- // TODO: this case contains collinearities and should still be solved
- test_one_lp<LineString, LineString, MultiPolygon>("case_mp_ls_4",
- "LINESTRING(0 5,0 6,1 6,1 5,2 5,2 6,3 6,3 5,3 4,3 3,2 3,2 4,1 4,1 3,0 3,0 4)",
- "MULTIPOLYGON(((0 2,0 3,1 2,0 2)),((2 5,3 6,3 5,2 5)),((1 5,1 6,2 6,2 5,1 5)),((2 3,2 4,3 4,2 3)),((0 3,1 4,1 3,0 3)),((4 3,3 3,3 5,4 5,4 4,4 3)))", 5, 11, 6.0);
+#ifdef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS
+ test_one<Polygon, MultiPolygon, MultiPolygon>("mysql_21965285_b",
+ mysql_21965285_b[0],
+ mysql_21965285_b[1],
+ 2, -1, 183.71376870369406,
+ 2, -1, 131.21376870369406,
+ 4, -1, 183.71376870369406 + 131.21376870369406);
+#endif
}
template <typename P>
void test_all()
{
- //typedef bg::model::box<P> box;
typedef bg::model::ring<P> ring;
typedef bg::model::polygon<P> polygon;
typedef bg::model::multi_polygon<polygon> multi_polygon;
test_areal<ring, polygon, multi_polygon>();
- test_areal_linear<multi_polygon, bg::model::multi_linestring<bg::model::linestring<P> > >();
+}
+
+
+// Test cases for integer coordinates / ccw / open
+template <typename Point, bool ClockWise, bool Closed>
+void test_specific()
+{
+ typedef bg::model::polygon<Point, ClockWise, Closed> polygon;
+ typedef bg::model::multi_polygon<polygon> multi_polygon;
+
+ {
+ // Spikes in a-b and b-a, failure in symmetric difference
+
+ ut_settings settings;
+ settings.sym_difference = false;
+#ifdef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS
+ settings.test_validity = true;
+ settings.sym_difference = true;
+#endif
+
+ test_one<polygon, multi_polygon, multi_polygon>("ticket_11674",
+ ticket_11674[0], ticket_11674[1],
+ 3, 27, 9105781.5,
+ 5, 22, 119059.5,
+ 2, -1, -1,
+ settings);
+ }
+
+ {
+ ut_settings settings;
+ settings.test_validity = true;
+
+ std::string a_min_b =
+ test_one<polygon, multi_polygon, multi_polygon>("ticket_10661_1",
+ ticket_10661[0], ticket_10661[1],
+ 2, 11, 1441632.5,
+ 2, 7, 13167454,
+ settings);
+
+ settings.test_validity = false;
+#ifdef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS
+ settings.test_validity = true;
+#endif
+ test_one<polygon, multi_polygon, multi_polygon>("ticket_10661_2",
+ a_min_b, ticket_10661[2],
+ 1, 8, 825192.0,
+ 1, 10, 27226370.5,
+ 1, -1, 825192.0 + 27226370.5,
+ settings);
+ }
}
@@ -218,6 +245,8 @@ int test_main(int, char* [])
{
test_all<bg::model::d2::point_xy<double > >();
+ test_specific<bg::model::d2::point_xy<int>, false, false>();
+
#if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE)
test_all<bg::model::d2::point_xy<float> >();
diff --git a/libs/geometry/test/algorithms/set_operations/difference/difference_multi_areal_linear.cpp b/libs/geometry/test/algorithms/set_operations/difference/difference_multi_areal_linear.cpp
new file mode 100644
index 0000000000..d42fcd0425
--- /dev/null
+++ b/libs/geometry/test/algorithms/set_operations/difference/difference_multi_areal_linear.cpp
@@ -0,0 +1,87 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// Unit Test
+
+// Copyright (c) 2010-2015 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <iostream>
+#include <string>
+
+// If defined, tests are run without rescaling-to-integer or robustness policy
+// This multi_difference currently contains no tests for double which then fail
+// #define BOOST_GEOMETRY_NO_ROBUSTNESS
+
+//#define HAVE_TTMATH
+//#define BOOST_GEOMETRY_DEBUG_ASSEMBLE
+//#define BOOST_GEOMETRY_CHECK_WITH_SQLSERVER
+
+//#define BOOST_GEOMETRY_DEBUG_SEGMENT_IDENTIFIER
+//#define BOOST_GEOMETRY_DEBUG_FOLLOW
+//#define BOOST_GEOMETRY_DEBUG_TRAVERSE
+
+
+#include "test_difference.hpp"
+#include <algorithms/test_overlay.hpp>
+#include <algorithms/overlay/multi_overlay_cases.hpp>
+
+#include <boost/geometry/geometries/point_xy.hpp>
+#include <boost/geometry/geometries/multi_linestring.hpp>
+#include <boost/geometry/geometries/multi_polygon.hpp>
+
+#include <boost/geometry/io/wkt/read.hpp>
+
+
+template <typename MultiPolygon, typename MultiLineString>
+void test_areal_linear()
+{
+ typedef typename boost::range_value<MultiPolygon>::type polygon;
+ typedef typename boost::range_value<MultiLineString>::type linestring;
+ typedef typename bg::point_type<polygon>::type point;
+ typedef bg::model::ring<point> ring;
+
+ test_one_lp<linestring, linestring, MultiPolygon>("case_mp_ls_1", "LINESTRING(2 0,2 5)", case_multi_simplex[0], 2, 4, 1.30);
+ test_one_lp<linestring, MultiLineString, polygon>("case_p_mls_1", "MULTILINESTRING((2 0,2 5),(3 0,3 5))", case_single_simplex, 3, 6, 2.5);
+ test_one_lp<linestring, MultiLineString, MultiPolygon>("case_mp_mls_1", "MULTILINESTRING((2 0,2 5),(3 0,3 5))", case_multi_simplex[0], 5, 10, 3.1666667);
+ test_one_lp<linestring, MultiLineString, ring>("case_r_mls_1", "MULTILINESTRING((2 0,2 5),(3 0,3 5))", case_single_simplex, 3, 6, 2.5);
+
+ // Collinear cases, with multiple turn points at the same location
+ test_one_lp<linestring, linestring, MultiPolygon>("case_mp_ls_2a", "LINESTRING(1 0,1 1,2 1,2 0)", "MULTIPOLYGON(((0 0,0 1,1 1,1 0,0 0)),((1 1,1 2,2 2,2 1,1 1)))", 1, 2, 1.0);
+ test_one_lp<linestring, linestring, MultiPolygon>("case_mp_ls_2b", "LINESTRING(1 0,1 1,2 1,2 0)", "MULTIPOLYGON(((1 1,1 2,2 2,2 1,1 1)),((0 0,0 1,1 1,1 0,0 0)))", 1, 2, 1.0);
+
+ test_one_lp<linestring, linestring, MultiPolygon>("case_mp_ls_3",
+ "LINESTRING(6 6,6 7,7 7,7 6,8 6,8 7,9 7,9 6)",
+ "MULTIPOLYGON(((5 7,5 8,6 8,6 7,5 7)),((6 6,6 7,7 7,7 6,6 6)),((8 8,9 8,9 7,8 7,7 7,7 8,8 8)))", 2, 5, 3.0);
+
+ return;
+
+ // TODO: this case contains collinearities and should still be solved
+ test_one_lp<linestring, linestring, MultiPolygon>("case_mp_ls_4",
+ "LINESTRING(0 5,0 6,1 6,1 5,2 5,2 6,3 6,3 5,3 4,3 3,2 3,2 4,1 4,1 3,0 3,0 4)",
+ "MULTIPOLYGON(((0 2,0 3,1 2,0 2)),((2 5,3 6,3 5,2 5)),((1 5,1 6,2 6,2 5,1 5)),((2 3,2 4,3 4,2 3)),((0 3,1 4,1 3,0 3)),((4 3,3 3,3 5,4 5,4 4,4 3)))", 5, 11, 6.0);
+}
+
+
+template <typename P>
+void test_all()
+{
+ typedef bg::model::polygon<P> polygon;
+ typedef bg::model::linestring<P> linestring;
+ typedef bg::model::multi_polygon<polygon> multi_polygon;
+ typedef bg::model::multi_linestring<linestring> multi_linestring;
+ test_areal_linear<multi_polygon, multi_linestring>();
+}
+
+
+int test_main(int, char* [])
+{
+ test_all<bg::model::d2::point_xy<double> >();
+
+#if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE)
+ test_all<bg::model::d2::point_xy<float> >();
+#endif
+
+ return 0;
+}
diff --git a/libs/geometry/test/algorithms/set_operations/difference/test_difference.hpp b/libs/geometry/test/algorithms/set_operations/difference/test_difference.hpp
index 72eb218a63..685e83f0b3 100644
--- a/libs/geometry/test/algorithms/set_operations/difference/test_difference.hpp
+++ b/libs/geometry/test/algorithms/set_operations/difference/test_difference.hpp
@@ -24,8 +24,10 @@
#include <boost/geometry/algorithms/sym_difference.hpp>
#include <boost/geometry/algorithms/area.hpp>
+#include <boost/geometry/algorithms/is_valid.hpp>
#include <boost/geometry/algorithms/length.hpp>
#include <boost/geometry/algorithms/num_points.hpp>
+#include <boost/geometry/algorithms/remove_spikes.hpp>
#include <boost/geometry/geometries/geometries.hpp>
@@ -47,6 +49,32 @@
#endif
+struct ut_settings
+{
+ double percentage;
+ bool sym_difference;
+ bool remove_spikes;
+
+ // TODO: set by default to true when all tests pass
+ bool test_validity;
+
+ ut_settings()
+ : percentage(0.0001)
+ , sym_difference(true)
+ , remove_spikes(false)
+ , test_validity(false)
+ {}
+
+};
+
+inline ut_settings tolerance(double percentage)
+{
+ ut_settings result;
+ result.percentage = percentage;
+ return result;
+}
+
+
template <typename Output, typename G1, typename G2>
void difference_output(std::string const& caseid, G1 const& g1, G2 const& g2, Output const& output)
{
@@ -88,41 +116,50 @@ void difference_output(std::string const& caseid, G1 const& g1, G2 const& g2, Ou
}
template <typename OutputType, typename G1, typename G2>
-void test_difference(std::string const& caseid, G1 const& g1, G2 const& g2,
+std::string test_difference(std::string const& caseid, G1 const& g1, G2 const& g2,
int expected_count, int expected_point_count,
double expected_area,
- double percentage = 0.0001,
- bool sym = false)
+ bool sym,
+ ut_settings const& settings)
{
typedef typename bg::coordinate_type<G1>::type coordinate_type;
boost::ignore_unused<coordinate_type>();
- std::vector<OutputType> clip;
+ bg::model::multi_polygon<OutputType> result;
if (sym)
{
- bg::sym_difference(g1, g2, clip);
+ bg::sym_difference(g1, g2, result);
}
else
{
- bg::difference(g1, g2, clip);
+ bg::difference(g1, g2, result);
}
- typename bg::default_area_result<G1>::type area = 0;
- std::size_t n = 0;
- for (typename std::vector<OutputType>::iterator it = clip.begin();
- it != clip.end();
- ++it)
+ if (settings.remove_spikes)
{
- if (expected_point_count >= 0)
- {
- n += bg::num_points(*it);
- }
+ bg::remove_spikes(result);
+ }
+
+ std::ostringstream return_string;
+ return_string << bg::wkt(result);
- area += bg::area(*it);
+ typename bg::default_area_result<G1>::type const area = bg::area(result);
+ std::size_t const n = expected_point_count >= 0
+ ? bg::num_points(result) : 0;
+
+#if ! defined(BOOST_GEOMETRY_NO_BOOST_TEST)
+ if (settings.test_validity)
+ {
+ // std::cout << bg::dsv(result) << std::endl;
+ std::string message;
+ bool const valid = bg::is_valid(result, message);
+ BOOST_CHECK_MESSAGE(valid,
+ "difference: " << caseid << " not valid " << message);
}
+#endif
- difference_output(caseid, g1, g2, clip);
+ difference_output(caseid, g1, g2, result);
#ifndef BOOST_GEOMETRY_DEBUG_ASSEMBLE
{
@@ -150,7 +187,7 @@ void test_difference(std::string const& caseid, G1 const& g1, G2 const& g2,
g1, g2, rescale_policy, std::back_inserter(inserted)));
}
- BOOST_CHECK_EQUAL(boost::size(clip), boost::size(inserted) - 1);
+ BOOST_CHECK_EQUAL(boost::size(result), boost::size(inserted) - 1);
}
#endif
@@ -169,18 +206,19 @@ void test_difference(std::string const& caseid, G1 const& g1, G2 const& g2,
if (expected_count >= 0)
{
- BOOST_CHECK_MESSAGE(int(clip.size()) == expected_count,
+ BOOST_CHECK_MESSAGE(int(result.size()) == expected_count,
"difference: " << caseid
<< " #outputs expected: " << expected_count
- << " detected: " << clip.size()
+ << " detected: " << result.size()
<< " type: " << (type_for_assert_message<G1, G2>())
);
}
- BOOST_CHECK_CLOSE(area, expected_area, percentage);
+ BOOST_CHECK_CLOSE(area, expected_area, settings.percentage);
#endif
+ return return_string.str();
}
@@ -190,7 +228,7 @@ static int counter = 0;
template <typename OutputType, typename G1, typename G2>
-void test_one(std::string const& caseid,
+std::string test_one(std::string const& caseid,
std::string const& wkt1, std::string const& wkt2,
int expected_count1,
int expected_point_count1,
@@ -201,21 +239,8 @@ void test_one(std::string const& caseid,
int expected_count_s,
int expected_point_count_s,
double expected_area_s,
- double percentage = 0.0001)
+ ut_settings const& settings = ut_settings())
{
-#ifdef BOOST_GEOMETRY_CHECK_WITH_SQLSERVER
- std::cout
- << "-- " << caseid << std::endl
- << "with qu as (" << std::endl
- << "select geometry::STGeomFromText('" << wkt1 << "',0) as p," << std::endl
- << "geometry::STGeomFromText('" << wkt2 << "',0) as q)" << std::endl
- << "select " << std::endl
- << " p.STDifference(q).STNumGeometries() as cnt1,p.STDifference(q).STNumPoints() as pcnt1,p.STDifference(q).STArea() as area1," << std::endl
- << " q.STDifference(p).STNumGeometries() as cnt2,q.STDifference(p).STNumPoints() as pcnt2,q.STDifference(p).STArea() as area2," << std::endl
- << " p.STDifference(q) as d1,q.STDifference(p) as d2 from qu" << std::endl << std::endl;
-#endif
-
-
G1 g1;
bg::read_wkt(wkt1, g1);
@@ -225,58 +250,31 @@ void test_one(std::string const& caseid,
bg::correct(g1);
bg::correct(g2);
- test_difference<OutputType>(caseid + "_a", g1, g2,
+ std::string result = test_difference<OutputType>(caseid + "_a", g1, g2,
expected_count1, expected_point_count1,
- expected_area1, percentage);
+ expected_area1, false, settings);
+
#ifdef BOOST_GEOMETRY_DEBUG_ASSEMBLE
- return;
+ return result;
#endif
+
test_difference<OutputType>(caseid + "_b", g2, g1,
expected_count2, expected_point_count2,
- expected_area2, percentage);
- test_difference<OutputType>(caseid + "_s", g1, g2,
- expected_count_s,
- expected_point_count_s,
- expected_area_s,
- percentage, true);
-
-
-#ifdef BOOST_GEOMETRY_CHECK_WITH_POSTGIS
- std::cout
- << (counter > 0 ? "union " : "")
- << "select " << counter++
- << ", '" << caseid << "' as caseid"
- << ", ST_NumPoints(ST_Difference(ST_GeomFromText('" << wkt1 << "'), "
- << " ST_GeomFromText('" << wkt2 << "'))) "
- << ", ST_NumGeometries(ST_Difference(ST_GeomFromText('" << wkt1 << "'), "
- << " ST_GeomFromText('" << wkt2 << "'))) "
- << ", ST_Area(ST_Difference(ST_GeomFromText('" << wkt1 << "'), "
- << " ST_GeomFromText('" << wkt2 << "'))) "
- //<< ", " << expected_area1 << " as expected_area_a"
- //<< ", " << expected_count1 << " as expected_count_a"
- << ", ST_NumPoints(ST_Difference(ST_GeomFromText('" << wkt2 << "'), "
- << " ST_GeomFromText('" << wkt1 << "'))) "
- << ", ST_NumGeometries(ST_Difference(ST_GeomFromText('" << wkt2 << "'), "
- << " ST_GeomFromText('" << wkt1 << "'))) "
- << ", ST_Area(ST_Difference(ST_GeomFromText('" << wkt2 << "'), "
- << " ST_GeomFromText('" << wkt1 << "'))) "
- //<< ", " << expected_area2 << " as expected_area_b"
- //<< ", " << expected_count2 << " as expected_count_b"
- << ", ST_NumPoints(ST_SymDifference(ST_GeomFromText('" << wkt1 << "'), "
- << " ST_GeomFromText('" << wkt2 << "'))) "
- << ", ST_NumGeometries(ST_SymDifference(ST_GeomFromText('" << wkt1 << "'), "
- << " ST_GeomFromText('" << wkt2 << "'))) "
- << ", ST_Area(ST_SymDifference(ST_GeomFromText('" << wkt1 << "'), "
- << " ST_GeomFromText('" << wkt2 << "'))) "
- //<< ", " << expected_area1 + expected_area2 << " as expected_area_s"
- //<< ", " << expected_count1 + expected_count2 << " as expected_count_s"
- << std::endl;
-#endif
+ expected_area2, false, settings);
+ if (settings.sym_difference)
+ {
+ test_difference<OutputType>(caseid + "_s", g1, g2,
+ expected_count_s,
+ expected_point_count_s,
+ expected_area_s,
+ true, settings);
+ }
+ return result;
}
template <typename OutputType, typename G1, typename G2>
-void test_one(std::string const& caseid,
+std::string test_one(std::string const& caseid,
std::string const& wkt1, std::string const& wkt2,
int expected_count1,
int expected_point_count1,
@@ -284,16 +282,16 @@ void test_one(std::string const& caseid,
int expected_count2,
int expected_point_count2,
double expected_area2,
- double percentage = 0.0001)
+ ut_settings const& settings = ut_settings())
{
- test_one<OutputType, G1, G2>(caseid, wkt1, wkt2,
+ 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,
- percentage);
+ settings);
}
template <typename OutputType, typename G1, typename G2>
@@ -337,7 +335,12 @@ void test_one_lp(std::string const& caseid,
if (expected_point_count >= 0)
{
- BOOST_CHECK_EQUAL(n, std::size_t(expected_point_count));
+ BOOST_CHECK_MESSAGE(n == std::size_t(expected_point_count),
+ "difference: " << caseid
+ << " #points expected: " << std::size_t(expected_point_count)
+ << " detected: " << n
+ << " type: " << (type_for_assert_message<G1, G2>())
+ );
}
BOOST_CHECK_CLOSE(length, expected_length, 0.001);
@@ -347,5 +350,4 @@ void test_one_lp(std::string const& caseid,
}
-
#endif
diff --git a/libs/geometry/test/algorithms/set_operations/difference/test_difference_linear_linear.hpp b/libs/geometry/test/algorithms/set_operations/difference/test_difference_linear_linear.hpp
index 4245f83068..258d5cfb43 100644
--- a/libs/geometry/test/algorithms/set_operations/difference/test_difference_linear_linear.hpp
+++ b/libs/geometry/test/algorithms/set_operations/difference/test_difference_linear_linear.hpp
@@ -64,6 +64,7 @@ private:
<< ", difference L/L: " << bg::wkt(geometry1)
<< " " << bg::wkt(geometry2)
<< " -> Expected: " << bg::wkt(mls_diff)
+ << std::setprecision(20)
<< " computed: " << bg::wkt(mls_output) );
set_operation_output("difference", case_id,
diff --git a/libs/geometry/test/algorithms/set_operations/intersection/intersection.cpp b/libs/geometry/test/algorithms/set_operations/intersection/intersection.cpp
index 95b0f69733..3261d2da92 100644
--- a/libs/geometry/test/algorithms/set_operations/intersection/intersection.cpp
+++ b/libs/geometry/test/algorithms/set_operations/intersection/intersection.cpp
@@ -9,6 +9,7 @@
// Modifications copyright (c) 2015, Oracle and/or its affiliates.
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
+// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
@@ -323,14 +324,40 @@ void test_areal()
test_one<Polygon, Polygon, Polygon>("buffer_mp2", buffer_mp2[0], buffer_mp2[1],
1, 29, 0.457126);
- return;
+ 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);
+
+#ifdef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS
+ test_one<Polygon, Polygon, Polygon>("mysql_21965285_b_inv",
+ mysql_21965285_b_inv[0],
+ mysql_21965285_b_inv[1],
+ 2, -1, 183.71376870369406);
+#endif
+
+ 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);
+ "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);
}
template <typename Polygon, typename Box>
@@ -446,6 +473,86 @@ void test_areal_linear()
test_one_lp<LineString, Polygon, LineString>("case19", poly_9, "LINESTRING(1 2,1 3,0 3)", 1, 2, 1.0);
test_one_lp<LineString, Polygon, LineString>("case20", poly_9, "LINESTRING(1 2,1 3,2 3)", 1, 3, 2.0);
+ test_one_lp<LineString, Polygon, LineString>("case21",
+ "POLYGON((2 3,-9 -7,12 -13,2 3))",
+ "LINESTRING(-1.3 0,-15 0,-1.3 0)",
+ 0, 0, 0);
+
+ test_one_lp<LineString, Polygon, LineString>("case22",
+ "POLYGON((0 0,0 10,10 10,10 0,0 0))",
+ "LINESTRING(5 5,-10 5,5 5)",
+ 2, 4, 10);
+
+ test_one_lp<LineString, Polygon, LineString>("case22a",
+ "POLYGON((0 0,0 10,10 10,10 0,0 0))",
+ "LINESTRING(1 1,5 5,-10 5,5 5,6 6)",
+ 2, 6, 17.071068);
+
+ test_one_lp<LineString, Polygon, LineString>("case23",
+ "POLYGON((0 0,0 10,10 10,10 0,0 0))",
+ "LINESTRING(-10 5,5 5,-10 5)",
+ 1, 3, 10);
+
+ test_one_lp<LineString, Polygon, LineString>("case23a",
+ "POLYGON((0 0,0 10,10 10,10 0,0 0))",
+ "LINESTRING(-20 10,-10 5,5 5,-10 5,-20 -10)",
+ 1, 3, 10);
+
+ test_one_lp<LineString, Polygon, LineString>("case24",
+ "POLYGON((0 0,0 10,10 10,10 0,0 0))",
+ "LINESTRING(0 5,5 5,0 5)",
+ 1, 3, 10);
+
+ test_one_lp<LineString, Polygon, LineString>("case24",
+ "POLYGON((0 0,0 10,10 10,10 0,0 0))",
+ "LINESTRING(0 5,5 5,1 1,9 1,5 5,0 5)",
+ 1, 6, 29.313708);
+
+ test_one_lp<LineString, Polygon, LineString>("case25",
+ "POLYGON((0 0,0 10,10 10,10 0,0 0))",
+ "LINESTRING(5 5,0 5,5 5)",
+ 1, 3, 10);
+
+ test_one_lp<LineString, Polygon, LineString>("case25a",
+ "POLYGON((0 0,0 10,10 10,10 0,0 0))",
+ "LINESTRING(-10 10,5 5,0 5,5 5,20 10)",
+ 1, 4, 20.540925);
+
+ test_one_lp<LineString, Polygon, LineString>("case25b",
+ "POLYGON((0 0,0 10,10 10,10 0,0 0))",
+ "LINESTRING(-10 10,5 5,1 5,5 5,20 10)",
+ 1, 4, 18.540925);
+
+ test_one_lp<LineString, Polygon, LineString>("case25c",
+ "POLYGON((0 0,0 10,10 10,10 0,0 0))",
+ "LINESTRING(-10 10,5 5,-1 5,5 5,20 10)",
+ 2, 6, 20.540925);
+
+ test_one_lp<LineString, Polygon, LineString>("case26",
+ "POLYGON((0 0,0 10,10 10,10 0,0 0))",
+ "LINESTRING(-5 5,0 5,-5 5)",
+ 0, 0, 0);
+
+ test_one_lp<LineString, Polygon, LineString>("case26a",
+ "POLYGON((0 0,0 10,10 10,10 0,0 0))",
+ "LINESTRING(-10 10,-5 5,0 5,-5 5,-10 -10)",
+ 0, 0, 0);
+
+ test_one_lp<LineString, Polygon, LineString>("case27",
+ "POLYGON((0 0,0 10,10 10,10 0,0 0))",
+ "LINESTRING(5 5,0 5,5 5,5 4,0 4,5 4)",
+ 1, 6, 21.0);
+
+ test_one_lp<LineString, Polygon, LineString>("case28",
+ "POLYGON((0 0,0 10,10 10,10 0,0 0))",
+ "LINESTRING(5 5,0 5,5 5,5 4,0 4,5 3)",
+ 1, 6, 21.099019);
+
+ test_one_lp<LineString, Polygon, LineString>("case29",
+ "POLYGON((5 5,15 15,15 5,5 5))",
+ "LINESTRING(0 0,10 10)",
+ 1, 2, 5 * std::sqrt(2.0));
+
// PROPERTIES CHANGED BY switch_to_integer
// TODO test_one_lp<LineString, Polygon, LineString>("case21", poly_9, "LINESTRING(1 2,1 4,4 4,4 1,2 1,2 2)", 1, 6, 11.0);
@@ -681,6 +788,7 @@ void test_boxes_nd()
test_boxes_per_d(p3(0,0,0), p3(5,5,5), p3(3,3,3), p3(6,6,6), true);
}
+
template <typename CoordinateType>
void test_ticket_10868(std::string const& wkt_out)
{
diff --git a/libs/geometry/test/algorithms/set_operations/intersection/intersection_multi.cpp b/libs/geometry/test/algorithms/set_operations/intersection/intersection_multi.cpp
index 2399935cb3..21fcad1f7f 100644
--- a/libs/geometry/test/algorithms/set_operations/intersection/intersection_multi.cpp
+++ b/libs/geometry/test/algorithms/set_operations/intersection/intersection_multi.cpp
@@ -22,7 +22,6 @@
#include <boost/geometry/algorithms/correct.hpp>
#include <boost/geometry/algorithms/intersection.hpp>
-#include <boost/geometry/algorithms/within.hpp> // only for testing #77
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/multi_point.hpp>
@@ -56,6 +55,42 @@ void test_areal()
case_multi_simplex[0], case_single_simplex,
2, 12, 6.42);
+#ifdef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS
+ // Fails to generate one ring - would be correct if handle_tangencies is skipped
+ test_one<Polygon, MultiPolygon, MultiPolygon>("case_58_multi_a",
+ case_58_multi[0], case_58_multi[3],
+ 3, 12, 0.666666667);
+#endif
+
+#ifdef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS
+ // No output at all
+ test_one<Polygon, MultiPolygon, MultiPolygon>("case_58_multi_b",
+ case_58_multi[1], case_58_multi[2],
+ 1, 10, 11.16666666667);
+#endif
+
+ test_one<Polygon, MultiPolygon, MultiPolygon>("case_58_multi_b4",
+ case_58_multi[4], case_58_multi[2],
+ 1, 10, 12.66666666);
+
+#ifdef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS
+ // No output at all
+ test_one<Polygon, MultiPolygon, MultiPolygon>("case_58_multi_b5",
+ case_58_multi[5], case_58_multi[2],
+ 1, 10, 99.99);
+#endif
+ test_one<Polygon, MultiPolygon, MultiPolygon>("case_58_multi_b6",
+ case_58_multi[6], case_58_multi[2],
+ 1, 10, 13.25);
+
+#ifdef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS
+ // No output at all
+ test_one<Polygon, MultiPolygon, MultiPolygon>("case_58_multi_b7",
+ case_58_multi[7], case_58_multi[2],
+ 1, 10, 99.99);
+
+#endif
+
// Constructed cases for multi/touch/equal/etc
test_one<Polygon, MultiPolygon, MultiPolygon>("case_61_multi",
case_61_multi[0], case_61_multi[1],
@@ -105,6 +140,13 @@ void test_areal()
case_recursive_boxes_4[0], case_recursive_boxes_4[1],
13, 157, 67.0); // Area from SQL Server
+#ifdef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS
+ // Recent regression, missing one output polygon
+ test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_6",
+ case_recursive_boxes_6[0], case_recursive_boxes_6[1],
+ 99, 99, 99.0);
+#endif
+
test_one<Polygon, MultiPolygon, MultiPolygon>("ggl_list_20120915_h2_a",
ggl_list_20120915_h2[0], ggl_list_20120915_h2[1],
2, 10, 6.0); // Area from SQL Server
diff --git a/libs/geometry/test/algorithms/set_operations/intersection/test_intersection.hpp b/libs/geometry/test/algorithms/set_operations/intersection/test_intersection.hpp
index 1c45032a98..512bc9c95e 100644
--- a/libs/geometry/test/algorithms/set_operations/intersection/test_intersection.hpp
+++ b/libs/geometry/test/algorithms/set_operations/intersection/test_intersection.hpp
@@ -257,6 +257,9 @@ void test_one_lp(std::string const& caseid,
double percentage = 0.0001,
bool debug1 = false, bool debug2 = false)
{
+#ifdef BOOST_GEOMETRY_TEST_DEBUG
+ std::cout << caseid << " -- start" << std::endl;
+#endif
Areal areal;
bg::read_wkt(wkt_areal, areal);
bg::correct(areal);
@@ -274,6 +277,9 @@ void test_one_lp(std::string const& caseid,
test_intersection<OutputType, void>(caseid + "_rev", areal, linear,
expected_count, expected_point_count,
expected_length, percentage, debug2);
+#ifdef BOOST_GEOMETRY_TEST_DEBUG
+ std::cout << caseid << " -- end" << std::endl;
+#endif
}
template <typename Geometry1, typename Geometry2>
diff --git a/libs/geometry/test/algorithms/set_operations/sym_difference/sym_difference_areal_areal.cpp b/libs/geometry/test/algorithms/set_operations/sym_difference/sym_difference_areal_areal.cpp
index 1a163aa22c..02bc656180 100644
--- a/libs/geometry/test/algorithms/set_operations/sym_difference/sym_difference_areal_areal.cpp
+++ b/libs/geometry/test/algorithms/set_operations/sym_difference/sym_difference_areal_areal.cpp
@@ -67,12 +67,15 @@ struct test_sym_difference_of_areal_geometries
<< expected_area
<< "; detected: " << bg::area(sdf) << std::endl;
#endif
+ ut_settings settings;
+ settings.percentage = tolerance;
+
test_difference
<
PolygonOut
>(case_id, areal1, areal2,
expected_polygon_count, expected_point_count, expected_area,
- tolerance, true);
+ tolerance, settings);
}
};
diff --git a/libs/geometry/test/algorithms/set_operations/union/test_union.hpp b/libs/geometry/test/algorithms/set_operations/union/test_union.hpp
index 6a769827c8..67ef15b19e 100644
--- a/libs/geometry/test/algorithms/set_operations/union/test_union.hpp
+++ b/libs/geometry/test/algorithms/set_operations/union/test_union.hpp
@@ -7,6 +7,7 @@
// Modifications copyright (c) 2015 Oracle and/or its affiliates.
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
+// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@@ -29,6 +30,7 @@
#include <boost/geometry/algorithms/is_empty.hpp>
#include <boost/geometry/algorithms/length.hpp>
#include <boost/geometry/algorithms/num_points.hpp>
+#include <boost/geometry/algorithms/is_valid.hpp>
#include <boost/geometry/geometries/geometries.hpp>
@@ -41,17 +43,30 @@
# include <boost/geometry/io/svg/svg_mapper.hpp>
#endif
+struct ut_settings
+{
+ double percentage;
+ bool test_validity;
+
+ ut_settings()
+ : percentage(0.001)
+ , test_validity(false)
+ {}
+
+};
template <typename OutputType, typename G1, typename G2>
void test_union(std::string const& caseid, G1 const& g1, G2 const& g2,
int expected_count, int expected_hole_count,
int expected_point_count, double expected_area,
- double percentage)
+ ut_settings const& settings)
{
typedef typename bg::coordinate_type<G1>::type coordinate_type;
boost::ignore_unused<coordinate_type>();
+ boost::ignore_unused(expected_point_count);
+ // Declare output (vector of rings, or vector of polygons)
std::vector<OutputType> clip;
#if defined(BOOST_GEOMETRY_DEBUG_ROBUSTNESS)
@@ -69,8 +84,19 @@ void test_union(std::string const& caseid, G1 const& g1, G2 const& g2,
area += bg::area(*it);
holes += bg::num_interior_rings(*it);
n += bg::num_points(*it, true);
+
+ if (settings.test_validity)
+ {
+ // Check validity (currently on separate clips only)
+ // std::cout << bg::dsv(*it) << std::endl;
+ std::string message;
+ bool const valid = bg::is_valid(*it, message);
+ BOOST_CHECK_MESSAGE(valid,
+ "union: " << caseid << " not valid " << message);
+ }
}
+
#if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE)
{
// Test inserter functionality
@@ -92,7 +118,7 @@ void test_union(std::string const& caseid, G1 const& g1, G2 const& g2,
}
}
BOOST_CHECK_EQUAL(boost::size(clip), boost::size(inserted) - 1);
- BOOST_CHECK_CLOSE(area_inserted, expected_area, percentage);
+ BOOST_CHECK_CLOSE(area_inserted, expected_area, settings.percentage);
}
#endif
@@ -130,7 +156,7 @@ void test_union(std::string const& caseid, G1 const& g1, G2 const& g2,
<< " type: " << (type_for_assert_message<G1, G2>())
);
- BOOST_CHECK_CLOSE(area, expected_area, percentage);
+ BOOST_CHECK_CLOSE(area, expected_area, settings.percentage);
#if defined(TEST_WITH_SVG)
{
@@ -180,10 +206,11 @@ 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,
+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,
- double percentage = 0.001)
+ ut_settings const& settings = ut_settings())
{
G1 g1;
bg::read_wkt(wkt1, g1);
@@ -191,15 +218,13 @@ void test_one(std::string const& caseid, std::string const& wkt1, std::string co
G2 g2;
bg::read_wkt(wkt2, g2);
- // Reverse if necessary
+ // 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, percentage);
+ expected_area, settings);
}
-
-
#endif
diff --git a/libs/geometry/test/algorithms/set_operations/union/union.cpp b/libs/geometry/test/algorithms/set_operations/union/union.cpp
index a2bfa9b988..ae71c3f68f 100644
--- a/libs/geometry/test/algorithms/set_operations/union/union.cpp
+++ b/libs/geometry/test/algorithms/set_operations/union/union.cpp
@@ -1,9 +1,9 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Unit Test
-// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
-// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
-// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
@@ -181,6 +181,11 @@ void test_areal()
test_one<Polygon, Polygon, Polygon>("59_iet",
case_59[0], case_59[2], 1, 1, 14, 17.20833);
+ test_one<Polygon, Polygon, Polygon>("80",
+ case_80[0], case_80[1], 2, 2, 18, 129.0);
+
+ test_one<Polygon, Polygon, Polygon>("81",
+ case_81[0], case_81[1], 1, 2, 15, 163.5);
/*
test_one<Polygon, Polygon, Polygon>(102,
@@ -242,16 +247,20 @@ void test_areal()
67.3550722317627);
#endif
+ {
+ ut_settings settings;
+ settings.percentage = 0.1;
- test_one<Polygon, Polygon, Polygon>("isovist",
- isovist1[0], isovist1[1],
- 1,
- 0,
- -1,
- 313.36036462, 0.01);
+ test_one<Polygon, Polygon, Polygon>("isovist",
+ isovist1[0], isovist1[1],
+ 1,
+ 0,
+ -1,
+ 313.36036462, settings);
- // SQL Server gives: 313.360374193241
- // PostGIS gives: 313.360364623393
+ // SQL Server gives: 313.360374193241
+ // PostGIS gives: 313.360364623393
+ }
// Ticket 5103 https://svn.boost.org/trac/boost/ticket/5103
// This ticket was actually reported for Boost.Polygon
@@ -261,10 +270,13 @@ void test_areal()
// Boost.Geometry gives: 2515271327070.5237746891 (ttmath)
// 2515271327070.5156 (double)
// 2515271320603.0000 (int)
- // Note the int-test was tested outside of this unit test. It is in two points 0.37 off (logical for an int).
- // Because of the width of the polygon (400000 meter) this causes a substantial difference.
+ // Note the int-test was tested outside of this unit test.
+ // It is in two points 0.37 off (logical for an int).
+ // Because of the width of the polygon (400000 meter)
+ // this causes a substantial difference.
- test_one<Polygon, Polygon, Polygon>("ticket_5103", ticket_5103[0], ticket_5103[1],
+ test_one<Polygon, Polygon, Polygon>("ticket_5103",
+ ticket_5103[0], ticket_5103[1],
1, 0, 25, 2515271327070.5);
test_one<Polygon, Polygon, Polygon>("ticket_8310a", ticket_8310a[0], ticket_8310a[1],
@@ -319,10 +331,8 @@ void test_areal()
1, 0, if_typed<ct, double>(18, 23), 4.60853);
#endif
-#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
test_one<Polygon, Polygon, Polygon>("buffer_rt_g", buffer_rt_g[0], buffer_rt_g[1],
1, 0, if_typed<ct, float>(18, 17), 16.571);
-#endif
test_one<Polygon, Polygon, Polygon>("buffer_rt_g_rev", buffer_rt_g[1], buffer_rt_g[0],
1, 0, if_typed<ct, float>(18, 17), 16.571);
@@ -355,10 +365,8 @@ void test_areal()
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);
-#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
test_one<Polygon, Polygon, Polygon>("buffer_rt_q", buffer_rt_q[0], buffer_rt_q[1],
1, 0, 18, 18.5710);
-#endif
test_one<Polygon, Polygon, Polygon>("buffer_rt_q_rev", buffer_rt_q[1], buffer_rt_q[0],
1, 0, 18, 18.5710);
@@ -376,13 +384,27 @@ void test_areal()
1, 0, if_typed_tt<ct>(16, if_typed<ct, float>(15, 14)), 15.6569);
#endif
-#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
test_one<Polygon, Polygon, Polygon>("buffer_mp1", buffer_mp1[0], buffer_mp1[1],
1, 0, if_typed_tt<ct>(93, 91), 22.815);
-#endif
test_one<Polygon, Polygon, Polygon>("buffer_mp2", buffer_mp2[0], buffer_mp2[1],
1, 0, 217, 36.752837);
+
+#ifdef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS
+ test_one<Polygon, Polygon, Polygon>("ticket_11725",
+ ticket_11725[0], ticket_11725[1],
+ 1, 1, -1, 7.5);
+#endif
+
+ test_one<Polygon, Polygon, Polygon>("mysql_21964079_1",
+ mysql_21964079_1[0], mysql_21964079_1[1],
+ 2, 1, -1, 234.5);
+ test_one<Polygon, Polygon, Polygon>("mysql_21964079_2",
+ mysql_21964079_2[0], mysql_21964079_2[1],
+ 2, 1, -1, 112.0);
+ test_one<Polygon, Polygon, Polygon>("mysql_21964049",
+ mysql_21964049[0], mysql_21964049[1],
+ 1, 1, -1, 220.5);
}
template <typename P>
diff --git a/libs/geometry/test/algorithms/set_operations/union/union_multi.cpp b/libs/geometry/test/algorithms/set_operations/union/union_multi.cpp
index a80a249cae..31c7fe1b84 100644
--- a/libs/geometry/test/algorithms/set_operations/union/union_multi.cpp
+++ b/libs/geometry/test/algorithms/set_operations/union/union_multi.cpp
@@ -59,6 +59,13 @@ void test_areal()
case_multi_2[0], case_multi_2[1],
3, 0, 16, 59.1);
+ test_one<Polygon, MultiPolygon, MultiPolygon>("case_58_multi_a",
+ case_58_multi[0], case_58_multi[3],
+ 2, 0, 21, 19.83333333);
+ test_one<Polygon, MultiPolygon, MultiPolygon>("case_58_multi_b",
+ case_58_multi[1], case_58_multi[2],
+ 1, 3, 17, 48.333333);
+
// Constructed cases for multi/touch/equal/etc
test_one<Polygon, MultiPolygon, MultiPolygon>("case_61_multi",
case_61_multi[0], case_61_multi[1],
@@ -113,6 +120,18 @@ void test_areal()
case_recursive_boxes_3[0], case_recursive_boxes_3[1],
17, 0, 159, 56.5); // Area from SQL Server
+ test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_4",
+ case_recursive_boxes_4[0], case_recursive_boxes_4[1],
+ 1, 1, 42, 96.75);
+ test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_5",
+ case_recursive_boxes_5[0], case_recursive_boxes_5[1],
+ 3, 2, 110, 70.0);
+
+ // TODO: fix self touching interior ring (should get 3 interior rings)
+ test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_6",
+ case_recursive_boxes_6[0], case_recursive_boxes_6[1],
+ 1, 2, 25, 24.0);
+
test_one<Polygon, MultiPolygon, MultiPolygon>("ggl_list_20120915_h2_a",
ggl_list_20120915_h2[0], ggl_list_20120915_h2[1],
1, 0, 12, 23.0); // Area from SQL Server
@@ -132,35 +151,48 @@ void test_areal()
4,
#endif
0, 31, 0.2187385);
+
+ test_one<Polygon, MultiPolygon, MultiPolygon>("ticket_10803",
+ ticket_10803[0], ticket_10803[1],
+ 1, 0, 9, 2663736.07038);
}
-template <typename P>
+// Test cases (generic)
+template <typename Point, bool ClockWise, bool Closed>
void test_all()
{
- {
- typedef bg::model::ring<P> ring;
- typedef bg::model::polygon<P> polygon;
- typedef bg::model::multi_polygon<polygon> multi_polygon;
- test_areal<ring, polygon, multi_polygon>();
- }
+ typedef bg::model::ring<Point, ClockWise, Closed> ring;
+ typedef bg::model::polygon<Point, ClockWise, Closed> polygon;
+ typedef bg::model::multi_polygon<polygon> multi_polygon;
+ test_areal<ring, polygon, multi_polygon>();
+}
+
+// Test cases for integer coordinates / ccw / open
+template <typename Point, bool ClockWise, bool Closed>
+void test_specific()
+{
+ typedef bg::model::polygon<Point, ClockWise, Closed> polygon;
+ typedef bg::model::multi_polygon<polygon> multi_polygon;
- {
- typedef bg::model::ring<P, false> ring_ccw;
- typedef bg::model::polygon<P, false> polygon_ccw;
- typedef bg::model::multi_polygon<polygon_ccw> multi_polygon_ccw;
- test_areal<ring_ccw, polygon_ccw, multi_polygon_ccw>();
- }
+ ut_settings settings;
+ settings.test_validity = true;
+ test_one<polygon, multi_polygon, multi_polygon>("ticket_10803",
+ ticket_10803[0], ticket_10803[1],
+ 1, 0, 9, 2664270, settings);
}
int test_main(int, char* [])
{
- test_all<bg::model::d2::point_xy<double> >();
+ test_all<bg::model::d2::point_xy<double>, true, true>();
+ test_all<bg::model::d2::point_xy<double>, false, false>();
+
+ test_specific<bg::model::d2::point_xy<int>, false, false>();
#if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE)
- test_all<bg::model::d2::point_xy<float> >();
+ test_all<bg::model::d2::point_xy<float>, true, true>();
#if defined(HAVE_TTMATH)
std::cout << "Testing TTMATH" << std::endl;
diff --git a/libs/geometry/test/algorithms/test_centroid.hpp b/libs/geometry/test/algorithms/test_centroid.hpp
index cfbe017832..7e4d994835 100644
--- a/libs/geometry/test/algorithms/test_centroid.hpp
+++ b/libs/geometry/test/algorithms/test_centroid.hpp
@@ -126,5 +126,21 @@ void test_centroid_exception()
BOOST_CHECK_MESSAGE(false, "A centroid_exception should have been thrown" );
}
+template <typename Geometry>
+void test_centroid_exception(std::string const& wkt)
+{
+ Geometry geometry;
+ bg::read_wkt(wkt, geometry);
+ try
+ {
+ typename bg::point_type<Geometry>::type c;
+ bg::centroid(geometry, c);
+ }
+ catch(bg::centroid_exception const& )
+ {
+ return;
+ }
+ BOOST_CHECK_MESSAGE(false, "A centroid_exception should have been thrown" );
+}
#endif
diff --git a/libs/geometry/test/arithmetic/Jamfile.v2 b/libs/geometry/test/arithmetic/Jamfile.v2
index ac1ad55b5c..23a11b2bdd 100644
--- a/libs/geometry/test/arithmetic/Jamfile.v2
+++ b/libs/geometry/test/arithmetic/Jamfile.v2
@@ -11,6 +11,6 @@
test-suite boost-geometry-arithmetic
:
- [ run arithmetic.cpp : : : : arithmetic ]
+ [ run general.cpp : : : : arithmetic_general ]
[ run dot_product.cpp : : : : arithmetic_dot_product ]
;
diff --git a/libs/geometry/test/arithmetic/arithmetic.cpp b/libs/geometry/test/arithmetic/general.cpp
index a329a6e524..a329a6e524 100644
--- a/libs/geometry/test/arithmetic/arithmetic.cpp
+++ b/libs/geometry/test/arithmetic/general.cpp
diff --git a/libs/geometry/test/geometries/Jamfile.v2 b/libs/geometry/test/geometries/Jamfile.v2
index cde618d06e..c6b360f7a9 100644
--- a/libs/geometry/test/geometries/Jamfile.v2
+++ b/libs/geometry/test/geometries/Jamfile.v2
@@ -25,6 +25,6 @@ test-suite boost-geometry-geometries
# geometries_custom_linestring_test_fail_clear
#]
[ run custom_linestring.cpp : : : : geometries_custom_linestring ]
- [ run geometries.cpp : : : : geometries ]
+ [ run initialization.cpp : : : : geometries_initialization ]
[ run segment.cpp : : : : geometries_segment ]
;
diff --git a/libs/geometry/test/geometries/geometries.cpp b/libs/geometry/test/geometries/initialization.cpp
index 23dd11f522..23dd11f522 100644
--- a/libs/geometry/test/geometries/geometries.cpp
+++ b/libs/geometry/test/geometries/initialization.cpp
diff --git a/libs/geometry/test/iterators/ever_circling_iterator.cpp b/libs/geometry/test/iterators/ever_circling_iterator.cpp
index 90142e13d7..1e4c254fdb 100644
--- a/libs/geometry/test/iterators/ever_circling_iterator.cpp
+++ b/libs/geometry/test/iterators/ever_circling_iterator.cpp
@@ -33,12 +33,12 @@ void test_geometry(std::string const& wkt)
// Run 3 times through the geometry
- int n = boost::size(geo) * 3;
+ std::size_t n = boost::size(geo) * 3;
{
std::ostringstream out;
bg::ever_circling_iterator<iterator_type> it(boost::begin(geo), boost::end(geo));
- for (int i = 0; i < n; ++i, ++it)
+ for (std::size_t i = 0; i < n; ++i, ++it)
{
out << bg::get<0>(*it);
}
@@ -50,7 +50,7 @@ void test_geometry(std::string const& wkt)
// Start somewhere
bg::ever_circling_iterator<iterator_type> it(
boost::begin(geo), boost::end(geo), boost::begin(geo) + 1);
- for (int i = 0; i < n; ++i, ++it)
+ for (std::size_t i = 0; i < n; ++i, ++it)
{
out << bg::get<0>(*it);
}
@@ -62,9 +62,9 @@ void test_geometry(std::string const& wkt)
// Navigate to somewhere
bg::ever_circling_iterator<iterator_type> it(boost::begin(geo), boost::end(geo));
- for (int i = 0; i < n; ++i, ++it)
+ for (std::size_t i = 0; i < n; ++i, ++it)
{
- const int m = boost::size(geo);
+ std::size_t const m = boost::size(geo);
it.moveto(boost::begin(geo) + m - (i % m) - 1);
out << bg::get<0>(*it);
}
@@ -75,7 +75,7 @@ void test_geometry(std::string const& wkt)
{
std::ostringstream out;
bg::ever_circling_range_iterator<G> it(geo);
- for (int i = 0; i < n; ++i, ++it)
+ for (std::size_t i = 0; i < n; ++i, ++it)
{
out << bg::get<0>(*it);
}
diff --git a/libs/geometry/test/views/Jamfile.v2 b/libs/geometry/test/views/Jamfile.v2
index cb2f5fb5ad..3b23c2f362 100644
--- a/libs/geometry/test/views/Jamfile.v2
+++ b/libs/geometry/test/views/Jamfile.v2
@@ -1,8 +1,9 @@
# Boost.Geometry (aka GGL, Generic Geometry Library)
#
-# Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
-# Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
-# Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+# Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
+# Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
+# Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
+# Copyright (c) 2015 Adam Wulkiewicz, Lodz, Poland.
#
# Use, modification and distribution is subject to the Boost Software License,
# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@@ -10,9 +11,9 @@
test-suite boost-geometry-views
:
- [ run segment_view.cpp ]
- [ run box_view.cpp ]
- [ run reversible_view.cpp ]
- [ run closeable_view.cpp ]
- [ run reversible_closeable.cpp ]
+ [ run segment_view.cpp : : : : views_segment_view ]
+ [ run box_view.cpp : : : : views_box_view ]
+ [ run reversible_view.cpp : : : : views_reversible_view ]
+ [ run closeable_view.cpp : : : : views_closeable_view ]
+ [ run reversible_closeable.cpp : : : : views_reversible_closeable ]
;