helper_geometry.hpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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 = cs_tag_t<Point>
  32. >
  33. struct helper_point
  34. {
  35. typedef model::point
  36. <
  37. NewCoordinateType,
  38. dimension<Point>::value,
  39. cs_tag_to_coordinate_system_t<NewUnits, CS_Tag>
  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 = tag_t<Geometry>
  51. >
  52. struct helper_geometry : not_implemented<Geometry>
  53. {};
  54. template <typename Point, typename NewCoordinateType, typename NewUnits>
  55. struct helper_geometry<Point, NewCoordinateType, NewUnits, point_tag>
  56. {
  57. using type = typename detail::helper_geometries::helper_point
  58. <
  59. Point, NewCoordinateType, NewUnits
  60. >::type;
  61. };
  62. template <typename Box, typename NewCoordinateType, typename NewUnits>
  63. struct helper_geometry<Box, NewCoordinateType, NewUnits, box_tag>
  64. {
  65. using type = model::box
  66. <
  67. typename helper_geometry
  68. <
  69. point_type_t<Box>, NewCoordinateType, NewUnits
  70. >::type
  71. >;
  72. };
  73. template <typename Linestring, typename NewCoordinateType, typename NewUnits>
  74. struct helper_geometry<Linestring, NewCoordinateType, NewUnits, linestring_tag>
  75. {
  76. using type = model::linestring
  77. <
  78. typename helper_geometry
  79. <
  80. point_type_t<Linestring>, NewCoordinateType, NewUnits
  81. >::type
  82. >;
  83. };
  84. template <typename Ring, typename NewCoordinateType, typename NewUnits>
  85. struct helper_geometry<Ring, NewCoordinateType, NewUnits, ring_tag>
  86. {
  87. using type = model::ring
  88. <
  89. typename helper_geometry
  90. <
  91. point_type_t<Ring>, NewCoordinateType, NewUnits
  92. >::type,
  93. point_order<Ring>::value != counterclockwise,
  94. closure<Ring>::value != open
  95. >;
  96. };
  97. } // detail_dispatch
  98. // Meta-function that provides a new helper geometry of the same kind as
  99. // the input geometry and the same coordinate system type,
  100. // but with a possibly different coordinate type and coordinate system units
  101. template
  102. <
  103. typename Geometry,
  104. typename NewCoordinateType = coordinate_type_t<Geometry>,
  105. typename NewUnits = typename detail::cs_angular_units<Geometry>::type
  106. >
  107. struct helper_geometry
  108. {
  109. using type = typename detail_dispatch::helper_geometry
  110. <
  111. Geometry, NewCoordinateType, NewUnits
  112. >::type;
  113. };
  114. }} // namespace boost::geometry
  115. #endif // BOOST_GEOMETRY_GEOMETRIES_HELPER_GEOMETRY_HPP