helper_geometry.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2015-2017, Oracle and/or its affiliates.
  3. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
  4. // Contributed and/or modified by Adam Wulkiewicz, 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_GEOMETRIES_HELPER_GEOMETRY_HPP
  8. #define BOOST_GEOMETRY_GEOMETRIES_HELPER_GEOMETRY_HPP
  9. #include <boost/mpl/assert.hpp>
  10. #include <boost/geometry/core/cs.hpp>
  11. #include <boost/geometry/core/coordinate_dimension.hpp>
  12. #include <boost/geometry/core/coordinate_type.hpp>
  13. #include <boost/geometry/core/point_type.hpp>
  14. #include <boost/geometry/core/tag.hpp>
  15. #include <boost/geometry/core/tags.hpp>
  16. #include <boost/geometry/geometries/box.hpp>
  17. #include <boost/geometry/geometries/point.hpp>
  18. #include <boost/geometry/algorithms/not_implemented.hpp>
  19. namespace boost { namespace geometry
  20. {
  21. namespace detail { namespace helper_geometries
  22. {
  23. template
  24. <
  25. typename Point,
  26. typename NewCoordinateType,
  27. typename NewUnits,
  28. typename CS_Tag = typename cs_tag<Point>::type
  29. >
  30. struct helper_point
  31. {
  32. typedef model::point
  33. <
  34. NewCoordinateType,
  35. dimension<Point>::value,
  36. typename cs_tag_to_coordinate_system<NewUnits, CS_Tag>::type
  37. > type;
  38. };
  39. }} // detail::helper_geometries
  40. namespace detail_dispatch
  41. {
  42. template
  43. <
  44. typename Geometry,
  45. typename NewCoordinateType,
  46. typename NewUnits,
  47. typename Tag = typename tag<Geometry>::type>
  48. struct helper_geometry : not_implemented<Geometry>
  49. {};
  50. template <typename Point, typename NewCoordinateType, typename NewUnits>
  51. struct helper_geometry<Point, NewCoordinateType, NewUnits, point_tag>
  52. {
  53. typedef typename detail::helper_geometries::helper_point
  54. <
  55. Point, NewCoordinateType, NewUnits
  56. >::type type;
  57. };
  58. template <typename Box, typename NewCoordinateType, typename NewUnits>
  59. struct helper_geometry<Box, NewCoordinateType, NewUnits, box_tag>
  60. {
  61. typedef model::box
  62. <
  63. typename helper_geometry
  64. <
  65. typename point_type<Box>::type, NewCoordinateType, NewUnits
  66. >::type
  67. > type;
  68. };
  69. } // detail_dispatch
  70. // Meta-function that provides a new helper geometry of the same kind as
  71. // the input geometry and the same coordinate system type,
  72. // but with a possibly different coordinate type and coordinate system units
  73. template
  74. <
  75. typename Geometry,
  76. typename NewCoordinateType = typename coordinate_type<Geometry>::type,
  77. typename NewUnits = typename detail::cs_angular_units<Geometry>::type
  78. >
  79. struct helper_geometry
  80. {
  81. typedef typename detail_dispatch::helper_geometry
  82. <
  83. Geometry, NewCoordinateType, NewUnits
  84. >::type type;
  85. };
  86. }} // namespace boost::geometry
  87. #endif // BOOST_GEOMETRY_GEOMETRIES_HELPER_GEOMETRY_HPP