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 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
7
8 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
9 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
10
11 // Use, modification and distribution is subject to the Boost Software License,
12 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
13 // http://www.boost.org/LICENSE_1_0.txt)
14
15
16 #include <boost/geometry/core/cs.hpp>
17 #include <boost/geometry/geometries/concepts/check.hpp>
18
19 struct ro_point
20 {
21 float x, y;
22 };
23
24
25 struct rw_point
26 {
27 float x, y;
28 };
29
30
31 namespace boost { namespace geometry { namespace traits {
32
33 template <> struct tag<ro_point> { typedef point_tag type; };
34 template <> struct coordinate_type<ro_point> { typedef float type; };
35 template <> struct coordinate_system<ro_point> { typedef bg::cs::cartesian type; };
36 template <> struct dimension<ro_point> { enum { value = 2 }; };
37
38 template <> struct access<ro_point, 0>
39 {
getboost::geometry::traits::access40 static float get(ro_point const& p) { return p.x; }
41 };
42
43 template <> struct access<ro_point, 1>
44 {
getboost::geometry::traits::access45 static float get(ro_point const& p) { return p.y; }
46 };
47
48
49
50
51 template <> struct tag<rw_point> { typedef point_tag type; };
52 template <> struct coordinate_type<rw_point> { typedef float type; };
53 template <> struct coordinate_system<rw_point> { typedef bg::cs::cartesian type; };
54 template <> struct dimension<rw_point> { enum { value = 2 }; };
55
56 template <> struct access<rw_point, 0>
57 {
getboost::geometry::traits::access58 static float get(rw_point const& p) { return p.x; }
setboost::geometry::traits::access59 static void set(rw_point& p, float value) { p.x = value; }
60 };
61
62 template <> struct access<rw_point, 1>
63 {
getboost::geometry::traits::access64 static float get(rw_point const& p) { return p.y; }
setboost::geometry::traits::access65 static void set(rw_point& p, float value) { p.y = value; }
66 };
67
68
69 }}} // namespace bg::traits
70
71
main()72 int main()
73 {
74 bg::concepts::check<const ro_point>();
75 bg::concepts::check<rw_point>();
76 }
77