envelope_point.hpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
  5. // This file was modified by Oracle on 2015, 2016, 2017, 2018.
  6. // Modifications copyright (c) 2015-2018, Oracle and/or its affiliates.
  7. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
  8. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
  9. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  10. // Distributed under the Boost Software License, Version 1.0.
  11. // (See accompanying file LICENSE_1_0.txt or copy at
  12. // http://www.boost.org/LICENSE_1_0.txt)
  13. #ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_POINT_HPP
  14. #define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_POINT_HPP
  15. #include <cstddef>
  16. #include <boost/geometry/core/access.hpp>
  17. #include <boost/geometry/core/cs.hpp>
  18. #include <boost/geometry/core/coordinate_dimension.hpp>
  19. #include <boost/geometry/core/coordinate_system.hpp>
  20. #include <boost/geometry/core/tags.hpp>
  21. #include <boost/geometry/views/detail/indexed_point_view.hpp>
  22. #include <boost/geometry/algorithms/detail/convert_point_to_point.hpp>
  23. #include <boost/geometry/algorithms/detail/normalize.hpp>
  24. #include <boost/geometry/algorithms/detail/envelope/transform_units.hpp>
  25. #include <boost/geometry/strategies/cartesian/envelope_point.hpp>
  26. #include <boost/geometry/strategies/envelope.hpp>
  27. namespace boost { namespace geometry
  28. {
  29. namespace strategy { namespace envelope
  30. {
  31. struct spherical_point
  32. {
  33. template<typename Point, typename Box>
  34. static inline void apply(Point const& point, Box& mbr)
  35. {
  36. Point normalized_point;
  37. strategy::normalize::spherical_point::apply(point, normalized_point);
  38. typename point_type<Box>::type box_point;
  39. // transform units of input point to units of a box point
  40. geometry::detail::envelope::transform_units(normalized_point, box_point);
  41. geometry::set<min_corner, 0>(mbr, geometry::get<0>(box_point));
  42. geometry::set<min_corner, 1>(mbr, geometry::get<1>(box_point));
  43. geometry::set<max_corner, 0>(mbr, geometry::get<0>(box_point));
  44. geometry::set<max_corner, 1>(mbr, geometry::get<1>(box_point));
  45. typedef geometry::detail::envelope::envelope_one_point
  46. <
  47. 2, dimension<Point>::value
  48. > per_corner;
  49. per_corner::template apply<min_corner>(normalized_point, mbr);
  50. per_corner::template apply<max_corner>(normalized_point, mbr);
  51. }
  52. };
  53. #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  54. namespace services
  55. {
  56. template <typename CalculationType>
  57. struct default_strategy<point_tag, spherical_equatorial_tag, CalculationType>
  58. {
  59. typedef strategy::envelope::spherical_point type;
  60. };
  61. template <typename CalculationType>
  62. struct default_strategy<point_tag, spherical_polar_tag, CalculationType>
  63. {
  64. typedef strategy::envelope::spherical_point type;
  65. };
  66. template <typename CalculationType>
  67. struct default_strategy<point_tag, geographic_tag, CalculationType>
  68. {
  69. typedef strategy::envelope::spherical_point type;
  70. };
  71. }
  72. #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  73. }} // namespace strategy::envelope
  74. }} // namespace boost::geometry
  75. #endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_POINT_HPP