summaryrefslogtreecommitdiff
path: root/libs/geometry/index/test/algorithms
diff options
context:
space:
mode:
Diffstat (limited to 'libs/geometry/index/test/algorithms')
-rw-r--r--libs/geometry/index/test/algorithms/Jamfile.v220
-rw-r--r--libs/geometry/index/test/algorithms/content.cpp71
-rw-r--r--libs/geometry/index/test/algorithms/intersection_content.cpp70
-rw-r--r--libs/geometry/index/test/algorithms/is_valid.cpp110
-rw-r--r--libs/geometry/index/test/algorithms/margin.cpp66
-rw-r--r--libs/geometry/index/test/algorithms/minmaxdist.cpp101
-rw-r--r--libs/geometry/index/test/algorithms/path_intersection.cpp133
-rw-r--r--libs/geometry/index/test/algorithms/segment_intersection.cpp129
-rw-r--r--libs/geometry/index/test/algorithms/test_content.hpp49
-rw-r--r--libs/geometry/index/test/algorithms/test_intersection_content.hpp47
-rw-r--r--libs/geometry/index/test/algorithms/test_margin.hpp48
-rw-r--r--libs/geometry/index/test/algorithms/test_union_content.hpp47
-rw-r--r--libs/geometry/index/test/algorithms/union_content.cpp70
13 files changed, 961 insertions, 0 deletions
diff --git a/libs/geometry/index/test/algorithms/Jamfile.v2 b/libs/geometry/index/test/algorithms/Jamfile.v2
new file mode 100644
index 000000000..1fe75c6fc
--- /dev/null
+++ b/libs/geometry/index/test/algorithms/Jamfile.v2
@@ -0,0 +1,20 @@
+# Boost.Geometry Index
+#
+# Copyright (c) 2011-2013 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
+# http://www.boost.org/LICENSE_1_0.txt)
+
+test-suite boost-geometry-index-algorithms
+ :
+ [ run content.cpp ]
+ [ run intersection_content.cpp ] # this tests overlap() too
+ [ run is_valid.cpp ]
+ [ run margin.cpp ]
+ #[ run minmaxdist.cpp ]
+ [ run union_content.cpp ]
+ [ run segment_intersection.cpp ]
+ [ run path_intersection.cpp ]
+ ;
+
diff --git a/libs/geometry/index/test/algorithms/content.cpp b/libs/geometry/index/test/algorithms/content.cpp
new file mode 100644
index 000000000..0d8cc0818
--- /dev/null
+++ b/libs/geometry/index/test/algorithms/content.cpp
@@ -0,0 +1,71 @@
+// Boost.Geometry Index
+// Unit Test
+
+// Copyright (c) 2011-2013 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
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <algorithms/test_content.hpp>
+
+#include <boost/geometry/geometries/point_xy.hpp>
+#include <boost/geometry/geometries/point.hpp>
+#include <boost/geometry/geometries/box.hpp>
+
+//#define GEOMETRY_TEST_DEBUG
+
+void test_large_integers()
+{
+ typedef bg::model::point<int, 2, bg::cs::cartesian> int_point_type;
+ typedef bg::model::point<double, 2, bg::cs::cartesian> double_point_type;
+
+ bg::model::box<int_point_type> int_box;
+ bg::model::box<double_point_type> double_box;
+
+ std::string const box_li = "POLYGON((1536119 192000, 1872000 528000))";
+ bg::read_wkt(box_li, int_box);
+ bg::read_wkt(box_li, double_box);
+
+ double int_value = bgi::detail::content(int_box);
+ double double_value = bgi::detail::content(double_box);
+
+ BOOST_CHECK_CLOSE(int_value, double_value, 0.0001);
+}
+
+int test_main(int, char* [])
+{
+ typedef bg::model::point<int, 2, bg::cs::cartesian> P2ic;
+ typedef bg::model::point<float, 2, bg::cs::cartesian> P2fc;
+ typedef bg::model::point<double, 2, bg::cs::cartesian> P2dc;
+
+ typedef bg::model::point<int, 3, bg::cs::cartesian> P3ic;
+ typedef bg::model::point<float, 3, bg::cs::cartesian> P3fc;
+ typedef bg::model::point<double, 3, bg::cs::cartesian> P3dc;
+
+ test_content(P2ic(0, 0), 0);
+ test_content(P2fc(0, 0), 0);
+ test_content(P2dc(0, 0), 0);
+ test_content(P3ic(0, 0, 0), 0);
+ test_content(P3fc(0, 0, 0), 0);
+ test_content(P3dc(0, 0, 0), 0);
+
+ test_geometry<bg::model::box<P2ic> >("POLYGON((0 1,2 4))", 6.0);
+ test_geometry<bg::model::box<P2fc> >("POLYGON((0 1,2 4))", 6.0);
+ test_geometry<bg::model::box<P2dc> >("POLYGON((0 1,2 4))", 6.0);
+ test_geometry<bg::model::box<P3ic> >("POLYGON((0 1 2,2 4 6))", 24.0);
+ test_geometry<bg::model::box<P3fc> >("POLYGON((0 1 2,2 4 6))", 24.0);
+ test_geometry<bg::model::box<P3dc> >("POLYGON((0 1 2,2 4 6))", 24.0);
+
+#ifdef HAVE_TTMATH
+ typedef bg::model::point<ttmath_big, 2, bg::cs::cartesian> P2ttmc;
+ typedef bg::model::point<ttmath_big, 3, bg::cs::cartesian> P3ttmc;
+
+ test_geometry<bg::model::box<P2ttmc> >("POLYGON((0 1,2 4))", 6.0);
+ test_geometry<bg::model::box<P3ttmc> >("POLYGON((0 1 2,2 4 6))", 24.0);
+#endif
+
+ test_large_integers();
+
+ return 0;
+}
diff --git a/libs/geometry/index/test/algorithms/intersection_content.cpp b/libs/geometry/index/test/algorithms/intersection_content.cpp
new file mode 100644
index 000000000..b53873bcd
--- /dev/null
+++ b/libs/geometry/index/test/algorithms/intersection_content.cpp
@@ -0,0 +1,70 @@
+// Boost.Geometry Index
+// Unit Test
+
+// Copyright (c) 2011-2013 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
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <algorithms/test_intersection_content.hpp>
+
+#include <boost/geometry/geometries/point_xy.hpp>
+#include <boost/geometry/geometries/point.hpp>
+#include <boost/geometry/geometries/box.hpp>
+
+//#define GEOMETRY_TEST_DEBUG
+
+void test_large_integers()
+{
+ typedef bg::model::point<int, 2, bg::cs::cartesian> int_point_type;
+ typedef bg::model::point<double, 2, bg::cs::cartesian> double_point_type;
+
+ bg::model::box<int_point_type> int_box1, int_box2;
+ bg::model::box<double_point_type> double_box1, double_box2;
+
+ std::string const box_li1 = "POLYGON((1536119 192000, 1872000 528000))";
+ std::string const box_li2 = "POLYGON((1701234 368250, 2673400 777400))";
+ bg::read_wkt(box_li1, int_box1);
+ bg::read_wkt(box_li1, double_box1);
+ bg::read_wkt(box_li2, int_box2);
+ bg::read_wkt(box_li2, double_box2);
+
+ double int_value = bgi::detail::intersection_content(int_box1, int_box2);
+ double double_value = bgi::detail::intersection_content(double_box1, double_box2);
+
+ BOOST_CHECK_CLOSE(int_value, double_value, 0.0001);
+}
+
+int test_main(int, char* [])
+{
+ typedef bg::model::point<int, 2, bg::cs::cartesian> P2ic;
+ typedef bg::model::point<float, 2, bg::cs::cartesian> P2fc;
+ typedef bg::model::point<double, 2, bg::cs::cartesian> P2dc;
+
+ typedef bg::model::point<int, 3, bg::cs::cartesian> P3ic;
+ typedef bg::model::point<float, 3, bg::cs::cartesian> P3fc;
+ typedef bg::model::point<double, 3, bg::cs::cartesian> P3dc;
+
+ test_geometry<bg::model::box<P2ic> >("POLYGON((0 1,2 4))", "POLYGON((1 2,3 5))", 2.0);
+ test_geometry<bg::model::box<P2fc> >("POLYGON((0 1,2 4))", "POLYGON((1 2,3 5))", 2.0);
+ test_geometry<bg::model::box<P2dc> >("POLYGON((0 1,2 4))", "POLYGON((1 2,3 5))", 2.0);
+ test_geometry<bg::model::box<P3ic> >("POLYGON((0 1 2,2 4 6))", "POLYGON((1 2 3,3 5 7))", 6.0);
+ test_geometry<bg::model::box<P3fc> >("POLYGON((0 1 2,2 4 6))", "POLYGON((1 2 3,3 5 7))", 6.0);
+ test_geometry<bg::model::box<P3dc> >("POLYGON((0 1 2,2 4 6))", "POLYGON((1 2 3,3 5 7))", 6.0);
+
+ test_geometry<bg::model::box<P2dc> >("POLYGON((0 1,2 4))", "POLYGON((2 1,3 4))", 0.0);
+ test_geometry<bg::model::box<P2dc> >("POLYGON((0 1,2 4))", "POLYGON((2 4,3 5))", 0.0);
+
+#ifdef HAVE_TTMATH
+ typedef bg::model::point<ttmath_big, 2, bg::cs::cartesian> P2ttmc;
+ typedef bg::model::point<ttmath_big, 3, bg::cs::cartesian> P3ttmc;
+
+ test_geometry<bg::model::box<P2ttmc> >("POLYGON((0 1,2 4))", "POLYGON((1 2,3 5))", 2.0);
+ test_geometry<bg::model::box<P3ttmc> >("POLYGON((0 1 2,2 4 6))", "POLYGON((1 2 3,3 5 7))", 6.0);
+#endif
+
+ test_large_integers();
+
+ return 0;
+}
diff --git a/libs/geometry/index/test/algorithms/is_valid.cpp b/libs/geometry/index/test/algorithms/is_valid.cpp
new file mode 100644
index 000000000..ff3dae0ba
--- /dev/null
+++ b/libs/geometry/index/test/algorithms/is_valid.cpp
@@ -0,0 +1,110 @@
+// Boost.Geometry Index
+// Unit Test
+
+// Copyright (c) 2011-2013 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
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <algorithm>
+
+#include <geometry_index_test_common.hpp>
+
+#include <boost/geometry/index/detail/algorithms/is_valid.hpp>
+
+#include <boost/geometry/geometries/point_xy.hpp>
+#include <boost/geometry/geometries/point.hpp>
+#include <boost/geometry/geometries/box.hpp>
+
+//#define GEOMETRY_TEST_DEBUG
+
+template <typename Geometry>
+void test(Geometry const& geometry, bool expected_value)
+{
+ bool value = bgi::detail::is_valid(geometry);
+
+#ifdef GEOMETRY_TEST_DEBUG
+ std::ostringstream out;
+ out << typeid(typename bg::coordinate_type<Geometry>::type).name()
+ << " "
+ << typeid(bool).name()
+ << " "
+ << "is_valid : " << value
+ << std::endl;
+ std::cout << out.str();
+#endif
+
+ BOOST_CHECK(value == expected_value);
+}
+
+template <typename Box>
+void test_box(std::string const& wkt, bool expected_value)
+{
+ Box box;
+ bg::read_wkt(wkt, box);
+ test(box, expected_value);
+ typename bg::point_type<Box>::type temp_pt;
+ temp_pt = box.min_corner();
+ box.min_corner() = box.max_corner();
+ box.max_corner() = temp_pt;
+ test(box, !expected_value);
+}
+
+void test_large_integers()
+{
+ typedef bg::model::point<int, 2, bg::cs::cartesian> int_point_type;
+ typedef bg::model::point<double, 2, bg::cs::cartesian> double_point_type;
+
+ bg::model::box<int_point_type> int_box;
+ bg::model::box<double_point_type> double_box;
+
+ std::string const box_li = "POLYGON((1536119 192000, 1872000 528000))";
+ bg::read_wkt(box_li, int_box);
+ bg::read_wkt(box_li, double_box);
+
+ BOOST_CHECK(bgi::detail::is_valid(int_box) == bgi::detail::is_valid(double_box));
+
+ std::string const box_li2 = "POLYGON((1872000 528000, 1536119 192000))";
+ bg::read_wkt(box_li2, int_box);
+ bg::read_wkt(box_li2, double_box);
+
+ BOOST_CHECK(bgi::detail::is_valid(int_box) == bgi::detail::is_valid(double_box));
+}
+
+int test_main(int, char* [])
+{
+ typedef bg::model::point<int, 2, bg::cs::cartesian> P2ic;
+ typedef bg::model::point<float, 2, bg::cs::cartesian> P2fc;
+ typedef bg::model::point<double, 2, bg::cs::cartesian> P2dc;
+
+ typedef bg::model::point<int, 3, bg::cs::cartesian> P3ic;
+ typedef bg::model::point<float, 3, bg::cs::cartesian> P3fc;
+ typedef bg::model::point<double, 3, bg::cs::cartesian> P3dc;
+
+ test(P2ic(0, 0), true);
+ test(P2fc(0, 0), true);
+ test(P2dc(0, 0), true);
+ test(P3ic(0, 0, 0), true);
+ test(P3fc(0, 0, 0), true);
+ test(P3dc(0, 0, 0), true);
+
+ test_box<bg::model::box<P2ic> >("POLYGON((0 1,2 4))", true);
+ test_box<bg::model::box<P2fc> >("POLYGON((0 1,2 4))", true);
+ test_box<bg::model::box<P2dc> >("POLYGON((0 1,2 4))", true);
+ test_box<bg::model::box<P3ic> >("POLYGON((0 1 2,2 4 6))", true);
+ test_box<bg::model::box<P3fc> >("POLYGON((0 1 2,2 4 6))", true);
+ test_box<bg::model::box<P3dc> >("POLYGON((0 1 2,2 4 6))", true);
+
+#ifdef HAVE_TTMATH
+ typedef bg::model::point<ttmath_big, 2, bg::cs::cartesian> P2ttmc;
+ typedef bg::model::point<ttmath_big, 3, bg::cs::cartesian> P3ttmc;
+
+ test_geometry<bg::model::box<P2ttmc> >("POLYGON((0 1,2 4))", true);
+ test_geometry<bg::model::box<P3ttmc> >("POLYGON((0 1 2,2 4 6))", true);
+#endif
+
+ test_large_integers();
+
+ return 0;
+}
diff --git a/libs/geometry/index/test/algorithms/margin.cpp b/libs/geometry/index/test/algorithms/margin.cpp
new file mode 100644
index 000000000..cd83ded93
--- /dev/null
+++ b/libs/geometry/index/test/algorithms/margin.cpp
@@ -0,0 +1,66 @@
+// Boost.Geometry Index
+// Unit Test
+
+// Copyright (c) 2011-2013 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
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <algorithms/test_margin.hpp>
+
+#include <boost/geometry/geometries/point_xy.hpp>
+#include <boost/geometry/geometries/point.hpp>
+#include <boost/geometry/geometries/box.hpp>
+
+//#define GEOMETRY_TEST_DEBUG
+
+void test_large_integers()
+{
+ typedef bg::model::point<int, 2, bg::cs::cartesian> int_point_type;
+ typedef bg::model::point<double, 2, bg::cs::cartesian> double_point_type;
+
+ bg::model::box<int_point_type> int_box;
+ bg::model::box<double_point_type> double_box;
+
+ std::string const box_li = "POLYGON((1536119 192000, 1872000 528000))";
+ bg::read_wkt(box_li, int_box);
+ bg::read_wkt(box_li, double_box);
+
+ double int_value = bgi::detail::comparable_margin(int_box);
+ double double_value = bgi::detail::comparable_margin(double_box);
+
+ BOOST_CHECK_CLOSE(int_value, double_value, 0.0001);
+}
+
+int test_main(int, char* [])
+{
+ typedef bg::model::point<int, 2, bg::cs::cartesian> P2ic;
+ typedef bg::model::point<float, 2, bg::cs::cartesian> P2fc;
+ typedef bg::model::point<double, 2, bg::cs::cartesian> P2dc;
+
+ typedef bg::model::point<int, 3, bg::cs::cartesian> P3ic;
+ typedef bg::model::point<float, 3, bg::cs::cartesian> P3fc;
+ typedef bg::model::point<double, 3, bg::cs::cartesian> P3dc;
+
+ test_geometry<bg::model::box<P2ic> >("POLYGON((0 1,2 4))", 5);
+ test_geometry<bg::model::box<P2fc> >("POLYGON((0 1,2 4))", 5.0);
+ test_geometry<bg::model::box<P2dc> >("POLYGON((0 1,2 4))", 5.0);
+ test_geometry<bg::model::box<P3ic> >("POLYGON((0 1 2,2 4 6))", 9);
+ test_geometry<bg::model::box<P3fc> >("POLYGON((0 1 2,2 4 6))", 9.0);
+ test_geometry<bg::model::box<P3dc> >("POLYGON((0 1 2,2 4 6))", 9.0);
+
+#ifdef HAVE_TTMATH
+ typedef bg::model::point<ttmath_big, 2, bg::cs::cartesian> P2ttmc;
+ typedef bg::model::point<ttmath_big, 3, bg::cs::cartesian> P3ttmc;
+
+ test_geometry<bg::model::box<P2ttmc> >("POLYGON((0 1,2 4))", 10.0);
+ test_geometry<bg::model::box<P3ttmc> >("POLYGON((0 1 2,2 4 6))", 52.0);
+#endif
+
+ test_large_integers();
+
+ // test_empty_input<bg::model::d2::point_xy<int> >();
+
+ return 0;
+}
diff --git a/libs/geometry/index/test/algorithms/minmaxdist.cpp b/libs/geometry/index/test/algorithms/minmaxdist.cpp
new file mode 100644
index 000000000..dd7e8e5e2
--- /dev/null
+++ b/libs/geometry/index/test/algorithms/minmaxdist.cpp
@@ -0,0 +1,101 @@
+// Boost.Geometry Index
+// Unit Test
+
+// Copyright (c) 2011-2013 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
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <algorithm>
+
+#include <geometry_index_test_common.hpp>
+
+#include <boost/geometry/index/detail/algorithms/minmaxdist.hpp>
+
+#include <boost/geometry/geometries/point_xy.hpp>
+#include <boost/geometry/geometries/point.hpp>
+#include <boost/geometry/geometries/box.hpp>
+
+#define GEOMETRY_TEST_DEBUG
+
+template <typename Point, typename Indexable>
+void test(Point const& pt, Indexable const& indexable,
+ typename bg::default_distance_result<Point, Indexable>::type expected_value)
+{
+ typename bg::default_distance_result<Point, Indexable>::type value = bgi::detail::minmaxdist(pt, indexable);
+
+#ifdef GEOMETRY_TEST_DEBUG
+ std::ostringstream out;
+ out << typeid(typename bg::coordinate_type<Point>::type).name()
+ << " "
+ << typeid(typename bg::coordinate_type<Indexable>::type).name()
+ << " "
+ << typeid(bg::default_distance_result<Point, Indexable>::type).name()
+ << " "
+ << "minmaxdist : " << value
+ << std::endl;
+ std::cout << out.str();
+#endif
+
+ BOOST_CHECK_CLOSE(value, expected_value, 0.0001);
+}
+
+template <typename Indexable, typename Point>
+void test_indexable(Point const& pt, std::string const& wkt,
+ typename bg::default_distance_result<Point, Indexable>::type expected_value)
+{
+ Indexable indexable;
+ bg::read_wkt(wkt, indexable);
+ test(pt, indexable, expected_value);
+}
+
+void test_large_integers()
+{
+ typedef bg::model::point<int, 2, bg::cs::cartesian> int_point_type;
+ typedef bg::model::point<double, 2, bg::cs::cartesian> double_point_type;
+
+ int_point_type int_pt(0, 0);
+ double_point_type double_pt(0, 0);
+
+ bg::model::box<int_point_type> int_box;
+ bg::model::box<double_point_type> double_box;
+
+ std::string const box_li = "POLYGON((1536119 192000, 1872000 528000))";
+ bg::read_wkt(box_li, int_box);
+ bg::read_wkt(box_li, double_box);
+
+ BOOST_CHECK(bgi::detail::minmaxdist(int_pt, int_box) == bgi::detail::minmaxdist(double_pt, double_box));
+}
+
+int test_main(int, char* [])
+{
+ typedef bg::model::point<int, 2, bg::cs::cartesian> P2ic;
+ typedef bg::model::point<float, 2, bg::cs::cartesian> P2fc;
+ typedef bg::model::point<double, 2, bg::cs::cartesian> P2dc;
+
+ typedef bg::model::point<int, 3, bg::cs::cartesian> P3ic;
+ typedef bg::model::point<float, 3, bg::cs::cartesian> P3fc;
+ typedef bg::model::point<double, 3, bg::cs::cartesian> P3dc;
+
+ test_indexable<bg::model::box<P2ic> >(P2ic(1, 2), "POLYGON((0 1,2 4))", 5.0);
+ test_indexable<bg::model::box<P2fc> >(P2fc(1, 2), "POLYGON((0 1,2 4))", 5.0);
+ test_indexable<bg::model::box<P2dc> >(P2dc(1, 2), "POLYGON((0 1,2 4))", 5.0);
+ test_indexable<bg::model::box<P3ic> >(P3ic(1, 2, 3), "POLYGON((0 1 2,2 4 6))", 14.0);
+ test_indexable<bg::model::box<P3fc> >(P3fc(1, 2, 3), "POLYGON((0 1 2,2 4 6))", 14.0);
+ test_indexable<bg::model::box<P3dc> >(P3dc(1, 2, 3), "POLYGON((0 1 2,2 4 6))", 14.0);
+
+ test_indexable<bg::model::box<P2ic> >(P2ic(1, 2), "POLYGON((1 2,3 5))", 4.0);
+
+#ifdef HAVE_TTMATH
+ typedef bg::model::point<ttmath_big, 2, bg::cs::cartesian> P2ttmc;
+ typedef bg::model::point<ttmath_big, 3, bg::cs::cartesian> P3ttmc;
+
+ test_indexable<bg::model::box<P2ttmc> >(P2ttmc(1, 2), "POLYGON((0 1,2 4))", 5.0);
+ test_indexable<bg::model::box<P3ttmc> >(P3ttmc(1, 2, 3), "POLYGON((0 1 2,2 4 6))", 14.0);
+#endif
+
+ test_large_integers();
+
+ return 0;
+}
diff --git a/libs/geometry/index/test/algorithms/path_intersection.cpp b/libs/geometry/index/test/algorithms/path_intersection.cpp
new file mode 100644
index 000000000..2670d0775
--- /dev/null
+++ b/libs/geometry/index/test/algorithms/path_intersection.cpp
@@ -0,0 +1,133 @@
+// Boost.Geometry Index
+// Unit Test
+
+// Copyright (c) 2011-2013 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
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <geometry_index_test_common.hpp>
+
+#include <boost/geometry/index/detail/algorithms/path_intersection.hpp>
+
+#include <boost/geometry/geometries/point_xy.hpp>
+#include <boost/geometry/geometries/point.hpp>
+#include <boost/geometry/geometries/box.hpp>
+#include <boost/geometry/geometries/linestring.hpp>
+#include <boost/geometry/geometries/segment.hpp>
+
+//#include <boost/geometry/io/wkt/read.hpp>
+
+template <typename Box, typename Linestring>
+void test_path_intersection(Box const& box, Linestring const& path,
+ bool expected_result,
+ typename bg::default_length_result<Linestring>::type expected_dist)
+{
+ typename bgi::detail::default_path_intersection_distance_type<Box, Linestring>::type dist;
+
+ bool value = bgi::detail::path_intersection(box, path, dist);
+ BOOST_CHECK(value == expected_result);
+ if ( value && expected_result )
+ BOOST_CHECK_CLOSE(dist, expected_dist, 0.0001);
+
+ if ( ::boost::size(path) == 2 )
+ {
+ typedef typename ::boost::range_value<Linestring>::type P;
+ typedef bg::model::segment<P> Seg;
+ typename bgi::detail::default_path_intersection_distance_type<Box, Seg>::type dist;
+ Seg seg(*::boost::begin(path), *(::boost::begin(path)+1));
+ bool value = bgi::detail::path_intersection(box, seg, dist);
+ BOOST_CHECK(value == expected_result);
+ if ( value && expected_result )
+ BOOST_CHECK_CLOSE(dist, expected_dist, 0.0001);
+ }
+}
+
+template <typename Box, typename Linestring>
+void test_geometry(std::string const& wkt_g, std::string const& wkt_path,
+ bool expected_result,
+ typename bg::default_length_result<Linestring>::type expected_dist)
+{
+ Box box;
+ bg::read_wkt(wkt_g, box);
+ Linestring path;
+ bg::read_wkt(wkt_path, path);
+ test_path_intersection(box, path, expected_result, expected_dist);
+}
+
+void test_large_integers()
+{
+ typedef bg::model::point<int, 2, bg::cs::cartesian> int_point_type;
+ typedef bg::model::point<double, 2, bg::cs::cartesian> double_point_type;
+
+ bg::model::box<int_point_type> int_box;
+ bg::model::box<double_point_type> double_box;
+ typedef bg::model::linestring<int_point_type> IP;
+ IP int_path;
+ typedef bg::model::linestring<double_point_type> DP;
+ DP double_path;
+
+ std::string const str_box = "POLYGON((1536119 192000, 1872000 528000))";
+ std::string const str_path = "LINESTRING(1535000 191000, 1873000 191000, 1873000 300000, 1536119 300000)";
+ bg::read_wkt(str_box, int_box);
+ bg::read_wkt(str_box, double_box);
+ bg::read_wkt(str_path, int_path);
+ bg::read_wkt(str_path, double_path);
+
+ bg::default_length_result<IP>::type int_value;
+ bool int_result = bgi::detail::path_intersection(int_box, int_path, int_value);
+ bg::default_length_result<DP>::type double_value;
+ bool double_result = bgi::detail::path_intersection(double_box, double_path, double_value);
+
+ BOOST_CHECK(int_result == double_result);
+ if ( int_result && double_result )
+ BOOST_CHECK_CLOSE(int_value, double_value, 0.0001);
+}
+
+int test_main(int, char* [])
+{
+ typedef bg::model::point<int, 2, bg::cs::cartesian> P2ic;
+ typedef bg::model::point<float, 2, bg::cs::cartesian> P2fc;
+ typedef bg::model::point<double, 2, bg::cs::cartesian> P2dc;
+
+ typedef bg::model::point<int, 3, bg::cs::cartesian> P3ic;
+ typedef bg::model::point<float, 3, bg::cs::cartesian> P3fc;
+ typedef bg::model::point<double, 3, bg::cs::cartesian> P3dc;
+
+ typedef bg::model::linestring<P2ic> L2ic;
+ typedef bg::model::linestring<P2fc> L2fc;
+ typedef bg::model::linestring<P2dc> L2dc;
+
+ typedef bg::model::linestring<P3ic> L3ic;
+ typedef bg::model::linestring<P3fc> L3fc;
+ typedef bg::model::linestring<P3dc> L3dc;
+
+ // IMPORTANT! For 2-point linestrings comparable distance optimization is enabled!
+
+ test_geometry<bg::model::box<P2ic>, L2ic>("POLYGON((0 1,2 4))", "LINESTRING(0 0, 2 5)", true, 1.0f/5);
+ test_geometry<bg::model::box<P2fc>, L2fc>("POLYGON((0 1,2 4))", "LINESTRING(0 0, 2 5)", true, 1.0f/5);
+ test_geometry<bg::model::box<P2dc>, L2dc>("POLYGON((0 1,2 4))", "LINESTRING(0 0, 2 5)", true, 1.0/5);
+ test_geometry<bg::model::box<P3ic>, L3ic>("POLYGON((0 1 2,2 4 6))", "LINESTRING(0 0 0, 2 5 7)", true, 2.0f/7);
+ test_geometry<bg::model::box<P3fc>, L3fc>("POLYGON((0 1 2,2 4 6))", "LINESTRING(0 0 0, 2 5 7)", true, 2.0f/7);
+ test_geometry<bg::model::box<P3dc>, L3dc>("POLYGON((0 1 2,2 4 6))", "LINESTRING(0 0 0, 2 5 7)", true, 2.0/7);
+
+ test_geometry<bg::model::box<P2fc>, L2fc>("POLYGON((0 1,2 4))", "LINESTRING(0 0, 1 0, 1 5)", true, 2);
+ test_geometry<bg::model::box<P2fc>, L2fc>("POLYGON((0 1,2 4))", "LINESTRING(0 0, 3 0, 3 2, 0 2)", true, 6);
+ test_geometry<bg::model::box<P2fc>, L2fc>("POLYGON((0 1,2 4))", "LINESTRING(1 2, 3 3, 0 3)", true, 0);
+
+#ifdef HAVE_TTMATH
+ typedef bg::model::point<ttmath_big, 2, bg::cs::cartesian> P2ttmc;
+ typedef bg::model::point<ttmath_big, 3, bg::cs::cartesian> P3ttmc;
+
+ typedef bg::model::linestring<P2ttmc> L2ttmc;
+ typedef bg::model::linestring<P3ttmc> L3ttmc;
+
+ test_geometry<bg::model::box<P2ttmc>, L2ttmc>("POLYGON((0 1,2 4))", "LINESTRING(0 0, 2 5)", true, 1.0/5);
+ test_geometry<bg::model::box<P3ttmc>, L3ttmc>("POLYGON((0 1 2,2 4 6))", "LINESTRING(0 0 0, 2 5 7)", true, 2.0/7);
+#endif
+
+ test_large_integers();
+
+ return 0;
+}
diff --git a/libs/geometry/index/test/algorithms/segment_intersection.cpp b/libs/geometry/index/test/algorithms/segment_intersection.cpp
new file mode 100644
index 000000000..1cc6dc22b
--- /dev/null
+++ b/libs/geometry/index/test/algorithms/segment_intersection.cpp
@@ -0,0 +1,129 @@
+// Boost.Geometry Index
+// Unit Test
+
+// Copyright (c) 2011-2013 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
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <geometry_index_test_common.hpp>
+
+#include <boost/geometry/index/detail/algorithms/segment_intersection.hpp>
+
+//#include <boost/geometry/io/wkt/read.hpp>
+
+template <typename Box, typename Point, typename RelativeDistance>
+void test_segment_intersection(Box const& box, Point const& p0, Point const& p1,
+ bool expected_result,
+ RelativeDistance expected_rel_dist)
+{
+ RelativeDistance rel_dist;
+ bool value = bgi::detail::segment_intersection(box, p0, p1, rel_dist);
+ BOOST_CHECK(value == expected_result);
+ if ( value && expected_result )
+ BOOST_CHECK_CLOSE(rel_dist, expected_rel_dist, 0.0001);
+}
+
+template <typename Box, typename Point, typename RelativeDistance>
+void test_geometry(std::string const& wkt_g, std::string const& wkt_p0, std::string const& wkt_p1,
+ bool expected_result,
+ RelativeDistance expected_rel_dist)
+{
+ Box box;
+ bg::read_wkt(wkt_g, box);
+ Point p0, p1;
+ bg::read_wkt(wkt_p0, p0);
+ bg::read_wkt(wkt_p1, p1);
+ test_segment_intersection(box, p0, p1, expected_result, expected_rel_dist);
+}
+
+#include <boost/geometry/geometries/point_xy.hpp>
+#include <boost/geometry/geometries/point.hpp>
+#include <boost/geometry/geometries/box.hpp>
+
+void test_large_integers()
+{
+ typedef bg::model::point<int, 2, bg::cs::cartesian> int_point_type;
+ typedef bg::model::point<double, 2, bg::cs::cartesian> double_point_type;
+
+ bg::model::box<int_point_type> int_box;
+ bg::model::box<double_point_type> double_box;
+ int_point_type int_p0, int_p1;
+ double_point_type double_p0, double_p1;
+
+ std::string const str_box = "POLYGON((1536119 192000, 1872000 528000))";
+ std::string const str_p0 = "POINT(1535000 191000)";
+ std::string const str_p1 = "POINT(1873000 529000)";
+ bg::read_wkt(str_box, int_box);
+ bg::read_wkt(str_box, double_box);
+ bg::read_wkt(str_p0, int_p0);
+ bg::read_wkt(str_p1, int_p1);
+ bg::read_wkt(str_p0, double_p0);
+ bg::read_wkt(str_p1, double_p1);
+
+ float int_value;
+ bool int_result = bgi::detail::segment_intersection(int_box, int_p0, int_p1, int_value);
+ double double_value;
+ bool double_result = bgi::detail::segment_intersection(double_box, double_p0, double_p1, double_value);
+ BOOST_CHECK(int_result == double_result);
+ if ( int_result && double_result )
+ BOOST_CHECK_CLOSE(int_value, double_value, 0.0001);
+}
+
+int test_main(int, char* [])
+{
+ typedef bg::model::point<int, 2, bg::cs::cartesian> P2ic;
+ typedef bg::model::point<float, 2, bg::cs::cartesian> P2fc;
+ typedef bg::model::point<double, 2, bg::cs::cartesian> P2dc;
+
+ typedef bg::model::point<int, 3, bg::cs::cartesian> P3ic;
+ typedef bg::model::point<float, 3, bg::cs::cartesian> P3fc;
+ typedef bg::model::point<double, 3, bg::cs::cartesian> P3dc;
+
+ test_geometry<bg::model::box<P2ic>, P2ic>("POLYGON((0 1,2 4))", "POINT(0 0)", "POINT(2 5)", true, 1.0f/5);
+ test_geometry<bg::model::box<P2fc>, P2fc>("POLYGON((0 1,2 4))", "POINT(0 0)", "POINT(2 5)", true, 1.0f/5);
+ test_geometry<bg::model::box<P2dc>, P2dc>("POLYGON((0 1,2 4))", "POINT(0 0)", "POINT(2 5)", true, 1.0/5);
+ test_geometry<bg::model::box<P3ic>, P3ic>("POLYGON((0 1 2,2 4 6))", "POINT(0 0 0)", "POINT(2 5 7)", true, 2.0f/7);
+ test_geometry<bg::model::box<P3fc>, P3fc>("POLYGON((0 1 2,2 4 6))", "POINT(0 0 0)", "POINT(2 5 7)", true, 2.0f/7);
+ test_geometry<bg::model::box<P3dc>, P3dc>("POLYGON((0 1 2,2 4 6))", "POINT(0 0 0)", "POINT(2 5 7)", true, 2.0/7);
+
+ test_geometry<bg::model::box<P2ic>, P2ic>("POLYGON((0 1,2 4))", "POINT(3 4)", "POINT(0 0)", true, 1.0f/3);
+ test_geometry<bg::model::box<P2fc>, P2fc>("POLYGON((0 1,2 4))", "POINT(3 4)", "POINT(0 2)", true, 1.0f/3);
+ test_geometry<bg::model::box<P2dc>, P2dc>("POLYGON((0 1,2 4))", "POINT(3 4)", "POINT(0 2)", true, 1.0/3);
+ test_geometry<bg::model::box<P3ic>, P3ic>("POLYGON((0 1 2,2 4 6))", "POINT(3 5 6)", "POINT(0 3 3)", true, 1.0f/2);
+ test_geometry<bg::model::box<P3fc>, P3fc>("POLYGON((0 1 2,2 4 6))", "POINT(3 5 6)", "POINT(0 3 3)", true, 1.0f/2);
+ test_geometry<bg::model::box<P3dc>, P3dc>("POLYGON((0 1 2,2 4 6))", "POINT(3 5 6)", "POINT(0 3 3)", true, 1.0/2);
+
+ test_geometry<bg::model::box<P2ic>, P2ic>("POLYGON((0 1,2 4))", "POINT(1 0)", "POINT(1 5)", true, 1.0f/5);
+ test_geometry<bg::model::box<P2fc>, P2fc>("POLYGON((0 1,2 4))", "POINT(1 5)", "POINT(1 0)", true, 1.0f/5);
+ test_geometry<bg::model::box<P2dc>, P2dc>("POLYGON((0 1,2 4))", "POINT(1 0)", "POINT(1 5)", true, 1.0/5);
+ test_geometry<bg::model::box<P3ic>, P3ic>("POLYGON((0 1 2,2 4 6))", "POINT(1 3 0)", "POINT(1 3 7)", true, 2.0f/7);
+ test_geometry<bg::model::box<P3fc>, P3fc>("POLYGON((0 1 2,2 4 6))", "POINT(1 3 7)", "POINT(1 3 0)", true, 1.0f/7);
+ test_geometry<bg::model::box<P3dc>, P3dc>("POLYGON((0 1 2,2 4 6))", "POINT(1 3 0)", "POINT(1 3 7)", true, 2.0/7);
+
+ test_geometry<bg::model::box<P2ic>, P2ic>("POLYGON((0 1,2 4))", "POINT(0 0)", "POINT(0 5)", true, 0.2f);
+ test_geometry<bg::model::box<P2fc>, P2fc>("POLYGON((0 1,2 4))", "POINT(0 5)", "POINT(0 0)", true, 0.2f);
+ test_geometry<bg::model::box<P2dc>, P2dc>("POLYGON((0 1,2 4))", "POINT(0 0)", "POINT(0 5)", true, 0.2);
+
+ test_geometry<bg::model::box<P2ic>, P2ic>("POLYGON((0 1,2 4))", "POINT(3 0)", "POINT(3 5)", false, 0.0f);
+ test_geometry<bg::model::box<P2fc>, P2fc>("POLYGON((0 1,2 4))", "POINT(3 5)", "POINT(3 0)", false, 0.0f);
+ test_geometry<bg::model::box<P2dc>, P2dc>("POLYGON((0 1,2 4))", "POINT(3 0)", "POINT(3 5)", false, 0.0);
+
+ test_geometry<bg::model::box<P2fc>, P2fc>("POLYGON((0 1,2 4))", "POINT(1 0)", "POINT(1 1)", true, 1.0f);
+ test_geometry<bg::model::box<P2fc>, P2fc>("POLYGON((0 1,2 4))", "POINT(1 4)", "POINT(1 5)", true, 0.0f);
+
+ test_geometry<bg::model::box<P2fc>, P2fc>("POLYGON((0 1,2 4))", "POINT(0.5 2)", "POINT(1.5 3)", true, 0.0f);
+
+#ifdef HAVE_TTMATH
+ typedef bg::model::point<ttmath_big, 2, bg::cs::cartesian> P2ttmc;
+ typedef bg::model::point<ttmath_big, 3, bg::cs::cartesian> P3ttmc;
+
+ test_geometry<bg::model::box<P2ttmc>, P2ttmc>("POLYGON((0 1,2 4))", "POINT(0 0)", "POINT(2 5)", true, 1.0f/5);
+ test_geometry<bg::model::box<P3ttmc>, P3ttmc>("POLYGON((0 1 2,2 4 6))", "POINT(0 0 0)", "POINT(2 5 7)", true, 2.0f/7);
+#endif
+
+ test_large_integers();
+
+ return 0;
+}
diff --git a/libs/geometry/index/test/algorithms/test_content.hpp b/libs/geometry/index/test/algorithms/test_content.hpp
new file mode 100644
index 000000000..226bbcd36
--- /dev/null
+++ b/libs/geometry/index/test/algorithms/test_content.hpp
@@ -0,0 +1,49 @@
+// Boost.Geometry Index
+// Unit Test
+
+// Copyright (c) 2011-2013 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
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_INDEX_TEST_CONTENT_HPP
+#define BOOST_GEOMETRY_INDEX_TEST_CONTENT_HPP
+
+#include <geometry_index_test_common.hpp>
+
+#include <boost/geometry/index/detail/algorithms/content.hpp>
+
+//#include <boost/geometry/io/wkt/read.hpp>
+
+
+template <typename Geometry>
+void test_content(Geometry const& geometry,
+ typename bgi::detail::default_content_result<Geometry>::type expected_value)
+{
+ typename bgi::detail::default_content_result<Geometry>::type value = bgi::detail::content(geometry);
+
+#ifdef GEOMETRY_TEST_DEBUG
+ std::ostringstream out;
+ out << typeid(typename bg::coordinate_type<Geometry>::type).name()
+ << " "
+ << typeid(typename bgi::detail::default_content_result<Geometry>::type).name()
+ << " "
+ << "content : " << value
+ << std::endl;
+ std::cout << out.str();
+#endif
+
+ BOOST_CHECK_CLOSE(value, expected_value, 0.0001);
+}
+
+template <typename Geometry>
+void test_geometry(std::string const& wkt,
+ typename bgi::detail::default_content_result<Geometry>::type expected_value)
+{
+ Geometry geometry;
+ bg::read_wkt(wkt, geometry);
+ test_content(geometry, expected_value);
+}
+
+#endif
diff --git a/libs/geometry/index/test/algorithms/test_intersection_content.hpp b/libs/geometry/index/test/algorithms/test_intersection_content.hpp
new file mode 100644
index 000000000..5a074b7c1
--- /dev/null
+++ b/libs/geometry/index/test/algorithms/test_intersection_content.hpp
@@ -0,0 +1,47 @@
+// Boost.Geometry Index
+// Unit Test
+
+// Copyright (c) 2011-2013 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
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_INDEX_TEST_INTERSECTION_CONTENT_HPP
+#define BOOST_GEOMETRY_INDEX_TEST_INTERSECTION_CONTENT_HPP
+
+#include <geometry_index_test_common.hpp>
+
+#include <boost/geometry/index/detail/algorithms/intersection_content.hpp>
+
+template <typename Geometry>
+void test_intersection_content(Geometry const& geometry1, Geometry const& geometry2,
+ typename bgi::detail::default_content_result<Geometry>::type expected_value)
+{
+ typename bgi::detail::default_content_result<Geometry>::type value = bgi::detail::intersection_content(geometry1, geometry2);
+
+#ifdef GEOMETRY_TEST_DEBUG
+ std::ostringstream out;
+ out << typeid(typename bg::coordinate_type<Geometry>::type).name()
+ << " "
+ << typeid(typename bgi::detail::default_content_result<Geometry>::type).name()
+ << " "
+ << "intersection_content : " << value
+ << std::endl;
+ std::cout << out.str();
+#endif
+
+ BOOST_CHECK_CLOSE(value, expected_value, 0.0001);
+}
+
+template <typename Geometry>
+void test_geometry(std::string const& wkt1, std::string const& wkt2,
+ typename bgi::detail::default_content_result<Geometry>::type expected_value)
+{
+ Geometry geometry1, geometry2;
+ bg::read_wkt(wkt1, geometry1);
+ bg::read_wkt(wkt2, geometry2);
+ test_intersection_content(geometry1, geometry2, expected_value);
+}
+
+#endif
diff --git a/libs/geometry/index/test/algorithms/test_margin.hpp b/libs/geometry/index/test/algorithms/test_margin.hpp
new file mode 100644
index 000000000..45d10dfe9
--- /dev/null
+++ b/libs/geometry/index/test/algorithms/test_margin.hpp
@@ -0,0 +1,48 @@
+// Boost.Geometry Index
+// Unit Test
+
+// Copyright (c) 2011-2013 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
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_INDEX_TEST_MARGIN_HPP
+#define BOOST_GEOMETRY_INDEX_TEST_MARGIN_HPP
+
+#include <geometry_index_test_common.hpp>
+
+#include <boost/geometry/index/detail/algorithms/margin.hpp>
+
+//#include <boost/geometry/io/wkt/read.hpp>
+
+template <typename Geometry>
+void test_margin(Geometry const& geometry,
+ typename bgi::detail::default_margin_result<Geometry>::type expected_value)
+{
+ typename bgi::detail::default_margin_result<Geometry>::type value = bgi::detail::comparable_margin(geometry);
+
+#ifdef GEOMETRY_TEST_DEBUG
+ std::ostringstream out;
+ out << typeid(typename bg::coordinate_type<Geometry>::type).name()
+ << " "
+ << typeid(typename bgi::detail::default_margin_result<Geometry>::type).name()
+ << " "
+ << "content : " << value
+ << std::endl;
+ std::cout << out.str();
+#endif
+
+ BOOST_CHECK_CLOSE(value, expected_value, 0.0001);
+}
+
+template <typename Geometry>
+void test_geometry(std::string const& wkt,
+ typename bgi::detail::default_margin_result<Geometry>::type expected_value)
+{
+ Geometry geometry;
+ bg::read_wkt(wkt, geometry);
+ test_margin(geometry, expected_value);
+}
+
+#endif
diff --git a/libs/geometry/index/test/algorithms/test_union_content.hpp b/libs/geometry/index/test/algorithms/test_union_content.hpp
new file mode 100644
index 000000000..fe0268795
--- /dev/null
+++ b/libs/geometry/index/test/algorithms/test_union_content.hpp
@@ -0,0 +1,47 @@
+// Boost.Geometry Index
+// Unit Test
+
+// Copyright (c) 2011-2013 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
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_INDEX_TEST_UNION_CONTENT_HPP
+#define BOOST_GEOMETRY_INDEX_TEST_UNION_CONTENT_HPP
+
+#include <geometry_index_test_common.hpp>
+
+#include <boost/geometry/index/detail/algorithms/union_content.hpp>
+
+template <typename Geometry>
+void test_union_content(Geometry const& geometry1, Geometry const& geometry2,
+ typename bgi::detail::default_content_result<Geometry>::type expected_value)
+{
+ typename bgi::detail::default_content_result<Geometry>::type value = bgi::detail::union_content(geometry1, geometry2);
+
+#ifdef GEOMETRY_TEST_DEBUG
+ std::ostringstream out;
+ out << typeid(typename bg::coordinate_type<Geometry>::type).name()
+ << " "
+ << typeid(typename bgi::detail::default_content_result<Geometry>::type).name()
+ << " "
+ << "union_content : " << value
+ << std::endl;
+ std::cout << out.str();
+#endif
+
+ BOOST_CHECK_CLOSE(value, expected_value, 0.0001);
+}
+
+template <typename Geometry>
+void test_geometry(std::string const& wkt1, std::string const& wkt2,
+ typename bgi::detail::default_content_result<Geometry>::type expected_value)
+{
+ Geometry geometry1, geometry2;
+ bg::read_wkt(wkt1, geometry1);
+ bg::read_wkt(wkt2, geometry2);
+ test_union_content(geometry1, geometry2, expected_value);
+}
+
+#endif
diff --git a/libs/geometry/index/test/algorithms/union_content.cpp b/libs/geometry/index/test/algorithms/union_content.cpp
new file mode 100644
index 000000000..4939e57ad
--- /dev/null
+++ b/libs/geometry/index/test/algorithms/union_content.cpp
@@ -0,0 +1,70 @@
+// Boost.Geometry Index
+// Unit Test
+
+// Copyright (c) 2011-2013 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
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <algorithms/test_union_content.hpp>
+
+#include <boost/geometry/geometries/point_xy.hpp>
+#include <boost/geometry/geometries/point.hpp>
+#include <boost/geometry/geometries/box.hpp>
+
+//#define GEOMETRY_TEST_DEBUG
+
+void test_large_integers()
+{
+ typedef bg::model::point<int, 2, bg::cs::cartesian> int_point_type;
+ typedef bg::model::point<double, 2, bg::cs::cartesian> double_point_type;
+
+ bg::model::box<int_point_type> int_box1, int_box2;
+ bg::model::box<double_point_type> double_box1, double_box2;
+
+ std::string const box_li1 = "POLYGON((1536119 192000, 1872000 528000))";
+ std::string const box_li2 = "POLYGON((1701234 368250, 2673400 777400))";
+ bg::read_wkt(box_li1, int_box1);
+ bg::read_wkt(box_li1, double_box1);
+ bg::read_wkt(box_li2, int_box2);
+ bg::read_wkt(box_li2, double_box2);
+
+ double int_value = bgi::detail::union_content(int_box1, int_box2);
+ double double_value = bgi::detail::union_content(double_box1, double_box2);
+
+ BOOST_CHECK_CLOSE(int_value, double_value, 0.0001);
+}
+
+int test_main(int, char* [])
+{
+ typedef bg::model::point<int, 2, bg::cs::cartesian> P2ic;
+ typedef bg::model::point<float, 2, bg::cs::cartesian> P2fc;
+ typedef bg::model::point<double, 2, bg::cs::cartesian> P2dc;
+
+ typedef bg::model::point<int, 3, bg::cs::cartesian> P3ic;
+ typedef bg::model::point<float, 3, bg::cs::cartesian> P3fc;
+ typedef bg::model::point<double, 3, bg::cs::cartesian> P3dc;
+
+ test_geometry<bg::model::box<P2ic> >("POLYGON((0 1,2 4))", "POLYGON((1 2,3 5))", 12.0);
+ test_geometry<bg::model::box<P2fc> >("POLYGON((0 1,2 4))", "POLYGON((1 2,3 5))", 12.0);
+ test_geometry<bg::model::box<P2dc> >("POLYGON((0 1,2 4))", "POLYGON((1 2,3 5))", 12.0);
+ test_geometry<bg::model::box<P3ic> >("POLYGON((0 1 2,2 4 6))", "POLYGON((1 2 3,3 5 7))", 60.0);
+ test_geometry<bg::model::box<P3fc> >("POLYGON((0 1 2,2 4 6))", "POLYGON((1 2 3,3 5 7))", 60.0);
+ test_geometry<bg::model::box<P3dc> >("POLYGON((0 1 2,2 4 6))", "POLYGON((1 2 3,3 5 7))", 60.0);
+
+ test_geometry<bg::model::box<P2dc> >("POLYGON((0 1,2 4))", "POLYGON((2 1,3 4))", 9.0);
+ test_geometry<bg::model::box<P2dc> >("POLYGON((0 1,2 4))", "POLYGON((2 4,3 5))", 12.0);
+
+#ifdef HAVE_TTMATH
+ typedef bg::model::point<ttmath_big, 2, bg::cs::cartesian> P2ttmc;
+ typedef bg::model::point<ttmath_big, 3, bg::cs::cartesian> P3ttmc;
+
+ test_geometry<bg::model::box<P2ttmc> >("POLYGON((0 1,2 4))", "POLYGON((1 2,3 5))", 12.0);
+ test_geometry<bg::model::box<P3ttmc> >("POLYGON((0 1 2,2 4 6))", "POLYGON((1 2 3,3 5 7))", 60.0);
+#endif
+
+ test_large_integers();
+
+ return 0;
+}