123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_BUFFER_SIDE_STRAIGHT_HPP
- #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_BUFFER_SIDE_STRAIGHT_HPP
- #include <cstddef>
- #include <boost/range/value_type.hpp>
- #include <boost/geometry/core/radian_access.hpp>
- #include <boost/geometry/srs/spheroid.hpp>
- #include <boost/geometry/strategies/buffer.hpp>
- #include <boost/geometry/strategies/geographic/buffer_helper.hpp>
- #include <boost/geometry/strategies/geographic/parameters.hpp>
- #include <boost/geometry/util/math.hpp>
- #include <boost/geometry/util/select_calculation_type.hpp>
- namespace boost { namespace geometry
- {
- namespace strategy { namespace buffer
- {
- template
- <
- typename FormulaPolicy = strategy::andoyer,
- typename Spheroid = srs::spheroid<double>,
- typename CalculationType = void
- >
- class geographic_side_straight
- {
- public :
-
-
- explicit inline geographic_side_straight(Spheroid const& spheroid)
- : m_spheroid(spheroid)
- {}
-
- inline geographic_side_straight()
- {}
- #ifndef DOXYGEN_SHOULD_SKIP_THIS
-
- static inline bool equidistant()
- {
- return true;
- }
- template
- <
- typename Point,
- typename DistanceStrategy,
- typename RangeOut
- >
- inline result_code apply(Point const& input_p1, Point const& input_p2,
- buffer_side_selector side,
- DistanceStrategy const& distance_strategy,
- RangeOut& range_out) const
- {
- using calc_t = typename select_calculation_type
- <
- Point,
- typename boost::range_value<RangeOut>::type,
- CalculationType
- >::type;
- using helper = geographic_buffer_helper<FormulaPolicy, calc_t>;
- calc_t const lon1_rad = get_as_radian<0>(input_p1);
- calc_t const lat1_rad = get_as_radian<1>(input_p1);
- calc_t const lon2_rad = get_as_radian<0>(input_p2);
- calc_t const lat2_rad = get_as_radian<1>(input_p2);
- if (lon1_rad == lon2_rad && lat1_rad == lat2_rad)
- {
-
-
-
- return result_no_output;
- }
-
-
- auto const inv = helper::azimuth(lon1_rad, lat1_rad, input_p2, m_spheroid);
- auto const angle = math::wrap_azimuth_in_radian(inv - geometry::math::half_pi<calc_t>());
-
- auto const distance = distance_strategy.apply(input_p1, input_p2, side);
- helper::append_point(lon1_rad, lat1_rad, distance, angle, m_spheroid, range_out);
- helper::append_point(lon2_rad, lat2_rad, distance, angle, m_spheroid, range_out);
- return result_normal;
- }
- #endif
- private :
- Spheroid m_spheroid;
- };
- }}
- }}
- #endif
|