helper_geometry.hpp 2.8 KB

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