• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit Test
3 
4 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
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 
11 #ifndef GEOMETRY_TEST_COMMON_WITH_POINTER_HPP
12 #define GEOMETRY_TEST_COMMON_WITH_POINTER_HPP
13 
14 
15 #include <boost/geometry/core/access.hpp>
16 #include <boost/geometry/core/coordinate_type.hpp>
17 #include <boost/geometry/core/coordinate_system.hpp>
18 #include <boost/geometry/core/coordinate_dimension.hpp>
19 #include <boost/geometry/core/cs.hpp>
20 #include <boost/geometry/core/tag.hpp>
21 
22 // NOTE: since Boost 1.51 the Point type may always be a pointer.
23 // Therefore the traits class don't need to add a pointer.
24 // This obsoletes this whole test-point-type
25 
26 
27 
28 namespace test
29 {
30 
31 // Sample point, having x/y
32 struct test_point_xy
33 {
34     float x,y;
35 };
36 
37 }
38 
39 
40 namespace boost { namespace geometry { namespace traits {
41 
42 template<> struct tag<test::test_point_xy>
43 { typedef point_tag type; };
44 
45 template<> struct coordinate_type<test::test_point_xy>
46 { typedef double type; };
47 
48 template<> struct coordinate_system<test::test_point_xy>
49 { typedef cs::cartesian type; };
50 
51 template<> struct dimension<test::test_point_xy> : boost::mpl::int_<2> {};
52 
53 template<>
54 struct access<test::test_point_xy, 0>
55 {
getboost::geometry::traits::access56     static double get(test::test_point_xy const& p)
57     {
58         return p.x;
59     }
60 
setboost::geometry::traits::access61     static void set(test::test_point_xy& p, double const& value)
62     {
63         p.x = value;
64     }
65 
66 };
67 
68 
69 template<>
70 struct access<test::test_point_xy, 1>
71 {
getboost::geometry::traits::access72     static double get(test::test_point_xy const& p)
73     {
74         return p.y;
75     }
76 
setboost::geometry::traits::access77     static void set(test::test_point_xy& p, double const& value)
78     {
79         p.y = value;
80     }
81 
82 };
83 
84 }}} // namespace bg::traits
85 
86 
87 #endif // #ifndef GEOMETRY_TEST_COMMON_WITH_POINTER_HPP
88