/
usr
/
include
/
boost
/
geometry
/
strategies
/
cartesian
/
/usr/include/boost/geometry/strategies/cartesian
mkdir
upload
Name
Size
Mode
Actions
area.hpp
3958
0644
edit
dl
rm
area_surveyor.hpp
1221
0644
edit
dl
rm
azimuth.hpp
1212
0644
edit
dl
rm
box_in_box.hpp
10614
0644
edit
dl
rm
buffer_end_flat.hpp
3757
0644
edit
dl
rm
buffer_end_round.hpp
6084
0644
edit
dl
rm
buffer_join_miter.hpp
4540
0644
edit
dl
rm
buffer_join_round.hpp
6206
0644
edit
dl
rm
buffer_join_round_by_divide.hpp
4659
0644
edit
dl
rm
buffer_point_circle.hpp
4016
0644
edit
dl
rm
buffer_point_square.hpp
3654
0644
edit
dl
rm
buffer_side_straight.hpp
4587
0644
edit
dl
rm
centroid_average.hpp
2880
0644
edit
dl
rm
centroid_bashein_detmer.hpp
8541
0644
edit
dl
rm
centroid_weighted_length.hpp
4855
0644
edit
dl
rm
densify.hpp
3902
0644
edit
dl
rm
disjoint_box_box.hpp
2985
0644
edit
dl
rm
disjoint_segment_box.hpp
8965
0644
edit
dl
rm
distance_projected_point.hpp
9635
0644
edit
dl
rm
distance_projected_point_ax.hpp
9835
0644
edit
dl
rm
distance_pythagoras.hpp
7674
0644
edit
dl
rm
distance_pythagoras_box_box.hpp
8993
0644
edit
dl
rm
distance_pythagoras_point_box.hpp
9230
0644
edit
dl
rm
distance_segment_box.hpp
6893
0644
edit
dl
rm
envelope.hpp
4299
0644
edit
dl
rm
envelope_box.hpp
3479
0644
edit
dl
rm
envelope_multipoint.hpp
1442
0644
edit
dl
rm
envelope_point.hpp
2963
0644
edit
dl
rm
envelope_segment.hpp
2458
0644
edit
dl
rm
expand_box.hpp
1868
0644
edit
dl
rm
expand_point.hpp
3340
0644
edit
dl
rm
expand_segment.hpp
1900
0644
edit
dl
rm
index.hpp
6976
0644
edit
dl
rm
intersection.hpp
30855
0644
edit
dl
rm
io.hpp
1873
0644
edit
dl
rm
line_interpolate.hpp
3772
0644
edit
dl
rm
point_in_box.hpp
8761
0644
edit
dl
rm
point_in_point.hpp
3543
0644
edit
dl
rm
point_in_poly_crossings_multiply.hpp
3593
0644
edit
dl
rm
point_in_poly_franklin.hpp
3464
0644
edit
dl
rm
point_in_poly_winding.hpp
9889
0644
edit
dl
rm
point_order.hpp
1024
0644
edit
dl
rm
side_by_triangle.hpp
9669
0644
edit
dl
rm
turn_in_ring_winding.hpp
7463
0644
edit
dl
rm
Edit:
/usr/include/boost/geometry/strategies/cartesian/distance_projected_point.hpp
(9635B)
// Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2008-2014 Bruno Lalande, Paris, France. // Copyright (c) 2008-2014 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2009-2014 Mateusz Loskot, London, UK. // This file was modified by Oracle on 2014, 2018, 2019. // Modifications copyright (c) 2014-2019, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_PROJECTED_POINT_HPP #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_PROJECTED_POINT_HPP #include <boost/concept_check.hpp> #include <boost/core/ignore_unused.hpp> #include <boost/mpl/if.hpp> #include <boost/type_traits/is_void.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/distance_pythagoras.hpp> #include <boost/geometry/strategies/cartesian/point_in_point.hpp> #include <boost/geometry/strategies/cartesian/intersection.hpp> #include <boost/geometry/util/select_coordinate_type.hpp> // Helper geometry (projected point on line) #include <boost/geometry/geometries/point.hpp> namespace boost { namespace geometry { namespace strategy { namespace distance { /*! \brief Strategy for distance point to segment \ingroup strategies \details Calculates distance using projected-point method, and (optionally) Pythagoras \author Adapted from: http://geometryalgorithms.com/Archive/algorithm_0102/algorithm_0102.htm \tparam CalculationType \tparam_calculation \tparam Strategy underlying point-point distance strategy \par Concepts for Strategy: - cartesian_distance operator(Point,Point) \note If the Strategy is a "comparable::pythagoras", this strategy automatically is a comparable projected_point strategy (so without sqrt) \qbk{ [heading See also] [link geometry.reference.algorithms.distance.distance_3_with_strategy distance (with strategy)] } */ template < typename CalculationType = void, typename Strategy = pythagoras<CalculationType> > class projected_point { public : typedef within::cartesian_point_point equals_point_point_strategy_type; typedef intersection::cartesian_segments < CalculationType > relate_segment_segment_strategy_type; static inline relate_segment_segment_strategy_type get_relate_segment_segment_strategy() { return relate_segment_segment_strategy_type(); } typedef within::cartesian_winding < void, void, CalculationType > point_in_geometry_strategy_type; static inline point_in_geometry_strategy_type get_point_in_geometry_strategy() { return point_in_geometry_strategy_type(); } // The three typedefs below are necessary to calculate distances // from segments defined in integer coordinates. // Integer coordinates can still result in FP distances. // There is a division, which must be represented in FP. // So promote. 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; // A projected point of points in Integer coordinates must be able to be // represented in FP. typedef model::point < calculation_type, dimension<PointOfSegment>::value, typename coordinate_system<PointOfSegment>::type > fp_point_type; // For convenience typedef fp_point_type fp_vector_type; /* Algorithm [p: (px,py), p1: (x1,y1), p2: (x2,y2)] VECTOR v(x2 - x1, y2 - y1) VECTOR w(px - x1, py - y1) c1 = w . v c2 = v . v b = c1 / c2 RETURN POINT(x1 + b * vx, y1 + b * vy) */ // v is multiplied below with a (possibly) FP-value, so should be in FP // For consistency we define w also in FP fp_vector_type v, w, projected; geometry::convert(p2, v); geometry::convert(p, w); geometry::convert(p1, projected); subtract_point(v, projected); subtract_point(w, projected); Strategy strategy; boost::ignore_unused(strategy); calculation_type const zero = calculation_type(); calculation_type const c1 = dot_product(w, v); if (c1 <= zero) { return strategy.apply(p, p1); } calculation_type const c2 = dot_product(v, v); if (c2 <= c1) { return strategy.apply(p, p2); } // See above, c1 > 0 AND c2 > c1 so: c2 != 0 calculation_type const b = c1 / c2; multiply_value(v, b); add_point(projected, v); return strategy.apply(p, projected); } 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> > { // Define a projected_point strategy with its underlying point-point-strategy // being comparable 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); } }; // Get default-strategy for point-segment distance calculation // while still have the possibility to specify point-point distance strategy (PPS) // It is used in algorithms/distance.hpp where users specify PPS for distance // of point-to-segment or point-to-linestring. // Convenient for geographic coordinate systems especially. 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, typename boost::mpl::if_ < boost::is_void<Strategy>, typename default_strategy < point_tag, point_tag, Point, PointOfSegment, cartesian_tag, cartesian_tag >::type, Strategy >::type > 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; }; } // namespace services #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS }} // namespace strategy::distance }} // namespace boost::geometry #endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_PROJECTED_POINT_HPP
Save
cmd:
run