helper_geometry.hpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2015-2022, 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/closure.hpp>
  10. #include <boost/geometry/core/coordinate_dimension.hpp>
  11. #include <boost/geometry/core/coordinate_type.hpp>
  12. #include <boost/geometry/core/cs.hpp>
  13. #include <boost/geometry/core/point_order.hpp>
  14. #include <boost/geometry/core/point_type.hpp>
  15. #include <boost/geometry/core/tag.hpp>
  16. #include <boost/geometry/core/tags.hpp>
  17. #include <boost/geometry/geometries/box.hpp>
  18. #include <boost/geometry/geometries/linestring.hpp>
  19. #include <boost/geometry/geometries/point.hpp>
  20. #include <boost/geometry/geometries/ring.hpp>
  21. #include <boost/geometry/algorithms/not_implemented.hpp>
  22. namespace boost { namespace geometry
  23. {
  24. namespace detail { namespace helper_geometries
  25. {
  26. template
  27. <
  28. typename Point,
  29. typename NewCoordinateType,
  30. typename NewUnits,
  31. typename CS_Tag = typename cs_tag<Point>::type
  32. >
  33. struct helper_point
  34. {
  35. typedef model::point
  36. <
  37. NewCoordinateType,
  38. dimension<Point>::value,
  39. typename cs_tag_to_coordinate_system<NewUnits, CS_Tag>::type
  40. > type;
  41. };
  42. }} // detail::helper_geometries
  43. namespace detail_dispatch
  44. {
  45. template
  46. <
  47. typename Geometry,
  48. typename NewCoordinateType,
  49. typename NewUnits,
  50. typename Tag = typename tag<Geometry>::type>
  51. struct helper_geometry : not_implemented<Geometry>
  52. {};
  53. template <typename Point, typename NewCoordinateType, typename NewUnits>
  54. struct helper_geometry<Point, NewCoordinateType, NewUnits, point_tag>
  55. {
  56. using type = typename detail::helper_geometries::helper_point
  57. <
  58. Point, NewCoordinateType, NewUnits
  59. >::type;
  60. };
  61. template <typename Box, typename NewCoordinateType, typename NewUnits>
  62. struct helper_geometry<Box, NewCoordinateType, NewUnits, box_tag>
  63. {
  64. using type = model::box
  65. <
  66. typename helper_geometry
  67. <
  68. typename point_type<Box>::type, NewCoordinateType, NewUnits
  69. >::type
  70. >;
  71. };
  72. template <typename Linestring, typename NewCoordinateType, typename NewUnits>
  73. struct helper_geometry<Linestring, NewCoordinateType, NewUnits, linestring_tag>
  74. {
  75. using type = model::linestring
  76. <
  77. typename helper_geometry
  78. <
  79. typename point_type<Linestring>::type, NewCoordinateType, NewUnits
  80. >::type
  81. >;
  82. };
  83. template <typename Ring, typename NewCoordinateType, typename NewUnits>
  84. struct helper_geometry<Ring, NewCoordinateType, NewUnits, ring_tag>
  85. {
  86. using type = model::ring
  87. <
  88. typename helper_geometry
  89. <
  90. typename point_type<Ring>::type, NewCoordinateType, NewUnits
  91. >::type,
  92. point_order<Ring>::value != counterclockwise,
  93. closure<Ring>::value != open
  94. >;
  95. };
  96. } // detail_dispatch
  97. // Meta-function that provides a new helper geometry of the same kind as
  98. // the input geometry and the same coordinate system type,
  99. // but with a possibly different coordinate type and coordinate system units
  100. template
  101. <
  102. typename Geometry,
  103. typename NewCoordinateType = typename coordinate_type<Geometry>::type,
  104. typename NewUnits = typename detail::cs_angular_units<Geometry>::type
  105. >
  106. struct helper_geometry
  107. {
  108. using type = typename detail_dispatch::helper_geometry
  109. <
  110. Geometry, NewCoordinateType, NewUnits
  111. >::type;
  112. };
  113. }} // namespace boost::geometry
  114. #endif // BOOST_GEOMETRY_GEOMETRIES_HELPER_GEOMETRY_HPP