1// Boost.Geometry Index
2// Unit Test
3
4// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
5
6// Use, modification and distribution is subject to the Boost Software License,
7// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8// http://www.boost.org/LICENSE_1_0.txt)
9
10#include <algorithms/test_intersection_content.hpp>
11
12#include <boost/geometry/geometries/point_xy.hpp>
13#include <boost/geometry/geometries/point.hpp>
14#include <boost/geometry/geometries/box.hpp>
15
16//#define BOOST_GEOMETRY_TEST_DEBUG
17
18void test_large_integers()
19{
20 typedef bg::model::point<int, 2, bg::cs::cartesian> int_point_type;
21 typedef bg::model::point<double, 2, bg::cs::cartesian> double_point_type;
22
23 bg::model::box<int_point_type> int_box1, int_box2;
24 bg::model::box<double_point_type> double_box1, double_box2;
25
26 std::string const box_li1 = "POLYGON((1536119 192000, 1872000 528000))";
27 std::string const box_li2 = "POLYGON((1701234 368250, 2673400 777400))";
28 bg::read_wkt(wkt: box_li1, geometry&: int_box1);
29 bg::read_wkt(wkt: box_li1, geometry&: double_box1);
30 bg::read_wkt(wkt: box_li2, geometry&: int_box2);
31 bg::read_wkt(wkt: box_li2, geometry&: double_box2);
32
33 double int_value = bgi::detail::intersection_content(box1: int_box1, box2: int_box2);
34 double double_value = bgi::detail::intersection_content(box1: double_box1, box2: double_box2);
35
36 BOOST_CHECK_CLOSE(int_value, double_value, 0.0001);
37}
38
39int test_main(int, char* [])
40{
41 typedef bg::model::point<int, 2, bg::cs::cartesian> P2ic;
42 typedef bg::model::point<float, 2, bg::cs::cartesian> P2fc;
43 typedef bg::model::point<double, 2, bg::cs::cartesian> P2dc;
44
45 typedef bg::model::point<int, 3, bg::cs::cartesian> P3ic;
46 typedef bg::model::point<float, 3, bg::cs::cartesian> P3fc;
47 typedef bg::model::point<double, 3, bg::cs::cartesian> P3dc;
48
49 test_geometry<bg::model::box<P2ic> >(wkt1: "POLYGON((0 1,2 4))", wkt2: "POLYGON((1 2,3 5))", expected_value: 2.0);
50 test_geometry<bg::model::box<P2fc> >(wkt1: "POLYGON((0 1,2 4))", wkt2: "POLYGON((1 2,3 5))", expected_value: 2.0);
51 test_geometry<bg::model::box<P2dc> >(wkt1: "POLYGON((0 1,2 4))", wkt2: "POLYGON((1 2,3 5))", expected_value: 2.0);
52 test_geometry<bg::model::box<P3ic> >(wkt1: "POLYGON((0 1 2,2 4 6))", wkt2: "POLYGON((1 2 3,3 5 7))", expected_value: 6.0);
53 test_geometry<bg::model::box<P3fc> >(wkt1: "POLYGON((0 1 2,2 4 6))", wkt2: "POLYGON((1 2 3,3 5 7))", expected_value: 6.0);
54 test_geometry<bg::model::box<P3dc> >(wkt1: "POLYGON((0 1 2,2 4 6))", wkt2: "POLYGON((1 2 3,3 5 7))", expected_value: 6.0);
55
56 test_geometry<bg::model::box<P2dc> >(wkt1: "POLYGON((0 1,2 4))", wkt2: "POLYGON((2 1,3 4))", expected_value: 0.0);
57 test_geometry<bg::model::box<P2dc> >(wkt1: "POLYGON((0 1,2 4))", wkt2: "POLYGON((2 4,3 5))", expected_value: 0.0);
58
59#ifdef HAVE_TTMATH
60 typedef bg::model::point<ttmath_big, 2, bg::cs::cartesian> P2ttmc;
61 typedef bg::model::point<ttmath_big, 3, bg::cs::cartesian> P3ttmc;
62
63 test_geometry<bg::model::box<P2ttmc> >("POLYGON((0 1,2 4))", "POLYGON((1 2,3 5))", 2.0);
64 test_geometry<bg::model::box<P3ttmc> >("POLYGON((0 1 2,2 4 6))", "POLYGON((1 2 3,3 5 7))", 6.0);
65#endif
66
67 test_large_integers();
68
69 return 0;
70}
71

source code of boost/libs/geometry/index/test/algorithms/intersection_content.cpp