1 // Boost.Geometry (aka GGL, Generic Geometry Library)
4 // Copyright (c) 2014, Oracle and/or its affiliates.
6 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
8 // Licensed under the Boost Software License version 1.0.
9 // http://www.boost.org/users/license.html
11 #ifndef BOOST_GEOMETRY_TEST_TEST_GEOMETRIES_CUSTOM_LON_LAT_POINT_HPP
12 #define BOOST_GEOMETRY_TEST_TEST_GEOMETRIES_CUSTOM_LON_LAT_POINT_HPP
14 #include <boost/mpl/int.hpp>
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>
24 // read/write longitude/latitude point
25 template <typename CoordinateType, typename CoordinateSystem>
26 struct rw_lon_lat_point
28 CoordinateType longitude, latitude;
32 namespace boost { namespace geometry { namespace traits
34 template <typename CoordinateType, typename CoordinateSystem>
35 struct tag<rw_lon_lat_point<CoordinateType, CoordinateSystem> >
37 typedef point_tag type;
40 template <typename CoordinateType, typename CoordinateSystem>
41 struct coordinate_type<rw_lon_lat_point<CoordinateType, CoordinateSystem> >
43 typedef CoordinateType type;
46 template <typename CoordinateType, typename CoordinateSystem>
47 struct coordinate_system<rw_lon_lat_point<CoordinateType, CoordinateSystem> >
49 typedef CoordinateSystem type;
52 template <typename CoordinateType, typename CoordinateSystem>
53 struct dimension<rw_lon_lat_point<CoordinateType, CoordinateSystem> >
59 typename CoordinateType,
60 typename CoordinateSystem,
63 struct access<rw_lon_lat_point<CoordinateType, CoordinateSystem>, Dimension>
65 static inline CoordinateType
66 get(rw_lon_lat_point<CoordinateType, CoordinateSystem> const& p)
68 return (Dimension == 0) ? p.longitude : p.latitude;
72 void set(rw_lon_lat_point<CoordinateType, CoordinateSystem>& p,
73 CoordinateType const& value)
75 ( Dimension == 0 ? p.longitude : p.latitude ) = value;
79 }}} // namespace boost::geometry::traits
82 // read-only longitude/latitude point
83 template <typename CoordinateType, typename CoordinateSystem>
84 struct ro_lon_lat_point
86 CoordinateType longitude, latitude;
90 namespace boost { namespace geometry { namespace traits
92 template <typename CoordinateType, typename CoordinateSystem>
93 struct tag<ro_lon_lat_point<CoordinateType, CoordinateSystem> >
95 typedef point_tag type;
98 template <typename CoordinateType, typename CoordinateSystem>
99 struct coordinate_type<ro_lon_lat_point<CoordinateType, CoordinateSystem> >
101 typedef CoordinateType type;
104 template <typename CoordinateType, typename CoordinateSystem>
105 struct coordinate_system<ro_lon_lat_point<CoordinateType, CoordinateSystem> >
107 typedef CoordinateSystem type;
110 template <typename CoordinateType, typename CoordinateSystem>
111 struct dimension<ro_lon_lat_point<CoordinateType, CoordinateSystem> >
112 : boost::mpl::int_<2>
117 typename CoordinateType,
118 typename CoordinateSystem,
119 std::size_t Dimension
121 struct access<ro_lon_lat_point<CoordinateType, CoordinateSystem>, Dimension>
123 static inline CoordinateType
124 get(ro_lon_lat_point<CoordinateType, CoordinateSystem> const& p)
126 return (Dimension == 0) ? p.longitude : p.latitude;
130 }}} // namespace boost::geometry::traits
133 #endif // BOOST_GEOMETRY_TEST_TEST_GEOMETRIES_CUSTOM_LON_LAT_POINT_HPP