• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // QuickBook Example
3 
4 // Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
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 //[equals
11 //` Shows the predicate equals, which returns true if two geometries are spatially equal
12 
13 #include <iostream>
14 
15 #include <boost/geometry.hpp>
16 #include <boost/geometry/geometries/polygon.hpp>
17 #include <boost/geometry/geometries/adapted/boost_tuple.hpp>
18 
BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)19 BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
20 
21 #include <boost/assign.hpp>
22 
23 int main()
24 {
25     using boost::assign::tuple_list_of;
26 
27     typedef boost::tuple<int, int> point;
28 
29     boost::geometry::model::polygon<point> poly1, poly2;
30     boost::geometry::exterior_ring(poly1) = tuple_list_of(0, 0)(0, 5)(5, 5)(5, 0)(0, 0);
31     boost::geometry::exterior_ring(poly2) = tuple_list_of(5, 0)(0, 0)(0, 5)(5, 5)(5, 0);
32 
33     std::cout
34         << "polygons are spatially "
35         << (boost::geometry::equals(poly1, poly2) ? "equal" : "not equal")
36         << std::endl;
37 
38     boost::geometry::model::box<point> box;
39     boost::geometry::assign_values(box, 0, 0, 5, 5);
40 
41     std::cout
42         << "polygon and box are spatially "
43         << (boost::geometry::equals(box, poly2) ? "equal" : "not equal")
44         << std::endl;
45 
46 
47     return 0;
48 }
49 
50 //]
51 
52 
53 //[equals_output
54 /*`
55 Output:
56 [pre
57 polygons are spatially equal
58 polygon and box are spatially equal
59 ]
60 */
61 //]
62