• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit Test
3 
4 // Copyright (c) 2014, Oracle and/or its affiliates.
5 
6 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
7 
8 // Licensed under the Boost Software License version 1.0.
9 // http://www.boost.org/users/license.html
10 
11 #ifndef BOOST_GEOMETRY_TEST_TEST_GEOMETRIES_CUSTOM_LON_LAT_POINT_HPP
12 #define BOOST_GEOMETRY_TEST_TEST_GEOMETRIES_CUSTOM_LON_LAT_POINT_HPP
13 
14 #include <boost/mpl/int.hpp>
15 
16 #include <boost/geometry/core/access.hpp>
17 #include <boost/geometry/core/coordinate_dimension.hpp>
18 #include <boost/geometry/core/coordinate_system.hpp>
19 #include <boost/geometry/core/coordinate_type.hpp>
20 #include <boost/geometry/core/tag.hpp>
21 #include <boost/geometry/core/tags.hpp>
22 
23 
24 // read/write longitude/latitude point
25 template <typename CoordinateType, typename CoordinateSystem>
26 struct rw_lon_lat_point
27 {
28     CoordinateType longitude, latitude;
29 };
30 
31 
32 namespace boost { namespace geometry { namespace traits
33 {
34 template <typename CoordinateType, typename CoordinateSystem>
35 struct tag<rw_lon_lat_point<CoordinateType, CoordinateSystem> >
36 {
37     typedef point_tag type;
38 };
39 
40 template <typename CoordinateType, typename CoordinateSystem>
41 struct coordinate_type<rw_lon_lat_point<CoordinateType, CoordinateSystem> >
42 {
43     typedef CoordinateType type;
44 };
45 
46 template <typename CoordinateType, typename CoordinateSystem>
47 struct coordinate_system<rw_lon_lat_point<CoordinateType, CoordinateSystem> >
48 {
49     typedef CoordinateSystem type;
50 };
51 
52 template <typename CoordinateType, typename CoordinateSystem>
53 struct dimension<rw_lon_lat_point<CoordinateType, CoordinateSystem> >
54     : boost::mpl::int_<2>
55 {};
56 
57 template
58 <
59     typename CoordinateType,
60     typename CoordinateSystem,
61     std::size_t Dimension
62 >
63 struct access<rw_lon_lat_point<CoordinateType, CoordinateSystem>, Dimension>
64 {
65     static inline CoordinateType
getboost::geometry::traits::access66     get(rw_lon_lat_point<CoordinateType, CoordinateSystem> const& p)
67     {
68         return (Dimension == 0) ? p.longitude : p.latitude;
69     }
70 
71     static inline
setboost::geometry::traits::access72     void set(rw_lon_lat_point<CoordinateType, CoordinateSystem>& p,
73              CoordinateType const& value)
74     {
75         ( Dimension == 0 ? p.longitude : p.latitude ) = value;
76     }
77 };
78 
79 }}} // namespace boost::geometry::traits
80 
81 
82 // read-only longitude/latitude point
83 template <typename CoordinateType, typename CoordinateSystem>
84 struct ro_lon_lat_point
85 {
86     CoordinateType longitude, latitude;
87 };
88 
89 
90 namespace boost { namespace geometry { namespace traits
91 {
92 template <typename CoordinateType, typename CoordinateSystem>
93 struct tag<ro_lon_lat_point<CoordinateType, CoordinateSystem> >
94 {
95     typedef point_tag type;
96 };
97 
98 template <typename CoordinateType, typename CoordinateSystem>
99 struct coordinate_type<ro_lon_lat_point<CoordinateType, CoordinateSystem> >
100 {
101     typedef CoordinateType type;
102 };
103 
104 template <typename CoordinateType, typename CoordinateSystem>
105 struct coordinate_system<ro_lon_lat_point<CoordinateType, CoordinateSystem> >
106 {
107     typedef CoordinateSystem type;
108 };
109 
110 template <typename CoordinateType, typename CoordinateSystem>
111 struct dimension<ro_lon_lat_point<CoordinateType, CoordinateSystem> >
112     : boost::mpl::int_<2>
113 {};
114 
115 template
116 <
117     typename CoordinateType,
118     typename CoordinateSystem,
119     std::size_t Dimension
120 >
121 struct access<ro_lon_lat_point<CoordinateType, CoordinateSystem>, Dimension>
122 {
123     static inline CoordinateType
getboost::geometry::traits::access124     get(ro_lon_lat_point<CoordinateType, CoordinateSystem> const& p)
125     {
126         return (Dimension == 0) ? p.longitude : p.latitude;
127     }
128 };
129 
130 }}} // namespace boost::geometry::traits
131 
132 
133 #endif // BOOST_GEOMETRY_TEST_TEST_GEOMETRIES_CUSTOM_LON_LAT_POINT_HPP
134