Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:36:48

0001 // Boost.Geometry
0002 
0003 // Copyright (c) 2021, Oracle and/or its affiliates.
0004 
0005 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0006 
0007 // Licensed under the Boost Software License version 1.0.
0008 // http://www.boost.org/users/license.html
0009 
0010 #ifndef BOOST_GEOMETRY_STRATEGIES_SIMPLIFY_CARTESIAN_HPP
0011 #define BOOST_GEOMETRY_STRATEGIES_SIMPLIFY_CARTESIAN_HPP
0012 
0013 
0014 #include <boost/geometry/strategies/agnostic/simplify_douglas_peucker.hpp>
0015 #include <boost/geometry/strategies/cartesian/distance_projected_point.hpp>
0016 #include <boost/geometry/strategies/cartesian/distance_pythagoras.hpp>
0017 #include <boost/geometry/strategies/cartesian/point_in_point.hpp>
0018 
0019 #include <boost/geometry/strategies/detail.hpp>
0020 #include <boost/geometry/strategies/distance/comparable.hpp>
0021 #include <boost/geometry/strategies/distance/detail.hpp>
0022 #include <boost/geometry/strategies/simplify/services.hpp>
0023 
0024 #include <boost/geometry/strategy/cartesian/area.hpp>
0025 
0026 #include <boost/geometry/util/type_traits.hpp>
0027 
0028 
0029 namespace boost { namespace geometry
0030 {
0031 
0032 namespace strategies { namespace simplify
0033 {
0034 
0035 template <typename CalculationType = void>
0036 struct cartesian
0037     : public strategies::detail::cartesian_base
0038 {
0039     // TODO: Replace this if calculate_point_order() is used in simplify
0040     template <typename Geometry>
0041     static auto area(Geometry const&)
0042     {
0043         return strategy::area::cartesian<CalculationType>();
0044     }
0045 
0046     // For perimeter()
0047     template <typename Geometry1, typename Geometry2>
0048     static auto distance(Geometry1 const&, Geometry2 const&,
0049                          distance::detail::enable_if_pp_t<Geometry1, Geometry2> * = nullptr)
0050     {
0051         return strategy::distance::pythagoras<CalculationType>();
0052     }
0053 
0054     // For douglas_peucker
0055     template <typename Geometry1, typename Geometry2>
0056     static auto distance(Geometry1 const&, Geometry2 const&,
0057                          distance::detail::enable_if_ps_t<Geometry1, Geometry2> * = nullptr)
0058     {
0059         return strategy::distance::projected_point
0060             <
0061                 CalculationType,
0062                 strategy::distance::pythagoras<CalculationType>
0063             >();
0064     }
0065 
0066     // For equals()
0067     template <typename Geometry1, typename Geometry2>
0068     static auto relate(Geometry1 const&, Geometry2 const&,
0069                        std::enable_if_t
0070                             <
0071                                 util::is_pointlike<Geometry1>::value
0072                              && util::is_pointlike<Geometry2>::value
0073                             > * = nullptr)
0074     {
0075         return strategy::within::cartesian_point_point();
0076     }
0077 };
0078 
0079 
0080 namespace services
0081 {
0082 
0083 template <typename Geometry>
0084 struct default_strategy<Geometry, cartesian_tag>
0085 {
0086     using type = strategies::simplify::cartesian<>;
0087 };
0088 
0089 
0090 template <typename P, typename CT, typename S>
0091 struct strategy_converter
0092     <
0093         strategy::simplify::douglas_peucker
0094             <
0095                 P,
0096                 strategy::distance::projected_point<CT, S>
0097             >
0098     >
0099 {
0100     template <typename Strategy>
0101     static auto get(Strategy const& )
0102     {
0103         typedef strategies::simplify::cartesian<CT> strategy_type;
0104         return std::conditional_t
0105             <
0106                 std::is_same
0107                     <
0108                         S,
0109                         typename strategy::distance::services::comparable_type<S>::type
0110                     >::value,
0111                 strategies::distance::detail::comparable<strategy_type>,
0112                 strategy_type
0113             >();
0114     }
0115 };
0116 
0117 
0118 } // namespace services
0119 
0120 }} // namespace strategies::simplify
0121 
0122 }} // namespace boost::geometry
0123 
0124 #endif // BOOST_GEOMETRY_STRATEGIES_SIMPLIFY_CARTESIAN_HPP