mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-08-18 21:28:10 +00:00
Added thirdparty: boost library
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2020, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Licensed under the Boost Software License version 1.0.
|
||||
// http://www.boost.org/users/license.html
|
||||
|
||||
#ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_AREA_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_AREA_HPP
|
||||
|
||||
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.")
|
||||
|
||||
|
||||
#include <boost/geometry/strategy/geographic/area.hpp>
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_AREA_HPP
|
||||
+155
@@ -0,0 +1,155 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2016-2021 Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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_GEOGRAPHIC_AZIMUTH_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_AZIMUTH_HPP
|
||||
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include <boost/geometry/srs/spheroid.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/azimuth.hpp>
|
||||
#include <boost/geometry/strategies/geographic/parameters.hpp>
|
||||
|
||||
#include <boost/geometry/util/select_most_precise.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace azimuth
|
||||
{
|
||||
|
||||
template
|
||||
<
|
||||
typename FormulaPolicy = strategy::andoyer,
|
||||
typename Spheroid = srs::spheroid<double>,
|
||||
typename CalculationType = void
|
||||
>
|
||||
class geographic
|
||||
{
|
||||
public:
|
||||
template <typename T1, typename T2>
|
||||
struct result_type
|
||||
: geometry::select_most_precise
|
||||
<
|
||||
T1, T2, CalculationType
|
||||
>
|
||||
{};
|
||||
|
||||
typedef Spheroid model_type;
|
||||
|
||||
inline geographic()
|
||||
: m_spheroid()
|
||||
{}
|
||||
|
||||
explicit inline geographic(Spheroid const& spheroid)
|
||||
: m_spheroid(spheroid)
|
||||
{}
|
||||
|
||||
inline model_type const& model() const
|
||||
{
|
||||
return m_spheroid;
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename Result>
|
||||
inline void apply(T1 const& lon1_rad, T1 const& lat1_rad,
|
||||
T2 const& lon2_rad, T2 const& lat2_rad,
|
||||
Result& a1, Result& a2) const
|
||||
{
|
||||
compute<true, true>(lon1_rad, lat1_rad,
|
||||
lon2_rad, lat2_rad,
|
||||
a1, a2);
|
||||
}
|
||||
template <typename T1, typename T2, typename Result>
|
||||
inline void apply(T1 const& lon1_rad, T1 const& lat1_rad,
|
||||
T2 const& lon2_rad, T2 const& lat2_rad,
|
||||
Result& a1) const
|
||||
{
|
||||
compute<true, false>(lon1_rad, lat1_rad,
|
||||
lon2_rad, lat2_rad,
|
||||
a1, a1);
|
||||
}
|
||||
template <typename T1, typename T2, typename Result>
|
||||
inline void apply_reverse(T1 const& lon1_rad, T1 const& lat1_rad,
|
||||
T2 const& lon2_rad, T2 const& lat2_rad,
|
||||
Result& a2) const
|
||||
{
|
||||
compute<false, true>(lon1_rad, lat1_rad,
|
||||
lon2_rad, lat2_rad,
|
||||
a2, a2);
|
||||
}
|
||||
|
||||
private :
|
||||
|
||||
template
|
||||
<
|
||||
bool EnableAzimuth,
|
||||
bool EnableReverseAzimuth,
|
||||
typename T1, typename T2, typename Result
|
||||
>
|
||||
inline void compute(T1 const& lon1_rad, T1 const& lat1_rad,
|
||||
T2 const& lon2_rad, T2 const& lat2_rad,
|
||||
Result& a1, Result& a2) const
|
||||
{
|
||||
typedef typename result_type<T1, T2>::type calc_t;
|
||||
|
||||
typedef typename FormulaPolicy::template inverse
|
||||
<
|
||||
calc_t,
|
||||
false,
|
||||
EnableAzimuth,
|
||||
EnableReverseAzimuth,
|
||||
false,
|
||||
false
|
||||
> inverse_type;
|
||||
typedef typename inverse_type::result_type inverse_result;
|
||||
inverse_result i_res = inverse_type::apply(calc_t(lon1_rad), calc_t(lat1_rad),
|
||||
calc_t(lon2_rad), calc_t(lat2_rad),
|
||||
m_spheroid);
|
||||
if (EnableAzimuth)
|
||||
{
|
||||
a1 = i_res.azimuth;
|
||||
}
|
||||
if (EnableReverseAzimuth)
|
||||
{
|
||||
a2 = i_res.reverse_azimuth;
|
||||
}
|
||||
}
|
||||
|
||||
Spheroid m_spheroid;
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
namespace services
|
||||
{
|
||||
|
||||
template <>
|
||||
struct default_strategy<geographic_tag>
|
||||
{
|
||||
typedef strategy::azimuth::geographic
|
||||
<
|
||||
strategy::andoyer,
|
||||
srs::spheroid<double>
|
||||
> type;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
}} // namespace strategy::azimuth
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_AZIMUTH_HPP
|
||||
+153
@@ -0,0 +1,153 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2022 Barend Gehrels, 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_GEOGRAPHIC_BUFFER_END_ROUND_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_BUFFER_END_ROUND_HPP
|
||||
|
||||
#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_end_round
|
||||
{
|
||||
public :
|
||||
|
||||
//! \brief Constructs the strategy with a spheroid
|
||||
//! \param spheroid The spheroid to be used
|
||||
//! \param points_per_circle Number of points (minimum 4) that would be used for a full circle
|
||||
explicit inline geographic_end_round(Spheroid const& spheroid,
|
||||
std::size_t points_per_circle = default_points_per_circle)
|
||||
: m_spheroid(spheroid)
|
||||
, m_points_per_circle(get_point_count_for_end(points_per_circle))
|
||||
{}
|
||||
|
||||
//! \brief Constructs the strategy
|
||||
//! \param points_per_circle Number of points (minimum 4) that would be used for a full circle
|
||||
explicit inline geographic_end_round(std::size_t points_per_circle = default_points_per_circle)
|
||||
: m_points_per_circle(get_point_count_for_end(points_per_circle))
|
||||
{}
|
||||
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
template <typename T, typename RangeOut>
|
||||
inline void generate(T lon_rad, T lat_rad, T distance, T azimuth, RangeOut& range_out) const
|
||||
{
|
||||
using helper = geographic_buffer_helper<FormulaPolicy, T>;
|
||||
std::size_t const n = m_points_per_circle / 2;
|
||||
T const angle_diff = geometry::math::pi<T>() / n;
|
||||
T azi = math::wrap_azimuth_in_radian(azimuth + angle_diff);
|
||||
|
||||
// Generate points between 0 and n, not including them
|
||||
// because left and right are inserted before and after this range.
|
||||
for (std::size_t i = 1; i < n; i++)
|
||||
{
|
||||
helper::append_point(lon_rad, lat_rad, distance, azi, m_spheroid, range_out);
|
||||
azi = math::wrap_azimuth_in_radian(azi + angle_diff);
|
||||
}
|
||||
}
|
||||
|
||||
//! Fills output_range with a round end
|
||||
template <typename Point, typename DistanceStrategy, typename RangeOut>
|
||||
inline void apply(Point const& penultimate_point, Point const& perp_left_point,
|
||||
Point const& ultimate_point, Point const& perp_right_point,
|
||||
buffer_side_selector side, DistanceStrategy const& distance,
|
||||
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 lon_rad = get_as_radian<0>(ultimate_point);
|
||||
calc_t const lat_rad = get_as_radian<1>(ultimate_point);
|
||||
|
||||
auto const azimuth = helper::azimuth(lon_rad, lat_rad, perp_left_point, m_spheroid);
|
||||
|
||||
calc_t const dist_left = distance.apply(penultimate_point, ultimate_point, buffer_side_left);
|
||||
calc_t const dist_right = distance.apply(penultimate_point, ultimate_point, buffer_side_right);
|
||||
|
||||
bool const reversed = (side == buffer_side_left && dist_right < 0 && -dist_right > dist_left)
|
||||
|| (side == buffer_side_right && dist_left < 0 && -dist_left > dist_right)
|
||||
;
|
||||
|
||||
if (reversed)
|
||||
{
|
||||
range_out.push_back(perp_right_point);
|
||||
// generate
|
||||
range_out.push_back(perp_left_point);
|
||||
}
|
||||
else
|
||||
{
|
||||
range_out.push_back(perp_left_point);
|
||||
|
||||
if (geometry::math::equals(dist_left, dist_right))
|
||||
{
|
||||
generate(lon_rad, lat_rad, dist_left, azimuth, range_out);
|
||||
}
|
||||
else
|
||||
{
|
||||
static calc_t const two = 2.0;
|
||||
calc_t const dist_average = (dist_left + dist_right) / two;
|
||||
calc_t const dist_half
|
||||
= (side == buffer_side_right
|
||||
? (dist_right - dist_left)
|
||||
: (dist_left - dist_right)) / two;
|
||||
auto const shifted = helper::direct::apply(lon_rad, lat_rad, dist_half, azimuth, m_spheroid);
|
||||
generate(shifted.lon2, shifted.lat2, dist_average, azimuth, range_out);
|
||||
}
|
||||
|
||||
range_out.push_back(perp_right_point);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename NumericType>
|
||||
static inline NumericType max_distance(NumericType const& distance)
|
||||
{
|
||||
return distance;
|
||||
}
|
||||
|
||||
//! Returns the piece_type (flat end)
|
||||
static inline piece_type get_piece_type()
|
||||
{
|
||||
return buffered_round_end;
|
||||
}
|
||||
#endif // DOXYGEN_SHOULD_SKIP_THIS
|
||||
|
||||
private :
|
||||
Spheroid m_spheroid;
|
||||
std::size_t m_points_per_circle;
|
||||
};
|
||||
|
||||
}} // namespace strategy::buffer
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_BUFFER_END_ROUND_HPP
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2022 Barend Gehrels, 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_GEOGRAPHIC_BUFFER_HELPER_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_BUFFER_HELPER_HPP
|
||||
|
||||
#include <boost/geometry/core/assert.hpp>
|
||||
#include <boost/geometry/core/radian_access.hpp>
|
||||
#include <boost/geometry/strategies/geographic/parameters.hpp>
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace buffer
|
||||
{
|
||||
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
template <typename FormulaPolicy, typename CalculationType>
|
||||
struct geographic_buffer_helper
|
||||
{
|
||||
static bool const enable_azimuth = true;
|
||||
static bool const enable_coordinates = true;
|
||||
|
||||
using inverse = typename FormulaPolicy::template inverse
|
||||
<
|
||||
CalculationType, false, enable_azimuth, false, false, false
|
||||
>;
|
||||
|
||||
using direct = typename FormulaPolicy::template direct
|
||||
<
|
||||
CalculationType, enable_coordinates, false, false, false
|
||||
>;
|
||||
|
||||
// Calculates the azimuth using the inverse formula, where the first point
|
||||
// is specified by lon/lat (for pragmatic reasons) and the second point as a point.
|
||||
template <typename T, typename Point, typename Spheroid>
|
||||
static inline CalculationType azimuth(T const& lon_rad, T const& lat_rad,
|
||||
Point const& p, Spheroid const& spheroid)
|
||||
{
|
||||
return inverse::apply(lon_rad, lat_rad, get_as_radian<0>(p), get_as_radian<1>(p), spheroid).azimuth;
|
||||
}
|
||||
|
||||
// Using specified points, distance and azimuth it calculates a new point
|
||||
// and appends it to the range
|
||||
template <typename T, typename Spheroid, typename RangeOut>
|
||||
static inline void append_point(T const& lon_rad, T const& lat_rad,
|
||||
T const& distance, T const& angle,
|
||||
Spheroid const& spheroid, RangeOut& range_out)
|
||||
{
|
||||
using point_t = typename boost::range_value<RangeOut>::type;
|
||||
point_t point;
|
||||
auto const d = direct::apply(lon_rad, lat_rad, distance, angle, spheroid);
|
||||
set_from_radian<0>(point, d.lon2);
|
||||
set_from_radian<1>(point, d.lat2);
|
||||
range_out.emplace_back(point);
|
||||
}
|
||||
|
||||
// Calculates the angle diff and azimuth of a point (specified as lon/lat)
|
||||
// and two points, perpendicular in the buffer context.
|
||||
template <typename T, typename Point, typename Spheroid>
|
||||
static inline bool calculate_angles(T const& lon_rad, T const& lat_rad, Point const& perp1,
|
||||
Point const& perp2, Spheroid const& spheroid,
|
||||
T& angle_diff, T& first_azimuth)
|
||||
{
|
||||
T const inv1 = azimuth(lon_rad, lat_rad, perp1, spheroid);
|
||||
T const inv2 = azimuth(lon_rad, lat_rad, perp2, spheroid);
|
||||
|
||||
static CalculationType const two_pi = geometry::math::two_pi<CalculationType>();
|
||||
static CalculationType const pi = geometry::math::pi<CalculationType>();
|
||||
|
||||
// For a sharp corner, perpendicular points are nearly opposite and the
|
||||
// angle between the two azimuths can be nearly 180, but not more.
|
||||
angle_diff = inv2 < inv1 ? (two_pi + inv2) - inv1 : inv2 - inv1;
|
||||
|
||||
if (angle_diff < 0 || angle_diff > pi)
|
||||
{
|
||||
// Defensive check with asserts
|
||||
BOOST_GEOMETRY_ASSERT(angle_diff >= 0);
|
||||
BOOST_GEOMETRY_ASSERT(angle_diff <= pi);
|
||||
return false;
|
||||
}
|
||||
|
||||
first_azimuth = inv1;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
#endif // DOXYGEN_SHOULD_SKIP_THIS
|
||||
|
||||
}} // namespace strategy::buffer
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_BUFFER_HELPER_HPP
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2022 Barend Gehrels, 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_GEOGRAPHIC_BUFFER_JOIN_MITER_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_BUFFER_JOIN_MITER_HPP
|
||||
|
||||
#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_join_miter
|
||||
{
|
||||
public :
|
||||
|
||||
//! \brief Constructs the strategy with a spheroid
|
||||
//! \param spheroid The spheroid to be used
|
||||
//! \param miter_limit The miter limit, to avoid excessively long miters around sharp corners
|
||||
explicit inline geographic_join_miter(Spheroid const& spheroid,
|
||||
double miter_limit = 5.0)
|
||||
: m_spheroid(spheroid)
|
||||
, m_miter_limit(valid_limit(miter_limit))
|
||||
{}
|
||||
|
||||
//! \brief Constructs the strategy
|
||||
//! \param miter_limit The miter limit, to avoid excessively long miters around sharp corners
|
||||
explicit inline geographic_join_miter(double miter_limit = 5.0)
|
||||
: m_miter_limit(valid_limit(miter_limit))
|
||||
{}
|
||||
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
//! Fills output_range with a sharp shape around a vertex
|
||||
template <typename Point, typename DistanceType, typename RangeOut>
|
||||
inline bool apply(Point const& , Point const& vertex,
|
||||
Point const& perp1, Point const& perp2,
|
||||
DistanceType const& buffer_distance,
|
||||
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 lon_rad = get_as_radian<0>(vertex);
|
||||
calc_t const lat_rad = get_as_radian<1>(vertex);
|
||||
|
||||
calc_t first_azimuth;
|
||||
calc_t angle_diff;
|
||||
if (! helper::calculate_angles(lon_rad, lat_rad, perp1, perp2, m_spheroid,
|
||||
angle_diff, first_azimuth))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
calc_t const half = 0.5;
|
||||
calc_t const half_angle_diff = half * angle_diff;
|
||||
calc_t const azi = math::wrap_azimuth_in_radian(first_azimuth + half_angle_diff);
|
||||
|
||||
calc_t const cos_angle = std::cos(half_angle_diff);
|
||||
|
||||
if (cos_angle == 0)
|
||||
{
|
||||
// It is opposite, perp1==perp2, do not generate a miter cap
|
||||
return false;
|
||||
}
|
||||
|
||||
// If it is sharp (angle close to 0), the distance will become too high and will be capped.
|
||||
calc_t const max_distance = m_miter_limit * geometry::math::abs(buffer_distance);
|
||||
calc_t const distance = (std::min)(max_distance, buffer_distance / cos_angle);
|
||||
|
||||
range_out.push_back(perp1);
|
||||
helper::append_point(lon_rad, lat_rad, distance, azi, m_spheroid, range_out);
|
||||
range_out.push_back(perp2);
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename NumericType>
|
||||
inline NumericType max_distance(NumericType const& distance) const
|
||||
{
|
||||
return distance * m_miter_limit;
|
||||
}
|
||||
|
||||
#endif // DOXYGEN_SHOULD_SKIP_THIS
|
||||
|
||||
private :
|
||||
double valid_limit(double miter_limit) const
|
||||
{
|
||||
if (miter_limit < 1.0)
|
||||
{
|
||||
// It should always exceed the buffer distance
|
||||
miter_limit = 1.0;
|
||||
}
|
||||
return miter_limit;
|
||||
}
|
||||
|
||||
Spheroid m_spheroid;
|
||||
double m_miter_limit;
|
||||
};
|
||||
|
||||
}} // namespace strategy::buffer
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_BUFFER_JOIN_MITER_HPP
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2022 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// 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_GEOGRAPHIC_BUFFER_JOIN_ROUND_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_BUFFER_JOIN_ROUND_HPP
|
||||
|
||||
#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_join_round
|
||||
{
|
||||
public :
|
||||
|
||||
//! \brief Constructs the strategy with a spheroid
|
||||
//! \param spheroid The spheroid to be used
|
||||
//! \param points_per_circle Number of points (minimum 4) that would be used for a full circle
|
||||
explicit inline geographic_join_round(Spheroid const& spheroid,
|
||||
std::size_t points_per_circle = default_points_per_circle)
|
||||
: m_spheroid(spheroid)
|
||||
, m_points_per_circle(get_point_count_for_join(points_per_circle))
|
||||
{}
|
||||
|
||||
//! \brief Constructs the strategy
|
||||
//! \param points_per_circle Number of points (minimum 4) that would be used for a full circle
|
||||
explicit inline geographic_join_round(std::size_t points_per_circle = default_points_per_circle)
|
||||
: m_points_per_circle(get_point_count_for_join(points_per_circle))
|
||||
{}
|
||||
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
//! Fills output_range with a rounded shape around a vertex
|
||||
template <typename Point, typename DistanceType, typename RangeOut>
|
||||
inline bool apply(Point const& /*ip*/, Point const& vertex,
|
||||
Point const& perp1, Point const& perp2,
|
||||
DistanceType const& buffer_distance,
|
||||
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 lon_rad = get_as_radian<0>(vertex);
|
||||
calc_t const lat_rad = get_as_radian<1>(vertex);
|
||||
|
||||
calc_t first_azimuth;
|
||||
calc_t angle_diff;
|
||||
if (! helper::calculate_angles(lon_rad, lat_rad, perp1, perp2, m_spheroid,
|
||||
angle_diff, first_azimuth))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static calc_t const two_pi = geometry::math::two_pi<calc_t>();
|
||||
calc_t const circle_fraction = angle_diff / two_pi;
|
||||
std::size_t const n = (std::max)(static_cast<std::size_t>(
|
||||
std::ceil(m_points_per_circle * circle_fraction)), std::size_t(1));
|
||||
|
||||
calc_t const diff = angle_diff / static_cast<calc_t>(n);
|
||||
calc_t azi = math::wrap_azimuth_in_radian(first_azimuth + diff);
|
||||
|
||||
range_out.push_back(perp1);
|
||||
|
||||
// Generate points between 0 and n, not including them
|
||||
// because perp1 and perp2 are inserted before and after this range.
|
||||
for (std::size_t i = 1; i < n; i++)
|
||||
{
|
||||
helper::append_point(lon_rad, lat_rad, buffer_distance, azi, m_spheroid, range_out);
|
||||
azi = math::wrap_azimuth_in_radian(azi + diff);
|
||||
}
|
||||
|
||||
range_out.push_back(perp2);
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename NumericType>
|
||||
static inline NumericType max_distance(NumericType const& distance)
|
||||
{
|
||||
return distance;
|
||||
}
|
||||
|
||||
#endif // DOXYGEN_SHOULD_SKIP_THIS
|
||||
|
||||
private :
|
||||
Spheroid m_spheroid;
|
||||
std::size_t m_points_per_circle;
|
||||
};
|
||||
|
||||
}} // namespace strategy::buffer
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_BUFFER_JOIN_ROUND_HPP
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2018-2022 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2020-2021.
|
||||
// Modifications copyright (c) 2020-2021 Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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_GEOGRAPHIC_BUFFER_POINT_CIRCLE_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_BUFFER_POINT_CIRCLE_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
|
||||
{
|
||||
|
||||
/*!
|
||||
\brief Create a circular buffer around a point, on the Earth
|
||||
\ingroup strategies
|
||||
\details This strategy can be used as PointStrategy for the buffer algorithm.
|
||||
It creates a circular buffer around a point, on the Earth. It can be applied
|
||||
for points and multi_points.
|
||||
|
||||
\qbk{
|
||||
[heading Example]
|
||||
[buffer_geographic_point_circle]
|
||||
[buffer_geographic_point_circle_output]
|
||||
[heading See also]
|
||||
\* [link geometry.reference.algorithms.buffer.buffer_7_with_strategies buffer (with strategies)]
|
||||
\* [link geometry.reference.strategies.strategy_buffer_point_circle point_circle]
|
||||
\* [link geometry.reference.strategies.strategy_buffer_point_square point_square]
|
||||
}
|
||||
*/
|
||||
template
|
||||
<
|
||||
typename FormulaPolicy = strategy::andoyer,
|
||||
typename Spheroid = srs::spheroid<double>,
|
||||
typename CalculationType = void
|
||||
>
|
||||
class geographic_point_circle
|
||||
{
|
||||
public :
|
||||
|
||||
//! \brief Constructs the strategy with a spheroid
|
||||
//! \param spheroid The spheroid to be used
|
||||
//! \param count Number of points (minimum 3) for the created circle
|
||||
explicit inline geographic_point_circle(Spheroid const& spheroid,
|
||||
std::size_t count = default_points_per_circle)
|
||||
: m_spheroid(spheroid)
|
||||
, m_count(get_point_count_for_circle(count))
|
||||
{}
|
||||
|
||||
//! \brief Constructs the strategy
|
||||
//! \param count Number of points (minimum 3) for the created circle
|
||||
explicit inline geographic_point_circle(std::size_t count = default_points_per_circle)
|
||||
: m_count(get_point_count_for_circle(count))
|
||||
{}
|
||||
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
//! Fills range_out with a circle around point using distance_strategy
|
||||
template
|
||||
<
|
||||
typename Point,
|
||||
typename DistanceStrategy,
|
||||
typename RangeOut
|
||||
>
|
||||
inline void apply(Point const& point,
|
||||
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 lon_rad = get_as_radian<0>(point);
|
||||
calc_t const lat_rad = get_as_radian<1>(point);
|
||||
|
||||
calc_t const buffer_distance = distance_strategy.apply(point,
|
||||
point, strategy::buffer::buffer_side_left);
|
||||
|
||||
calc_t const two_pi = geometry::math::two_pi<calc_t>();
|
||||
calc_t const pi = geometry::math::pi<calc_t>();
|
||||
|
||||
calc_t const diff = two_pi / calc_t(m_count);
|
||||
calc_t angle = -pi;
|
||||
|
||||
for (std::size_t i = 0; i < m_count; i++, angle += diff)
|
||||
{
|
||||
// If angle is zero, shift angle a tiny bit to avoid spikes.
|
||||
calc_t const eps = angle == 0 ? 1.0e-10 : 0.0;
|
||||
helper::append_point(lon_rad, lat_rad, buffer_distance, angle + eps, m_spheroid, range_out);
|
||||
}
|
||||
|
||||
{
|
||||
// Close the range
|
||||
auto const p = range_out.front();
|
||||
range_out.push_back(p);
|
||||
}
|
||||
}
|
||||
#endif // DOXYGEN_SHOULD_SKIP_THIS
|
||||
|
||||
private :
|
||||
Spheroid m_spheroid;
|
||||
std::size_t m_count;
|
||||
};
|
||||
|
||||
}} // namespace strategy::buffer
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_BUFFER_POINT_CIRCLE_HPP
|
||||
Vendored
Executable
+119
@@ -0,0 +1,119 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2022 Barend Gehrels, 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_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
|
||||
{
|
||||
|
||||
/*!
|
||||
\brief Create a straight buffer along a side, on the Earth
|
||||
\ingroup strategies
|
||||
\details This strategy can be used as SideStrategy for the buffer algorithm.
|
||||
*/
|
||||
template
|
||||
<
|
||||
typename FormulaPolicy = strategy::andoyer,
|
||||
typename Spheroid = srs::spheroid<double>,
|
||||
typename CalculationType = void
|
||||
>
|
||||
class geographic_side_straight
|
||||
{
|
||||
public :
|
||||
//! \brief Constructs the strategy with a spheroid
|
||||
//! \param spheroid The spheroid to be used
|
||||
explicit inline geographic_side_straight(Spheroid const& spheroid)
|
||||
: m_spheroid(spheroid)
|
||||
{}
|
||||
|
||||
//! \brief Constructs the strategy
|
||||
inline geographic_side_straight()
|
||||
{}
|
||||
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
// Returns true if the buffer distance is always the same
|
||||
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)
|
||||
{
|
||||
// Coordinates are simplified and therefore most often not equal.
|
||||
// But if simplify is skipped, or for lines with two
|
||||
// equal points, length is 0 and we cannot generate output.
|
||||
return result_no_output;
|
||||
}
|
||||
|
||||
|
||||
// Measure the angle from p1 to p2 with the Inverse transformation,
|
||||
// and subtract pi/2 to make it perpendicular.
|
||||
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>());
|
||||
|
||||
// Calculate the distance and generate two points at that distance
|
||||
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 // DOXYGEN_SHOULD_SKIP_THIS
|
||||
|
||||
private :
|
||||
Spheroid m_spheroid;
|
||||
};
|
||||
|
||||
}} // namespace strategy::buffer
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_BUFFER_SIDE_STRAIGHT_HPP
|
||||
Vendored
Executable
+100
@@ -0,0 +1,100 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// Copyright (c) 2021, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||
|
||||
// Licensed under the Boost Software License version 1.0.
|
||||
// http://www.boost.org/users/license.html
|
||||
|
||||
#ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_CLOSEST_POINTS_CROSS_TRACK_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_CLOSEST_POINTS_CROSS_TRACK_HPP
|
||||
|
||||
#include <boost/geometry/core/coordinate_dimension.hpp>
|
||||
#include <boost/geometry/core/coordinate_promotion.hpp>
|
||||
#include <boost/geometry/core/coordinate_system.hpp>
|
||||
#include <boost/geometry/core/radian_access.hpp>
|
||||
#include <boost/geometry/geometries/point.hpp>
|
||||
#include <boost/geometry/srs/spheroid.hpp>
|
||||
#include <boost/geometry/strategies/geographic/distance_cross_track.hpp>
|
||||
#include <boost/geometry/util/select_calculation_type.hpp>
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace closest_points
|
||||
{
|
||||
|
||||
template
|
||||
<
|
||||
typename FormulaPolicy = geometry::strategy::andoyer,
|
||||
typename Spheroid = srs::spheroid<double>,
|
||||
typename CalculationType = void
|
||||
>
|
||||
class geographic_cross_track
|
||||
: public distance::detail::geographic_cross_track
|
||||
<
|
||||
FormulaPolicy,
|
||||
Spheroid,
|
||||
CalculationType,
|
||||
false,
|
||||
true
|
||||
>
|
||||
{
|
||||
using base_t = distance::detail::geographic_cross_track
|
||||
<
|
||||
FormulaPolicy,
|
||||
Spheroid,
|
||||
CalculationType,
|
||||
false,
|
||||
true
|
||||
>;
|
||||
|
||||
template <typename Point, typename PointOfSegment>
|
||||
struct calculation_type
|
||||
: promote_floating_point
|
||||
<
|
||||
typename select_calculation_type
|
||||
<
|
||||
Point,
|
||||
PointOfSegment,
|
||||
CalculationType
|
||||
>::type
|
||||
>
|
||||
{};
|
||||
|
||||
public :
|
||||
explicit geographic_cross_track(Spheroid const& spheroid = Spheroid())
|
||||
: base_t(spheroid)
|
||||
{}
|
||||
|
||||
template <typename Point, typename PointOfSegment>
|
||||
auto apply(Point const& p,
|
||||
PointOfSegment const& sp1,
|
||||
PointOfSegment const& sp2) const
|
||||
{
|
||||
auto result = base_t::apply(get_as_radian<0>(sp1), get_as_radian<1>(sp1),
|
||||
get_as_radian<0>(sp2), get_as_radian<1>(sp2),
|
||||
get_as_radian<0>(p), get_as_radian<1>(p),
|
||||
base_t::m_spheroid);
|
||||
|
||||
model::point
|
||||
<
|
||||
typename calculation_type<Point, PointOfSegment>::type,
|
||||
dimension<PointOfSegment>::value,
|
||||
typename coordinate_system<PointOfSegment>::type
|
||||
> cp;
|
||||
|
||||
geometry::set_from_radian<0>(cp, result.lon);
|
||||
geometry::set_from_radian<1>(cp, result.lat);
|
||||
|
||||
return cp;
|
||||
}
|
||||
};
|
||||
|
||||
}} // namespace strategy::closest_points
|
||||
|
||||
}} // namespace boost::geometry
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_CLOSEST_POINTS_CROSS_TRACK_HPP
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2017-2021, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Licensed under the Boost Software License version 1.0.
|
||||
// http://www.boost.org/users/license.html
|
||||
|
||||
#ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DENSIFY_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DENSIFY_HPP
|
||||
|
||||
|
||||
#include <boost/geometry/algorithms/detail/convert_point_to_point.hpp>
|
||||
#include <boost/geometry/algorithms/detail/signed_size_type.hpp>
|
||||
#include <boost/geometry/core/assert.hpp>
|
||||
#include <boost/geometry/core/coordinate_dimension.hpp>
|
||||
#include <boost/geometry/core/coordinate_type.hpp>
|
||||
#include <boost/geometry/core/radian_access.hpp>
|
||||
#include <boost/geometry/srs/spheroid.hpp>
|
||||
#include <boost/geometry/strategies/densify.hpp>
|
||||
#include <boost/geometry/strategies/geographic/parameters.hpp>
|
||||
#include <boost/geometry/util/select_most_precise.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace densify
|
||||
{
|
||||
|
||||
|
||||
/*!
|
||||
\brief Densification of geographic segment.
|
||||
\ingroup strategies
|
||||
\tparam FormulaPolicy The geodesic formulas used internally.
|
||||
\tparam Spheroid The spheroid model.
|
||||
\tparam CalculationType \tparam_calculation
|
||||
|
||||
\qbk{
|
||||
[heading See also]
|
||||
\* [link geometry.reference.algorithms.densify.densify_4_with_strategy densify (with strategy)]
|
||||
\* [link geometry.reference.srs.srs_spheroid srs::spheroid]
|
||||
}
|
||||
*/
|
||||
template
|
||||
<
|
||||
typename FormulaPolicy = strategy::andoyer,
|
||||
typename Spheroid = srs::spheroid<double>,
|
||||
typename CalculationType = void
|
||||
>
|
||||
class geographic
|
||||
{
|
||||
public:
|
||||
geographic()
|
||||
: m_spheroid()
|
||||
{}
|
||||
|
||||
explicit geographic(Spheroid const& spheroid)
|
||||
: m_spheroid(spheroid)
|
||||
{}
|
||||
|
||||
template <typename Point, typename AssignPolicy, typename T>
|
||||
inline void apply(Point const& p0, Point const& p1, AssignPolicy & policy, T const& length_threshold) const
|
||||
{
|
||||
typedef typename AssignPolicy::point_type out_point_t;
|
||||
typedef typename select_most_precise
|
||||
<
|
||||
typename coordinate_type<Point>::type,
|
||||
typename coordinate_type<out_point_t>::type,
|
||||
CalculationType
|
||||
>::type calc_t;
|
||||
|
||||
typedef typename FormulaPolicy::template direct<calc_t, true, false, false, false> direct_t;
|
||||
typedef typename FormulaPolicy::template inverse<calc_t, true, true, false, false, false> inverse_t;
|
||||
|
||||
typename inverse_t::result_type
|
||||
inv_r = inverse_t::apply(get_as_radian<0>(p0), get_as_radian<1>(p0),
|
||||
get_as_radian<0>(p1), get_as_radian<1>(p1),
|
||||
m_spheroid);
|
||||
|
||||
BOOST_GEOMETRY_ASSERT(length_threshold > T(0));
|
||||
|
||||
signed_size_type n = signed_size_type(inv_r.distance / length_threshold);
|
||||
if (n <= 0)
|
||||
return;
|
||||
|
||||
calc_t step = inv_r.distance / (n + 1);
|
||||
|
||||
calc_t current = step;
|
||||
for (signed_size_type i = 0 ; i < n ; ++i, current += step)
|
||||
{
|
||||
typename direct_t::result_type
|
||||
dir_r = direct_t::apply(get_as_radian<0>(p0), get_as_radian<1>(p0),
|
||||
current, inv_r.azimuth,
|
||||
m_spheroid);
|
||||
|
||||
out_point_t p;
|
||||
set_from_radian<0>(p, dir_r.lon2);
|
||||
set_from_radian<1>(p, dir_r.lat2);
|
||||
geometry::detail::conversion::point_to_point
|
||||
<
|
||||
Point, out_point_t,
|
||||
2, dimension<out_point_t>::value
|
||||
>::apply(p0, p);
|
||||
|
||||
policy.apply(p);
|
||||
}
|
||||
}
|
||||
|
||||
inline Spheroid const& model() const
|
||||
{
|
||||
return m_spheroid;
|
||||
}
|
||||
|
||||
private:
|
||||
Spheroid m_spheroid;
|
||||
};
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
namespace services
|
||||
{
|
||||
|
||||
template <>
|
||||
struct default_strategy<geographic_tag>
|
||||
{
|
||||
typedef strategy::densify::geographic<> type;
|
||||
};
|
||||
|
||||
|
||||
} // namespace services
|
||||
#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
|
||||
}} // namespace strategy::densify
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_ALGORITHMS_DENSIFY_HPP
|
||||
Vendored
Executable
+136
@@ -0,0 +1,136 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2017-2019 Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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_GEOGRAPHIC_DISJOINT_SEGMENT_BOX_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISJOINT_SEGMENT_BOX_HPP
|
||||
|
||||
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
#include <boost/numeric/conversion/cast.hpp>
|
||||
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
#include <boost/geometry/util/calculation_type.hpp>
|
||||
|
||||
#include <boost/geometry/core/access.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
#include <boost/geometry/core/coordinate_dimension.hpp>
|
||||
#include <boost/geometry/core/point_type.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/assign_indexed_point.hpp>
|
||||
#include <boost/geometry/algorithms/detail/disjoint/segment_box.hpp>
|
||||
|
||||
#include <boost/geometry/srs/spheroid.hpp>
|
||||
|
||||
// TODO: spherical_point_box currently defined in the same file as cartesian
|
||||
#include <boost/geometry/strategies/cartesian/point_in_box.hpp>
|
||||
#include <boost/geometry/strategies/disjoint.hpp>
|
||||
#include <boost/geometry/strategies/geographic/azimuth.hpp>
|
||||
#include <boost/geometry/strategies/geographic/parameters.hpp>
|
||||
#include <boost/geometry/strategies/normalize.hpp>
|
||||
#include <boost/geometry/strategies/spherical/disjoint_box_box.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry { namespace strategy { namespace disjoint
|
||||
{
|
||||
|
||||
// NOTE: This may be temporary place for this or corresponding strategy
|
||||
// It seems to be more appropriate to implement the opposite of it
|
||||
// e.g. intersection::segment_box because in disjoint() algorithm
|
||||
// other strategies that are used are intersection and covered_by strategies.
|
||||
template
|
||||
<
|
||||
typename FormulaPolicy = strategy::andoyer,
|
||||
typename Spheroid = srs::spheroid<double>,
|
||||
typename CalculationType = void
|
||||
>
|
||||
struct segment_box_geographic
|
||||
{
|
||||
public:
|
||||
typedef Spheroid model_type;
|
||||
|
||||
inline segment_box_geographic()
|
||||
: m_spheroid()
|
||||
{}
|
||||
|
||||
explicit inline segment_box_geographic(Spheroid const& spheroid)
|
||||
: m_spheroid(spheroid)
|
||||
{}
|
||||
|
||||
typedef covered_by::spherical_point_box disjoint_point_box_strategy_type;
|
||||
|
||||
static inline disjoint_point_box_strategy_type get_disjoint_point_box_strategy()
|
||||
{
|
||||
return disjoint_point_box_strategy_type();
|
||||
}
|
||||
|
||||
template <typename Segment, typename Box>
|
||||
inline bool apply(Segment const& segment, Box const& box) const
|
||||
{
|
||||
geometry::strategy::azimuth::geographic
|
||||
<
|
||||
FormulaPolicy,
|
||||
Spheroid,
|
||||
CalculationType
|
||||
> azimuth_geographic(m_spheroid);
|
||||
|
||||
return geometry::detail::disjoint::disjoint_segment_box_sphere_or_spheroid
|
||||
<
|
||||
geographic_tag
|
||||
>::apply(segment, box,
|
||||
azimuth_geographic,
|
||||
strategy::normalize::spherical_point(),
|
||||
strategy::covered_by::spherical_point_box(),
|
||||
strategy::disjoint::spherical_box_box());
|
||||
}
|
||||
|
||||
Spheroid const& model() const
|
||||
{
|
||||
return m_spheroid;
|
||||
}
|
||||
|
||||
private:
|
||||
Spheroid m_spheroid;
|
||||
};
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
|
||||
namespace services
|
||||
{
|
||||
|
||||
template <typename Linear, typename Box, typename LinearTag>
|
||||
struct default_strategy<Linear, Box, LinearTag, box_tag, 1, 2,
|
||||
geographic_tag, geographic_tag>
|
||||
{
|
||||
typedef segment_box_geographic<> type;
|
||||
};
|
||||
|
||||
template <typename Box, typename Linear, typename LinearTag>
|
||||
struct default_strategy<Box, Linear, box_tag, LinearTag, 2, 1,
|
||||
geographic_tag, geographic_tag>
|
||||
{
|
||||
typedef segment_box_geographic<> type;
|
||||
};
|
||||
|
||||
|
||||
} // namespace services
|
||||
|
||||
|
||||
#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
|
||||
}}}} // namespace boost::geometry::strategy::disjoint
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISJOINT_SEGMENT_BOX_HPP
|
||||
+237
@@ -0,0 +1,237 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2016 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2014-2018.
|
||||
// Modifications copyright (c) 2014-2018 Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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_GEOGRAPHIC_DISTANCE_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_HPP
|
||||
|
||||
|
||||
#include <boost/geometry/core/coordinate_promotion.hpp>
|
||||
#include <boost/geometry/core/coordinate_type.hpp>
|
||||
#include <boost/geometry/core/radian_access.hpp>
|
||||
#include <boost/geometry/core/radius.hpp>
|
||||
|
||||
#include <boost/geometry/formulas/andoyer_inverse.hpp>
|
||||
#include <boost/geometry/formulas/meridian_inverse.hpp>
|
||||
#include <boost/geometry/formulas/flattening.hpp>
|
||||
|
||||
#include <boost/geometry/srs/spheroid.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/distance.hpp>
|
||||
#include <boost/geometry/strategies/geographic/parameters.hpp>
|
||||
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
#include <boost/geometry/util/normalize_spheroidal_coordinates.hpp>
|
||||
#include <boost/geometry/util/select_calculation_type.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace distance
|
||||
{
|
||||
|
||||
/*!
|
||||
\brief Distance calculation for geographic coordinates on a spheroid
|
||||
\ingroup strategies
|
||||
\tparam FormulaPolicy Formula used to calculate azimuths
|
||||
\tparam Spheroid The spheroid model
|
||||
\tparam CalculationType \tparam_calculation
|
||||
|
||||
\qbk{
|
||||
[heading See also]
|
||||
\* [link geometry.reference.algorithms.distance.distance_3_with_strategy distance (with strategy)]
|
||||
\* [link geometry.reference.srs.srs_spheroid srs::spheroid]
|
||||
}
|
||||
*/
|
||||
template
|
||||
<
|
||||
typename FormulaPolicy = strategy::andoyer,
|
||||
typename Spheroid = srs::spheroid<double>,
|
||||
typename CalculationType = void
|
||||
>
|
||||
class geographic
|
||||
{
|
||||
public :
|
||||
template <typename Point1, typename Point2>
|
||||
struct calculation_type
|
||||
: promote_floating_point
|
||||
<
|
||||
typename select_calculation_type
|
||||
<
|
||||
Point1,
|
||||
Point2,
|
||||
CalculationType
|
||||
>::type
|
||||
>
|
||||
{};
|
||||
|
||||
typedef Spheroid model_type;
|
||||
|
||||
inline geographic()
|
||||
: m_spheroid()
|
||||
{}
|
||||
|
||||
explicit inline geographic(Spheroid const& spheroid)
|
||||
: m_spheroid(spheroid)
|
||||
{}
|
||||
|
||||
template <typename CT>
|
||||
static inline CT apply(CT lon1, CT lat1, CT lon2, CT lat2,
|
||||
Spheroid const& spheroid)
|
||||
{
|
||||
typedef typename formula::meridian_inverse
|
||||
<
|
||||
CT, strategy::default_order<FormulaPolicy>::value
|
||||
> meridian_inverse;
|
||||
|
||||
typename meridian_inverse::result res =
|
||||
meridian_inverse::apply(lon1, lat1, lon2, lat2, spheroid);
|
||||
|
||||
if (res.meridian)
|
||||
{
|
||||
return res.distance;
|
||||
}
|
||||
|
||||
return FormulaPolicy::template inverse
|
||||
<
|
||||
CT, true, false, false, false, false
|
||||
>::apply(lon1, lat1, lon2, lat2, spheroid).distance;
|
||||
}
|
||||
|
||||
template <typename Point1, typename Point2>
|
||||
inline typename calculation_type<Point1, Point2>::type
|
||||
apply(Point1 const& point1, Point2 const& point2) const
|
||||
{
|
||||
typedef typename calculation_type<Point1, Point2>::type CT;
|
||||
|
||||
CT lon1 = get_as_radian<0>(point1);
|
||||
CT lat1 = get_as_radian<1>(point1);
|
||||
CT lon2 = get_as_radian<0>(point2);
|
||||
CT lat2 = get_as_radian<1>(point2);
|
||||
|
||||
return apply(lon1, lat1, lon2, lat2, m_spheroid);
|
||||
}
|
||||
|
||||
inline Spheroid const& model() const
|
||||
{
|
||||
return m_spheroid;
|
||||
}
|
||||
|
||||
private :
|
||||
Spheroid m_spheroid;
|
||||
};
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
namespace services
|
||||
{
|
||||
|
||||
template
|
||||
<
|
||||
typename FormulaPolicy,
|
||||
typename Spheroid,
|
||||
typename CalculationType
|
||||
>
|
||||
struct tag<geographic<FormulaPolicy, Spheroid, CalculationType> >
|
||||
{
|
||||
typedef strategy_tag_distance_point_point type;
|
||||
};
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
typename FormulaPolicy,
|
||||
typename Spheroid,
|
||||
typename CalculationType,
|
||||
typename P1,
|
||||
typename P2
|
||||
>
|
||||
struct return_type<geographic<FormulaPolicy, Spheroid, CalculationType>, P1, P2>
|
||||
: geographic<FormulaPolicy, Spheroid, CalculationType>::template calculation_type<P1, P2>
|
||||
{};
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
typename FormulaPolicy,
|
||||
typename Spheroid,
|
||||
typename CalculationType
|
||||
>
|
||||
struct comparable_type<geographic<FormulaPolicy, Spheroid, CalculationType> >
|
||||
{
|
||||
typedef geographic<FormulaPolicy, Spheroid, CalculationType> type;
|
||||
};
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
typename FormulaPolicy,
|
||||
typename Spheroid,
|
||||
typename CalculationType
|
||||
>
|
||||
struct get_comparable<geographic<FormulaPolicy, Spheroid, CalculationType> >
|
||||
{
|
||||
static inline geographic<FormulaPolicy, Spheroid, CalculationType>
|
||||
apply(geographic<FormulaPolicy, Spheroid, CalculationType> const& input)
|
||||
{
|
||||
return input;
|
||||
}
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename FormulaPolicy,
|
||||
typename Spheroid,
|
||||
typename CalculationType,
|
||||
typename P1,
|
||||
typename P2
|
||||
>
|
||||
struct result_from_distance<geographic<FormulaPolicy, Spheroid, CalculationType>, P1, P2>
|
||||
{
|
||||
template <typename T>
|
||||
static inline typename return_type<geographic<FormulaPolicy, Spheroid, CalculationType>, P1, P2>::type
|
||||
apply(geographic<FormulaPolicy, Spheroid, CalculationType> const& , T const& value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename Point1, typename Point2>
|
||||
struct default_strategy<point_tag, point_tag, Point1, Point2, geographic_tag, geographic_tag>
|
||||
{
|
||||
typedef strategy::distance::geographic
|
||||
<
|
||||
strategy::andoyer,
|
||||
srs::spheroid
|
||||
<
|
||||
typename select_coordinate_type<Point1, Point2>::type
|
||||
>
|
||||
> type;
|
||||
};
|
||||
|
||||
|
||||
} // namespace services
|
||||
#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
|
||||
}} // namespace strategy::distance
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_HPP
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2016 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2014, 2017.
|
||||
// Modifications copyright (c) 2014-2017 Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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_GEOGRAPHIC_DISTANCE_DETAIL_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_DETAIL_HPP
|
||||
|
||||
|
||||
#include <boost/geometry/strategies/geographic/distance.hpp>
|
||||
#include <boost/geometry/strategies/geographic/parameters.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace distance
|
||||
{
|
||||
|
||||
|
||||
/*!
|
||||
\brief Point-point distance approximation taking flattening into account
|
||||
\ingroup distance
|
||||
\tparam Spheroid The reference spheroid model
|
||||
\tparam CalculationType \tparam_calculation
|
||||
\author After Andoyer, 19xx, republished 1950, republished by Meeus, 1999
|
||||
\note Although not so well-known, the approximation is very good: in all cases the results
|
||||
are about the same as Vincenty. In my (Barend's) testcases the results didn't differ more than 6 m
|
||||
\see http://nacc.upc.es/tierra/node16.html
|
||||
\see http://sci.tech-archive.net/Archive/sci.geo.satellite-nav/2004-12/2724.html
|
||||
\see http://home.att.net/~srschmitt/great_circle_route.html (implementation)
|
||||
\see http://www.codeguru.com/Cpp/Cpp/algorithms/article.php/c5115 (implementation)
|
||||
\see http://futureboy.homeip.net/frinksamp/navigation.frink (implementation)
|
||||
\see http://www.voidware.com/earthdist.htm (implementation)
|
||||
\see http://www.dtic.mil/docs/citations/AD0627893
|
||||
\see http://www.dtic.mil/docs/citations/AD703541
|
||||
*/
|
||||
template
|
||||
<
|
||||
typename Spheroid = srs::spheroid<double>,
|
||||
typename CalculationType = void
|
||||
>
|
||||
class andoyer
|
||||
: public strategy::distance::geographic
|
||||
<
|
||||
strategy::andoyer, Spheroid, CalculationType
|
||||
>
|
||||
{
|
||||
typedef strategy::distance::geographic
|
||||
<
|
||||
strategy::andoyer, Spheroid, CalculationType
|
||||
> base_type;
|
||||
|
||||
public :
|
||||
inline andoyer()
|
||||
: base_type()
|
||||
{}
|
||||
|
||||
explicit inline andoyer(Spheroid const& spheroid)
|
||||
: base_type(spheroid)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
namespace services
|
||||
{
|
||||
|
||||
template <typename Spheroid, typename CalculationType>
|
||||
struct tag<andoyer<Spheroid, CalculationType> >
|
||||
{
|
||||
typedef strategy_tag_distance_point_point type;
|
||||
};
|
||||
|
||||
|
||||
template <typename Spheroid, typename CalculationType, typename P1, typename P2>
|
||||
struct return_type<andoyer<Spheroid, CalculationType>, P1, P2>
|
||||
: andoyer<Spheroid, CalculationType>::template calculation_type<P1, P2>
|
||||
{};
|
||||
|
||||
|
||||
template <typename Spheroid, typename CalculationType>
|
||||
struct comparable_type<andoyer<Spheroid, CalculationType> >
|
||||
{
|
||||
typedef andoyer<Spheroid, CalculationType> type;
|
||||
};
|
||||
|
||||
|
||||
template <typename Spheroid, typename CalculationType>
|
||||
struct get_comparable<andoyer<Spheroid, CalculationType> >
|
||||
{
|
||||
static inline andoyer<Spheroid, CalculationType> apply(andoyer<Spheroid, CalculationType> const& input)
|
||||
{
|
||||
return input;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Spheroid, typename CalculationType, typename P1, typename P2>
|
||||
struct result_from_distance<andoyer<Spheroid, CalculationType>, P1, P2>
|
||||
{
|
||||
template <typename T>
|
||||
static inline typename return_type<andoyer<Spheroid, CalculationType>, P1, P2>::type
|
||||
apply(andoyer<Spheroid, CalculationType> const& , T const& value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace services
|
||||
#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
|
||||
}} // namespace strategy::distance
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_DETAIL_HPP
|
||||
Vendored
Executable
+1023
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+238
@@ -0,0 +1,238 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2017-2021, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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_GEOGRAPHIC_DISTANCE_CROSS_TRACK_BOX_BOX_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_CROSS_TRACK_BOX_BOX_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/concept_check.hpp>
|
||||
|
||||
#include <boost/geometry/core/access.hpp>
|
||||
#include <boost/geometry/core/assert.hpp>
|
||||
#include <boost/geometry/core/point_type.hpp>
|
||||
#include <boost/geometry/core/radian_access.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/distance.hpp>
|
||||
#include <boost/geometry/strategies/concepts/distance_concept.hpp>
|
||||
#include <boost/geometry/strategies/geographic/distance.hpp>
|
||||
#include <boost/geometry/strategies/geographic/distance_cross_track.hpp>
|
||||
#include <boost/geometry/strategies/spherical/distance_cross_track.hpp>
|
||||
#include <boost/geometry/strategies/spherical/distance_cross_track_box_box.hpp>
|
||||
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
#include <boost/geometry/algorithms/detail/assign_box_corners.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace distance
|
||||
{
|
||||
|
||||
|
||||
/*!
|
||||
\brief Strategy functor for distance point to box calculation
|
||||
\ingroup strategies
|
||||
\details Class which calculates the distance of a point to a box, for
|
||||
points and boxes on a sphere or globe
|
||||
\tparam CalculationType \tparam_calculation
|
||||
\tparam Strategy underlying point-segment distance strategy, defaults
|
||||
to cross track
|
||||
\qbk{
|
||||
[heading See also]
|
||||
[link geometry.reference.algorithms.distance.distance_3_with_strategy distance (with strategy)]
|
||||
}
|
||||
*/
|
||||
template
|
||||
<
|
||||
typename FormulaPolicy = strategy::andoyer,
|
||||
typename Spheroid = srs::spheroid<double>,
|
||||
typename CalculationType = void
|
||||
>
|
||||
class geographic_cross_track_box_box
|
||||
{
|
||||
public:
|
||||
|
||||
// point-point strategy getters
|
||||
struct distance_pp_strategy
|
||||
{
|
||||
typedef geographic<FormulaPolicy, Spheroid, CalculationType> type;
|
||||
};
|
||||
|
||||
// point-segment strategy getters
|
||||
struct distance_ps_strategy
|
||||
{
|
||||
typedef geographic_cross_track
|
||||
<
|
||||
FormulaPolicy,
|
||||
Spheroid,
|
||||
CalculationType
|
||||
> type;
|
||||
};
|
||||
|
||||
template <typename Box1, typename Box2>
|
||||
struct return_type : services::return_type
|
||||
<
|
||||
typename distance_ps_strategy::type,
|
||||
typename point_type<Box1>::type,
|
||||
typename point_type<Box2>::type
|
||||
>
|
||||
{};
|
||||
|
||||
//constructor
|
||||
|
||||
explicit geographic_cross_track_box_box(Spheroid const& spheroid = Spheroid())
|
||||
: m_spheroid(spheroid)
|
||||
{}
|
||||
|
||||
template <typename Box1, typename Box2>
|
||||
inline typename return_type<Box1, Box2>::type
|
||||
apply(Box1 const& box1, Box2 const& box2) const
|
||||
{
|
||||
/*
|
||||
#if !defined(BOOST_MSVC)
|
||||
BOOST_CONCEPT_ASSERT
|
||||
(
|
||||
(concepts::PointSegmentDistanceStrategy
|
||||
<
|
||||
Strategy,
|
||||
typename point_type<Box1>::type,
|
||||
typename point_type<Box2>::type
|
||||
>)
|
||||
);
|
||||
#endif
|
||||
*/
|
||||
typedef typename return_type<Box1, Box2>::type return_type;
|
||||
return details::cross_track_box_box_generic
|
||||
<return_type>::apply(box1, box2,
|
||||
typename distance_pp_strategy::type(m_spheroid),
|
||||
typename distance_ps_strategy::type(m_spheroid));
|
||||
}
|
||||
|
||||
Spheroid model() const
|
||||
{
|
||||
return m_spheroid;
|
||||
}
|
||||
|
||||
private :
|
||||
Spheroid m_spheroid;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
namespace services
|
||||
{
|
||||
|
||||
template <typename Strategy, typename Spheroid, typename CalculationType>
|
||||
struct tag<geographic_cross_track_box_box<Strategy, Spheroid, CalculationType> >
|
||||
{
|
||||
typedef strategy_tag_distance_box_box type;
|
||||
};
|
||||
|
||||
|
||||
template <typename Strategy, typename Spheroid, typename CalculationType, typename Box1, typename Box2>
|
||||
struct return_type<geographic_cross_track_box_box<Strategy, Spheroid, CalculationType>, Box1, Box2>
|
||||
: geographic_cross_track_box_box
|
||||
<
|
||||
Strategy, Spheroid, CalculationType
|
||||
>::template return_type<Box1, Box2>
|
||||
{};
|
||||
|
||||
template <typename Strategy, typename Spheroid, typename Box1, typename Box2>
|
||||
struct return_type<geographic_cross_track_box_box<Strategy, Spheroid>, Box1, Box2>
|
||||
: geographic_cross_track_box_box
|
||||
<
|
||||
Strategy, Spheroid
|
||||
>::template return_type<Box1, Box2>
|
||||
{};
|
||||
|
||||
template <typename Strategy, typename Box1, typename Box2>
|
||||
struct return_type<geographic_cross_track_box_box<Strategy>, Box1, Box2>
|
||||
: geographic_cross_track_box_box
|
||||
<
|
||||
Strategy
|
||||
>::template return_type<Box1, Box2>
|
||||
{};
|
||||
|
||||
template <typename Strategy, typename Spheroid, typename CalculationType>
|
||||
struct comparable_type<geographic_cross_track_box_box<Strategy, Spheroid, CalculationType> >
|
||||
{
|
||||
typedef geographic_cross_track_box_box
|
||||
<
|
||||
typename comparable_type<Strategy>::type, Spheroid, CalculationType
|
||||
> type;
|
||||
};
|
||||
|
||||
|
||||
template <typename Strategy, typename Spheroid, typename CalculationType>
|
||||
struct get_comparable<geographic_cross_track_box_box<Strategy, Spheroid, CalculationType> >
|
||||
{
|
||||
public:
|
||||
static inline geographic_cross_track_box_box<Strategy, Spheroid, CalculationType>
|
||||
apply(geographic_cross_track_box_box<Strategy, Spheroid, CalculationType> const& str)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename Strategy, typename Spheroid, typename CalculationType, typename Box1, typename Box2>
|
||||
struct result_from_distance
|
||||
<
|
||||
geographic_cross_track_box_box<Strategy, Spheroid, CalculationType>, Box1, Box2
|
||||
>
|
||||
{
|
||||
private:
|
||||
typedef geographic_cross_track_box_box<Strategy, Spheroid, CalculationType> this_strategy;
|
||||
|
||||
typedef typename this_strategy::template return_type
|
||||
<
|
||||
Box1, Box2
|
||||
>::type return_type;
|
||||
|
||||
public:
|
||||
template <typename T>
|
||||
static inline return_type apply(this_strategy const& strategy,
|
||||
T const& distance)
|
||||
{
|
||||
result_from_distance
|
||||
<
|
||||
Strategy,
|
||||
typename point_type<Box1>::type,
|
||||
typename point_type<Box2>::type
|
||||
>::apply(strategy, distance);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Box1, typename Box2>
|
||||
struct default_strategy
|
||||
<
|
||||
box_tag, box_tag, Box1, Box2,
|
||||
geographic_tag, geographic_tag
|
||||
>
|
||||
{
|
||||
typedef geographic_cross_track_box_box<> type;
|
||||
};
|
||||
|
||||
|
||||
} // namespace services
|
||||
#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
|
||||
}} // namespace strategy::distance
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_CROSS_TRACK_BOX_BOX_HPP
|
||||
Vendored
Executable
+231
@@ -0,0 +1,231 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2017-2021, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle.
|
||||
|
||||
// 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_GEOGRAPHIC_DISTANCE_CROSS_TRACK_POINT_BOX_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_CROSS_TRACK_POINT_BOX_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/concept_check.hpp>
|
||||
|
||||
#include <boost/geometry/core/access.hpp>
|
||||
#include <boost/geometry/core/assert.hpp>
|
||||
#include <boost/geometry/core/point_type.hpp>
|
||||
#include <boost/geometry/core/radian_access.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/distance.hpp>
|
||||
#include <boost/geometry/strategies/concepts/distance_concept.hpp>
|
||||
#include <boost/geometry/strategies/spherical/distance_cross_track.hpp>
|
||||
#include <boost/geometry/strategies/geographic/distance_cross_track.hpp>
|
||||
#include <boost/geometry/strategies/spherical/distance_cross_track_point_box.hpp>
|
||||
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
#include <boost/geometry/algorithms/detail/assign_box_corners.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace distance
|
||||
{
|
||||
|
||||
|
||||
/*!
|
||||
\brief Strategy functor for distance point to box calculation
|
||||
\ingroup strategies
|
||||
\details Class which calculates the distance of a point to a box, for
|
||||
points and boxes on a sphere or globe
|
||||
\tparam CalculationType \tparam_calculation
|
||||
\tparam Strategy underlying point-segment distance strategy, defaults
|
||||
to cross track
|
||||
\qbk{
|
||||
[heading See also]
|
||||
[link geometry.reference.algorithms.distance.distance_3_with_strategy distance (with strategy)]
|
||||
}
|
||||
*/
|
||||
template
|
||||
<
|
||||
typename FormulaPolicy = strategy::andoyer,
|
||||
typename Spheroid = srs::spheroid<double>,
|
||||
typename CalculationType = void
|
||||
>
|
||||
class geographic_cross_track_point_box
|
||||
{
|
||||
public:
|
||||
// point-point strategy getters
|
||||
struct distance_ps_strategy
|
||||
{
|
||||
typedef geographic_cross_track<FormulaPolicy, Spheroid, CalculationType> type;
|
||||
};
|
||||
|
||||
template <typename Point, typename Box>
|
||||
struct return_type
|
||||
: services::return_type<typename distance_ps_strategy::type,
|
||||
Point, typename point_type<Box>::type>
|
||||
{};
|
||||
|
||||
//constructor
|
||||
|
||||
explicit geographic_cross_track_point_box(Spheroid const& spheroid = Spheroid())
|
||||
: m_spheroid(spheroid)
|
||||
{}
|
||||
|
||||
template <typename Point, typename Box>
|
||||
inline typename return_type<Point, Box>::type
|
||||
apply(Point const& point, Box const& box) const
|
||||
{
|
||||
/*
|
||||
#if !defined(BOOST_MSVC)
|
||||
BOOST_CONCEPT_ASSERT
|
||||
(
|
||||
(concepts::PointSegmentDistanceStrategy
|
||||
<
|
||||
Strategy, Point, typename point_type<Box>::type
|
||||
>)
|
||||
);
|
||||
#endif
|
||||
*/
|
||||
|
||||
typedef typename return_type<Point, Box>::type return_type;
|
||||
|
||||
return details::cross_track_point_box_generic
|
||||
<return_type>::apply(point, box,
|
||||
typename distance_ps_strategy::type(m_spheroid));
|
||||
}
|
||||
|
||||
Spheroid model() const
|
||||
{
|
||||
return m_spheroid;
|
||||
}
|
||||
|
||||
private :
|
||||
Spheroid m_spheroid;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
namespace services
|
||||
{
|
||||
|
||||
template <typename Strategy, typename Spheroid, typename CalculationType>
|
||||
struct tag<geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> >
|
||||
{
|
||||
typedef strategy_tag_distance_point_box type;
|
||||
};
|
||||
|
||||
|
||||
template <typename Strategy, typename Spheroid, typename CalculationType, typename P, typename Box>
|
||||
struct return_type<geographic_cross_track_point_box<Strategy, Spheroid, CalculationType>, P, Box>
|
||||
: geographic_cross_track_point_box
|
||||
<
|
||||
Strategy, Spheroid, CalculationType
|
||||
>::template return_type<P, Box>
|
||||
{};
|
||||
|
||||
template <typename Strategy, typename Spheroid, typename P, typename Box>
|
||||
struct return_type<geographic_cross_track_point_box<Strategy, Spheroid>, P, Box>
|
||||
: geographic_cross_track_point_box
|
||||
<
|
||||
Strategy, Spheroid
|
||||
>::template return_type<P, Box>
|
||||
{};
|
||||
|
||||
template <typename Strategy, typename P, typename Box>
|
||||
struct return_type<geographic_cross_track_point_box<Strategy>, P, Box>
|
||||
: geographic_cross_track_point_box
|
||||
<
|
||||
Strategy
|
||||
>::template return_type<P, Box>
|
||||
{};
|
||||
|
||||
template <typename Strategy, typename Spheroid, typename CalculationType>
|
||||
struct comparable_type<geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> >
|
||||
{
|
||||
typedef geographic_cross_track_point_box
|
||||
<
|
||||
Strategy, Spheroid, CalculationType
|
||||
> type;
|
||||
};
|
||||
|
||||
|
||||
template <typename Strategy, typename Spheroid, typename CalculationType>
|
||||
struct get_comparable<geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> >
|
||||
{
|
||||
public:
|
||||
static inline geographic_cross_track_point_box<Strategy, Spheroid, CalculationType>
|
||||
apply(geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> const& str)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename Strategy, typename Spheroid, typename CalculationType, typename P, typename Box>
|
||||
struct result_from_distance
|
||||
<
|
||||
geographic_cross_track_point_box<Strategy, Spheroid, CalculationType>, P, Box
|
||||
>
|
||||
{
|
||||
private:
|
||||
typedef geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> this_strategy;
|
||||
|
||||
typedef typename this_strategy::template return_type
|
||||
<
|
||||
P, Box
|
||||
>::type return_type;
|
||||
|
||||
public:
|
||||
template <typename T>
|
||||
static inline return_type apply(this_strategy const& strategy,
|
||||
T const& distance)
|
||||
{
|
||||
result_from_distance
|
||||
<
|
||||
Strategy, P, typename point_type<Box>::type
|
||||
>::apply(strategy, distance);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Point, typename Box>
|
||||
struct default_strategy
|
||||
<
|
||||
point_tag, box_tag, Point, Box,
|
||||
geographic_tag, geographic_tag
|
||||
>
|
||||
{
|
||||
typedef geographic_cross_track_point_box<> type;
|
||||
};
|
||||
|
||||
template <typename Box, typename Point>
|
||||
struct default_strategy
|
||||
<
|
||||
box_tag, point_tag, Box, Point,
|
||||
geographic_tag, geographic_tag
|
||||
>
|
||||
{
|
||||
typedef typename default_strategy
|
||||
<
|
||||
point_tag, box_tag, Point, Box,
|
||||
geographic_tag, geographic_tag
|
||||
>::type type;
|
||||
};
|
||||
|
||||
} // namespace services
|
||||
#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
|
||||
}} // namespace strategy::distance
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_CROSS_TRACK_POINT_BOX_HPP
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2018 Adeel Ahmad, Islamabad, Pakistan.
|
||||
|
||||
// Contributed and/or modified by Adeel Ahmad, as part of Google Summer of Code 2018 program.
|
||||
|
||||
// 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_GEOGRAPHIC_KARNEY_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_KARNEY_HPP
|
||||
|
||||
|
||||
#include <boost/geometry/strategies/geographic/distance.hpp>
|
||||
#include <boost/geometry/strategies/geographic/parameters.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace distance
|
||||
{
|
||||
|
||||
/*!
|
||||
\brief The solution of the inverse problem of geodesics on latlong coordinates,
|
||||
after Karney (2011).
|
||||
\ingroup distance
|
||||
\tparam Spheroid The reference spheroid model
|
||||
\tparam CalculationType \tparam_calculation
|
||||
\author See
|
||||
- Charles F.F Karney, Algorithms for geodesics, 2011
|
||||
https://arxiv.org/pdf/1109.4448.pdf
|
||||
*/
|
||||
template
|
||||
<
|
||||
typename Spheroid = srs::spheroid<double>,
|
||||
typename CalculationType = void
|
||||
>
|
||||
class karney
|
||||
: public strategy::distance::geographic
|
||||
<
|
||||
strategy::karney, Spheroid, CalculationType
|
||||
>
|
||||
{
|
||||
typedef strategy::distance::geographic
|
||||
<
|
||||
strategy::karney, Spheroid, CalculationType
|
||||
> base_type;
|
||||
|
||||
public:
|
||||
inline karney()
|
||||
: base_type()
|
||||
{}
|
||||
|
||||
explicit inline karney(Spheroid const& spheroid)
|
||||
: base_type(spheroid)
|
||||
{}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
namespace services
|
||||
{
|
||||
|
||||
template <typename Spheroid, typename CalculationType>
|
||||
struct tag<karney<Spheroid, CalculationType> >
|
||||
{
|
||||
typedef strategy_tag_distance_point_point type;
|
||||
};
|
||||
|
||||
|
||||
template <typename Spheroid, typename CalculationType, typename P1, typename P2>
|
||||
struct return_type<karney<Spheroid, CalculationType>, P1, P2>
|
||||
: karney<Spheroid, CalculationType>::template calculation_type<P1, P2>
|
||||
{};
|
||||
|
||||
|
||||
template <typename Spheroid, typename CalculationType>
|
||||
struct comparable_type<karney<Spheroid, CalculationType> >
|
||||
{
|
||||
typedef karney<Spheroid, CalculationType> type;
|
||||
};
|
||||
|
||||
|
||||
template <typename Spheroid, typename CalculationType>
|
||||
struct get_comparable<karney<Spheroid, CalculationType> >
|
||||
{
|
||||
static inline karney<Spheroid, CalculationType> apply(karney<Spheroid, CalculationType> const& input)
|
||||
{
|
||||
return input;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Spheroid, typename CalculationType, typename P1, typename P2>
|
||||
struct result_from_distance<karney<Spheroid, CalculationType>, P1, P2 >
|
||||
{
|
||||
template <typename T>
|
||||
static inline typename return_type<karney<Spheroid, CalculationType>, P1, P2>::type
|
||||
apply(karney<Spheroid, CalculationType> const& , T const& value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace services
|
||||
#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
|
||||
}} // namespace strategy::distance
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_KARNEY_HPP
|
||||
Vendored
Executable
+296
@@ -0,0 +1,296 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2018-2021 Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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_GEOGRAPHIC_DISTANCE_SEGMENT_BOX_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_SEGMENT_BOX_HPP
|
||||
|
||||
#include <boost/geometry/srs/spheroid.hpp>
|
||||
|
||||
#include <boost/geometry/core/coordinate_promotion.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/distance/segment_to_box.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/distance.hpp>
|
||||
#include <boost/geometry/strategies/geographic/azimuth.hpp>
|
||||
#include <boost/geometry/strategies/geographic/distance_cross_track.hpp>
|
||||
#include <boost/geometry/strategies/geographic/distance_cross_track_point_box.hpp>
|
||||
#include <boost/geometry/strategies/geographic/parameters.hpp>
|
||||
#include <boost/geometry/strategies/geographic/side.hpp>
|
||||
#include <boost/geometry/strategies/normalize.hpp>
|
||||
#include <boost/geometry/strategies/spherical/disjoint_box_box.hpp>
|
||||
#include <boost/geometry/strategies/spherical/distance_segment_box.hpp>
|
||||
#include <boost/geometry/strategies/spherical/point_in_point.hpp>
|
||||
|
||||
#include <boost/geometry/util/select_calculation_type.hpp>
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
|
||||
namespace strategy { namespace distance
|
||||
{
|
||||
|
||||
template
|
||||
<
|
||||
typename FormulaPolicy = strategy::andoyer,
|
||||
typename Spheroid = srs::spheroid<double>,
|
||||
typename CalculationType = void
|
||||
>
|
||||
struct geographic_segment_box
|
||||
{
|
||||
template <typename PointOfSegment, typename PointOfBox>
|
||||
struct return_type
|
||||
: promote_floating_point
|
||||
<
|
||||
typename select_calculation_type
|
||||
<
|
||||
PointOfSegment,
|
||||
PointOfBox,
|
||||
CalculationType
|
||||
>::type
|
||||
>
|
||||
{};
|
||||
|
||||
typedef geographic_tag cs_tag;
|
||||
|
||||
//constructor
|
||||
|
||||
explicit geographic_segment_box(Spheroid const& spheroid = Spheroid())
|
||||
: m_spheroid(spheroid)
|
||||
{}
|
||||
|
||||
Spheroid model() const
|
||||
{
|
||||
return m_spheroid;
|
||||
}
|
||||
|
||||
// methods
|
||||
|
||||
template
|
||||
<
|
||||
typename LessEqual, typename ReturnType,
|
||||
typename SegmentPoint, typename BoxPoint,
|
||||
typename Strategies
|
||||
>
|
||||
inline ReturnType segment_below_of_box(SegmentPoint const& p0,
|
||||
SegmentPoint const& p1,
|
||||
BoxPoint const& top_left,
|
||||
BoxPoint const& top_right,
|
||||
BoxPoint const& bottom_left,
|
||||
BoxPoint const& bottom_right,
|
||||
Strategies const& strategies) const
|
||||
{
|
||||
return generic_segment_box::segment_below_of_box
|
||||
<
|
||||
LessEqual,
|
||||
ReturnType
|
||||
>(p0,p1,top_left,top_right,bottom_left,bottom_right,
|
||||
strategies);
|
||||
}
|
||||
|
||||
template <typename SPoint, typename BPoint>
|
||||
static void mirror(SPoint& p0,
|
||||
SPoint& p1,
|
||||
BPoint& bottom_left,
|
||||
BPoint& bottom_right,
|
||||
BPoint& top_left,
|
||||
BPoint& top_right)
|
||||
{
|
||||
|
||||
generic_segment_box::mirror(p0, p1,
|
||||
bottom_left, bottom_right,
|
||||
top_left, top_right);
|
||||
}
|
||||
|
||||
private :
|
||||
Spheroid m_spheroid;
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
namespace services
|
||||
{
|
||||
|
||||
//tags
|
||||
|
||||
template <typename FormulaPolicy>
|
||||
struct tag<geographic_segment_box<FormulaPolicy> >
|
||||
{
|
||||
typedef strategy_tag_distance_segment_box type;
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename FormulaPolicy,
|
||||
typename Spheroid
|
||||
>
|
||||
struct tag<geographic_segment_box<FormulaPolicy, Spheroid> >
|
||||
{
|
||||
typedef strategy_tag_distance_segment_box type;
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename FormulaPolicy,
|
||||
typename Spheroid,
|
||||
typename CalculationType
|
||||
>
|
||||
struct tag<geographic_segment_box<FormulaPolicy, Spheroid, CalculationType> >
|
||||
{
|
||||
typedef strategy_tag_distance_segment_box type;
|
||||
};
|
||||
|
||||
// return types
|
||||
|
||||
template <typename FormulaPolicy, typename PS, typename PB>
|
||||
struct return_type<geographic_segment_box<FormulaPolicy>, PS, PB>
|
||||
: geographic_segment_box<FormulaPolicy>::template return_type<PS, PB>
|
||||
{};
|
||||
|
||||
template
|
||||
<
|
||||
typename FormulaPolicy,
|
||||
typename Spheroid,
|
||||
typename PS,
|
||||
typename PB
|
||||
>
|
||||
struct return_type<geographic_segment_box<FormulaPolicy, Spheroid>, PS, PB>
|
||||
: geographic_segment_box<FormulaPolicy, Spheroid>::template return_type<PS, PB>
|
||||
{};
|
||||
|
||||
template
|
||||
<
|
||||
typename FormulaPolicy,
|
||||
typename Spheroid,
|
||||
typename CalculationType,
|
||||
typename PS,
|
||||
typename PB
|
||||
>
|
||||
struct return_type<geographic_segment_box<FormulaPolicy, Spheroid, CalculationType>, PS, PB>
|
||||
: geographic_segment_box<FormulaPolicy, Spheroid, CalculationType>::template return_type<PS, PB>
|
||||
{};
|
||||
|
||||
//comparable types
|
||||
|
||||
template
|
||||
<
|
||||
typename FormulaPolicy,
|
||||
typename Spheroid,
|
||||
typename CalculationType
|
||||
>
|
||||
struct comparable_type<geographic_segment_box<FormulaPolicy, Spheroid, CalculationType> >
|
||||
{
|
||||
typedef geographic_segment_box
|
||||
<
|
||||
FormulaPolicy, Spheroid, CalculationType
|
||||
> type;
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename FormulaPolicy,
|
||||
typename Spheroid,
|
||||
typename CalculationType
|
||||
>
|
||||
struct get_comparable<geographic_segment_box<FormulaPolicy, Spheroid, CalculationType> >
|
||||
{
|
||||
typedef typename comparable_type
|
||||
<
|
||||
geographic_segment_box<FormulaPolicy, Spheroid, CalculationType>
|
||||
>::type comparable_type;
|
||||
public :
|
||||
static inline comparable_type
|
||||
apply(geographic_segment_box<FormulaPolicy, Spheroid, CalculationType> const& )
|
||||
{
|
||||
return comparable_type();
|
||||
}
|
||||
};
|
||||
|
||||
// result from distance
|
||||
|
||||
template
|
||||
<
|
||||
typename FormulaPolicy,
|
||||
typename PS,
|
||||
typename PB
|
||||
>
|
||||
struct result_from_distance<geographic_segment_box<FormulaPolicy>, PS, PB>
|
||||
{
|
||||
private :
|
||||
typedef typename geographic_segment_box
|
||||
<
|
||||
FormulaPolicy
|
||||
>::template return_type<PS, PB>::type return_type;
|
||||
public :
|
||||
template <typename T>
|
||||
static inline return_type
|
||||
apply(geographic_segment_box<FormulaPolicy> const& , T const& distance)
|
||||
{
|
||||
return distance;
|
||||
}
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename FormulaPolicy,
|
||||
typename Spheroid,
|
||||
typename CalculationType,
|
||||
typename PS,
|
||||
typename PB
|
||||
>
|
||||
struct result_from_distance<geographic_segment_box<FormulaPolicy, Spheroid, CalculationType>, PS, PB>
|
||||
{
|
||||
private :
|
||||
typedef typename geographic_segment_box
|
||||
<
|
||||
FormulaPolicy, Spheroid, CalculationType
|
||||
>::template return_type<PS, PB>::type return_type;
|
||||
public :
|
||||
template <typename T>
|
||||
static inline return_type
|
||||
apply(geographic_segment_box<FormulaPolicy, Spheroid, CalculationType> const& , T const& distance)
|
||||
{
|
||||
return distance;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// default strategies
|
||||
|
||||
template <typename Segment, typename Box>
|
||||
struct default_strategy
|
||||
<
|
||||
segment_tag, box_tag, Segment, Box,
|
||||
geographic_tag, geographic_tag
|
||||
>
|
||||
{
|
||||
typedef geographic_segment_box<> type;
|
||||
};
|
||||
|
||||
template <typename Box, typename Segment>
|
||||
struct default_strategy
|
||||
<
|
||||
box_tag, segment_tag, Box, Segment,
|
||||
geographic_tag, geographic_tag
|
||||
>
|
||||
{
|
||||
typedef typename default_strategy
|
||||
<
|
||||
segment_tag, box_tag, Segment, Box,
|
||||
geographic_tag, geographic_tag
|
||||
>::type type;
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
}} // namespace strategy::distance
|
||||
|
||||
}} // namespace boost::geometry
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_SEGMENT_BOX_HPP
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2015-2017.
|
||||
// Modifications copyright (c) 2015-2017 Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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_GEOGRAPHIC_THOMAS_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_THOMAS_HPP
|
||||
|
||||
|
||||
#include <boost/geometry/strategies/geographic/distance.hpp>
|
||||
#include <boost/geometry/strategies/geographic/parameters.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace distance
|
||||
{
|
||||
|
||||
/*!
|
||||
\brief The solution of the inverse problem of geodesics on latlong coordinates,
|
||||
Forsyth-Andoyer-Lambert type approximation with second order terms.
|
||||
\ingroup distance
|
||||
\tparam Spheroid The reference spheroid model
|
||||
\tparam CalculationType \tparam_calculation
|
||||
\author See
|
||||
- Technical Report: PAUL D. THOMAS, MATHEMATICAL MODELS FOR NAVIGATION SYSTEMS, 1965
|
||||
http://www.dtic.mil/docs/citations/AD0627893
|
||||
- Technical Report: PAUL D. THOMAS, SPHEROIDAL GEODESICS, REFERENCE SYSTEMS, AND LOCAL GEOMETRY, 1970
|
||||
http://www.dtic.mil/docs/citations/AD703541
|
||||
*/
|
||||
template
|
||||
<
|
||||
typename Spheroid = srs::spheroid<double>,
|
||||
typename CalculationType = void
|
||||
>
|
||||
class thomas
|
||||
: public strategy::distance::geographic
|
||||
<
|
||||
strategy::thomas, Spheroid, CalculationType
|
||||
>
|
||||
{
|
||||
typedef strategy::distance::geographic
|
||||
<
|
||||
strategy::thomas, Spheroid, CalculationType
|
||||
> base_type;
|
||||
|
||||
public :
|
||||
inline thomas()
|
||||
: base_type()
|
||||
{}
|
||||
|
||||
explicit inline thomas(Spheroid const& spheroid)
|
||||
: base_type(spheroid)
|
||||
{}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
namespace services
|
||||
{
|
||||
|
||||
template <typename Spheroid, typename CalculationType>
|
||||
struct tag<thomas<Spheroid, CalculationType> >
|
||||
{
|
||||
typedef strategy_tag_distance_point_point type;
|
||||
};
|
||||
|
||||
|
||||
template <typename Spheroid, typename CalculationType, typename P1, typename P2>
|
||||
struct return_type<thomas<Spheroid, CalculationType>, P1, P2>
|
||||
: thomas<Spheroid, CalculationType>::template calculation_type<P1, P2>
|
||||
{};
|
||||
|
||||
|
||||
template <typename Spheroid, typename CalculationType>
|
||||
struct comparable_type<thomas<Spheroid, CalculationType> >
|
||||
{
|
||||
typedef thomas<Spheroid, CalculationType> type;
|
||||
};
|
||||
|
||||
|
||||
template <typename Spheroid, typename CalculationType>
|
||||
struct get_comparable<thomas<Spheroid, CalculationType> >
|
||||
{
|
||||
static inline thomas<Spheroid, CalculationType> apply(thomas<Spheroid, CalculationType> const& input)
|
||||
{
|
||||
return input;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Spheroid, typename CalculationType, typename P1, typename P2>
|
||||
struct result_from_distance<thomas<Spheroid, CalculationType>, P1, P2 >
|
||||
{
|
||||
template <typename T>
|
||||
static inline typename return_type<thomas<Spheroid, CalculationType>, P1, P2>::type
|
||||
apply(thomas<Spheroid, CalculationType> const& , T const& value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace services
|
||||
#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
|
||||
}} // namespace strategy::distance
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_THOMAS_HPP
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2014-2017.
|
||||
// Modifications copyright (c) 2014-2017 Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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_GEOGRAPHIC_VINCENTY_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_VINCENTY_HPP
|
||||
|
||||
|
||||
#include <boost/geometry/strategies/geographic/distance.hpp>
|
||||
#include <boost/geometry/strategies/geographic/parameters.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace distance
|
||||
{
|
||||
|
||||
/*!
|
||||
\brief Distance calculation formulae on latlong coordinates, after Vincenty, 1975
|
||||
\ingroup distance
|
||||
\tparam Spheroid The reference spheroid model
|
||||
\tparam CalculationType \tparam_calculation
|
||||
\author See
|
||||
- http://www.ngs.noaa.gov/PUBS_LIB/inverse.pdf
|
||||
- http://www.icsm.gov.au/gda/gdav2.3.pdf
|
||||
\author Adapted from various implementations to get it close to the original document
|
||||
- http://www.movable-type.co.uk/scripts/LatLongVincenty.html
|
||||
- http://exogen.case.edu/projects/geopy/source/geopy.distance.html
|
||||
- http://futureboy.homeip.net/fsp/colorize.fsp?fileName=navigation.frink
|
||||
|
||||
*/
|
||||
template
|
||||
<
|
||||
typename Spheroid = srs::spheroid<double>,
|
||||
typename CalculationType = void
|
||||
>
|
||||
class vincenty
|
||||
: public strategy::distance::geographic
|
||||
<
|
||||
strategy::vincenty, Spheroid, CalculationType
|
||||
>
|
||||
{
|
||||
typedef strategy::distance::geographic
|
||||
<
|
||||
strategy::vincenty, Spheroid, CalculationType
|
||||
> base_type;
|
||||
|
||||
public:
|
||||
inline vincenty()
|
||||
: base_type()
|
||||
{}
|
||||
|
||||
explicit inline vincenty(Spheroid const& spheroid)
|
||||
: base_type(spheroid)
|
||||
{}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
namespace services
|
||||
{
|
||||
|
||||
template <typename Spheroid, typename CalculationType>
|
||||
struct tag<vincenty<Spheroid, CalculationType> >
|
||||
{
|
||||
typedef strategy_tag_distance_point_point type;
|
||||
};
|
||||
|
||||
|
||||
template <typename Spheroid, typename CalculationType, typename P1, typename P2>
|
||||
struct return_type<vincenty<Spheroid, CalculationType>, P1, P2>
|
||||
: vincenty<Spheroid, CalculationType>::template calculation_type<P1, P2>
|
||||
{};
|
||||
|
||||
|
||||
template <typename Spheroid, typename CalculationType>
|
||||
struct comparable_type<vincenty<Spheroid, CalculationType> >
|
||||
{
|
||||
typedef vincenty<Spheroid, CalculationType> type;
|
||||
};
|
||||
|
||||
|
||||
template <typename Spheroid, typename CalculationType>
|
||||
struct get_comparable<vincenty<Spheroid, CalculationType> >
|
||||
{
|
||||
static inline vincenty<Spheroid, CalculationType> apply(vincenty<Spheroid, CalculationType> const& input)
|
||||
{
|
||||
return input;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Spheroid, typename CalculationType, typename P1, typename P2>
|
||||
struct result_from_distance<vincenty<Spheroid, CalculationType>, P1, P2 >
|
||||
{
|
||||
template <typename T>
|
||||
static inline typename return_type<vincenty<Spheroid, CalculationType>, P1, P2>::type
|
||||
apply(vincenty<Spheroid, CalculationType> const& , T const& value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace services
|
||||
#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
|
||||
// We might add a vincenty-like strategy also for point-segment distance, but to calculate the projected point is not trivial
|
||||
|
||||
|
||||
|
||||
}} // namespace strategy::distance
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_VINCENTY_HPP
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2020, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Licensed under the Boost Software License version 1.0.
|
||||
// http://www.boost.org/users/license.html
|
||||
|
||||
#ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_ENVELOPE_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_ENVELOPE_HPP
|
||||
|
||||
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.")
|
||||
|
||||
|
||||
#include <boost/geometry/strategy/geographic/envelope.hpp>
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_ENVELOPE_HPP
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2020, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Licensed under the Boost Software License version 1.0.
|
||||
// http://www.boost.org/users/license.html
|
||||
|
||||
#ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_ENVELOPE_SEGMENT_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_ENVELOPE_SEGMENT_HPP
|
||||
|
||||
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.")
|
||||
|
||||
|
||||
#include <boost/geometry/strategy/geographic/envelope_segment.hpp>
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_ENVELOPE_SEGMENT_HPP
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2020, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Licensed under the Boost Software License version 1.0.
|
||||
// http://www.boost.org/users/license.html
|
||||
|
||||
#ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_EXPAND_SEGMENT_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_EXPAND_SEGMENT_HPP
|
||||
|
||||
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.")
|
||||
|
||||
|
||||
#include <boost/geometry/strategy/geographic/expand_segment.hpp>
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_EXPAND_SEGMENT_HPP
|
||||
+889
@@ -0,0 +1,889 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// Copyright (c) 2016-2021, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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_GEOGRAPHIC_INTERSECTION_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_INTERSECTION_HPP
|
||||
|
||||
#include <algorithm>
|
||||
#include <type_traits>
|
||||
|
||||
#include <boost/geometry/core/cs.hpp>
|
||||
#include <boost/geometry/core/access.hpp>
|
||||
#include <boost/geometry/core/radian_access.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/assign_values.hpp>
|
||||
#include <boost/geometry/algorithms/detail/assign_indexed_point.hpp>
|
||||
#include <boost/geometry/algorithms/detail/equals/point_point.hpp>
|
||||
#include <boost/geometry/algorithms/detail/recalculate.hpp>
|
||||
|
||||
#include <boost/geometry/formulas/andoyer_inverse.hpp>
|
||||
#include <boost/geometry/formulas/sjoberg_intersection.hpp>
|
||||
#include <boost/geometry/formulas/spherical.hpp>
|
||||
#include <boost/geometry/formulas/unit_spheroid.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/concepts/point_concept.hpp>
|
||||
#include <boost/geometry/geometries/concepts/segment_concept.hpp>
|
||||
#include <boost/geometry/geometries/segment.hpp>
|
||||
|
||||
#include <boost/geometry/policies/robustness/segment_ratio.hpp>
|
||||
|
||||
#include <boost/geometry/srs/spheroid.hpp>
|
||||
|
||||
#include <boost/geometry/strategy/geographic/area.hpp>
|
||||
#include <boost/geometry/strategy/geographic/envelope.hpp>
|
||||
#include <boost/geometry/strategy/geographic/expand_segment.hpp>
|
||||
#include <boost/geometry/strategy/spherical/expand_box.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/geographic/disjoint_segment_box.hpp>
|
||||
#include <boost/geometry/strategies/geographic/distance.hpp>
|
||||
#include <boost/geometry/strategies/geographic/parameters.hpp>
|
||||
#include <boost/geometry/strategies/geographic/point_in_poly_winding.hpp>
|
||||
#include <boost/geometry/strategies/geographic/side.hpp>
|
||||
#include <boost/geometry/strategies/spherical/disjoint_box_box.hpp>
|
||||
#include <boost/geometry/strategies/spherical/point_in_point.hpp>
|
||||
#include <boost/geometry/strategies/intersection.hpp>
|
||||
#include <boost/geometry/strategies/intersection_result.hpp>
|
||||
#include <boost/geometry/strategies/side_info.hpp>
|
||||
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
#include <boost/geometry/util/select_calculation_type.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace intersection
|
||||
{
|
||||
|
||||
// CONSIDER: Improvement of the robustness/accuracy/repeatability by
|
||||
// moving all segments to 0 longitude
|
||||
// picking latitudes closer to 0
|
||||
// etc.
|
||||
|
||||
template
|
||||
<
|
||||
typename FormulaPolicy = strategy::andoyer,
|
||||
std::size_t Order = strategy::default_order<FormulaPolicy>::value,
|
||||
typename Spheroid = srs::spheroid<double>,
|
||||
typename CalculationType = void
|
||||
>
|
||||
struct geographic_segments
|
||||
{
|
||||
typedef geographic_tag cs_tag;
|
||||
|
||||
enum intersection_point_flag { ipi_inters = 0, ipi_at_a1, ipi_at_a2, ipi_at_b1, ipi_at_b2 };
|
||||
|
||||
template <typename CoordinateType, typename SegmentRatio>
|
||||
struct segment_intersection_info
|
||||
{
|
||||
template <typename Point, typename Segment1, typename Segment2>
|
||||
void calculate(Point& point, Segment1 const& a, Segment2 const& b) const
|
||||
{
|
||||
if (ip_flag == ipi_inters)
|
||||
{
|
||||
// TODO: assign the rest of coordinates
|
||||
set_from_radian<0>(point, lon);
|
||||
set_from_radian<1>(point, lat);
|
||||
}
|
||||
else if (ip_flag == ipi_at_a1)
|
||||
{
|
||||
detail::assign_point_from_index<0>(a, point);
|
||||
}
|
||||
else if (ip_flag == ipi_at_a2)
|
||||
{
|
||||
detail::assign_point_from_index<1>(a, point);
|
||||
}
|
||||
else if (ip_flag == ipi_at_b1)
|
||||
{
|
||||
detail::assign_point_from_index<0>(b, point);
|
||||
}
|
||||
else // ip_flag == ipi_at_b2
|
||||
{
|
||||
detail::assign_point_from_index<1>(b, point);
|
||||
}
|
||||
}
|
||||
|
||||
CoordinateType lon;
|
||||
CoordinateType lat;
|
||||
SegmentRatio robust_ra;
|
||||
SegmentRatio robust_rb;
|
||||
intersection_point_flag ip_flag;
|
||||
};
|
||||
|
||||
explicit geographic_segments(Spheroid const& spheroid = Spheroid())
|
||||
: m_spheroid(spheroid)
|
||||
{}
|
||||
|
||||
Spheroid model() const
|
||||
{
|
||||
return m_spheroid;
|
||||
}
|
||||
|
||||
// Relate segments a and b
|
||||
template
|
||||
<
|
||||
typename UniqueSubRange1,
|
||||
typename UniqueSubRange2,
|
||||
typename Policy
|
||||
>
|
||||
inline typename Policy::return_type apply(UniqueSubRange1 const& range_p,
|
||||
UniqueSubRange2 const& range_q,
|
||||
Policy const&) const
|
||||
{
|
||||
typedef typename UniqueSubRange1::point_type point1_type;
|
||||
typedef typename UniqueSubRange2::point_type point2_type;
|
||||
typedef model::referring_segment<point1_type const> segment_type1;
|
||||
typedef model::referring_segment<point2_type const> segment_type2;
|
||||
|
||||
BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<point1_type>) );
|
||||
BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<point2_type>) );
|
||||
|
||||
/*
|
||||
typename coordinate_type<Point1>::type
|
||||
const a1_lon = get<0>(a1),
|
||||
const a2_lon = get<0>(a2);
|
||||
typename coordinate_type<Point2>::type
|
||||
const b1_lon = get<0>(b1),
|
||||
const b2_lon = get<0>(b2);
|
||||
bool is_a_reversed = a1_lon > a2_lon || a1_lon == a2_lon && get<1>(a1) > get<1>(a2);
|
||||
bool is_b_reversed = b1_lon > b2_lon || b1_lon == b2_lon && get<1>(b1) > get<1>(b2);
|
||||
*/
|
||||
|
||||
point1_type const& p0 = range_p.at(0);
|
||||
point1_type const& p1 = range_p.at(1);
|
||||
point2_type const& q0 = range_q.at(0);
|
||||
point2_type const& q1 = range_q.at(1);
|
||||
|
||||
bool const is_p_reversed = get<1>(p0) > get<1>(p1);
|
||||
bool const is_q_reversed = get<1>(q0) > get<1>(q1);
|
||||
|
||||
// Call apply with original segments and ordered points
|
||||
return apply<Policy>(segment_type1(p0, p1),
|
||||
segment_type2(q0, q1),
|
||||
(is_p_reversed ? p1 : p0),
|
||||
(is_p_reversed ? p0 : p1),
|
||||
(is_q_reversed ? q1 : q0),
|
||||
(is_q_reversed ? q0 : q1),
|
||||
is_p_reversed, is_q_reversed);
|
||||
}
|
||||
|
||||
private:
|
||||
// Relate segments a and b
|
||||
template
|
||||
<
|
||||
typename Policy,
|
||||
typename Segment1,
|
||||
typename Segment2,
|
||||
typename Point1,
|
||||
typename Point2
|
||||
>
|
||||
inline typename Policy::return_type apply(Segment1 const& a, Segment2 const& b,
|
||||
Point1 const& a1, Point1 const& a2,
|
||||
Point2 const& b1, Point2 const& b2,
|
||||
bool is_a_reversed, bool is_b_reversed) const
|
||||
{
|
||||
BOOST_CONCEPT_ASSERT( (concepts::ConstSegment<Segment1>) );
|
||||
BOOST_CONCEPT_ASSERT( (concepts::ConstSegment<Segment2>) );
|
||||
|
||||
typedef typename select_calculation_type
|
||||
<Segment1, Segment2, CalculationType>::type calc_t;
|
||||
|
||||
typedef srs::spheroid<calc_t> spheroid_type;
|
||||
|
||||
static const calc_t c0 = 0;
|
||||
|
||||
// normalized spheroid
|
||||
spheroid_type spheroid = formula::unit_spheroid<spheroid_type>(m_spheroid);
|
||||
|
||||
// TODO: check only 2 first coordinates here?
|
||||
bool a_is_point = equals_point_point(a1, a2);
|
||||
bool b_is_point = equals_point_point(b1, b2);
|
||||
|
||||
if(a_is_point && b_is_point)
|
||||
{
|
||||
return equals_point_point(a1, b2)
|
||||
? Policy::degenerate(a, true)
|
||||
: Policy::disjoint()
|
||||
;
|
||||
}
|
||||
|
||||
calc_t const a1_lon = get_as_radian<0>(a1);
|
||||
calc_t const a1_lat = get_as_radian<1>(a1);
|
||||
calc_t const a2_lon = get_as_radian<0>(a2);
|
||||
calc_t const a2_lat = get_as_radian<1>(a2);
|
||||
calc_t const b1_lon = get_as_radian<0>(b1);
|
||||
calc_t const b1_lat = get_as_radian<1>(b1);
|
||||
calc_t const b2_lon = get_as_radian<0>(b2);
|
||||
calc_t const b2_lat = get_as_radian<1>(b2);
|
||||
|
||||
side_info sides;
|
||||
|
||||
// NOTE: potential optimization, don't calculate distance at this point
|
||||
// this would require to reimplement inverse strategy to allow
|
||||
// calculation of distance if needed, probably also storing intermediate
|
||||
// results somehow inside an object.
|
||||
typedef typename FormulaPolicy::template inverse<calc_t, true, true, false, false, false> inverse_dist_azi;
|
||||
typedef typename inverse_dist_azi::result_type inverse_result;
|
||||
|
||||
// TODO: no need to call inverse formula if we know that the points are equal
|
||||
// distance can be set to 0 in this case and azimuth may be not calculated
|
||||
bool is_equal_a1_b1 = equals_point_point(a1, b1);
|
||||
bool is_equal_a2_b1 = equals_point_point(a2, b1);
|
||||
bool degen_neq_coords = false;
|
||||
|
||||
inverse_result res_b1_b2, res_b1_a1, res_b1_a2;
|
||||
if (! b_is_point)
|
||||
{
|
||||
res_b1_b2 = inverse_dist_azi::apply(b1_lon, b1_lat, b2_lon, b2_lat, spheroid);
|
||||
if (math::equals(res_b1_b2.distance, c0))
|
||||
{
|
||||
b_is_point = true;
|
||||
degen_neq_coords = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
res_b1_a1 = inverse_dist_azi::apply(b1_lon, b1_lat, a1_lon, a1_lat, spheroid);
|
||||
if (math::equals(res_b1_a1.distance, c0))
|
||||
{
|
||||
is_equal_a1_b1 = true;
|
||||
}
|
||||
res_b1_a2 = inverse_dist_azi::apply(b1_lon, b1_lat, a2_lon, a2_lat, spheroid);
|
||||
if (math::equals(res_b1_a2.distance, c0))
|
||||
{
|
||||
is_equal_a2_b1 = true;
|
||||
}
|
||||
sides.set<0>(is_equal_a1_b1 ? 0 : formula::azimuth_side_value(res_b1_a1.azimuth, res_b1_b2.azimuth),
|
||||
is_equal_a2_b1 ? 0 : formula::azimuth_side_value(res_b1_a2.azimuth, res_b1_b2.azimuth));
|
||||
if (sides.same<0>())
|
||||
{
|
||||
// Both points are at the same side of other segment, we can leave
|
||||
return Policy::disjoint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool is_equal_a1_b2 = equals_point_point(a1, b2);
|
||||
|
||||
inverse_result res_a1_a2, res_a1_b1, res_a1_b2;
|
||||
if (! a_is_point)
|
||||
{
|
||||
res_a1_a2 = inverse_dist_azi::apply(a1_lon, a1_lat, a2_lon, a2_lat, spheroid);
|
||||
if (math::equals(res_a1_a2.distance, c0))
|
||||
{
|
||||
a_is_point = true;
|
||||
degen_neq_coords = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
res_a1_b1 = inverse_dist_azi::apply(a1_lon, a1_lat, b1_lon, b1_lat, spheroid);
|
||||
if (math::equals(res_a1_b1.distance, c0))
|
||||
{
|
||||
is_equal_a1_b1 = true;
|
||||
}
|
||||
res_a1_b2 = inverse_dist_azi::apply(a1_lon, a1_lat, b2_lon, b2_lat, spheroid);
|
||||
if (math::equals(res_a1_b2.distance, c0))
|
||||
{
|
||||
is_equal_a1_b2 = true;
|
||||
}
|
||||
sides.set<1>(is_equal_a1_b1 ? 0 : formula::azimuth_side_value(res_a1_b1.azimuth, res_a1_a2.azimuth),
|
||||
is_equal_a1_b2 ? 0 : formula::azimuth_side_value(res_a1_b2.azimuth, res_a1_a2.azimuth));
|
||||
if (sides.same<1>())
|
||||
{
|
||||
// Both points are at the same side of other segment, we can leave
|
||||
return Policy::disjoint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(a_is_point && b_is_point)
|
||||
{
|
||||
return is_equal_a1_b2
|
||||
? Policy::degenerate(a, true)
|
||||
: Policy::disjoint()
|
||||
;
|
||||
}
|
||||
|
||||
// NOTE: at this point the segments may still be disjoint
|
||||
// NOTE: at this point one of the segments may be degenerated
|
||||
|
||||
bool collinear = sides.collinear();
|
||||
|
||||
if (! collinear)
|
||||
{
|
||||
// WARNING: the side strategy doesn't have the info about the other
|
||||
// segment so it may return results inconsistent with this intersection
|
||||
// strategy, as it checks both segments for consistency
|
||||
|
||||
if (sides.get<0, 0>() == 0 && sides.get<0, 1>() == 0)
|
||||
{
|
||||
collinear = true;
|
||||
sides.set<1>(0, 0);
|
||||
}
|
||||
else if (sides.get<1, 0>() == 0 && sides.get<1, 1>() == 0)
|
||||
{
|
||||
collinear = true;
|
||||
sides.set<0>(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (collinear)
|
||||
{
|
||||
if (a_is_point)
|
||||
{
|
||||
return collinear_one_degenerated<Policy, calc_t>(a, true, b1, b2, a1, a2, res_b1_b2, res_b1_a1, res_b1_a2, is_b_reversed, degen_neq_coords);
|
||||
}
|
||||
else if (b_is_point)
|
||||
{
|
||||
return collinear_one_degenerated<Policy, calc_t>(b, false, a1, a2, b1, b2, res_a1_a2, res_a1_b1, res_a1_b2, is_a_reversed, degen_neq_coords);
|
||||
}
|
||||
else
|
||||
{
|
||||
calc_t dist_a1_a2, dist_a1_b1, dist_a1_b2;
|
||||
calc_t dist_b1_b2, dist_b1_a1, dist_b1_a2;
|
||||
// use shorter segment
|
||||
if (res_a1_a2.distance <= res_b1_b2.distance)
|
||||
{
|
||||
calculate_collinear_data(a1, a2, b1, b2, res_a1_a2, res_a1_b1, res_a1_b2, dist_a1_a2, dist_a1_b1);
|
||||
calculate_collinear_data(a1, a2, b2, b1, res_a1_a2, res_a1_b2, res_a1_b1, dist_a1_a2, dist_a1_b2);
|
||||
dist_b1_b2 = dist_a1_b2 - dist_a1_b1;
|
||||
dist_b1_a1 = -dist_a1_b1;
|
||||
dist_b1_a2 = dist_a1_a2 - dist_a1_b1;
|
||||
}
|
||||
else
|
||||
{
|
||||
calculate_collinear_data(b1, b2, a1, a2, res_b1_b2, res_b1_a1, res_b1_a2, dist_b1_b2, dist_b1_a1);
|
||||
calculate_collinear_data(b1, b2, a2, a1, res_b1_b2, res_b1_a2, res_b1_a1, dist_b1_b2, dist_b1_a2);
|
||||
dist_a1_a2 = dist_b1_a2 - dist_b1_a1;
|
||||
dist_a1_b1 = -dist_b1_a1;
|
||||
dist_a1_b2 = dist_b1_b2 - dist_b1_a1;
|
||||
}
|
||||
|
||||
// NOTE: this is probably not needed
|
||||
int a1_on_b = position_value(c0, dist_a1_b1, dist_a1_b2);
|
||||
int a2_on_b = position_value(dist_a1_a2, dist_a1_b1, dist_a1_b2);
|
||||
int b1_on_a = position_value(c0, dist_b1_a1, dist_b1_a2);
|
||||
int b2_on_a = position_value(dist_b1_b2, dist_b1_a1, dist_b1_a2);
|
||||
|
||||
if ((a1_on_b < 1 && a2_on_b < 1) || (a1_on_b > 3 && a2_on_b > 3))
|
||||
{
|
||||
return Policy::disjoint();
|
||||
}
|
||||
|
||||
if (a1_on_b == 1)
|
||||
{
|
||||
dist_b1_a1 = 0;
|
||||
dist_a1_b1 = 0;
|
||||
}
|
||||
else if (a1_on_b == 3)
|
||||
{
|
||||
dist_b1_a1 = dist_b1_b2;
|
||||
dist_a1_b2 = 0;
|
||||
}
|
||||
|
||||
if (a2_on_b == 1)
|
||||
{
|
||||
dist_b1_a2 = 0;
|
||||
dist_a1_b1 = dist_a1_a2;
|
||||
}
|
||||
else if (a2_on_b == 3)
|
||||
{
|
||||
dist_b1_a2 = dist_b1_b2;
|
||||
dist_a1_b2 = dist_a1_a2;
|
||||
}
|
||||
|
||||
bool opposite = ! same_direction(res_a1_a2.azimuth, res_b1_b2.azimuth);
|
||||
|
||||
// NOTE: If segment was reversed opposite, positions and segment ratios has to be altered
|
||||
if (is_a_reversed)
|
||||
{
|
||||
// opposite
|
||||
opposite = ! opposite;
|
||||
// positions
|
||||
std::swap(a1_on_b, a2_on_b);
|
||||
b1_on_a = 4 - b1_on_a;
|
||||
b2_on_a = 4 - b2_on_a;
|
||||
// distances for ratios
|
||||
std::swap(dist_b1_a1, dist_b1_a2);
|
||||
dist_a1_b1 = dist_a1_a2 - dist_a1_b1;
|
||||
dist_a1_b2 = dist_a1_a2 - dist_a1_b2;
|
||||
}
|
||||
if (is_b_reversed)
|
||||
{
|
||||
// opposite
|
||||
opposite = ! opposite;
|
||||
// positions
|
||||
a1_on_b = 4 - a1_on_b;
|
||||
a2_on_b = 4 - a2_on_b;
|
||||
std::swap(b1_on_a, b2_on_a);
|
||||
// distances for ratios
|
||||
dist_b1_a1 = dist_b1_b2 - dist_b1_a1;
|
||||
dist_b1_a2 = dist_b1_b2 - dist_b1_a2;
|
||||
std::swap(dist_a1_b1, dist_a1_b2);
|
||||
}
|
||||
|
||||
segment_ratio<calc_t> ra_from(dist_b1_a1, dist_b1_b2);
|
||||
segment_ratio<calc_t> ra_to(dist_b1_a2, dist_b1_b2);
|
||||
segment_ratio<calc_t> rb_from(dist_a1_b1, dist_a1_a2);
|
||||
segment_ratio<calc_t> rb_to(dist_a1_b2, dist_a1_a2);
|
||||
|
||||
return Policy::segments_collinear(a, b, opposite,
|
||||
a1_on_b, a2_on_b, b1_on_a, b2_on_a,
|
||||
ra_from, ra_to, rb_from, rb_to);
|
||||
}
|
||||
}
|
||||
else // crossing or touching
|
||||
{
|
||||
if (a_is_point || b_is_point)
|
||||
{
|
||||
return Policy::disjoint();
|
||||
}
|
||||
|
||||
calc_t lon = 0, lat = 0;
|
||||
intersection_point_flag ip_flag;
|
||||
calc_t dist_a1_a2, dist_a1_i1, dist_b1_b2, dist_b1_i1;
|
||||
if (calculate_ip_data(a1, a2, b1, b2,
|
||||
a1_lon, a1_lat, a2_lon, a2_lat,
|
||||
b1_lon, b1_lat, b2_lon, b2_lat,
|
||||
res_a1_a2, res_a1_b1, res_a1_b2,
|
||||
res_b1_b2, res_b1_a1, res_b1_a2,
|
||||
sides, spheroid,
|
||||
lon, lat,
|
||||
dist_a1_a2, dist_a1_i1, dist_b1_b2, dist_b1_i1,
|
||||
ip_flag))
|
||||
{
|
||||
// NOTE: If segment was reversed sides and segment ratios has to be altered
|
||||
if (is_a_reversed)
|
||||
{
|
||||
// sides
|
||||
sides_reverse_segment<0>(sides);
|
||||
// distance for ratio
|
||||
dist_a1_i1 = dist_a1_a2 - dist_a1_i1;
|
||||
// ip flag
|
||||
ip_flag_reverse_segment(ip_flag, ipi_at_a1, ipi_at_a2);
|
||||
}
|
||||
if (is_b_reversed)
|
||||
{
|
||||
// sides
|
||||
sides_reverse_segment<1>(sides);
|
||||
// distance for ratio
|
||||
dist_b1_i1 = dist_b1_b2 - dist_b1_i1;
|
||||
// ip flag
|
||||
ip_flag_reverse_segment(ip_flag, ipi_at_b1, ipi_at_b2);
|
||||
}
|
||||
|
||||
// intersects
|
||||
segment_intersection_info
|
||||
<
|
||||
calc_t,
|
||||
segment_ratio<calc_t>
|
||||
> sinfo;
|
||||
|
||||
sinfo.lon = lon;
|
||||
sinfo.lat = lat;
|
||||
sinfo.robust_ra.assign(dist_a1_i1, dist_a1_a2);
|
||||
sinfo.robust_rb.assign(dist_b1_i1, dist_b1_b2);
|
||||
sinfo.ip_flag = ip_flag;
|
||||
|
||||
return Policy::segments_crosses(sides, sinfo, a, b);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Policy::disjoint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Policy, typename CalcT, typename Segment, typename Point1, typename Point2, typename ResultInverse>
|
||||
static inline typename Policy::return_type
|
||||
collinear_one_degenerated(Segment const& segment, bool degenerated_a,
|
||||
Point1 const& a1, Point1 const& a2,
|
||||
Point2 const& b1, Point2 const& b2,
|
||||
ResultInverse const& res_a1_a2,
|
||||
ResultInverse const& res_a1_b1,
|
||||
ResultInverse const& res_a1_b2,
|
||||
bool is_other_reversed,
|
||||
bool degen_neq_coords)
|
||||
{
|
||||
CalcT dist_1_2, dist_1_o;
|
||||
if (! calculate_collinear_data(a1, a2, b1, b2, res_a1_a2, res_a1_b1, res_a1_b2, dist_1_2, dist_1_o, degen_neq_coords))
|
||||
{
|
||||
return Policy::disjoint();
|
||||
}
|
||||
|
||||
// NOTE: If segment was reversed segment ratio has to be altered
|
||||
if (is_other_reversed)
|
||||
{
|
||||
// distance for ratio
|
||||
dist_1_o = dist_1_2 - dist_1_o;
|
||||
}
|
||||
|
||||
return Policy::one_degenerate(segment, segment_ratio<CalcT>(dist_1_o, dist_1_2), degenerated_a);
|
||||
}
|
||||
|
||||
// TODO: instead of checks below test bi against a1 and a2 here?
|
||||
// in order to make this independent from is_near()
|
||||
template <typename Point1, typename Point2, typename ResultInverse, typename CalcT>
|
||||
static inline bool calculate_collinear_data(Point1 const& a1, Point1 const& a2, // in
|
||||
Point2 const& b1, Point2 const& /*b2*/, // in
|
||||
ResultInverse const& res_a1_a2, // in
|
||||
ResultInverse const& res_a1_b1, // in
|
||||
ResultInverse const& res_a1_b2, // in
|
||||
CalcT& dist_a1_a2, // out
|
||||
CalcT& dist_a1_b1, // out
|
||||
bool degen_neq_coords = false) // in
|
||||
{
|
||||
dist_a1_a2 = res_a1_a2.distance;
|
||||
|
||||
dist_a1_b1 = res_a1_b1.distance;
|
||||
if (! same_direction(res_a1_b1.azimuth, res_a1_a2.azimuth))
|
||||
{
|
||||
dist_a1_b1 = -dist_a1_b1;
|
||||
}
|
||||
|
||||
// if b1 is close a1
|
||||
if (is_endpoint_equal(dist_a1_b1, a1, b1))
|
||||
{
|
||||
dist_a1_b1 = 0;
|
||||
return true;
|
||||
}
|
||||
// if b1 is close a2
|
||||
else if (is_endpoint_equal(dist_a1_a2 - dist_a1_b1, a2, b1))
|
||||
{
|
||||
dist_a1_b1 = dist_a1_a2;
|
||||
return true;
|
||||
}
|
||||
|
||||
// check the other endpoint of degenerated segment near a pole
|
||||
if (degen_neq_coords)
|
||||
{
|
||||
static CalcT const c0 = 0;
|
||||
if (math::equals(res_a1_b2.distance, c0))
|
||||
{
|
||||
dist_a1_b1 = 0;
|
||||
return true;
|
||||
}
|
||||
else if (math::equals(dist_a1_a2 - res_a1_b2.distance, c0))
|
||||
{
|
||||
dist_a1_b1 = dist_a1_a2;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// or i1 is on b
|
||||
return segment_ratio<CalcT>(dist_a1_b1, dist_a1_a2).on_segment();
|
||||
}
|
||||
|
||||
template <typename Point1, typename Point2, typename CalcT, typename ResultInverse, typename Spheroid_>
|
||||
static inline bool calculate_ip_data(Point1 const& a1, Point1 const& a2, // in
|
||||
Point2 const& b1, Point2 const& b2, // in
|
||||
CalcT const& a1_lon, CalcT const& a1_lat, // in
|
||||
CalcT const& a2_lon, CalcT const& a2_lat, // in
|
||||
CalcT const& b1_lon, CalcT const& b1_lat, // in
|
||||
CalcT const& b2_lon, CalcT const& b2_lat, // in
|
||||
ResultInverse const& res_a1_a2, // in
|
||||
ResultInverse const& res_a1_b1, // in
|
||||
ResultInverse const& res_a1_b2, // in
|
||||
ResultInverse const& res_b1_b2, // in
|
||||
ResultInverse const& res_b1_a1, // in
|
||||
ResultInverse const& res_b1_a2, // in
|
||||
side_info const& sides, // in
|
||||
Spheroid_ const& spheroid, // in
|
||||
CalcT & lon, CalcT & lat, // out
|
||||
CalcT& dist_a1_a2, CalcT& dist_a1_ip, // out
|
||||
CalcT& dist_b1_b2, CalcT& dist_b1_ip, // out
|
||||
intersection_point_flag& ip_flag) // out
|
||||
{
|
||||
dist_a1_a2 = res_a1_a2.distance;
|
||||
dist_b1_b2 = res_b1_b2.distance;
|
||||
|
||||
// assign the IP if some endpoints overlap
|
||||
if (equals_point_point(a1, b1))
|
||||
{
|
||||
lon = a1_lon;
|
||||
lat = a1_lat;
|
||||
dist_a1_ip = 0;
|
||||
dist_b1_ip = 0;
|
||||
ip_flag = ipi_at_a1;
|
||||
return true;
|
||||
}
|
||||
else if (equals_point_point(a1, b2))
|
||||
{
|
||||
lon = a1_lon;
|
||||
lat = a1_lat;
|
||||
dist_a1_ip = 0;
|
||||
dist_b1_ip = dist_b1_b2;
|
||||
ip_flag = ipi_at_a1;
|
||||
return true;
|
||||
}
|
||||
else if (equals_point_point(a2, b1))
|
||||
{
|
||||
lon = a2_lon;
|
||||
lat = a2_lat;
|
||||
dist_a1_ip = dist_a1_a2;
|
||||
dist_b1_ip = 0;
|
||||
ip_flag = ipi_at_a2;
|
||||
return true;
|
||||
}
|
||||
else if (equals_point_point(a2, b2))
|
||||
{
|
||||
lon = a2_lon;
|
||||
lat = a2_lat;
|
||||
dist_a1_ip = dist_a1_a2;
|
||||
dist_b1_ip = dist_b1_b2;
|
||||
ip_flag = ipi_at_a2;
|
||||
return true;
|
||||
}
|
||||
|
||||
// at this point we know that the endpoints doesn't overlap
|
||||
// check cases when an endpoint lies on the other geodesic
|
||||
if (sides.template get<0, 0>() == 0) // a1 wrt b
|
||||
{
|
||||
if (res_b1_a1.distance <= res_b1_b2.distance
|
||||
&& same_direction(res_b1_a1.azimuth, res_b1_b2.azimuth))
|
||||
{
|
||||
lon = a1_lon;
|
||||
lat = a1_lat;
|
||||
dist_a1_ip = 0;
|
||||
dist_b1_ip = res_b1_a1.distance;
|
||||
ip_flag = ipi_at_a1;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (sides.template get<0, 1>() == 0) // a2 wrt b
|
||||
{
|
||||
if (res_b1_a2.distance <= res_b1_b2.distance
|
||||
&& same_direction(res_b1_a2.azimuth, res_b1_b2.azimuth))
|
||||
{
|
||||
lon = a2_lon;
|
||||
lat = a2_lat;
|
||||
dist_a1_ip = res_a1_a2.distance;
|
||||
dist_b1_ip = res_b1_a2.distance;
|
||||
ip_flag = ipi_at_a2;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (sides.template get<1, 0>() == 0) // b1 wrt a
|
||||
{
|
||||
if (res_a1_b1.distance <= res_a1_a2.distance
|
||||
&& same_direction(res_a1_b1.azimuth, res_a1_a2.azimuth))
|
||||
{
|
||||
lon = b1_lon;
|
||||
lat = b1_lat;
|
||||
dist_a1_ip = res_a1_b1.distance;
|
||||
dist_b1_ip = 0;
|
||||
ip_flag = ipi_at_b1;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (sides.template get<1, 1>() == 0) // b2 wrt a
|
||||
{
|
||||
if (res_a1_b2.distance <= res_a1_a2.distance
|
||||
&& same_direction(res_a1_b2.azimuth, res_a1_a2.azimuth))
|
||||
{
|
||||
lon = b2_lon;
|
||||
lat = b2_lat;
|
||||
dist_a1_ip = res_a1_b2.distance;
|
||||
dist_b1_ip = res_b1_b2.distance;
|
||||
ip_flag = ipi_at_b2;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// At this point neither the endpoints overlaps
|
||||
// nor any andpoint lies on the other geodesic
|
||||
// So the endpoints should lie on the opposite sides of both geodesics
|
||||
|
||||
bool const ok = formula::sjoberg_intersection<CalcT, FormulaPolicy::template inverse, Order>
|
||||
::apply(a1_lon, a1_lat, a2_lon, a2_lat, res_a1_a2.azimuth,
|
||||
b1_lon, b1_lat, b2_lon, b2_lat, res_b1_b2.azimuth,
|
||||
lon, lat, spheroid);
|
||||
|
||||
if (! ok)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
typedef typename FormulaPolicy::template inverse<CalcT, true, true, false, false, false> inverse_dist_azi;
|
||||
typedef typename inverse_dist_azi::result_type inverse_result;
|
||||
|
||||
inverse_result const res_a1_ip = inverse_dist_azi::apply(a1_lon, a1_lat, lon, lat, spheroid);
|
||||
dist_a1_ip = res_a1_ip.distance;
|
||||
if (! same_direction(res_a1_ip.azimuth, res_a1_a2.azimuth))
|
||||
{
|
||||
dist_a1_ip = -dist_a1_ip;
|
||||
}
|
||||
|
||||
bool is_on_a = segment_ratio<CalcT>(dist_a1_ip, dist_a1_a2).on_segment();
|
||||
// NOTE: not fully consistent with equals_point_point() since radians are always used.
|
||||
bool is_on_a1 = math::equals(lon, a1_lon) && math::equals(lat, a1_lat);
|
||||
bool is_on_a2 = math::equals(lon, a2_lon) && math::equals(lat, a2_lat);
|
||||
|
||||
if (! (is_on_a || is_on_a1 || is_on_a2))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
inverse_result const res_b1_ip = inverse_dist_azi::apply(b1_lon, b1_lat, lon, lat, spheroid);
|
||||
dist_b1_ip = res_b1_ip.distance;
|
||||
if (! same_direction(res_b1_ip.azimuth, res_b1_b2.azimuth))
|
||||
{
|
||||
dist_b1_ip = -dist_b1_ip;
|
||||
}
|
||||
|
||||
bool is_on_b = segment_ratio<CalcT>(dist_b1_ip, dist_b1_b2).on_segment();
|
||||
// NOTE: not fully consistent with equals_point_point() since radians are always used.
|
||||
bool is_on_b1 = math::equals(lon, b1_lon) && math::equals(lat, b1_lat);
|
||||
bool is_on_b2 = math::equals(lon, b2_lon) && math::equals(lat, b2_lat);
|
||||
|
||||
if (! (is_on_b || is_on_b1 || is_on_b2))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
typedef typename FormulaPolicy::template inverse<CalcT, true, false, false, false, false> inverse_dist;
|
||||
|
||||
ip_flag = ipi_inters;
|
||||
|
||||
if (is_on_b1)
|
||||
{
|
||||
lon = b1_lon;
|
||||
lat = b1_lat;
|
||||
dist_a1_ip = inverse_dist::apply(a1_lon, a1_lat, lon, lat, spheroid).distance; // for consistency
|
||||
dist_b1_ip = 0;
|
||||
ip_flag = ipi_at_b1;
|
||||
}
|
||||
else if (is_on_b2)
|
||||
{
|
||||
lon = b2_lon;
|
||||
lat = b2_lat;
|
||||
dist_a1_ip = inverse_dist::apply(a1_lon, a1_lat, lon, lat, spheroid).distance; // for consistency
|
||||
dist_b1_ip = res_b1_b2.distance;
|
||||
ip_flag = ipi_at_b2;
|
||||
}
|
||||
|
||||
if (is_on_a1)
|
||||
{
|
||||
lon = a1_lon;
|
||||
lat = a1_lat;
|
||||
dist_a1_ip = 0;
|
||||
dist_b1_ip = inverse_dist::apply(b1_lon, b1_lat, lon, lat, spheroid).distance; // for consistency
|
||||
ip_flag = ipi_at_a1;
|
||||
}
|
||||
else if (is_on_a2)
|
||||
{
|
||||
lon = a2_lon;
|
||||
lat = a2_lat;
|
||||
dist_a1_ip = res_a1_a2.distance;
|
||||
dist_b1_ip = inverse_dist::apply(b1_lon, b1_lat, lon, lat, spheroid).distance; // for consistency
|
||||
ip_flag = ipi_at_a2;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename CalcT, typename P1, typename P2>
|
||||
static inline bool is_endpoint_equal(CalcT const& dist,
|
||||
P1 const& ai, P2 const& b1)
|
||||
{
|
||||
static CalcT const c0 = 0;
|
||||
return is_near(dist) && (math::equals(dist, c0) || equals_point_point(ai, b1));
|
||||
}
|
||||
|
||||
template <typename CalcT>
|
||||
static inline bool is_near(CalcT const& dist)
|
||||
{
|
||||
// NOTE: This strongly depends on the Inverse method
|
||||
CalcT const small_number = CalcT(std::is_same<CalcT, float>::value ? 0.0001 : 0.00000001);
|
||||
return math::abs(dist) <= small_number;
|
||||
}
|
||||
|
||||
template <typename ProjCoord1, typename ProjCoord2>
|
||||
static inline int position_value(ProjCoord1 const& ca1,
|
||||
ProjCoord2 const& cb1,
|
||||
ProjCoord2 const& cb2)
|
||||
{
|
||||
// S1x 0 1 2 3 4
|
||||
// S2 |---------->
|
||||
return math::equals(ca1, cb1) ? 1
|
||||
: math::equals(ca1, cb2) ? 3
|
||||
: cb1 < cb2 ?
|
||||
( ca1 < cb1 ? 0
|
||||
: ca1 > cb2 ? 4
|
||||
: 2 )
|
||||
: ( ca1 > cb1 ? 0
|
||||
: ca1 < cb2 ? 4
|
||||
: 2 );
|
||||
}
|
||||
|
||||
template <typename CalcT>
|
||||
static inline bool same_direction(CalcT const& azimuth1, CalcT const& azimuth2)
|
||||
{
|
||||
// distance between two angles normalized to (-180, 180]
|
||||
CalcT const angle_diff = math::longitude_distance_signed<radian>(azimuth1, azimuth2);
|
||||
return math::abs(angle_diff) <= math::half_pi<CalcT>();
|
||||
}
|
||||
|
||||
template <int Which>
|
||||
static inline void sides_reverse_segment(side_info & sides)
|
||||
{
|
||||
// names assuming segment A is reversed (Which == 0)
|
||||
int a1_wrt_b = sides.template get<Which, 0>();
|
||||
int a2_wrt_b = sides.template get<Which, 1>();
|
||||
std::swap(a1_wrt_b, a2_wrt_b);
|
||||
sides.template set<Which>(a1_wrt_b, a2_wrt_b);
|
||||
int b1_wrt_a = sides.template get<1 - Which, 0>();
|
||||
int b2_wrt_a = sides.template get<1 - Which, 1>();
|
||||
sides.template set<1 - Which>(-b1_wrt_a, -b2_wrt_a);
|
||||
}
|
||||
|
||||
static inline void ip_flag_reverse_segment(intersection_point_flag & ip_flag,
|
||||
intersection_point_flag const& ipi_at_p1,
|
||||
intersection_point_flag const& ipi_at_p2)
|
||||
{
|
||||
ip_flag = ip_flag == ipi_at_p1 ? ipi_at_p2 :
|
||||
ip_flag == ipi_at_p2 ? ipi_at_p1 :
|
||||
ip_flag;
|
||||
}
|
||||
|
||||
template <typename Point1, typename Point2>
|
||||
static inline bool equals_point_point(Point1 const& point1, Point2 const& point2)
|
||||
{
|
||||
return strategy::within::spherical_point_point::apply(point1, point2);
|
||||
}
|
||||
|
||||
private:
|
||||
Spheroid m_spheroid;
|
||||
};
|
||||
|
||||
|
||||
}} // namespace strategy::intersection
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_INTERSECTION_HPP
|
||||
Vendored
Executable
+243
@@ -0,0 +1,243 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2016-2017, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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_GEOGRAPHIC_INTERSECTION_ELLIPTIC_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_INTERSECTION_ELLIPTIC_HPP
|
||||
|
||||
|
||||
#include <boost/geometry/srs/spheroid.hpp>
|
||||
|
||||
#include <boost/geometry/formulas/geographic.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/spherical/intersection.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace intersection
|
||||
{
|
||||
|
||||
template <typename Spheroid>
|
||||
struct great_elliptic_segments_calc_policy
|
||||
: spherical_segments_calc_policy
|
||||
{
|
||||
explicit great_elliptic_segments_calc_policy(Spheroid const& spheroid = Spheroid())
|
||||
: m_spheroid(spheroid)
|
||||
{}
|
||||
|
||||
template <typename Point, typename Point3d>
|
||||
Point from_cart3d(Point3d const& point_3d) const
|
||||
{
|
||||
return formula::cart3d_to_geo<Point>(point_3d, m_spheroid);
|
||||
}
|
||||
|
||||
template <typename Point3d, typename Point>
|
||||
Point3d to_cart3d(Point const& point) const
|
||||
{
|
||||
return formula::geo_to_cart3d<Point3d>(point, m_spheroid);
|
||||
}
|
||||
|
||||
// relate_xxx_calc_policy must live londer than plane because it contains
|
||||
// Spheroid object and plane keeps the reference to that object.
|
||||
template <typename Point3d>
|
||||
struct plane
|
||||
{
|
||||
typedef typename coordinate_type<Point3d>::type coord_t;
|
||||
|
||||
// not normalized
|
||||
plane(Point3d const& p1, Point3d const& p2)
|
||||
: normal(cross_product(p1, p2))
|
||||
{}
|
||||
|
||||
int side_value(Point3d const& pt) const
|
||||
{
|
||||
return formula::sph_side_value(normal, pt);
|
||||
}
|
||||
|
||||
coord_t cos_angle_between(Point3d const& p1, Point3d const& p2) const
|
||||
{
|
||||
Point3d v1 = p1;
|
||||
detail::vec_normalize(v1);
|
||||
Point3d v2 = p2;
|
||||
detail::vec_normalize(v2);
|
||||
|
||||
return dot_product(v1, v2);
|
||||
}
|
||||
|
||||
coord_t cos_angle_between(Point3d const& p1, Point3d const& p2, bool & is_forward) const
|
||||
{
|
||||
coord_t const c0 = 0;
|
||||
|
||||
Point3d v1 = p1;
|
||||
detail::vec_normalize(v1);
|
||||
Point3d v2 = p2;
|
||||
detail::vec_normalize(v2);
|
||||
|
||||
is_forward = dot_product(normal, cross_product(v1, v2)) >= c0;
|
||||
return dot_product(v1, v2);
|
||||
}
|
||||
|
||||
Point3d normal;
|
||||
};
|
||||
|
||||
template <typename Point3d>
|
||||
plane<Point3d> get_plane(Point3d const& p1, Point3d const& p2) const
|
||||
{
|
||||
return plane<Point3d>(p1, p2);
|
||||
}
|
||||
|
||||
template <typename Point3d>
|
||||
bool intersection_points(plane<Point3d> const& plane1,
|
||||
plane<Point3d> const& plane2,
|
||||
Point3d & ip1, Point3d & ip2) const
|
||||
{
|
||||
typedef typename coordinate_type<Point3d>::type coord_t;
|
||||
|
||||
Point3d id = cross_product(plane1.normal, plane2.normal);
|
||||
// NOTE: the length should be greater than 0 at this point
|
||||
// NOTE: no need to normalize in this case
|
||||
|
||||
ip1 = formula::projected_to_surface(id, m_spheroid);
|
||||
|
||||
ip2 = ip1;
|
||||
multiply_value(ip2, coord_t(-1));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
Spheroid m_spheroid;
|
||||
};
|
||||
|
||||
template <typename Spheroid>
|
||||
struct experimental_elliptic_segments_calc_policy
|
||||
{
|
||||
explicit experimental_elliptic_segments_calc_policy(Spheroid const& spheroid = Spheroid())
|
||||
: m_spheroid(spheroid)
|
||||
{}
|
||||
|
||||
template <typename Point, typename Point3d>
|
||||
Point from_cart3d(Point3d const& point_3d) const
|
||||
{
|
||||
return formula::cart3d_to_geo<Point>(point_3d, m_spheroid);
|
||||
}
|
||||
|
||||
template <typename Point3d, typename Point>
|
||||
Point3d to_cart3d(Point const& point) const
|
||||
{
|
||||
return formula::geo_to_cart3d<Point3d>(point, m_spheroid);
|
||||
}
|
||||
|
||||
// relate_xxx_calc_policy must live londer than plane because it contains
|
||||
// Spheroid object and plane keeps the reference to that object.
|
||||
template <typename Point3d>
|
||||
struct plane
|
||||
{
|
||||
typedef typename coordinate_type<Point3d>::type coord_t;
|
||||
|
||||
// not normalized
|
||||
plane(Point3d const& p1, Point3d const& p2, Spheroid const& spheroid)
|
||||
: m_spheroid(spheroid)
|
||||
{
|
||||
formula::experimental_elliptic_plane(p1, p2, origin, normal, m_spheroid);
|
||||
}
|
||||
|
||||
int side_value(Point3d const& pt) const
|
||||
{
|
||||
return formula::elliptic_side_value(origin, normal, pt);
|
||||
}
|
||||
|
||||
coord_t cos_angle_between(Point3d const& p1, Point3d const& p2) const
|
||||
{
|
||||
Point3d const v1 = normalized_vec(p1);
|
||||
Point3d const v2 = normalized_vec(p2);
|
||||
return dot_product(v1, v2);
|
||||
}
|
||||
|
||||
coord_t cos_angle_between(Point3d const& p1, Point3d const& p2, bool & is_forward) const
|
||||
{
|
||||
coord_t const c0 = 0;
|
||||
|
||||
Point3d const v1 = normalized_vec(p1);
|
||||
Point3d const v2 = normalized_vec(p2);
|
||||
|
||||
is_forward = dot_product(normal, cross_product(v1, v2)) >= c0;
|
||||
return dot_product(v1, v2);
|
||||
}
|
||||
|
||||
Point3d origin;
|
||||
Point3d normal;
|
||||
|
||||
private:
|
||||
Point3d normalized_vec(Point3d const& p) const
|
||||
{
|
||||
Point3d v = p;
|
||||
subtract_point(v, origin);
|
||||
detail::vec_normalize(v);
|
||||
return v;
|
||||
}
|
||||
|
||||
Spheroid const& m_spheroid;
|
||||
};
|
||||
|
||||
template <typename Point3d>
|
||||
plane<Point3d> get_plane(Point3d const& p1, Point3d const& p2) const
|
||||
{
|
||||
return plane<Point3d>(p1, p2, m_spheroid);
|
||||
}
|
||||
|
||||
template <typename Point3d>
|
||||
bool intersection_points(plane<Point3d> const& plane1,
|
||||
plane<Point3d> const& plane2,
|
||||
Point3d & ip1, Point3d & ip2) const
|
||||
{
|
||||
return formula::planes_spheroid_intersection(plane1.origin, plane1.normal,
|
||||
plane2.origin, plane2.normal,
|
||||
ip1, ip2, m_spheroid);
|
||||
}
|
||||
|
||||
private:
|
||||
Spheroid m_spheroid;
|
||||
};
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
typename Spheroid = srs::spheroid<double>,
|
||||
typename CalculationType = void
|
||||
>
|
||||
struct great_elliptic_segments
|
||||
: ecef_segments
|
||||
<
|
||||
great_elliptic_segments_calc_policy<Spheroid>,
|
||||
CalculationType
|
||||
>
|
||||
{};
|
||||
|
||||
template
|
||||
<
|
||||
typename Spheroid = srs::spheroid<double>,
|
||||
typename CalculationType = void
|
||||
>
|
||||
struct experimental_elliptic_segments
|
||||
: ecef_segments
|
||||
<
|
||||
experimental_elliptic_segments_calc_policy<Spheroid>,
|
||||
CalculationType
|
||||
>
|
||||
{};
|
||||
|
||||
|
||||
}} // namespace strategy::intersection
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_INTERSECTION_ELLIPTIC_HPP
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2018-2021, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Licensed under the Boost Software License version 1.0.
|
||||
// http://www.boost.org/users/license.html
|
||||
|
||||
#ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_LINE_INTERPOLATE_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_LINE_INTERPOLATE_HPP
|
||||
|
||||
#include <boost/geometry/core/assert.hpp>
|
||||
#include <boost/geometry/core/coordinate_dimension.hpp>
|
||||
#include <boost/geometry/core/coordinate_type.hpp>
|
||||
#include <boost/geometry/core/radian_access.hpp>
|
||||
#include <boost/geometry/srs/spheroid.hpp>
|
||||
#include <boost/geometry/strategies/line_interpolate.hpp>
|
||||
#include <boost/geometry/strategies/geographic/parameters.hpp>
|
||||
#include <boost/geometry/util/select_calculation_type.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace line_interpolate
|
||||
{
|
||||
|
||||
|
||||
/*!
|
||||
\brief Interpolate point on a geographic segment.
|
||||
\ingroup strategies
|
||||
\tparam FormulaPolicy The geodesic formulas used internally.
|
||||
\tparam Spheroid The spheroid model.
|
||||
\tparam CalculationType \tparam_calculation
|
||||
|
||||
\qbk{
|
||||
[heading See also]
|
||||
\* [link geometry.reference.algorithms.line_interpolate.line_interpolate_4_with_strategy line_interpolate (with strategy)]
|
||||
\* [link geometry.reference.srs.srs_spheroid srs::spheroid]
|
||||
}
|
||||
*/
|
||||
template
|
||||
<
|
||||
typename FormulaPolicy = strategy::andoyer,
|
||||
typename Spheroid = srs::spheroid<double>,
|
||||
typename CalculationType = void
|
||||
>
|
||||
class geographic
|
||||
{
|
||||
public:
|
||||
geographic() = default;
|
||||
|
||||
explicit geographic(Spheroid const& spheroid)
|
||||
: m_spheroid(spheroid)
|
||||
{}
|
||||
|
||||
template <typename Point, typename Fraction, typename Distance>
|
||||
inline void apply(Point const& p0,
|
||||
Point const& p1,
|
||||
Fraction const& fraction, //fraction of segment
|
||||
Point & p,
|
||||
Distance const& distance) const
|
||||
{
|
||||
typedef typename select_calculation_type_alt
|
||||
<
|
||||
CalculationType,
|
||||
Point
|
||||
>::type calc_t;
|
||||
|
||||
typedef typename FormulaPolicy::template inverse
|
||||
<calc_t, false, true, false, false, false> inverse_t;
|
||||
|
||||
calc_t azimuth = inverse_t::apply(get_as_radian<0>(p0), get_as_radian<1>(p0),
|
||||
get_as_radian<0>(p1), get_as_radian<1>(p1),
|
||||
m_spheroid).azimuth;
|
||||
|
||||
typedef typename FormulaPolicy::template direct
|
||||
<calc_t, true, false, false, false> direct_t;
|
||||
|
||||
typename direct_t::result_type
|
||||
dir_r = direct_t::apply(get_as_radian<0>(p0), get_as_radian<1>(p0),
|
||||
distance * fraction, azimuth,
|
||||
m_spheroid);
|
||||
|
||||
set_from_radian<0>(p, dir_r.lon2);
|
||||
set_from_radian<1>(p, dir_r.lat2);
|
||||
}
|
||||
|
||||
inline Spheroid model() const
|
||||
{
|
||||
return m_spheroid;
|
||||
}
|
||||
|
||||
private:
|
||||
Spheroid m_spheroid;
|
||||
};
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
namespace services
|
||||
{
|
||||
|
||||
template <>
|
||||
struct default_strategy<geographic_tag>
|
||||
{
|
||||
typedef strategy::line_interpolate::geographic<> type;
|
||||
};
|
||||
|
||||
|
||||
} // namespace services
|
||||
#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
|
||||
}} // namespace strategy::line_interpolate
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_LINE_INTERPOLATE_HPP
|
||||
+185
@@ -0,0 +1,185 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2014, 2017.
|
||||
// Modifications copyright (c) 2014-2017 Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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_GEOGRAPHIC_MAPPING_SSF_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_MAPPING_SSF_HPP
|
||||
|
||||
|
||||
#include <boost/core/ignore_unused.hpp>
|
||||
|
||||
#include <boost/geometry/core/coordinate_promotion.hpp>
|
||||
#include <boost/geometry/core/radius.hpp>
|
||||
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
#include <boost/geometry/util/select_calculation_type.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/side.hpp>
|
||||
#include <boost/geometry/strategies/spherical/ssf.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace side
|
||||
{
|
||||
|
||||
|
||||
// An enumeration type defining types of mapping of geographical
|
||||
// latitude to spherical latitude.
|
||||
// See: http://en.wikipedia.org/wiki/Great_ellipse
|
||||
// http://en.wikipedia.org/wiki/Latitude#Auxiliary_latitudes
|
||||
enum mapping_type { mapping_geodetic, mapping_reduced, mapping_geocentric };
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <typename Spheroid, mapping_type Mapping>
|
||||
struct mapper
|
||||
{
|
||||
explicit inline mapper(Spheroid const& /*spheroid*/) {}
|
||||
|
||||
template <typename CalculationType>
|
||||
static inline CalculationType const& apply(CalculationType const& lat)
|
||||
{
|
||||
return lat;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Spheroid>
|
||||
struct mapper<Spheroid, mapping_reduced>
|
||||
{
|
||||
typedef typename promote_floating_point
|
||||
<
|
||||
typename radius_type<Spheroid>::type
|
||||
>::type fraction_type;
|
||||
|
||||
explicit inline mapper(Spheroid const& spheroid)
|
||||
{
|
||||
fraction_type const a = geometry::get_radius<0>(spheroid);
|
||||
fraction_type const b = geometry::get_radius<2>(spheroid);
|
||||
b_div_a = b / a;
|
||||
}
|
||||
|
||||
template <typename CalculationType>
|
||||
inline CalculationType apply(CalculationType const& lat) const
|
||||
{
|
||||
return atan(static_cast<CalculationType>(b_div_a) * tan(lat));
|
||||
}
|
||||
|
||||
fraction_type b_div_a;
|
||||
};
|
||||
|
||||
template <typename Spheroid>
|
||||
struct mapper<Spheroid, mapping_geocentric>
|
||||
{
|
||||
typedef typename promote_floating_point
|
||||
<
|
||||
typename radius_type<Spheroid>::type
|
||||
>::type fraction_type;
|
||||
|
||||
explicit inline mapper(Spheroid const& spheroid)
|
||||
{
|
||||
fraction_type const a = geometry::get_radius<0>(spheroid);
|
||||
fraction_type const b = geometry::get_radius<2>(spheroid);
|
||||
sqr_b_div_a = b / a;
|
||||
sqr_b_div_a *= sqr_b_div_a;
|
||||
}
|
||||
|
||||
template <typename CalculationType>
|
||||
inline CalculationType apply(CalculationType const& lat) const
|
||||
{
|
||||
return atan(static_cast<CalculationType>(sqr_b_div_a) * tan(lat));
|
||||
}
|
||||
|
||||
fraction_type sqr_b_div_a;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
/*!
|
||||
\brief Check at which side of a geographical segment a point lies
|
||||
left of segment (> 0), right of segment (< 0), on segment (0).
|
||||
The check is performed by mapping the geographical coordinates
|
||||
to spherical coordinates and using spherical_side_formula.
|
||||
\ingroup strategies
|
||||
\tparam Spheroid The reference spheroid model
|
||||
\tparam Mapping The type of mapping of geographical to spherical latitude
|
||||
\tparam CalculationType \tparam_calculation
|
||||
*/
|
||||
template <typename Spheroid,
|
||||
mapping_type Mapping = mapping_geodetic,
|
||||
typename CalculationType = void>
|
||||
class mapping_spherical_side_formula
|
||||
{
|
||||
|
||||
public :
|
||||
inline mapping_spherical_side_formula()
|
||||
: m_mapper(Spheroid())
|
||||
{}
|
||||
|
||||
explicit inline mapping_spherical_side_formula(Spheroid const& spheroid)
|
||||
: m_mapper(spheroid)
|
||||
{}
|
||||
|
||||
template <typename P1, typename P2, typename P>
|
||||
inline int apply(P1 const& p1, P2 const& p2, P const& p) const
|
||||
{
|
||||
typedef typename promote_floating_point
|
||||
<
|
||||
typename select_calculation_type_alt
|
||||
<
|
||||
CalculationType,
|
||||
P1, P2, P
|
||||
>::type
|
||||
>::type calculation_type;
|
||||
|
||||
calculation_type lon1 = get_as_radian<0>(p1);
|
||||
calculation_type lat1 = m_mapper.template apply<calculation_type>(get_as_radian<1>(p1));
|
||||
calculation_type lon2 = get_as_radian<0>(p2);
|
||||
calculation_type lat2 = m_mapper.template apply<calculation_type>(get_as_radian<1>(p2));
|
||||
calculation_type lon = get_as_radian<0>(p);
|
||||
calculation_type lat = m_mapper.template apply<calculation_type>(get_as_radian<1>(p));
|
||||
|
||||
return detail::spherical_side_formula(lon1, lat1, lon2, lat2, lon, lat);
|
||||
}
|
||||
|
||||
private:
|
||||
side::detail::mapper<Spheroid, Mapping> const m_mapper;
|
||||
};
|
||||
|
||||
// The specialization for geodetic latitude which can be used directly
|
||||
template <typename Spheroid,
|
||||
typename CalculationType>
|
||||
class mapping_spherical_side_formula<Spheroid, mapping_geodetic, CalculationType>
|
||||
{
|
||||
|
||||
public :
|
||||
inline mapping_spherical_side_formula() {}
|
||||
explicit inline mapping_spherical_side_formula(Spheroid const& /*spheroid*/) {}
|
||||
|
||||
template <typename P1, typename P2, typename P>
|
||||
static inline int apply(P1 const& p1, P2 const& p2, P const& p)
|
||||
{
|
||||
return spherical_side_formula<CalculationType>::apply(p1, p2, p);
|
||||
}
|
||||
};
|
||||
|
||||
}} // namespace strategy::side
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_MAPPING_SSF_HPP
|
||||
+210
@@ -0,0 +1,210 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2017-2020, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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_GEOGRAPHIC_PARAMETERS_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_PARAMETERS_HPP
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include <boost/geometry/core/static_assert.hpp>
|
||||
#include <boost/geometry/formulas/andoyer_inverse.hpp>
|
||||
#include <boost/geometry/formulas/thomas_direct.hpp>
|
||||
#include <boost/geometry/formulas/thomas_inverse.hpp>
|
||||
#include <boost/geometry/formulas/vincenty_direct.hpp>
|
||||
#include <boost/geometry/formulas/vincenty_inverse.hpp>
|
||||
#include <boost/geometry/formulas/karney_direct.hpp>
|
||||
#include <boost/geometry/formulas/karney_inverse.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry { namespace strategy
|
||||
{
|
||||
|
||||
struct andoyer
|
||||
{
|
||||
template
|
||||
<
|
||||
typename CT,
|
||||
bool EnableCoordinates = true,
|
||||
bool EnableReverseAzimuth = false,
|
||||
bool EnableReducedLength = false,
|
||||
bool EnableGeodesicScale = false
|
||||
>
|
||||
struct direct
|
||||
: formula::thomas_direct
|
||||
<
|
||||
CT, false,
|
||||
EnableCoordinates, EnableReverseAzimuth,
|
||||
EnableReducedLength, EnableGeodesicScale
|
||||
>
|
||||
{};
|
||||
|
||||
template
|
||||
<
|
||||
typename CT,
|
||||
bool EnableDistance,
|
||||
bool EnableAzimuth,
|
||||
bool EnableReverseAzimuth = false,
|
||||
bool EnableReducedLength = false,
|
||||
bool EnableGeodesicScale = false
|
||||
>
|
||||
struct inverse
|
||||
: formula::andoyer_inverse
|
||||
<
|
||||
CT, EnableDistance,
|
||||
EnableAzimuth, EnableReverseAzimuth,
|
||||
EnableReducedLength, EnableGeodesicScale
|
||||
>
|
||||
{};
|
||||
};
|
||||
|
||||
struct thomas
|
||||
{
|
||||
template
|
||||
<
|
||||
typename CT,
|
||||
bool EnableCoordinates = true,
|
||||
bool EnableReverseAzimuth = false,
|
||||
bool EnableReducedLength = false,
|
||||
bool EnableGeodesicScale = false
|
||||
>
|
||||
struct direct
|
||||
: formula::thomas_direct
|
||||
<
|
||||
CT, true,
|
||||
EnableCoordinates, EnableReverseAzimuth,
|
||||
EnableReducedLength, EnableGeodesicScale
|
||||
>
|
||||
{};
|
||||
|
||||
template
|
||||
<
|
||||
typename CT,
|
||||
bool EnableDistance,
|
||||
bool EnableAzimuth,
|
||||
bool EnableReverseAzimuth = false,
|
||||
bool EnableReducedLength = false,
|
||||
bool EnableGeodesicScale = false
|
||||
>
|
||||
struct inverse
|
||||
: formula::thomas_inverse
|
||||
<
|
||||
CT, EnableDistance,
|
||||
EnableAzimuth, EnableReverseAzimuth,
|
||||
EnableReducedLength, EnableGeodesicScale
|
||||
>
|
||||
{};
|
||||
};
|
||||
|
||||
struct vincenty
|
||||
{
|
||||
template
|
||||
<
|
||||
typename CT,
|
||||
bool EnableCoordinates = true,
|
||||
bool EnableReverseAzimuth = false,
|
||||
bool EnableReducedLength = false,
|
||||
bool EnableGeodesicScale = false
|
||||
>
|
||||
struct direct
|
||||
: formula::vincenty_direct
|
||||
<
|
||||
CT, EnableCoordinates, EnableReverseAzimuth,
|
||||
EnableReducedLength, EnableGeodesicScale
|
||||
>
|
||||
{};
|
||||
|
||||
template
|
||||
<
|
||||
typename CT,
|
||||
bool EnableDistance,
|
||||
bool EnableAzimuth,
|
||||
bool EnableReverseAzimuth = false,
|
||||
bool EnableReducedLength = false,
|
||||
bool EnableGeodesicScale = false
|
||||
>
|
||||
struct inverse
|
||||
: formula::vincenty_inverse
|
||||
<
|
||||
CT, EnableDistance,
|
||||
EnableAzimuth, EnableReverseAzimuth,
|
||||
EnableReducedLength, EnableGeodesicScale
|
||||
>
|
||||
{};
|
||||
};
|
||||
|
||||
struct karney
|
||||
{
|
||||
template
|
||||
<
|
||||
typename CT,
|
||||
bool EnableCoordinates = true,
|
||||
bool EnableReverseAzimuth = false,
|
||||
bool EnableReducedLength = false,
|
||||
bool EnableGeodesicScale = false
|
||||
>
|
||||
struct direct
|
||||
: formula::karney_direct
|
||||
<
|
||||
CT, EnableCoordinates, EnableReverseAzimuth,
|
||||
EnableReducedLength, EnableGeodesicScale
|
||||
>
|
||||
{};
|
||||
|
||||
template
|
||||
<
|
||||
typename CT,
|
||||
bool EnableDistance,
|
||||
bool EnableAzimuth,
|
||||
bool EnableReverseAzimuth = false,
|
||||
bool EnableReducedLength = false,
|
||||
bool EnableGeodesicScale = false
|
||||
>
|
||||
struct inverse
|
||||
: formula::karney_inverse
|
||||
<
|
||||
CT, EnableDistance,
|
||||
EnableAzimuth, EnableReverseAzimuth,
|
||||
EnableReducedLength, EnableGeodesicScale
|
||||
>
|
||||
{};
|
||||
};
|
||||
|
||||
template <typename FormulaPolicy>
|
||||
struct default_order
|
||||
{
|
||||
BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
|
||||
"Not implemented for this type.",
|
||||
FormulaPolicy);
|
||||
};
|
||||
|
||||
template<>
|
||||
struct default_order<andoyer>
|
||||
: std::integral_constant<unsigned int, 1>
|
||||
{};
|
||||
|
||||
template<>
|
||||
struct default_order<thomas>
|
||||
: std::integral_constant<unsigned int, 2>
|
||||
{};
|
||||
|
||||
template<>
|
||||
struct default_order<vincenty>
|
||||
: std::integral_constant<unsigned int, 4>
|
||||
{};
|
||||
|
||||
template<>
|
||||
struct default_order<karney>
|
||||
: std::integral_constant<unsigned int, 8>
|
||||
{};
|
||||
|
||||
|
||||
}}} // namespace boost::geometry::strategy
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_PARAMETERS_HPP
|
||||
Vendored
Executable
+81
@@ -0,0 +1,81 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2017-2021 Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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_STRATEGY_GEOGRAPHIC_POINT_IN_POLY_WINDING_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGY_GEOGRAPHIC_POINT_IN_POLY_WINDING_HPP
|
||||
|
||||
|
||||
#include <boost/geometry/strategies/geographic/side.hpp>
|
||||
#include <boost/geometry/strategies/spherical/point_in_poly_winding.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace within
|
||||
{
|
||||
|
||||
|
||||
/*!
|
||||
\brief Within detection using winding rule in geographic coordinate system.
|
||||
\ingroup strategies
|
||||
\tparam Point \tparam_point
|
||||
\tparam PointOfSegment \tparam_segment_point
|
||||
\tparam FormulaPolicy Geodesic formula policy
|
||||
\tparam Spheroid Spheroid model
|
||||
\tparam CalculationType \tparam_calculation
|
||||
|
||||
\qbk{
|
||||
[heading See also]
|
||||
[link geometry.reference.algorithms.within.within_3_with_strategy within (with strategy)]
|
||||
}
|
||||
*/
|
||||
template
|
||||
<
|
||||
typename Point = void, // for backward compatibility
|
||||
typename PointOfSegment = Point, // for backward compatibility
|
||||
typename FormulaPolicy = strategy::andoyer,
|
||||
typename Spheroid = srs::spheroid<double>,
|
||||
typename CalculationType = void
|
||||
>
|
||||
class geographic_winding
|
||||
: public within::detail::spherical_winding_base
|
||||
<
|
||||
side::geographic<FormulaPolicy, Spheroid, CalculationType>,
|
||||
CalculationType
|
||||
>
|
||||
{
|
||||
typedef within::detail::spherical_winding_base
|
||||
<
|
||||
side::geographic<FormulaPolicy, Spheroid, CalculationType>,
|
||||
CalculationType
|
||||
> base_t;
|
||||
|
||||
public:
|
||||
geographic_winding()
|
||||
{}
|
||||
|
||||
explicit geographic_winding(Spheroid const& model)
|
||||
: base_t(model)
|
||||
{}
|
||||
|
||||
Spheroid const& model() const
|
||||
{
|
||||
return base_t::m_side_strategy.model();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}} // namespace strategy::within
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGY_GEOGRAPHIC_POINT_IN_POLY_WINDING_HPP
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2019, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Licensed under the Boost Software License version 1.0.
|
||||
// http://www.boost.org/users/license.html
|
||||
|
||||
#ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_POINT_ORDER_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_POINT_ORDER_HPP
|
||||
|
||||
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/srs/spheroid.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/geographic/parameters.hpp>
|
||||
#include <boost/geometry/strategies/point_order.hpp>
|
||||
#include <boost/geometry/strategies/spherical/point_in_point.hpp>
|
||||
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
#include <boost/geometry/util/select_calculation_type.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace point_order
|
||||
{
|
||||
|
||||
template
|
||||
<
|
||||
typename FormulaPolicy = strategy::andoyer,
|
||||
typename Spheroid = srs::spheroid<double>,
|
||||
typename CalculationType = void
|
||||
>
|
||||
struct geographic
|
||||
{
|
||||
typedef azimuth_tag version_tag;
|
||||
|
||||
template <typename Geometry>
|
||||
struct result_type
|
||||
{
|
||||
typedef typename geometry::select_calculation_type_alt
|
||||
<
|
||||
CalculationType, Geometry
|
||||
>::type type;
|
||||
};
|
||||
|
||||
geographic()
|
||||
{}
|
||||
|
||||
explicit geographic(Spheroid const& spheroid)
|
||||
: m_spheroid(spheroid)
|
||||
{}
|
||||
|
||||
template <typename Point>
|
||||
inline bool apply(Point const& p1, Point const& p2,
|
||||
typename result_type<Point>::type & azi,
|
||||
typename result_type<Point>::type & razi) const
|
||||
{
|
||||
typedef typename result_type<Point>::type calc_t;
|
||||
|
||||
if (equals_point_point(p1, p2))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
formula::result_inverse<calc_t> res = FormulaPolicy::template inverse
|
||||
<
|
||||
calc_t, false, true, true, false, false
|
||||
>::apply(geometry::get_as_radian<0>(p1),
|
||||
geometry::get_as_radian<1>(p1),
|
||||
geometry::get_as_radian<0>(p2),
|
||||
geometry::get_as_radian<1>(p2),
|
||||
m_spheroid);
|
||||
|
||||
azi = res.azimuth;
|
||||
razi = res.reverse_azimuth;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename Point>
|
||||
inline typename result_type<Point>::type
|
||||
apply(Point const& /*p0*/, Point const& /*p1*/, Point const& /*p2*/,
|
||||
typename result_type<Point>::type const& azi1,
|
||||
typename result_type<Point>::type const& azi2) const
|
||||
{
|
||||
// TODO: support poles
|
||||
return math::longitude_distance_signed<radian>(azi1, azi2);
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename Point>
|
||||
static bool equals_point_point(Point const& p0, Point const& p1)
|
||||
{
|
||||
return strategy::within::spherical_point_point::apply(p0, p1);
|
||||
}
|
||||
|
||||
Spheroid m_spheroid;
|
||||
};
|
||||
|
||||
namespace services
|
||||
{
|
||||
|
||||
template <>
|
||||
struct default_strategy<geographic_tag>
|
||||
{
|
||||
typedef geographic<> type;
|
||||
};
|
||||
|
||||
} // namespace services
|
||||
|
||||
}} // namespace strategy::point_order
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_POINT_ORDER_HPP
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2014-2021.
|
||||
// Modifications copyright (c) 2014-2021 Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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_GEOGRAPHIC_SIDE_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_SIDE_HPP
|
||||
|
||||
#include <boost/geometry/core/cs.hpp>
|
||||
#include <boost/geometry/core/access.hpp>
|
||||
#include <boost/geometry/core/coordinate_promotion.hpp>
|
||||
#include <boost/geometry/core/radian_access.hpp>
|
||||
#include <boost/geometry/core/radius.hpp>
|
||||
|
||||
#include <boost/geometry/formulas/spherical.hpp>
|
||||
|
||||
#include <boost/geometry/srs/spheroid.hpp>
|
||||
|
||||
//#include <boost/geometry/strategies/concepts/side_concept.hpp>
|
||||
#include <boost/geometry/strategies/geographic/disjoint_segment_box.hpp>
|
||||
#include <boost/geometry/strategies/geographic/parameters.hpp>
|
||||
#include <boost/geometry/strategies/side.hpp>
|
||||
#include <boost/geometry/strategies/spherical/point_in_point.hpp>
|
||||
|
||||
#include <boost/geometry/strategy/geographic/envelope.hpp>
|
||||
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
#include <boost/geometry/util/select_calculation_type.hpp>
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
|
||||
namespace strategy { namespace side
|
||||
{
|
||||
|
||||
|
||||
/*!
|
||||
\brief Check at which side of a segment a point lies
|
||||
left of segment (> 0), right of segment (< 0), on segment (0)
|
||||
\ingroup strategies
|
||||
\tparam FormulaPolicy Geodesic solution formula policy.
|
||||
\tparam Spheroid Reference model of coordinate system.
|
||||
\tparam CalculationType \tparam_calculation
|
||||
|
||||
\qbk{
|
||||
[heading See also]
|
||||
[link geometry.reference.srs.srs_spheroid srs::spheroid]
|
||||
}
|
||||
*/
|
||||
template
|
||||
<
|
||||
typename FormulaPolicy = strategy::andoyer,
|
||||
typename Spheroid = srs::spheroid<double>,
|
||||
typename CalculationType = void
|
||||
>
|
||||
class geographic
|
||||
{
|
||||
public:
|
||||
typedef geographic_tag cs_tag;
|
||||
|
||||
geographic() = default;
|
||||
|
||||
explicit geographic(Spheroid const& model)
|
||||
: m_model(model)
|
||||
{}
|
||||
|
||||
template <typename P1, typename P2, typename P>
|
||||
inline int apply(P1 const& p1, P2 const& p2, P const& p) const
|
||||
{
|
||||
typedef strategy::within::spherical_point_point equals_point_point_strategy_type;
|
||||
if (equals_point_point_strategy_type::apply(p, p1)
|
||||
|| equals_point_point_strategy_type::apply(p, p2)
|
||||
|| equals_point_point_strategy_type::apply(p1, p2))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
typedef typename promote_floating_point
|
||||
<
|
||||
typename select_calculation_type_alt
|
||||
<
|
||||
CalculationType,
|
||||
P1, P2, P
|
||||
>::type
|
||||
>::type calc_t;
|
||||
|
||||
typedef typename FormulaPolicy::template inverse
|
||||
<calc_t, false, true, false, false, false> inverse_formula;
|
||||
|
||||
calc_t a1p = azimuth<calc_t, inverse_formula>(p1, p, m_model);
|
||||
calc_t a12 = azimuth<calc_t, inverse_formula>(p1, p2, m_model);
|
||||
|
||||
return formula::azimuth_side_value(a1p, a12);
|
||||
}
|
||||
|
||||
Spheroid const& model() const
|
||||
{
|
||||
return m_model;
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename ResultType,
|
||||
typename InverseFormulaType,
|
||||
typename Point1,
|
||||
typename Point2,
|
||||
typename ModelT>
|
||||
static inline ResultType azimuth(Point1 const& point1, Point2 const& point2,
|
||||
ModelT const& model)
|
||||
{
|
||||
return InverseFormulaType::apply(get_as_radian<0>(point1),
|
||||
get_as_radian<1>(point1),
|
||||
get_as_radian<0>(point2),
|
||||
get_as_radian<1>(point2),
|
||||
model).azimuth;
|
||||
}
|
||||
|
||||
Spheroid m_model;
|
||||
};
|
||||
|
||||
|
||||
}} // namespace strategy::side
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_SIDE_HPP
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2014-2017.
|
||||
// Modifications copyright (c) 2014-2017 Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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_GEOGRAPHIC_SIDE_ANDOYER_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_SIDE_ANDOYER_HPP
|
||||
|
||||
|
||||
#include <boost/geometry/strategies/geographic/side.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
|
||||
namespace strategy { namespace side
|
||||
{
|
||||
|
||||
/*!
|
||||
\brief Check at which side of a segment a point lies
|
||||
left of segment (> 0), right of segment (< 0), on segment (0)
|
||||
\ingroup strategies
|
||||
\tparam Spheroid Reference model of coordinate system.
|
||||
\tparam CalculationType \tparam_calculation
|
||||
*/
|
||||
template
|
||||
<
|
||||
typename Spheroid = srs::spheroid<double>,
|
||||
typename CalculationType = void
|
||||
>
|
||||
class andoyer
|
||||
: public side::geographic<strategy::andoyer, Spheroid, CalculationType>
|
||||
{
|
||||
typedef side::geographic<strategy::andoyer, Spheroid, CalculationType> base_t;
|
||||
|
||||
public:
|
||||
andoyer()
|
||||
{}
|
||||
|
||||
explicit andoyer(Spheroid const& model)
|
||||
: base_t(model)
|
||||
{}
|
||||
};
|
||||
|
||||
}} // namespace strategy::side
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_SIDE_ANDOYER_HPP
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2014-2017.
|
||||
// Modifications copyright (c) 2014-2017 Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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_GEOGRAPHIC_SIDE_THOMAS_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_SIDE_THOMAS_HPP
|
||||
|
||||
|
||||
#include <boost/geometry/strategies/geographic/side.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
|
||||
namespace strategy { namespace side
|
||||
{
|
||||
|
||||
/*!
|
||||
\brief Check at which side of a segment a point lies
|
||||
left of segment (> 0), right of segment (< 0), on segment (0)
|
||||
\ingroup strategies
|
||||
\tparam Spheroid Reference model of coordinate system.
|
||||
\tparam CalculationType \tparam_calculation
|
||||
*/
|
||||
template
|
||||
<
|
||||
typename Spheroid = srs::spheroid<double>,
|
||||
typename CalculationType = void
|
||||
>
|
||||
class thomas
|
||||
: public side::geographic<strategy::thomas, Spheroid, CalculationType>
|
||||
{
|
||||
typedef side::geographic<strategy::thomas, Spheroid, CalculationType> base_t;
|
||||
|
||||
public:
|
||||
thomas()
|
||||
{}
|
||||
|
||||
explicit thomas(Spheroid const& model)
|
||||
: base_t(model)
|
||||
{}
|
||||
};
|
||||
|
||||
}} // namespace strategy::side
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_SIDE_THOMAS_HPP
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2014-2017.
|
||||
// Modifications copyright (c) 2014-2017 Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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_GEOGRAPHIC_SIDE_VINCENTY_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_SIDE_VINCENTY_HPP
|
||||
|
||||
|
||||
#include <boost/geometry/strategies/geographic/side.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
|
||||
namespace strategy { namespace side
|
||||
{
|
||||
|
||||
/*!
|
||||
\brief Check at which side of a segment a point lies
|
||||
left of segment (> 0), right of segment (< 0), on segment (0)
|
||||
\ingroup strategies
|
||||
\tparam Spheroid Reference model of coordinate system.
|
||||
\tparam CalculationType \tparam_calculation
|
||||
*/
|
||||
template
|
||||
<
|
||||
typename Spheroid = srs::spheroid<double>,
|
||||
typename CalculationType = void
|
||||
>
|
||||
class vincenty
|
||||
: public side::geographic<strategy::vincenty, Spheroid, CalculationType>
|
||||
{
|
||||
typedef side::geographic<strategy::vincenty, Spheroid, CalculationType> base_t;
|
||||
|
||||
public:
|
||||
vincenty()
|
||||
{}
|
||||
|
||||
explicit vincenty(Spheroid const& model)
|
||||
: base_t(model)
|
||||
{}
|
||||
};
|
||||
|
||||
}} // namespace strategy::side
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_SIDE_VINCENTY_HPP
|
||||
Reference in New Issue
Block a user