]>
Commit | Line | Data |
---|---|---|
1e59de90 TL |
1 | // Boost.Geometry |
2 | ||
3 | // Copyright (c) 2021, Oracle and/or its affiliates. | |
4 | ||
5 | // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle | |
6 | ||
7 | // Licensed under the Boost Software License version 1.0. | |
8 | // http://www.boost.org/users/license.html | |
9 | ||
10 | #ifndef BOOST_GEOMETRY_STRATEGIES_SIMPLIFY_CARTESIAN_HPP | |
11 | #define BOOST_GEOMETRY_STRATEGIES_SIMPLIFY_CARTESIAN_HPP | |
12 | ||
13 | ||
14 | #include <boost/geometry/strategies/agnostic/simplify_douglas_peucker.hpp> | |
15 | #include <boost/geometry/strategies/cartesian/distance_projected_point.hpp> | |
16 | #include <boost/geometry/strategies/cartesian/distance_pythagoras.hpp> | |
17 | #include <boost/geometry/strategies/cartesian/point_in_point.hpp> | |
18 | ||
19 | #include <boost/geometry/strategies/detail.hpp> | |
20 | #include <boost/geometry/strategies/distance/comparable.hpp> | |
21 | #include <boost/geometry/strategies/distance/detail.hpp> | |
22 | #include <boost/geometry/strategies/simplify/services.hpp> | |
23 | ||
24 | #include <boost/geometry/strategy/cartesian/area.hpp> | |
25 | ||
26 | #include <boost/geometry/util/type_traits.hpp> | |
27 | ||
28 | ||
29 | namespace boost { namespace geometry | |
30 | { | |
31 | ||
32 | namespace strategies { namespace simplify | |
33 | { | |
34 | ||
35 | template <typename CalculationType = void> | |
36 | struct cartesian | |
37 | : public strategies::detail::cartesian_base | |
38 | { | |
39 | // TODO: Replace this if calculate_point_order() is used in simplify | |
40 | template <typename Geometry> | |
41 | static auto area(Geometry const&) | |
42 | { | |
43 | return strategy::area::cartesian<CalculationType>(); | |
44 | } | |
45 | ||
46 | // For perimeter() | |
47 | template <typename Geometry1, typename Geometry2> | |
48 | static auto distance(Geometry1 const&, Geometry2 const&, | |
49 | distance::detail::enable_if_pp_t<Geometry1, Geometry2> * = nullptr) | |
50 | { | |
51 | return strategy::distance::pythagoras<CalculationType>(); | |
52 | } | |
53 | ||
54 | // For douglas_peucker | |
55 | template <typename Geometry1, typename Geometry2> | |
56 | static auto distance(Geometry1 const&, Geometry2 const&, | |
57 | distance::detail::enable_if_ps_t<Geometry1, Geometry2> * = nullptr) | |
58 | { | |
59 | return strategy::distance::projected_point | |
60 | < | |
61 | CalculationType, | |
62 | strategy::distance::pythagoras<CalculationType> | |
63 | >(); | |
64 | } | |
65 | ||
66 | // For equals() | |
67 | template <typename Geometry1, typename Geometry2> | |
68 | static auto relate(Geometry1 const&, Geometry2 const&, | |
69 | std::enable_if_t | |
70 | < | |
71 | util::is_pointlike<Geometry1>::value | |
72 | && util::is_pointlike<Geometry2>::value | |
73 | > * = nullptr) | |
74 | { | |
75 | return strategy::within::cartesian_point_point(); | |
76 | } | |
77 | }; | |
78 | ||
79 | ||
80 | namespace services | |
81 | { | |
82 | ||
83 | template <typename Geometry> | |
84 | struct default_strategy<Geometry, cartesian_tag> | |
85 | { | |
86 | using type = strategies::simplify::cartesian<>; | |
87 | }; | |
88 | ||
89 | ||
90 | template <typename P, typename CT, typename S> | |
91 | struct strategy_converter | |
92 | < | |
93 | strategy::simplify::douglas_peucker | |
94 | < | |
95 | P, | |
96 | strategy::distance::projected_point<CT, S> | |
97 | > | |
98 | > | |
99 | { | |
100 | template <typename Strategy> | |
101 | static auto get(Strategy const& ) | |
102 | { | |
103 | typedef strategies::simplify::cartesian<CT> strategy_type; | |
104 | return std::conditional_t | |
105 | < | |
106 | std::is_same | |
107 | < | |
108 | S, | |
109 | typename strategy::distance::services::comparable_type<S>::type | |
110 | >::value, | |
111 | strategies::distance::detail::comparable<strategy_type>, | |
112 | strategy_type | |
113 | >(); | |
114 | } | |
115 | }; | |
116 | ||
117 | ||
118 | } // namespace services | |
119 | ||
120 | }} // namespace strategies::simplify | |
121 | ||
122 | }} // namespace boost::geometry | |
123 | ||
124 | #endif // BOOST_GEOMETRY_STRATEGIES_SIMPLIFY_CARTESIAN_HPP |