• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_margin.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 
test_large_integers()18 void 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_box;
24     bg::model::box<double_point_type> double_box;
25 
26     std::string const box_li = "POLYGON((1536119 192000, 1872000 528000))";
27     bg::read_wkt(box_li, int_box);
28     bg::read_wkt(box_li, double_box);
29 
30     double int_value = bgi::detail::comparable_margin(int_box);
31     double double_value = bgi::detail::comparable_margin(double_box);
32 
33     BOOST_CHECK_CLOSE(int_value, double_value, 0.0001);
34 }
35 
test_main(int,char * [])36 int test_main(int, char* [])
37 {
38     typedef bg::model::point<int, 2, bg::cs::cartesian> P2ic;
39     typedef bg::model::point<float, 2, bg::cs::cartesian> P2fc;
40     typedef bg::model::point<double, 2, bg::cs::cartesian> P2dc;
41 
42     typedef bg::model::point<int, 3, bg::cs::cartesian> P3ic;
43     typedef bg::model::point<float, 3, bg::cs::cartesian> P3fc;
44     typedef bg::model::point<double, 3, bg::cs::cartesian> P3dc;
45 
46     test_geometry<bg::model::box<P2ic> >("POLYGON((0 1,2 4))", 5);
47     test_geometry<bg::model::box<P2fc> >("POLYGON((0 1,2 4))", 5.0);
48     test_geometry<bg::model::box<P2dc> >("POLYGON((0 1,2 4))", 5.0);
49     test_geometry<bg::model::box<P3ic> >("POLYGON((0 1 2,2 4 6))", 9);
50     test_geometry<bg::model::box<P3fc> >("POLYGON((0 1 2,2 4 6))", 9.0);
51     test_geometry<bg::model::box<P3dc> >("POLYGON((0 1 2,2 4 6))", 9.0);
52 
53 #ifdef HAVE_TTMATH
54     typedef bg::model::point<ttmath_big, 2, bg::cs::cartesian> P2ttmc;
55     typedef bg::model::point<ttmath_big, 3, bg::cs::cartesian> P3ttmc;
56 
57     test_geometry<bg::model::box<P2ttmc> >("POLYGON((0 1,2 4))", 10.0);
58     test_geometry<bg::model::box<P3ttmc> >("POLYGON((0 1 2,2 4 6))", 52.0);
59 #endif
60 
61     test_large_integers();
62 
63     // test_empty_input<bg::model::d2::point_xy<int> >();
64 
65     return 0;
66 }
67