custom_lon_lat_point.hpp 3.6 KB

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