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_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_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::content(int_box);
31 double double_value = bgi::detail::content(double_box);
32
33 BOOST_CHECK_CLOSE(int_value, double_value, 0.0001);
34}
35
36int 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_content(P2ic(0, 0), 0);
47 test_content(P2fc(0, 0), 0);
48 test_content(P2dc(0, 0), 0);
49 test_content(P3ic(0, 0, 0), 0);
50 test_content(P3fc(0, 0, 0), 0);
51 test_content(P3dc(0, 0, 0), 0);
52
53 test_geometry<bg::model::box<P2ic> >("POLYGON((0 1,2 4))", 6.0);
54 test_geometry<bg::model::box<P2fc> >("POLYGON((0 1,2 4))", 6.0);
55 test_geometry<bg::model::box<P2dc> >("POLYGON((0 1,2 4))", 6.0);
56 test_geometry<bg::model::box<P3ic> >("POLYGON((0 1 2,2 4 6))", 24.0);
57 test_geometry<bg::model::box<P3fc> >("POLYGON((0 1 2,2 4 6))", 24.0);
58 test_geometry<bg::model::box<P3dc> >("POLYGON((0 1 2,2 4 6))", 24.0);
59
60#ifdef HAVE_TTMATH
61 typedef bg::model::point<ttmath_big, 2, bg::cs::cartesian> P2ttmc;
62 typedef bg::model::point<ttmath_big, 3, bg::cs::cartesian> P3ttmc;
63
64 test_geometry<bg::model::box<P2ttmc> >("POLYGON((0 1,2 4))", 6.0);
65 test_geometry<bg::model::box<P3ttmc> >("POLYGON((0 1 2,2 4 6))", 24.0);
66#endif
67
68 test_large_integers();
69
70 return 0;
71}
72