123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236 |
- #ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_PROJECTED_POINT_HPP
- #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_PROJECTED_POINT_HPP
- #include <type_traits>
- #include <boost/concept_check.hpp>
- #include <boost/core/ignore_unused.hpp>
- #include <boost/geometry/core/access.hpp>
- #include <boost/geometry/core/point_type.hpp>
- #include <boost/geometry/algorithms/convert.hpp>
- #include <boost/geometry/arithmetic/arithmetic.hpp>
- #include <boost/geometry/arithmetic/dot_product.hpp>
- #include <boost/geometry/strategies/tags.hpp>
- #include <boost/geometry/strategies/distance.hpp>
- #include <boost/geometry/strategies/default_distance_result.hpp>
- #include <boost/geometry/strategies/cartesian/closest_points_pt_seg.hpp>
- #include <boost/geometry/strategies/cartesian/distance_pythagoras.hpp>
- #include <boost/geometry/strategies/cartesian/point_in_point.hpp>
- #include <boost/geometry/strategies/cartesian/intersection.hpp>
- #include <boost/geometry/geometries/point.hpp>
- namespace boost { namespace geometry
- {
- namespace strategy { namespace distance
- {
- template
- <
- typename CalculationType = void,
- typename Strategy = pythagoras<CalculationType>
- >
- class projected_point
- {
- public:
-
-
-
-
-
- template <typename Point, typename PointOfSegment>
- struct calculation_type
- : promote_floating_point
- <
- typename strategy::distance::services::return_type
- <
- Strategy,
- Point,
- PointOfSegment
- >::type
- >
- {};
- template <typename Point, typename PointOfSegment>
- inline typename calculation_type<Point, PointOfSegment>::type
- apply(Point const& p, PointOfSegment const& p1, PointOfSegment const& p2) const
- {
- assert_dimension_equal<Point, PointOfSegment>();
- typedef typename calculation_type<Point, PointOfSegment>::type calculation_type;
- auto closest_point = closest_points::detail::compute_closest_point_to_segment
- <calculation_type>::apply(p, p1, p2);
- return Strategy().apply(p, closest_point);
- }
- template <typename CT>
- inline CT vertical_or_meridian(CT const& lat1, CT const& lat2) const
- {
- return lat1 - lat2;
- }
- };
- #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
- namespace services
- {
- template <typename CalculationType, typename Strategy>
- struct tag<projected_point<CalculationType, Strategy> >
- {
- typedef strategy_tag_distance_point_segment type;
- };
- template <typename CalculationType, typename Strategy, typename P, typename PS>
- struct return_type<projected_point<CalculationType, Strategy>, P, PS>
- : projected_point<CalculationType, Strategy>::template calculation_type<P, PS>
- {};
- template <typename CalculationType, typename Strategy>
- struct comparable_type<projected_point<CalculationType, Strategy> >
- {
-
-
- typedef projected_point
- <
- CalculationType,
- typename comparable_type<Strategy>::type
- > type;
- };
- template <typename CalculationType, typename Strategy>
- struct get_comparable<projected_point<CalculationType, Strategy> >
- {
- typedef typename comparable_type
- <
- projected_point<CalculationType, Strategy>
- >::type comparable_type;
- public :
- static inline comparable_type apply(projected_point<CalculationType, Strategy> const& )
- {
- return comparable_type();
- }
- };
- template <typename CalculationType, typename Strategy, typename P, typename PS>
- struct result_from_distance<projected_point<CalculationType, Strategy>, P, PS>
- {
- private :
- typedef typename return_type<projected_point<CalculationType, Strategy>, P, PS>::type return_type;
- public :
- template <typename T>
- static inline return_type apply(projected_point<CalculationType, Strategy> const& , T const& value)
- {
- Strategy s;
- return result_from_distance<Strategy, P, PS>::apply(s, value);
- }
- };
- template <typename Point, typename PointOfSegment, typename Strategy>
- struct default_strategy
- <
- point_tag, segment_tag, Point, PointOfSegment,
- cartesian_tag, cartesian_tag, Strategy
- >
- {
- typedef strategy::distance::projected_point
- <
- void,
- std::conditional_t
- <
- std::is_void<Strategy>::value,
- typename default_strategy
- <
- point_tag, point_tag, Point, PointOfSegment,
- cartesian_tag, cartesian_tag
- >::type,
- Strategy
- >
- > type;
- };
- template <typename PointOfSegment, typename Point, typename Strategy>
- struct default_strategy
- <
- segment_tag, point_tag, PointOfSegment, Point,
- cartesian_tag, cartesian_tag, Strategy
- >
- {
- typedef typename default_strategy
- <
- point_tag, segment_tag, Point, PointOfSegment,
- cartesian_tag, cartesian_tag, Strategy
- >::type type;
- };
- }
- #endif
- }}
- }}
- #endif
|