coordinate_type.hpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
  3. // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
  4. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
  5. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  6. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  7. // Use, modification and distribution is subject to the Boost Software License,
  8. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. #ifndef BOOST_GEOMETRY_CORE_COORDINATE_TYPE_HPP
  11. #define BOOST_GEOMETRY_CORE_COORDINATE_TYPE_HPP
  12. #include <boost/mpl/assert.hpp>
  13. #include <boost/geometry/core/point_type.hpp>
  14. #include <boost/geometry/core/tag.hpp>
  15. #include <boost/geometry/util/bare_type.hpp>
  16. #include <boost/geometry/util/promote_floating_point.hpp>
  17. namespace boost { namespace geometry
  18. {
  19. namespace traits
  20. {
  21. /*!
  22. \brief Traits class which indicate the coordinate type (double,float,...) of a point
  23. \ingroup traits
  24. \par Geometries:
  25. - point
  26. \par Specializations should provide:
  27. - typedef T type; (double,float,int,etc)
  28. */
  29. template <typename Point, typename Enable = void>
  30. struct coordinate_type
  31. {
  32. BOOST_MPL_ASSERT_MSG
  33. (
  34. false, NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE, (types<Point>)
  35. );
  36. };
  37. } // namespace traits
  38. #ifndef DOXYGEN_NO_DISPATCH
  39. namespace core_dispatch
  40. {
  41. template <typename GeometryTag, typename Geometry>
  42. struct coordinate_type
  43. {
  44. typedef typename point_type<GeometryTag, Geometry>::type point_type;
  45. // Call its own specialization on point-tag
  46. typedef typename coordinate_type<point_tag, point_type>::type type;
  47. };
  48. template <typename Point>
  49. struct coordinate_type<point_tag, Point>
  50. {
  51. typedef typename traits::coordinate_type
  52. <
  53. typename geometry::util::bare_type<Point>::type
  54. >::type type;
  55. };
  56. } // namespace core_dispatch
  57. #endif // DOXYGEN_NO_DISPATCH
  58. /*!
  59. \brief \brief_meta{type, coordinate type (int\, float\, double\, etc), \meta_point_type}
  60. \tparam Geometry \tparam_geometry
  61. \ingroup core
  62. \qbk{[include reference/core/coordinate_type.qbk]}
  63. */
  64. template <typename Geometry>
  65. struct coordinate_type
  66. {
  67. typedef typename core_dispatch::coordinate_type
  68. <
  69. typename tag<Geometry>::type,
  70. typename geometry::util::bare_type<Geometry>::type
  71. >::type type;
  72. };
  73. template <typename Geometry>
  74. struct fp_coordinate_type
  75. {
  76. typedef typename promote_floating_point
  77. <
  78. typename coordinate_type<Geometry>::type
  79. >::type type;
  80. };
  81. }} // namespace boost::geometry
  82. #endif // BOOST_GEOMETRY_CORE_COORDINATE_TYPE_HPP