updated boost on windows
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2016-2017 Oracle and/or its affiliates.
|
||||
// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// Copyright (c) 2016-2018 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
|
||||
|
||||
@@ -13,9 +15,9 @@
|
||||
|
||||
|
||||
#include <boost/geometry/formulas/area_formulas.hpp>
|
||||
#include <boost/geometry/core/radius.hpp>
|
||||
#include <boost/geometry/core/srs.hpp>
|
||||
#include <boost/geometry/srs/sphere.hpp>
|
||||
#include <boost/geometry/strategies/area.hpp>
|
||||
#include <boost/geometry/strategies/spherical/get_radius.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
@@ -24,11 +26,12 @@ namespace boost { namespace geometry
|
||||
namespace strategy { namespace area
|
||||
{
|
||||
|
||||
|
||||
/*!
|
||||
\brief Spherical area calculation
|
||||
\ingroup strategies
|
||||
\details Calculates area on the surface of a sphere using the trapezoidal rule
|
||||
\tparam PointOfSegment \tparam_segment_point
|
||||
\tparam RadiusTypeOrSphere \tparam_radius_or_sphere
|
||||
\tparam CalculationType \tparam_calculation
|
||||
|
||||
\qbk{
|
||||
@@ -38,7 +41,7 @@ namespace strategy { namespace area
|
||||
*/
|
||||
template
|
||||
<
|
||||
typename PointOfSegment,
|
||||
typename RadiusTypeOrSphere = double,
|
||||
typename CalculationType = void
|
||||
>
|
||||
class spherical
|
||||
@@ -46,34 +49,35 @@ class spherical
|
||||
// Enables special handling of long segments
|
||||
static const bool LongSegment = false;
|
||||
|
||||
typedef typename boost::mpl::if_c
|
||||
<
|
||||
boost::is_void<CalculationType>::type::value,
|
||||
typename select_most_precise
|
||||
public:
|
||||
template <typename Geometry>
|
||||
struct result_type
|
||||
: strategy::area::detail::result_type
|
||||
<
|
||||
typename coordinate_type<PointOfSegment>::type,
|
||||
double
|
||||
>::type,
|
||||
CalculationType
|
||||
>::type CT;
|
||||
Geometry,
|
||||
CalculationType
|
||||
>
|
||||
{};
|
||||
|
||||
protected :
|
||||
struct excess_sum
|
||||
template <typename Geometry>
|
||||
class state
|
||||
{
|
||||
CT m_sum;
|
||||
friend class spherical;
|
||||
|
||||
// Keep track if encircles some pole
|
||||
size_t m_crosses_prime_meridian;
|
||||
typedef typename result_type<Geometry>::type return_type;
|
||||
|
||||
inline excess_sum()
|
||||
public:
|
||||
inline state()
|
||||
: m_sum(0)
|
||||
, m_crosses_prime_meridian(0)
|
||||
{}
|
||||
template <typename SphereType>
|
||||
inline CT area(SphereType sphere) const
|
||||
|
||||
private:
|
||||
template <typename RadiusType>
|
||||
inline return_type area(RadiusType const& r) const
|
||||
{
|
||||
CT result;
|
||||
CT radius = geometry::get_radius<0>(sphere);
|
||||
return_type result;
|
||||
return_type radius = r;
|
||||
|
||||
// Encircles pole
|
||||
if(m_crosses_prime_meridian % 2 == 1)
|
||||
@@ -81,12 +85,12 @@ protected :
|
||||
size_t times_crosses_prime_meridian
|
||||
= 1 + (m_crosses_prime_meridian / 2);
|
||||
|
||||
result = CT(2)
|
||||
* geometry::math::pi<CT>()
|
||||
result = return_type(2)
|
||||
* geometry::math::pi<return_type>()
|
||||
* times_crosses_prime_meridian
|
||||
- geometry::math::abs(m_sum);
|
||||
|
||||
if(geometry::math::sign<CT>(m_sum) == 1)
|
||||
if(geometry::math::sign<return_type>(m_sum) == 1)
|
||||
{
|
||||
result = - result;
|
||||
}
|
||||
@@ -99,53 +103,62 @@ protected :
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return_type m_sum;
|
||||
|
||||
// Keep track if encircles some pole
|
||||
size_t m_crosses_prime_meridian;
|
||||
};
|
||||
|
||||
public :
|
||||
typedef CT return_type;
|
||||
typedef PointOfSegment segment_point_type;
|
||||
typedef excess_sum state_type;
|
||||
typedef geometry::srs::sphere<CT> sphere_type;
|
||||
|
||||
// For backward compatibility reasons the radius is set to 1
|
||||
inline spherical()
|
||||
: m_sphere(1.0)
|
||||
: m_radius(1.0)
|
||||
{}
|
||||
|
||||
template <typename T>
|
||||
explicit inline spherical(geometry::srs::sphere<T> const& sphere)
|
||||
: m_sphere(geometry::get_radius<0>(sphere))
|
||||
{}
|
||||
|
||||
explicit inline spherical(CT const& radius)
|
||||
: m_sphere(radius)
|
||||
template <typename RadiusOrSphere>
|
||||
explicit inline spherical(RadiusOrSphere const& radius_or_sphere)
|
||||
: m_radius(strategy_detail::get_radius
|
||||
<
|
||||
RadiusOrSphere
|
||||
>::apply(radius_or_sphere))
|
||||
{}
|
||||
|
||||
template <typename PointOfSegment, typename Geometry>
|
||||
inline void apply(PointOfSegment const& p1,
|
||||
PointOfSegment const& p2,
|
||||
excess_sum& state) const
|
||||
state<Geometry>& st) const
|
||||
{
|
||||
if (! geometry::math::equals(get<0>(p1), get<0>(p2)))
|
||||
{
|
||||
typedef geometry::formula::area_formulas
|
||||
<
|
||||
typename result_type<Geometry>::type
|
||||
> area_formulas;
|
||||
|
||||
state.m_sum += geometry::formula::area_formulas
|
||||
<CT>::template spherical<LongSegment>(p1, p2);
|
||||
st.m_sum += area_formulas::template spherical<LongSegment>(p1, p2);
|
||||
|
||||
// Keep track whenever a segment crosses the prime meridian
|
||||
geometry::formula::area_formulas
|
||||
<CT>::crosses_prime_meridian(p1, p2, state);
|
||||
|
||||
if (area_formulas::crosses_prime_meridian(p1, p2))
|
||||
{
|
||||
st.m_crosses_prime_meridian++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline return_type result(excess_sum const& state) const
|
||||
template <typename Geometry>
|
||||
inline typename result_type<Geometry>::type
|
||||
result(state<Geometry> const& st) const
|
||||
{
|
||||
return state.area(m_sphere);
|
||||
return st.area(m_radius);
|
||||
}
|
||||
|
||||
private :
|
||||
/// srs Sphere
|
||||
sphere_type m_sphere;
|
||||
typename strategy_detail::get_radius
|
||||
<
|
||||
RadiusTypeOrSphere
|
||||
>::type m_radius;
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
@@ -154,17 +167,17 @@ namespace services
|
||||
{
|
||||
|
||||
|
||||
template <typename Point>
|
||||
struct default_strategy<spherical_equatorial_tag, Point>
|
||||
template <>
|
||||
struct default_strategy<spherical_equatorial_tag>
|
||||
{
|
||||
typedef strategy::area::spherical<Point> type;
|
||||
typedef strategy::area::spherical<> type;
|
||||
};
|
||||
|
||||
// Note: spherical polar coordinate system requires "get_as_radian_equatorial"
|
||||
template <typename Point>
|
||||
struct default_strategy<spherical_polar_tag, Point>
|
||||
template <>
|
||||
struct default_strategy<spherical_polar_tag>
|
||||
{
|
||||
typedef strategy::area::spherical<Point> type;
|
||||
typedef strategy::area::spherical<> type;
|
||||
};
|
||||
|
||||
} // namespace services
|
||||
|
||||
@@ -37,9 +37,44 @@ public :
|
||||
{}
|
||||
|
||||
template <typename T>
|
||||
static inline void apply(T const& lon1_rad, T const& lat1_rad,
|
||||
T const& lon2_rad, T const& lat2_rad,
|
||||
T& a1, T& a2)
|
||||
inline void apply(T const& lon1_rad, T const& lat1_rad,
|
||||
T const& lon2_rad, T const& lat2_rad,
|
||||
T& a1, T& a2) const
|
||||
{
|
||||
compute<true, true>(lon1_rad, lat1_rad,
|
||||
lon2_rad, lat2_rad,
|
||||
a1, a2);
|
||||
}
|
||||
template <typename T>
|
||||
inline void apply(T const& lon1_rad, T const& lat1_rad,
|
||||
T const& lon2_rad, T const& lat2_rad,
|
||||
T& a1) const
|
||||
{
|
||||
compute<true, false>(lon1_rad, lat1_rad,
|
||||
lon2_rad, lat2_rad,
|
||||
a1, a1);
|
||||
}
|
||||
template <typename T>
|
||||
inline void apply_reverse(T const& lon1_rad, T const& lat1_rad,
|
||||
T const& lon2_rad, T const& lat2_rad,
|
||||
T& a2) const
|
||||
{
|
||||
compute<false, true>(lon1_rad, lat1_rad,
|
||||
lon2_rad, lat2_rad,
|
||||
a2, a2);
|
||||
}
|
||||
|
||||
private :
|
||||
|
||||
template
|
||||
<
|
||||
bool EnableAzimuth,
|
||||
bool EnableReverseAzimuth,
|
||||
typename T
|
||||
>
|
||||
inline void compute(T const& lon1_rad, T const& lat1_rad,
|
||||
T const& lon2_rad, T const& lat2_rad,
|
||||
T& a1, T& a2) const
|
||||
{
|
||||
typedef typename boost::mpl::if_
|
||||
<
|
||||
@@ -47,14 +82,22 @@ public :
|
||||
>::type calc_t;
|
||||
|
||||
geometry::formula::result_spherical<calc_t>
|
||||
result = geometry::formula::spherical_azimuth<calc_t, true>(
|
||||
calc_t(lon1_rad), calc_t(lat1_rad),
|
||||
calc_t(lon2_rad), calc_t(lat2_rad));
|
||||
result = geometry::formula::spherical_azimuth
|
||||
<
|
||||
calc_t,
|
||||
EnableReverseAzimuth
|
||||
>(calc_t(lon1_rad), calc_t(lat1_rad),
|
||||
calc_t(lon2_rad), calc_t(lat2_rad));
|
||||
|
||||
a1 = result.azimuth;
|
||||
a2 = result.reverse_azimuth;
|
||||
if (EnableAzimuth)
|
||||
{
|
||||
a1 = result.azimuth;
|
||||
}
|
||||
if (EnableReverseAzimuth)
|
||||
{
|
||||
a2 = result.reverse_azimuth;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
322
winx64/include/boost/geometry/strategies/spherical/compare.hpp
Normal file
322
winx64/include/boost/geometry/strategies/spherical/compare.hpp
Normal file
@@ -0,0 +1,322 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2017, 2018.
|
||||
// Modifications copyright (c) 2017-2018, 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_SPHERICAL_COMPARE_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_COMPARE_HPP
|
||||
|
||||
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/min.hpp>
|
||||
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
#include <boost/geometry/core/access.hpp>
|
||||
#include <boost/geometry/core/coordinate_dimension.hpp>
|
||||
#include <boost/geometry/core/coordinate_system.hpp>
|
||||
#include <boost/geometry/core/coordinate_type.hpp>
|
||||
#include <boost/geometry/core/cs.hpp>
|
||||
#include <boost/geometry/core/radian_access.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/compare.hpp>
|
||||
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
#include <boost/geometry/util/normalize_spheroidal_coordinates.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
|
||||
namespace strategy { namespace compare
|
||||
{
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <std::size_t I, typename P>
|
||||
static inline typename geometry::coordinate_type<P>::type
|
||||
get(P const& p, boost::true_type /*same units*/)
|
||||
{
|
||||
return geometry::get<I>(p);
|
||||
}
|
||||
|
||||
template <std::size_t I, typename P>
|
||||
static inline typename geometry::coordinate_type<P>::type
|
||||
get(P const& p, boost::false_type /*different units*/)
|
||||
{
|
||||
return geometry::get_as_radian<I>(p);
|
||||
}
|
||||
|
||||
template
|
||||
<
|
||||
typename ComparePolicy,
|
||||
typename Point1,
|
||||
typename Point2,
|
||||
std::size_t DimensionCount
|
||||
>
|
||||
struct spherical_latitude
|
||||
{
|
||||
typedef typename geometry::coordinate_type<Point1>::type coordinate1_type;
|
||||
typedef typename geometry::coordinate_system<Point1>::type::units units1_type;
|
||||
typedef typename geometry::coordinate_type<Point2>::type coordinate2_type;
|
||||
typedef typename geometry::coordinate_system<Point2>::type::units units2_type;
|
||||
typedef typename boost::is_same<units1_type, units2_type>::type same_units_type;
|
||||
|
||||
template <typename T1, typename T2>
|
||||
static inline bool apply(Point1 const& left, Point2 const& right,
|
||||
T1 const& l1, T2 const& r1)
|
||||
{
|
||||
// latitudes equal
|
||||
if (math::equals(l1, r1))
|
||||
{
|
||||
return compare::detail::compare_loop
|
||||
<
|
||||
ComparePolicy, 2, DimensionCount
|
||||
>::apply(left, right);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ComparePolicy::apply(l1, r1);
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool apply(Point1 const& left, Point2 const& right)
|
||||
{
|
||||
coordinate1_type const& l1 = compare::detail::get<1>(left, same_units_type());
|
||||
coordinate2_type const& r1 = compare::detail::get<1>(right, same_units_type());
|
||||
|
||||
return apply(left, right, l1, r1);
|
||||
}
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename ComparePolicy,
|
||||
typename Point1,
|
||||
typename Point2
|
||||
>
|
||||
struct spherical_latitude<ComparePolicy, Point1, Point2, 1>
|
||||
{
|
||||
template <typename T1, typename T2>
|
||||
static inline bool apply(Point1 const& left, Point2 const& right,
|
||||
T1 const& , T2 const& )
|
||||
{
|
||||
return apply(left, right);
|
||||
}
|
||||
|
||||
static inline bool apply(Point1 const& left, Point2 const& right)
|
||||
{
|
||||
return compare::detail::compare_loop
|
||||
<
|
||||
ComparePolicy, 1, 1
|
||||
>::apply(left, right);
|
||||
}
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename ComparePolicy,
|
||||
typename Point1,
|
||||
typename Point2,
|
||||
std::size_t DimensionCount
|
||||
>
|
||||
struct spherical_longitude
|
||||
{
|
||||
typedef typename geometry::coordinate_type<Point1>::type coordinate1_type;
|
||||
typedef typename geometry::coordinate_system<Point1>::type::units units1_type;
|
||||
typedef typename geometry::coordinate_type<Point2>::type coordinate2_type;
|
||||
typedef typename geometry::coordinate_system<Point2>::type::units units2_type;
|
||||
typedef typename boost::is_same<units1_type, units2_type>::type same_units_type;
|
||||
typedef typename boost::mpl::if_<same_units_type, units1_type, geometry::radian>::type units_type;
|
||||
|
||||
static const bool is_equatorial = ! boost::is_same
|
||||
<
|
||||
typename geometry::cs_tag<Point1>::type,
|
||||
geometry::spherical_polar_tag
|
||||
>::value;
|
||||
|
||||
static inline bool are_both_at_antimeridian(coordinate1_type const& l0,
|
||||
coordinate2_type const& r0,
|
||||
bool & is_left_at,
|
||||
bool & is_right_at)
|
||||
{
|
||||
is_left_at = math::is_longitude_antimeridian<units_type>(l0);
|
||||
is_right_at = math::is_longitude_antimeridian<units_type>(r0);
|
||||
return is_left_at && is_right_at;
|
||||
}
|
||||
|
||||
static inline bool apply(Point1 const& left, Point2 const& right)
|
||||
{
|
||||
// if units are different the coordinates are in radians
|
||||
coordinate1_type const& l0 = compare::detail::get<0>(left, same_units_type());
|
||||
coordinate2_type const& r0 = compare::detail::get<0>(right, same_units_type());
|
||||
coordinate1_type const& l1 = compare::detail::get<1>(left, same_units_type());
|
||||
coordinate2_type const& r1 = compare::detail::get<1>(right, same_units_type());
|
||||
|
||||
bool is_left_at_antimeridian = false;
|
||||
bool is_right_at_antimeridian = false;
|
||||
|
||||
// longitudes equal
|
||||
if (math::equals(l0, r0)
|
||||
// both at antimeridian
|
||||
|| are_both_at_antimeridian(l0, r0, is_left_at_antimeridian, is_right_at_antimeridian)
|
||||
// both at pole
|
||||
|| (math::equals(l1, r1)
|
||||
&& math::is_latitude_pole<units_type, is_equatorial>(l1)))
|
||||
{
|
||||
return spherical_latitude
|
||||
<
|
||||
ComparePolicy, Point1, Point2, DimensionCount
|
||||
>::apply(left, right, l1, r1);
|
||||
}
|
||||
// if left is at antimeridian and right is not at antimeridian
|
||||
// then left is greater than right
|
||||
else if (is_left_at_antimeridian)
|
||||
{
|
||||
// less/equal_to -> false, greater -> true
|
||||
return ComparePolicy::apply(1, 0);
|
||||
}
|
||||
// if right is at antimeridian and left is not at antimeridian
|
||||
// then left is lesser than right
|
||||
else if (is_right_at_antimeridian)
|
||||
{
|
||||
// less -> true, equal_to/greater -> false
|
||||
return ComparePolicy::apply(0, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ComparePolicy::apply(l0, r0);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace detail
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
/*!
|
||||
\brief Compare strategy for spherical coordinates
|
||||
\ingroup strategies
|
||||
\tparam Point point-type
|
||||
\tparam Dimension dimension
|
||||
*/
|
||||
template
|
||||
<
|
||||
typename ComparePolicy,
|
||||
int Dimension = -1
|
||||
>
|
||||
struct spherical
|
||||
: cartesian<ComparePolicy, Dimension>
|
||||
{};
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
// all dimensions starting from longitude
|
||||
template <typename ComparePolicy>
|
||||
struct spherical<ComparePolicy, -1>
|
||||
{
|
||||
template <typename Point1, typename Point2>
|
||||
static inline bool apply(Point1 const& left, Point2 const& right)
|
||||
{
|
||||
return compare::detail::spherical_longitude
|
||||
<
|
||||
ComparePolicy,
|
||||
Point1,
|
||||
Point2,
|
||||
boost::mpl::min
|
||||
<
|
||||
geometry::dimension<Point1>,
|
||||
geometry::dimension<Point2>
|
||||
>::type::value
|
||||
>::apply(left, right);
|
||||
}
|
||||
};
|
||||
|
||||
// only longitudes (and latitudes to check poles)
|
||||
template <typename ComparePolicy>
|
||||
struct spherical<ComparePolicy, 0>
|
||||
{
|
||||
template <typename Point1, typename Point2>
|
||||
static inline bool apply(Point1 const& left, Point2 const& right)
|
||||
{
|
||||
return compare::detail::spherical_longitude
|
||||
<
|
||||
ComparePolicy, Point1, Point2, 1
|
||||
>::apply(left, right);
|
||||
}
|
||||
};
|
||||
|
||||
// only latitudes
|
||||
template <typename ComparePolicy>
|
||||
struct spherical<ComparePolicy, 1>
|
||||
{
|
||||
template <typename Point1, typename Point2>
|
||||
static inline bool apply(Point1 const& left, Point2 const& right)
|
||||
{
|
||||
return compare::detail::spherical_latitude
|
||||
<
|
||||
ComparePolicy, Point1, Point2, 2
|
||||
>::apply(left, right);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
|
||||
namespace services
|
||||
{
|
||||
|
||||
|
||||
template <typename ComparePolicy, typename Point1, typename Point2, int Dimension>
|
||||
struct default_strategy
|
||||
<
|
||||
ComparePolicy, Point1, Point2, Dimension,
|
||||
spherical_polar_tag, spherical_polar_tag
|
||||
>
|
||||
{
|
||||
typedef compare::spherical<ComparePolicy, Dimension> type;
|
||||
};
|
||||
|
||||
template <typename ComparePolicy, typename Point1, typename Point2, int Dimension>
|
||||
struct default_strategy
|
||||
<
|
||||
ComparePolicy, Point1, Point2, Dimension,
|
||||
spherical_equatorial_tag, spherical_equatorial_tag
|
||||
>
|
||||
{
|
||||
typedef compare::spherical<ComparePolicy, Dimension> type;
|
||||
};
|
||||
|
||||
template <typename ComparePolicy, typename Point1, typename Point2, int Dimension>
|
||||
struct default_strategy
|
||||
<
|
||||
ComparePolicy, Point1, Point2, Dimension,
|
||||
geographic_tag, geographic_tag
|
||||
>
|
||||
{
|
||||
typedef compare::spherical<ComparePolicy, Dimension> type;
|
||||
};
|
||||
|
||||
|
||||
} // namespace services
|
||||
|
||||
|
||||
}} // namespace strategy::compare
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_COMPARE_HPP
|
||||
@@ -1,152 +0,0 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2012 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_SPHERICAL_COMPARE_SPHERICAL_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_COMPARE_SPHERICAL_HPP
|
||||
|
||||
#include <boost/math/constants/constants.hpp>
|
||||
|
||||
#include <boost/geometry/core/cs.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
#include <boost/geometry/strategies/compare.hpp>
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
|
||||
namespace strategy { namespace compare
|
||||
{
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <typename Units>
|
||||
struct shift
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct shift<degree>
|
||||
{
|
||||
static inline double full() { return 360.0; }
|
||||
static inline double half() { return 180.0; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct shift<radian>
|
||||
{
|
||||
static inline double full() { return 2.0 * boost::math::constants::pi<double>(); }
|
||||
static inline double half() { return boost::math::constants::pi<double>(); }
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
#endif
|
||||
|
||||
/*!
|
||||
\brief Compare (in one direction) strategy for spherical coordinates
|
||||
\ingroup strategies
|
||||
\tparam Point point-type
|
||||
\tparam Dimension dimension
|
||||
*/
|
||||
template <typename CoordinateType, typename Units, typename Compare>
|
||||
struct circular_comparator
|
||||
{
|
||||
static inline CoordinateType put_in_range(CoordinateType const& c,
|
||||
double min_border, double max_border)
|
||||
{
|
||||
CoordinateType value = c;
|
||||
while (value < min_border)
|
||||
{
|
||||
value += detail::shift<Units>::full();
|
||||
}
|
||||
while (value > max_border)
|
||||
{
|
||||
value -= detail::shift<Units>::full();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
inline bool operator()(CoordinateType const& c1, CoordinateType const& c2) const
|
||||
{
|
||||
Compare compare;
|
||||
|
||||
// Check situation that one of them is e.g. std::numeric_limits.
|
||||
static const double full = detail::shift<Units>::full();
|
||||
double mx = 10.0 * full;
|
||||
if (c1 < -mx || c1 > mx || c2 < -mx || c2 > mx)
|
||||
{
|
||||
// do normal comparison, using circular is not useful
|
||||
return compare(c1, c2);
|
||||
}
|
||||
|
||||
static const double half = full / 2.0;
|
||||
CoordinateType v1 = put_in_range(c1, -half, half);
|
||||
CoordinateType v2 = put_in_range(c2, -half, half);
|
||||
|
||||
// Two coordinates on a circle are
|
||||
// at max <= half a circle away from each other.
|
||||
// So if it is more, shift origin.
|
||||
CoordinateType diff = geometry::math::abs(v1 - v2);
|
||||
if (diff > half)
|
||||
{
|
||||
v1 = put_in_range(v1, 0, full);
|
||||
v2 = put_in_range(v2, 0, full);
|
||||
}
|
||||
|
||||
return compare(v1, v2);
|
||||
}
|
||||
};
|
||||
|
||||
}} // namespace strategy::compare
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
// Specialize for the longitude (dim 0)
|
||||
template
|
||||
<
|
||||
typename Point,
|
||||
template<typename> class CoordinateSystem,
|
||||
typename Units
|
||||
>
|
||||
struct strategy_compare<spherical_polar_tag, 1, Point, CoordinateSystem<Units>, 0>
|
||||
{
|
||||
typedef typename coordinate_type<Point>::type coordinate_type;
|
||||
typedef strategy::compare::circular_comparator
|
||||
<
|
||||
coordinate_type,
|
||||
Units,
|
||||
std::less<coordinate_type>
|
||||
> type;
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename Point,
|
||||
template<typename> class CoordinateSystem,
|
||||
typename Units
|
||||
>
|
||||
struct strategy_compare<spherical_polar_tag, -1, Point, CoordinateSystem<Units>, 0>
|
||||
{
|
||||
typedef typename coordinate_type<Point>::type coordinate_type;
|
||||
typedef strategy::compare::circular_comparator
|
||||
<
|
||||
coordinate_type,
|
||||
Units,
|
||||
std::greater<coordinate_type>
|
||||
> type;
|
||||
};
|
||||
|
||||
#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_COMPARE_SPHERICAL_HPP
|
||||
144
winx64/include/boost/geometry/strategies/spherical/densify.hpp
Normal file
144
winx64/include/boost/geometry/strategies/spherical/densify.hpp
Normal file
@@ -0,0 +1,144 @@
|
||||
// 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
|
||||
|
||||
// Licensed under the Boost Software License version 1.0.
|
||||
// http://www.boost.org/users/license.html
|
||||
|
||||
#ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_DENSIFY_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_DENSIFY_HPP
|
||||
|
||||
|
||||
#include <boost/geometry/algorithms/detail/convert_point_to_point.hpp>
|
||||
#include <boost/geometry/algorithms/detail/signed_size_type.hpp>
|
||||
#include <boost/geometry/arithmetic/arithmetic.hpp>
|
||||
#include <boost/geometry/arithmetic/cross_product.hpp>
|
||||
#include <boost/geometry/arithmetic/dot_product.hpp>
|
||||
#include <boost/geometry/arithmetic/normalize.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/formulas/spherical.hpp>
|
||||
#include <boost/geometry/formulas/interpolate_point_spherical.hpp>
|
||||
#include <boost/geometry/geometries/point.hpp>
|
||||
#include <boost/geometry/srs/sphere.hpp>
|
||||
#include <boost/geometry/strategies/densify.hpp>
|
||||
#include <boost/geometry/strategies/spherical/get_radius.hpp>
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
#include <boost/geometry/util/select_most_precise.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace densify
|
||||
{
|
||||
|
||||
|
||||
/*!
|
||||
\brief Densification of spherical segment.
|
||||
\ingroup strategies
|
||||
\tparam RadiusTypeOrSphere \tparam_radius_or_sphere
|
||||
\tparam CalculationType \tparam_calculation
|
||||
|
||||
\qbk{
|
||||
[heading See also]
|
||||
[link geometry.reference.algorithms.densify.densify_4_with_strategy densify (with strategy)]
|
||||
}
|
||||
*/
|
||||
template
|
||||
<
|
||||
typename RadiusTypeOrSphere = double,
|
||||
typename CalculationType = void
|
||||
>
|
||||
class spherical
|
||||
{
|
||||
public:
|
||||
// For consistency with area strategy the radius is set to 1
|
||||
inline spherical()
|
||||
: m_radius(1.0)
|
||||
{}
|
||||
|
||||
template <typename RadiusOrSphere>
|
||||
explicit inline spherical(RadiusOrSphere const& radius_or_sphere)
|
||||
: m_radius(strategy_detail::get_radius
|
||||
<
|
||||
RadiusOrSphere
|
||||
>::apply(radius_or_sphere))
|
||||
{}
|
||||
|
||||
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;
|
||||
|
||||
calc_t angle01;
|
||||
|
||||
formula::interpolate_point_spherical<calc_t> formula;
|
||||
formula.compute_angle(p0, p1, angle01);
|
||||
|
||||
BOOST_GEOMETRY_ASSERT(length_threshold > T(0));
|
||||
|
||||
signed_size_type n = signed_size_type(angle01 * m_radius / length_threshold);
|
||||
if (n <= 0)
|
||||
return;
|
||||
|
||||
formula.compute_axis(p0, angle01);
|
||||
|
||||
calc_t step = angle01 / (n + 1);
|
||||
|
||||
calc_t a = step;
|
||||
for (signed_size_type i = 0 ; i < n ; ++i, a += step)
|
||||
{
|
||||
out_point_t p;
|
||||
formula.compute_point(a, p);
|
||||
|
||||
geometry::detail::conversion::point_to_point
|
||||
<
|
||||
Point, out_point_t,
|
||||
2, dimension<out_point_t>::value
|
||||
>::apply(p0, p);
|
||||
|
||||
policy.apply(p);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
typename strategy_detail::get_radius
|
||||
<
|
||||
RadiusTypeOrSphere
|
||||
>::type m_radius;
|
||||
};
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
namespace services
|
||||
{
|
||||
|
||||
template <>
|
||||
struct default_strategy<spherical_equatorial_tag>
|
||||
{
|
||||
typedef strategy::densify::spherical<> type;
|
||||
};
|
||||
|
||||
|
||||
} // namespace services
|
||||
#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
|
||||
}} // namespace strategy::densify
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_ALGORITHMS_DENSIFY_HPP
|
||||
@@ -0,0 +1,134 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
|
||||
// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2013-2018.
|
||||
// Modifications copyright (c) 2013-2018, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
|
||||
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
||||
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_DISJOINT_BOX_BOX_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_DISJOINT_BOX_BOX_HPP
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <boost/geometry/core/cs.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/cartesian/disjoint_box_box.hpp>
|
||||
#include <boost/geometry/strategies/disjoint.hpp>
|
||||
|
||||
#include <boost/geometry/util/normalize_spheroidal_coordinates.hpp>
|
||||
#include <boost/geometry/util/select_most_precise.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry { namespace strategy { namespace disjoint
|
||||
{
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
struct box_box_on_spheroid
|
||||
{
|
||||
template <typename Box1, typename Box2>
|
||||
static inline bool apply(Box1 const& box1, Box2 const& box2)
|
||||
{
|
||||
typedef typename geometry::select_most_precise
|
||||
<
|
||||
typename coordinate_type<Box1>::type,
|
||||
typename coordinate_type<Box2>::type
|
||||
>::type calc_t;
|
||||
typedef typename geometry::detail::cs_angular_units<Box1>::type units_t;
|
||||
typedef math::detail::constants_on_spheroid<calc_t, units_t> constants;
|
||||
|
||||
calc_t const b1_min = get<min_corner, 0>(box1);
|
||||
calc_t const b1_max = get<max_corner, 0>(box1);
|
||||
calc_t const b2_min = get<min_corner, 0>(box2);
|
||||
calc_t const b2_max = get<max_corner, 0>(box2);
|
||||
|
||||
// min <= max <=> diff >= 0
|
||||
calc_t const diff1 = b1_max - b1_min;
|
||||
calc_t const diff2 = b2_max - b2_min;
|
||||
|
||||
// check the intersection if neither box cover the whole globe
|
||||
if (diff1 < constants::period() && diff2 < constants::period())
|
||||
{
|
||||
// calculate positive longitude translation with b1_min as origin
|
||||
calc_t const diff_min = math::longitude_distance_unsigned<units_t>(b1_min, b2_min);
|
||||
calc_t const b2_min_transl = b1_min + diff_min; // always right of b1_min
|
||||
calc_t b2_max_transl = b2_min_transl - constants::period() + diff2;
|
||||
|
||||
// if the translation is too close then use the original point
|
||||
// note that math::abs(b2_max_transl - b2_max) takes values very
|
||||
// close to k*2*constants::period() for k=0,1,2,...
|
||||
if (math::abs(b2_max_transl - b2_max) < constants::period() / 2)
|
||||
{
|
||||
b2_max_transl = b2_max;
|
||||
}
|
||||
|
||||
if (b2_min_transl > b1_max // b2_min right of b1_max
|
||||
&& b2_max_transl < b1_min) // b2_max left of b1_min
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return box_box
|
||||
<
|
||||
Box1, Box2, 1
|
||||
>::apply(box1, box2);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
struct spherical_box_box
|
||||
{
|
||||
template <typename Box1, typename Box2>
|
||||
static inline bool apply(Box1 const& box1, Box2 const& box2)
|
||||
{
|
||||
return detail::box_box_on_spheroid::apply(box1, box2);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
namespace services
|
||||
{
|
||||
|
||||
template <typename Box1, typename Box2, int TopDim1, int TopDim2>
|
||||
struct default_strategy<Box1, Box2, box_tag, box_tag, TopDim1, TopDim2, spherical_equatorial_tag, spherical_equatorial_tag>
|
||||
{
|
||||
typedef disjoint::spherical_box_box type;
|
||||
};
|
||||
|
||||
template <typename Box1, typename Box2, int TopDim1, int TopDim2>
|
||||
struct default_strategy<Box1, Box2, box_tag, box_tag, TopDim1, TopDim2, spherical_polar_tag, spherical_polar_tag>
|
||||
{
|
||||
typedef disjoint::spherical_box_box type;
|
||||
};
|
||||
|
||||
template <typename Box1, typename Box2, int TopDim1, int TopDim2>
|
||||
struct default_strategy<Box1, Box2, box_tag, box_tag, TopDim1, TopDim2, geographic_tag, geographic_tag>
|
||||
{
|
||||
typedef disjoint::spherical_box_box type;
|
||||
};
|
||||
|
||||
} // namespace services
|
||||
|
||||
}}}} // namespace boost::geometry::strategy::disjoint
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_DISJOINT_BOX_BOX_HPP
|
||||
@@ -0,0 +1,116 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2017-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_SPHERICAL_DISJOINT_SEGMENT_BOX_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_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>
|
||||
|
||||
// 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/normalize.hpp>
|
||||
#include <boost/geometry/strategies/spherical/azimuth.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.
|
||||
struct segment_box_spherical
|
||||
{
|
||||
template <typename Segment, typename Box>
|
||||
struct point_in_geometry_strategy
|
||||
: services::default_strategy
|
||||
<
|
||||
typename point_type<Segment>::type,
|
||||
Box
|
||||
>
|
||||
{};
|
||||
|
||||
template <typename Segment, typename Box>
|
||||
static inline typename point_in_geometry_strategy<Segment, Box>::type
|
||||
get_point_in_geometry_strategy()
|
||||
{
|
||||
typedef typename point_in_geometry_strategy<Segment, Box>::type strategy_type;
|
||||
|
||||
return strategy_type();
|
||||
}
|
||||
|
||||
template <typename Segment, typename Box>
|
||||
static inline bool apply(Segment const& segment, Box const& box)
|
||||
{
|
||||
typedef typename point_type<Segment>::type segment_point_type;
|
||||
typedef typename coordinate_type<segment_point_type>::type CT;
|
||||
geometry::strategy::azimuth::spherical<CT> azimuth_strategy;
|
||||
|
||||
return geometry::detail::disjoint::disjoint_segment_box_sphere_or_spheroid
|
||||
<
|
||||
spherical_equatorial_tag
|
||||
>::apply(segment, box,
|
||||
azimuth_strategy,
|
||||
strategy::normalize::spherical_point(),
|
||||
strategy::covered_by::spherical_point_box(),
|
||||
strategy::disjoint::spherical_box_box());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
|
||||
namespace services
|
||||
{
|
||||
|
||||
template <typename Linear, typename Box, typename LinearTag>
|
||||
struct default_strategy<Linear, Box, LinearTag, box_tag, 1, 2,
|
||||
spherical_equatorial_tag, spherical_equatorial_tag>
|
||||
{
|
||||
typedef segment_box_spherical type;
|
||||
};
|
||||
|
||||
template <typename Box, typename Linear, typename LinearTag>
|
||||
struct default_strategy<Box, Linear, box_tag, LinearTag, 2, 1,
|
||||
spherical_equatorial_tag, spherical_equatorial_tag>
|
||||
{
|
||||
typedef segment_box_spherical type;
|
||||
};
|
||||
|
||||
} // namespace services
|
||||
|
||||
|
||||
#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
|
||||
}}}} // namespace boost::geometry::strategy::disjoint
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_DISJOINT_SEGMENT_BOX_HPP
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
|
||||
// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2014.
|
||||
// Modifications copyright (c) 2014, Oracle and/or its affiliates.
|
||||
// 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 Menelaos Karavelas, 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
|
||||
@@ -26,11 +28,12 @@
|
||||
#include <boost/geometry/core/radian_access.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/course.hpp>
|
||||
#include <boost/geometry/formulas/spherical.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/distance.hpp>
|
||||
#include <boost/geometry/strategies/concepts/distance_concept.hpp>
|
||||
#include <boost/geometry/strategies/spherical/distance_haversine.hpp>
|
||||
#include <boost/geometry/strategies/spherical/point_in_point.hpp>
|
||||
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
#include <boost/geometry/util/promote_floating_point.hpp>
|
||||
@@ -327,6 +330,8 @@ template
|
||||
class cross_track
|
||||
{
|
||||
public :
|
||||
typedef within::spherical_point_point equals_point_point_strategy_type;
|
||||
|
||||
template <typename Point, typename PointOfSegment>
|
||||
struct return_type
|
||||
: promote_floating_point
|
||||
@@ -353,7 +358,6 @@ public :
|
||||
: m_strategy(s)
|
||||
{}
|
||||
|
||||
|
||||
// It might be useful in the future
|
||||
// to overload constructor with strategy info.
|
||||
// crosstrack(...) {}
|
||||
@@ -373,19 +377,6 @@ public :
|
||||
|
||||
typedef typename return_type<Point, PointOfSegment>::type return_type;
|
||||
|
||||
#ifdef BOOST_GEOMETRY_DEBUG_CROSS_TRACK
|
||||
std::cout << "Course " << dsv(sp1) << " to " << dsv(p) << " "
|
||||
<< crs_AD * geometry::math::r2d<return_type>() << std::endl;
|
||||
std::cout << "Course " << dsv(sp1) << " to " << dsv(sp2) << " "
|
||||
<< crs_AB * geometry::math::r2d<return_type>() << std::endl;
|
||||
std::cout << "Course " << dsv(sp2) << " to " << dsv(p) << " "
|
||||
<< crs_BD * geometry::math::r2d << std::endl;
|
||||
std::cout << "Projection AD-AB " << projection1 << " : "
|
||||
<< d_crs1 * geometry::math::r2d<return_type>() << std::endl;
|
||||
std::cout << "Projection BD-BA " << projection2 << " : "
|
||||
<< d_crs2 * geometry::math::r2d<return_type>() << std::endl;
|
||||
#endif
|
||||
|
||||
// http://williams.best.vwh.net/avform.htm#XTE
|
||||
return_type d1 = m_strategy.apply(sp1, p);
|
||||
return_type d3 = m_strategy.apply(sp1, sp2);
|
||||
@@ -398,10 +389,25 @@ public :
|
||||
|
||||
return_type d2 = m_strategy.apply(sp2, p);
|
||||
|
||||
return_type crs_AD = geometry::detail::course<return_type>(sp1, p);
|
||||
return_type crs_AB = geometry::detail::course<return_type>(sp1, sp2);
|
||||
return_type crs_BA = crs_AB - geometry::math::pi<return_type>();
|
||||
return_type crs_BD = geometry::detail::course<return_type>(sp2, p);
|
||||
return_type lon1 = geometry::get_as_radian<0>(sp1);
|
||||
return_type lat1 = geometry::get_as_radian<1>(sp1);
|
||||
return_type lon2 = geometry::get_as_radian<0>(sp2);
|
||||
return_type lat2 = geometry::get_as_radian<1>(sp2);
|
||||
return_type lon = geometry::get_as_radian<0>(p);
|
||||
return_type lat = geometry::get_as_radian<1>(p);
|
||||
|
||||
return_type crs_AD = geometry::formula::spherical_azimuth<return_type, false>
|
||||
(lon1, lat1, lon, lat).azimuth;
|
||||
|
||||
geometry::formula::result_spherical<return_type> result =
|
||||
geometry::formula::spherical_azimuth<return_type, true>
|
||||
(lon1, lat1, lon2, lat2);
|
||||
return_type crs_AB = result.azimuth;
|
||||
return_type crs_BA = result.reverse_azimuth - geometry::math::pi<return_type>();
|
||||
|
||||
return_type crs_BD = geometry::formula::spherical_azimuth<return_type, false>
|
||||
(lon2, lat2, lon, lat).azimuth;
|
||||
|
||||
return_type d_crs1 = crs_AD - crs_AB;
|
||||
return_type d_crs2 = crs_BD - crs_BA;
|
||||
|
||||
@@ -409,6 +415,24 @@ public :
|
||||
return_type projection1 = cos( d_crs1 ) * d1 / d3;
|
||||
return_type projection2 = cos( d_crs2 ) * d2 / d3;
|
||||
|
||||
#ifdef BOOST_GEOMETRY_DEBUG_CROSS_TRACK
|
||||
std::cout << "Course " << dsv(sp1) << " to " << dsv(p) << " "
|
||||
<< crs_AD * geometry::math::r2d<return_type>() << std::endl;
|
||||
std::cout << "Course " << dsv(sp1) << " to " << dsv(sp2) << " "
|
||||
<< crs_AB * geometry::math::r2d<return_type>() << std::endl;
|
||||
std::cout << "Course " << dsv(sp2) << " to " << dsv(sp1) << " "
|
||||
<< crs_BA * geometry::math::r2d<return_type>() << std::endl;
|
||||
std::cout << "Course " << dsv(sp2) << " to " << dsv(p) << " "
|
||||
<< crs_BD * geometry::math::r2d<return_type>() << std::endl;
|
||||
std::cout << "Projection AD-AB " << projection1 << " : "
|
||||
<< d_crs1 * geometry::math::r2d<return_type>() << std::endl;
|
||||
std::cout << "Projection BD-BA " << projection2 << " : "
|
||||
<< d_crs2 * geometry::math::r2d<return_type>() << std::endl;
|
||||
std::cout << " d1: " << (d1 )
|
||||
<< " d2: " << (d2 )
|
||||
<< std::endl;
|
||||
#endif
|
||||
|
||||
if (projection1 > 0.0 && projection2 > 0.0)
|
||||
{
|
||||
#ifdef BOOST_GEOMETRY_DEBUG_CROSS_TRACK
|
||||
@@ -449,6 +473,12 @@ public :
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
inline radius_type vertical_or_meridian(T1 lat1, T2 lat2) const
|
||||
{
|
||||
return m_strategy.radius() * (lat1 - lat2);
|
||||
}
|
||||
|
||||
inline typename Strategy::radius_type radius() const
|
||||
{ return m_strategy.radius(); }
|
||||
|
||||
@@ -481,6 +511,8 @@ template
|
||||
class cross_track
|
||||
{
|
||||
public :
|
||||
typedef within::spherical_point_point equals_point_point_strategy_type;
|
||||
|
||||
template <typename Point, typename PointOfSegment>
|
||||
struct return_type
|
||||
: promote_floating_point
|
||||
@@ -507,7 +539,6 @@ public :
|
||||
: m_strategy(s)
|
||||
{}
|
||||
|
||||
|
||||
// It might be useful in the future
|
||||
// to overload constructor with strategy info.
|
||||
// crosstrack(...) {}
|
||||
@@ -540,6 +571,12 @@ public :
|
||||
return c * radius();
|
||||
}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
inline radius_type vertical_or_meridian(T1 lat1, T2 lat2) const
|
||||
{
|
||||
return m_strategy.radius() * (lat1 - lat2);
|
||||
}
|
||||
|
||||
inline typename Strategy::radius_type radius() const
|
||||
{ return m_strategy.radius(); }
|
||||
|
||||
|
||||
@@ -0,0 +1,474 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2016-2018 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_SPHERICAL_DISTANCE_CROSS_TRACK_BOX_BOX_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_DISTANCE_CROSS_TRACK_BOX_BOX_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/concept_check.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/type_traits/is_void.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/util/math.hpp>
|
||||
#include <boost/geometry/algorithms/detail/assign_box_corners.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace distance
|
||||
{
|
||||
|
||||
namespace details
|
||||
{
|
||||
|
||||
template <typename ReturnType>
|
||||
class cross_track_box_box_generic
|
||||
{
|
||||
public :
|
||||
|
||||
template <typename Point, typename PPStrategy, typename PSStrategy>
|
||||
ReturnType static inline diagonal_case(Point topA,
|
||||
Point topB,
|
||||
Point bottomA,
|
||||
Point bottomB,
|
||||
bool north_shortest,
|
||||
bool non_overlap,
|
||||
PPStrategy pp_strategy,
|
||||
PSStrategy ps_strategy)
|
||||
{
|
||||
if (north_shortest && non_overlap)
|
||||
{
|
||||
return pp_strategy.apply(topA, bottomB);
|
||||
}
|
||||
if (north_shortest && !non_overlap)
|
||||
{
|
||||
return ps_strategy.apply(topA, topB, bottomB);
|
||||
}
|
||||
if (!north_shortest && non_overlap)
|
||||
{
|
||||
return pp_strategy.apply(bottomA, topB);
|
||||
}
|
||||
return ps_strategy.apply(bottomA, topB, bottomB);
|
||||
}
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
typename Box1,
|
||||
typename Box2,
|
||||
typename PPStrategy,
|
||||
typename PSStrategy
|
||||
>
|
||||
ReturnType static inline apply (Box1 const& box1,
|
||||
Box2 const& box2,
|
||||
PPStrategy pp_strategy,
|
||||
PSStrategy ps_strategy)
|
||||
{
|
||||
|
||||
// this method assumes that the coordinates of the point and
|
||||
// the box are normalized
|
||||
|
||||
typedef typename point_type<Box1>::type box_point_type1;
|
||||
typedef typename point_type<Box2>::type box_point_type2;
|
||||
|
||||
box_point_type1 bottom_left1, bottom_right1, top_left1, top_right1;
|
||||
geometry::detail::assign_box_corners(box1,
|
||||
bottom_left1, bottom_right1,
|
||||
top_left1, top_right1);
|
||||
|
||||
box_point_type2 bottom_left2, bottom_right2, top_left2, top_right2;
|
||||
geometry::detail::assign_box_corners(box2,
|
||||
bottom_left2, bottom_right2,
|
||||
top_left2, top_right2);
|
||||
|
||||
ReturnType lon_min1 = geometry::get_as_radian<0>(bottom_left1);
|
||||
ReturnType const lat_min1 = geometry::get_as_radian<1>(bottom_left1);
|
||||
ReturnType lon_max1 = geometry::get_as_radian<0>(top_right1);
|
||||
ReturnType const lat_max1 = geometry::get_as_radian<1>(top_right1);
|
||||
|
||||
ReturnType lon_min2 = geometry::get_as_radian<0>(bottom_left2);
|
||||
ReturnType const lat_min2 = geometry::get_as_radian<1>(bottom_left2);
|
||||
ReturnType lon_max2 = geometry::get_as_radian<0>(top_right2);
|
||||
ReturnType const lat_max2 = geometry::get_as_radian<1>(top_right2);
|
||||
|
||||
ReturnType const two_pi = math::two_pi<ReturnType>();
|
||||
|
||||
// Test which sides of the boxes are closer and if boxes cross
|
||||
// antimeridian
|
||||
bool right_wrap;
|
||||
|
||||
if (lon_min2 > 0 && lon_max2 < 0) // box2 crosses antimeridian
|
||||
{
|
||||
#ifdef BOOST_GEOMETRY_DEBUG_CROSS_TRACK_BOX_BOX
|
||||
std::cout << "(box2 crosses antimeridian)";
|
||||
#endif
|
||||
right_wrap = lon_min2 - lon_max1 < lon_min1 - lon_max2;
|
||||
lon_max2 += two_pi;
|
||||
if (lon_min1 > 0 && lon_max1 < 0) // both boxes crosses antimeridian
|
||||
{
|
||||
lon_max1 += two_pi;
|
||||
}
|
||||
}
|
||||
else if (lon_min1 > 0 && lon_max1 < 0) // only box1 crosses antimeridian
|
||||
{
|
||||
#ifdef BOOST_GEOMETRY_DEBUG_CROSS_TRACK_BOX_BOX
|
||||
std::cout << "(box1 crosses antimeridian)";
|
||||
#endif
|
||||
return apply(box2, box1, pp_strategy, ps_strategy);
|
||||
}
|
||||
else
|
||||
{
|
||||
right_wrap = lon_max1 <= lon_min2
|
||||
? lon_min2 - lon_max1 < two_pi - (lon_max2 - lon_min1)
|
||||
: lon_min1 - lon_max2 > two_pi - (lon_max1 - lon_min2);
|
||||
|
||||
}
|
||||
|
||||
// Check1: if box2 crosses the band defined by the
|
||||
// minimum and maximum longitude of box1; if yes, determine
|
||||
// if the box2 is above, below or intersects/is inside box1 and compute
|
||||
// the distance (easy in this case)
|
||||
|
||||
bool lon_min12 = lon_min1 <= lon_min2;
|
||||
bool right = lon_max1 <= lon_min2;
|
||||
bool left = lon_min1 >= lon_max2;
|
||||
bool lon_max12 = lon_max1 <= lon_max2;
|
||||
|
||||
if ((lon_min12 && !right)
|
||||
|| (!left && !lon_max12)
|
||||
|| (!lon_min12 && lon_max12))
|
||||
{
|
||||
#ifdef BOOST_GEOMETRY_DEBUG_CROSS_TRACK_BOX_BOX
|
||||
std::cout << "(up-down)\n";
|
||||
#endif
|
||||
if (lat_min1 > lat_max2)
|
||||
{
|
||||
return geometry::strategy::distance::services::result_from_distance
|
||||
<
|
||||
PSStrategy, box_point_type1, box_point_type2
|
||||
>::apply(ps_strategy, ps_strategy
|
||||
.vertical_or_meridian(lat_min1, lat_max2));
|
||||
}
|
||||
else if (lat_max1 < lat_min2)
|
||||
{
|
||||
return geometry::strategy::distance::services::result_from_distance
|
||||
<
|
||||
PSStrategy, box_point_type1, box_point_type2
|
||||
>::apply(ps_strategy, ps_strategy
|
||||
.vertical_or_meridian(lat_min2, lat_max1));
|
||||
}
|
||||
else
|
||||
{
|
||||
//BOOST_GEOMETRY_ASSERT(plat >= lat_min && plat <= lat_max);
|
||||
return ReturnType(0);
|
||||
}
|
||||
}
|
||||
|
||||
// Check2: if box2 is right/left of box1
|
||||
// the max lat of box2 should be less than the max lat of box1
|
||||
bool bottom_max;
|
||||
|
||||
ReturnType top_common = (std::min)(lat_max1, lat_max2);
|
||||
ReturnType bottom_common = (std::max)(lat_min1, lat_min2);
|
||||
|
||||
// true if the closest points are on northern hemisphere
|
||||
bool north_shortest = top_common + bottom_common > 0;
|
||||
// true if box bands do not overlap
|
||||
bool non_overlap = top_common < bottom_common;
|
||||
|
||||
if (north_shortest)
|
||||
{
|
||||
bottom_max = lat_max1 >= lat_max2;
|
||||
}
|
||||
else
|
||||
{
|
||||
bottom_max = lat_min1 <= lat_min2;
|
||||
}
|
||||
|
||||
#ifdef BOOST_GEOMETRY_DEBUG_CROSS_TRACK_BOX_BOX
|
||||
std::cout << "(diagonal)";
|
||||
#endif
|
||||
if (bottom_max && !right_wrap)
|
||||
{
|
||||
#ifdef BOOST_GEOMETRY_DEBUG_CROSS_TRACK_BOX_BOX
|
||||
std::cout << "(bottom left)";
|
||||
#endif
|
||||
return diagonal_case(top_right2, top_left1,
|
||||
bottom_right2, bottom_left1,
|
||||
north_shortest, non_overlap,
|
||||
pp_strategy, ps_strategy);
|
||||
}
|
||||
if (bottom_max && right_wrap)
|
||||
{
|
||||
#ifdef BOOST_GEOMETRY_DEBUG_CROSS_TRACK_BOX_BOX
|
||||
std::cout << "(bottom right)";
|
||||
#endif
|
||||
return diagonal_case(top_left2, top_right1,
|
||||
bottom_left2, bottom_right1,
|
||||
north_shortest, non_overlap,
|
||||
pp_strategy, ps_strategy);
|
||||
}
|
||||
if (!bottom_max && !right_wrap)
|
||||
{
|
||||
#ifdef BOOST_GEOMETRY_DEBUG_CROSS_TRACK_BOX_BOX
|
||||
std::cout << "(top left)";
|
||||
#endif
|
||||
return diagonal_case(top_left1, top_right2,
|
||||
bottom_left1, bottom_right2,
|
||||
north_shortest, non_overlap,
|
||||
pp_strategy, ps_strategy);
|
||||
}
|
||||
if (!bottom_max && right_wrap)
|
||||
{
|
||||
#ifdef BOOST_GEOMETRY_DEBUG_CROSS_TRACK_BOX_BOX
|
||||
std::cout << "(top right)";
|
||||
#endif
|
||||
return diagonal_case(top_right1, top_left2,
|
||||
bottom_right1, bottom_left2,
|
||||
north_shortest, non_overlap,
|
||||
pp_strategy, ps_strategy);
|
||||
}
|
||||
return ReturnType(0);
|
||||
}
|
||||
};
|
||||
|
||||
} //namespace details
|
||||
|
||||
/*!
|
||||
\brief Strategy functor for distance box to box calculation
|
||||
\ingroup strategies
|
||||
\details Class which calculates the distance of a box to a box, for
|
||||
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 CalculationType = void,
|
||||
typename Strategy = haversine<double, CalculationType>
|
||||
>
|
||||
class cross_track_box_box
|
||||
{
|
||||
public:
|
||||
template <typename Box1, typename Box2>
|
||||
struct return_type
|
||||
: services::return_type<Strategy,
|
||||
typename point_type<Box1>::type,
|
||||
typename point_type<Box2>::type>
|
||||
{};
|
||||
|
||||
typedef typename Strategy::radius_type radius_type;
|
||||
|
||||
// strategy getters
|
||||
|
||||
// point-segment strategy getters
|
||||
struct distance_ps_strategy
|
||||
{
|
||||
typedef cross_track<CalculationType, Strategy> type;
|
||||
};
|
||||
|
||||
typedef typename strategy::distance::services::comparable_type
|
||||
<
|
||||
Strategy
|
||||
>::type pp_comparable_strategy;
|
||||
|
||||
typedef typename boost::mpl::if_
|
||||
<
|
||||
boost::is_same
|
||||
<
|
||||
pp_comparable_strategy,
|
||||
Strategy
|
||||
>,
|
||||
typename strategy::distance::services::comparable_type
|
||||
<
|
||||
typename distance_ps_strategy::type
|
||||
>::type,
|
||||
typename distance_ps_strategy::type
|
||||
>::type ps_strategy_type;
|
||||
|
||||
// constructors
|
||||
|
||||
inline cross_track_box_box()
|
||||
{}
|
||||
|
||||
explicit inline cross_track_box_box(typename Strategy::radius_type const& r)
|
||||
: m_strategy(r)
|
||||
{}
|
||||
|
||||
inline cross_track_box_box(Strategy const& s)
|
||||
: m_strategy(s)
|
||||
{}
|
||||
|
||||
|
||||
// It might be useful in the future
|
||||
// to overload constructor with strategy info.
|
||||
// crosstrack(...) {}
|
||||
|
||||
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::PointDistanceStrategy
|
||||
<
|
||||
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,
|
||||
m_strategy,
|
||||
ps_strategy_type(m_strategy));
|
||||
}
|
||||
|
||||
inline typename Strategy::radius_type radius() const
|
||||
{
|
||||
return m_strategy.radius();
|
||||
}
|
||||
|
||||
private:
|
||||
Strategy m_strategy;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
namespace services
|
||||
{
|
||||
|
||||
template <typename CalculationType, typename Strategy>
|
||||
struct tag<cross_track_box_box<CalculationType, Strategy> >
|
||||
{
|
||||
typedef strategy_tag_distance_box_box type;
|
||||
};
|
||||
|
||||
|
||||
template <typename CalculationType, typename Strategy, typename Box1, typename Box2>
|
||||
struct return_type<cross_track_box_box<CalculationType, Strategy>, Box1, Box2>
|
||||
: cross_track_box_box
|
||||
<
|
||||
CalculationType, Strategy
|
||||
>::template return_type<Box1, Box2>
|
||||
{};
|
||||
|
||||
|
||||
template <typename CalculationType, typename Strategy>
|
||||
struct comparable_type<cross_track_box_box<CalculationType, Strategy> >
|
||||
{
|
||||
typedef cross_track_box_box
|
||||
<
|
||||
CalculationType, typename comparable_type<Strategy>::type
|
||||
> type;
|
||||
};
|
||||
|
||||
|
||||
template <typename CalculationType, typename Strategy>
|
||||
struct get_comparable<cross_track_box_box<CalculationType, Strategy> >
|
||||
{
|
||||
typedef cross_track_box_box<CalculationType, Strategy> this_strategy;
|
||||
typedef typename comparable_type<this_strategy>::type comparable_type;
|
||||
|
||||
public:
|
||||
static inline comparable_type apply(this_strategy const& strategy)
|
||||
{
|
||||
return comparable_type(strategy.radius());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename CalculationType, typename Strategy, typename Box1, typename Box2>
|
||||
struct result_from_distance
|
||||
<
|
||||
cross_track_box_box<CalculationType, Strategy>, Box1, Box2
|
||||
>
|
||||
{
|
||||
private:
|
||||
typedef cross_track_box_box<CalculationType, Strategy> 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)
|
||||
{
|
||||
Strategy s(strategy.radius());
|
||||
|
||||
return result_from_distance
|
||||
<
|
||||
Strategy,
|
||||
typename point_type<Box1>::type,
|
||||
typename point_type<Box2>::type
|
||||
>::apply(s, distance);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// define cross_track_box_box<default_point_segment_strategy> as
|
||||
// default box-box strategy for the spherical equatorial coordinate system
|
||||
template <typename Box1, typename Box2, typename Strategy>
|
||||
struct default_strategy
|
||||
<
|
||||
box_tag, box_tag, Box1, Box2,
|
||||
spherical_equatorial_tag, spherical_equatorial_tag,
|
||||
Strategy
|
||||
>
|
||||
{
|
||||
typedef cross_track_box_box
|
||||
<
|
||||
void,
|
||||
typename boost::mpl::if_
|
||||
<
|
||||
boost::is_void<Strategy>,
|
||||
typename default_strategy
|
||||
<
|
||||
point_tag, point_tag,
|
||||
typename point_type<Box1>::type, typename point_type<Box2>::type,
|
||||
spherical_equatorial_tag, spherical_equatorial_tag
|
||||
>::type,
|
||||
Strategy
|
||||
>::type
|
||||
> type;
|
||||
};
|
||||
|
||||
} // namespace services
|
||||
#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
|
||||
}} // namespace strategy::distance
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_DISTANCE_CROSS_TRACK_BOX_BOX_HPP
|
||||
@@ -4,11 +4,12 @@
|
||||
// Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
|
||||
|
||||
// This file was modified by Oracle on 2014, 2015.
|
||||
// Modifications copyright (c) 2014-2015, Oracle and/or its affiliates.
|
||||
// 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
|
||||
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||
// Contributed and/or modified by Menelaos Karavelas, 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
|
||||
@@ -42,92 +43,46 @@ 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 CalculationType = void,
|
||||
typename Strategy = cross_track<CalculationType>
|
||||
>
|
||||
class cross_track_point_box
|
||||
namespace details
|
||||
{
|
||||
public:
|
||||
template <typename Point, typename Box>
|
||||
struct return_type
|
||||
: services::return_type<Strategy, Point, typename point_type<Box>::type>
|
||||
{};
|
||||
|
||||
typedef typename Strategy::radius_type radius_type;
|
||||
template <typename ReturnType>
|
||||
class cross_track_point_box_generic
|
||||
{
|
||||
public :
|
||||
|
||||
inline cross_track_point_box()
|
||||
{}
|
||||
|
||||
explicit inline cross_track_point_box(typename Strategy::radius_type const& r)
|
||||
: m_ps_strategy(r)
|
||||
{}
|
||||
|
||||
inline cross_track_point_box(Strategy const& s)
|
||||
: m_ps_strategy(s)
|
||||
{}
|
||||
|
||||
|
||||
// It might be useful in the future
|
||||
// to overload constructor with strategy info.
|
||||
// crosstrack(...) {}
|
||||
|
||||
template <typename Point, typename Box>
|
||||
inline typename return_type<Point, Box>::type
|
||||
apply(Point const& point, Box const& box) const
|
||||
template
|
||||
<
|
||||
typename Point,
|
||||
typename Box,
|
||||
typename Strategy
|
||||
>
|
||||
ReturnType static inline apply (Point const& point,
|
||||
Box const& box,
|
||||
Strategy ps_strategy)
|
||||
{
|
||||
#if !defined(BOOST_MSVC)
|
||||
BOOST_CONCEPT_ASSERT
|
||||
(
|
||||
(concepts::PointSegmentDistanceStrategy
|
||||
<
|
||||
Strategy, Point, typename point_type<Box>::type
|
||||
>)
|
||||
);
|
||||
#endif
|
||||
|
||||
// this method assumes that the coordinates of the point and
|
||||
// the box are normalized
|
||||
|
||||
typedef typename return_type<Point, Box>::type return_type;
|
||||
typedef typename point_type<Box>::type box_point_type;
|
||||
|
||||
// TODO: This strategy as well as other cross-track strategies
|
||||
// and therefore e.g. spherical within(Point, Box) may not work
|
||||
// properly for a Box degenerated to a Segment or Point
|
||||
|
||||
box_point_type bottom_left, bottom_right, top_left, top_right;
|
||||
geometry::detail::assign_box_corners(box,
|
||||
bottom_left, bottom_right,
|
||||
top_left, top_right);
|
||||
|
||||
return_type const plon = geometry::get_as_radian<0>(point);
|
||||
return_type const plat = geometry::get_as_radian<1>(point);
|
||||
ReturnType const plon = geometry::get_as_radian<0>(point);
|
||||
ReturnType const plat = geometry::get_as_radian<1>(point);
|
||||
|
||||
return_type const lon_min = geometry::get_as_radian<0>(bottom_left);
|
||||
return_type const lat_min = geometry::get_as_radian<1>(bottom_left);
|
||||
return_type const lon_max = geometry::get_as_radian<0>(top_right);
|
||||
return_type const lat_max = geometry::get_as_radian<1>(top_right);
|
||||
ReturnType const lon_min = geometry::get_as_radian<0>(bottom_left);
|
||||
ReturnType const lat_min = geometry::get_as_radian<1>(bottom_left);
|
||||
ReturnType const lon_max = geometry::get_as_radian<0>(top_right);
|
||||
ReturnType const lat_max = geometry::get_as_radian<1>(top_right);
|
||||
|
||||
return_type const pi = math::pi<return_type>();
|
||||
return_type const two_pi = math::two_pi<return_type>();
|
||||
ReturnType const pi = math::pi<ReturnType>();
|
||||
ReturnType const two_pi = math::two_pi<ReturnType>();
|
||||
|
||||
typedef typename point_type<Box>::type box_point_type;
|
||||
|
||||
// First check if the point is within the band defined by the
|
||||
// minimum and maximum longitude of the box; if yes, determine
|
||||
@@ -142,22 +97,24 @@ public:
|
||||
{
|
||||
if (plat > lat_max)
|
||||
{
|
||||
return services::result_from_distance
|
||||
<
|
||||
Strategy, Point, box_point_type
|
||||
>::apply(m_ps_strategy, radius() * (plat - lat_max));
|
||||
return geometry::strategy::distance::services::result_from_distance
|
||||
<
|
||||
Strategy, Point, box_point_type
|
||||
>::apply(ps_strategy, ps_strategy
|
||||
.vertical_or_meridian(plat, lat_max));
|
||||
}
|
||||
else if (plat < lat_min)
|
||||
{
|
||||
return services::result_from_distance
|
||||
<
|
||||
Strategy, Point, box_point_type
|
||||
>::apply(m_ps_strategy, radius() * (lat_min - plat));
|
||||
return geometry::strategy::distance::services::result_from_distance
|
||||
<
|
||||
Strategy, Point, box_point_type
|
||||
>::apply(ps_strategy, ps_strategy
|
||||
.vertical_or_meridian(lat_min, plat));
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_GEOMETRY_ASSERT(plat >= lat_min && plat <= lat_max);
|
||||
return return_type(0);
|
||||
return ReturnType(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,14 +126,14 @@ public:
|
||||
// (1) is midway between the meridians of the left and right
|
||||
// meridians of the box, and
|
||||
// (2) does not intersect the box
|
||||
return_type const two = 2.0;
|
||||
ReturnType const two = 2.0;
|
||||
bool use_left_segment;
|
||||
if (lon_max > pi)
|
||||
{
|
||||
// the box crosses the antimeridian
|
||||
|
||||
// midway longitude = lon_min - (lon_min + (lon_max - 2 * pi)) / 2;
|
||||
return_type const lon_midway = (lon_min - lon_max) / two + pi;
|
||||
ReturnType const lon_midway = (lon_min - lon_max) / two + pi;
|
||||
BOOST_GEOMETRY_ASSERT(lon_midway >= -pi && lon_midway <= pi);
|
||||
|
||||
use_left_segment = plon > lon_midway;
|
||||
@@ -185,8 +142,8 @@ public:
|
||||
{
|
||||
// the box does not cross the antimeridian
|
||||
|
||||
return_type const lon_sum = lon_min + lon_max;
|
||||
if (math::equals(lon_sum, return_type(0)))
|
||||
ReturnType const lon_sum = lon_min + lon_max;
|
||||
if (math::equals(lon_sum, ReturnType(0)))
|
||||
{
|
||||
// special case: the box is symmetric with respect to
|
||||
// the prime meridian; the midway meridian is the antimeridian
|
||||
@@ -196,7 +153,7 @@ public:
|
||||
else
|
||||
{
|
||||
// midway long. = lon_min - (2 * pi - (lon_max - lon_min)) / 2;
|
||||
return_type lon_midway = (lon_min + lon_max) / two - pi;
|
||||
ReturnType lon_midway = (lon_min + lon_max) / two - pi;
|
||||
|
||||
// normalize the midway longitude
|
||||
if (lon_midway > pi)
|
||||
@@ -212,23 +169,119 @@ public:
|
||||
// if lon_sum is positive the midway meridian is left
|
||||
// of the box, or right of the box otherwise
|
||||
use_left_segment = lon_sum > 0
|
||||
? (plon < lon_min && plon >= lon_midway)
|
||||
: (plon <= lon_max || plon > lon_midway);
|
||||
? (plon < lon_min && plon >= lon_midway)
|
||||
: (plon <= lon_max || plon > lon_midway);
|
||||
}
|
||||
}
|
||||
|
||||
return use_left_segment
|
||||
? m_ps_strategy.apply(point, bottom_left, top_left)
|
||||
: m_ps_strategy.apply(point, bottom_right, top_right);
|
||||
? ps_strategy.apply(point, bottom_left, top_left)
|
||||
: ps_strategy.apply(point, bottom_right, top_right);
|
||||
}
|
||||
};
|
||||
|
||||
} //namespace details
|
||||
|
||||
/*!
|
||||
\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-point distance strategy
|
||||
\qbk{
|
||||
[heading See also]
|
||||
[link geometry.reference.algorithms.distance.distance_3_with_strategy distance (with strategy)]
|
||||
}
|
||||
*/
|
||||
template
|
||||
<
|
||||
typename CalculationType = void,
|
||||
typename Strategy = haversine<double, CalculationType>
|
||||
>
|
||||
class cross_track_point_box
|
||||
{
|
||||
public:
|
||||
template <typename Point, typename Box>
|
||||
struct return_type
|
||||
: services::return_type<Strategy, Point, typename point_type<Box>::type>
|
||||
{};
|
||||
|
||||
typedef typename Strategy::radius_type radius_type;
|
||||
|
||||
// strategy getters
|
||||
|
||||
// point-segment strategy getters
|
||||
struct distance_ps_strategy
|
||||
{
|
||||
typedef cross_track<CalculationType, Strategy> type;
|
||||
};
|
||||
|
||||
typedef typename strategy::distance::services::comparable_type
|
||||
<
|
||||
Strategy
|
||||
>::type pp_comparable_strategy;
|
||||
|
||||
typedef typename boost::mpl::if_
|
||||
<
|
||||
boost::is_same
|
||||
<
|
||||
pp_comparable_strategy,
|
||||
Strategy
|
||||
>,
|
||||
typename strategy::distance::services::comparable_type
|
||||
<
|
||||
typename distance_ps_strategy::type
|
||||
>::type,
|
||||
typename distance_ps_strategy::type
|
||||
>::type ps_strategy_type;
|
||||
|
||||
// constructors
|
||||
|
||||
inline cross_track_point_box()
|
||||
{}
|
||||
|
||||
explicit inline cross_track_point_box(typename Strategy::radius_type const& r)
|
||||
: m_strategy(r)
|
||||
{}
|
||||
|
||||
inline cross_track_point_box(Strategy const& s)
|
||||
: m_strategy(s)
|
||||
{}
|
||||
|
||||
|
||||
// methods
|
||||
|
||||
// It might be useful in the future
|
||||
// to overload constructor with strategy info.
|
||||
// crosstrack(...) {}
|
||||
|
||||
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::PointDistanceStrategy
|
||||
<
|
||||
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,
|
||||
ps_strategy_type(m_strategy));
|
||||
}
|
||||
|
||||
inline typename Strategy::radius_type radius() const
|
||||
{
|
||||
return m_ps_strategy.radius();
|
||||
return m_strategy.radius();
|
||||
}
|
||||
|
||||
private:
|
||||
Strategy m_ps_strategy;
|
||||
Strategy m_strategy;
|
||||
};
|
||||
|
||||
|
||||
@@ -324,7 +377,7 @@ struct default_strategy
|
||||
boost::is_void<Strategy>,
|
||||
typename default_strategy
|
||||
<
|
||||
point_tag, segment_tag,
|
||||
point_tag, point_tag,
|
||||
Point, typename point_type<Box>::type,
|
||||
spherical_equatorial_tag, spherical_equatorial_tag
|
||||
>::type,
|
||||
|
||||
@@ -2,6 +2,12 @@
|
||||
|
||||
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2017, 2018.
|
||||
// Modifications copyright (c) 2017-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)
|
||||
@@ -10,16 +16,18 @@
|
||||
#define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_DISTANCE_HAVERSINE_HPP
|
||||
|
||||
|
||||
#include <boost/geometry/core/cs.hpp>
|
||||
#include <boost/geometry/core/access.hpp>
|
||||
#include <boost/geometry/core/cs.hpp>
|
||||
#include <boost/geometry/core/radian_access.hpp>
|
||||
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
#include <boost/geometry/util/select_calculation_type.hpp>
|
||||
#include <boost/geometry/util/promote_floating_point.hpp>
|
||||
#include <boost/geometry/srs/sphere.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/distance.hpp>
|
||||
#include <boost/geometry/strategies/spherical/get_radius.hpp>
|
||||
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
#include <boost/geometry/util/promote_floating_point.hpp>
|
||||
#include <boost/geometry/util/select_calculation_type.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
@@ -40,7 +48,7 @@ namespace comparable
|
||||
// - applying asin (which is strictly (monotone) increasing)
|
||||
template
|
||||
<
|
||||
typename RadiusType,
|
||||
typename RadiusTypeOrSphere = double,
|
||||
typename CalculationType = void
|
||||
>
|
||||
class haversine
|
||||
@@ -59,10 +67,21 @@ public :
|
||||
>
|
||||
{};
|
||||
|
||||
typedef RadiusType radius_type;
|
||||
typedef typename strategy_detail::get_radius
|
||||
<
|
||||
RadiusTypeOrSphere
|
||||
>::type radius_type;
|
||||
|
||||
explicit inline haversine(RadiusType const& r = 1.0)
|
||||
: m_radius(r)
|
||||
inline haversine()
|
||||
: m_radius(1.0)
|
||||
{}
|
||||
|
||||
template <typename RadiusOrSphere>
|
||||
explicit inline haversine(RadiusOrSphere const& radius_or_sphere)
|
||||
: m_radius(strategy_detail::get_radius
|
||||
<
|
||||
RadiusOrSphere
|
||||
>::apply(radius_or_sphere))
|
||||
{}
|
||||
|
||||
template <typename Point1, typename Point2>
|
||||
@@ -75,7 +94,7 @@ public :
|
||||
);
|
||||
}
|
||||
|
||||
inline RadiusType radius() const
|
||||
inline radius_type radius() const
|
||||
{
|
||||
return m_radius;
|
||||
}
|
||||
@@ -90,7 +109,7 @@ private :
|
||||
+ cos(lat1) * cos(lat2) * math::hav(lon2 - lon1);
|
||||
}
|
||||
|
||||
RadiusType m_radius;
|
||||
radius_type m_radius;
|
||||
};
|
||||
|
||||
|
||||
@@ -101,7 +120,7 @@ private :
|
||||
\brief Distance calculation for spherical coordinates
|
||||
on a perfect sphere using haversine
|
||||
\ingroup strategies
|
||||
\tparam RadiusType \tparam_radius
|
||||
\tparam RadiusTypeOrSphere \tparam_radius_or_sphere
|
||||
\tparam CalculationType \tparam_calculation
|
||||
\author Adapted from: http://williams.best.vwh.net/avform.htm
|
||||
\see http://en.wikipedia.org/wiki/Great-circle_distance
|
||||
@@ -112,22 +131,19 @@ A mathematically equivalent formula, which is less subject
|
||||
to rounding error for short distances is:
|
||||
d=2*asin(sqrt((sin((lat1-lat2) / 2))^2
|
||||
+ cos(lat1)*cos(lat2)*(sin((lon1-lon2) / 2))^2))
|
||||
|
||||
|
||||
\qbk{
|
||||
[heading See also]
|
||||
[link geometry.reference.algorithms.distance.distance_3_with_strategy distance (with strategy)]
|
||||
}
|
||||
|
||||
*/
|
||||
template
|
||||
<
|
||||
typename RadiusType,
|
||||
typename RadiusTypeOrSphere = double,
|
||||
typename CalculationType = void
|
||||
>
|
||||
class haversine
|
||||
{
|
||||
typedef comparable::haversine<RadiusType, CalculationType> comparable_type;
|
||||
typedef comparable::haversine<RadiusTypeOrSphere, CalculationType> comparable_type;
|
||||
|
||||
public :
|
||||
template <typename Point1, typename Point2>
|
||||
@@ -135,14 +151,28 @@ public :
|
||||
: services::return_type<comparable_type, Point1, Point2>
|
||||
{};
|
||||
|
||||
typedef RadiusType radius_type;
|
||||
typedef typename strategy_detail::get_radius
|
||||
<
|
||||
RadiusTypeOrSphere
|
||||
>::type radius_type;
|
||||
|
||||
/*!
|
||||
\brief Default constructor, radius set to 1.0 for the unit sphere
|
||||
*/
|
||||
inline haversine()
|
||||
: m_radius(1.0)
|
||||
{}
|
||||
|
||||
/*!
|
||||
\brief Constructor
|
||||
\param radius radius of the sphere, defaults to 1.0 for the unit sphere
|
||||
\param radius_or_sphere radius of the sphere or sphere model
|
||||
*/
|
||||
inline haversine(RadiusType const& radius = 1.0)
|
||||
: m_radius(radius)
|
||||
template <typename RadiusOrSphere>
|
||||
explicit inline haversine(RadiusOrSphere const& radius_or_sphere)
|
||||
: m_radius(strategy_detail::get_radius
|
||||
<
|
||||
RadiusOrSphere
|
||||
>::apply(radius_or_sphere))
|
||||
{}
|
||||
|
||||
/*!
|
||||
@@ -165,13 +195,13 @@ public :
|
||||
\brief access to radius value
|
||||
\return the radius
|
||||
*/
|
||||
inline RadiusType radius() const
|
||||
inline radius_type radius() const
|
||||
{
|
||||
return m_radius;
|
||||
}
|
||||
|
||||
private :
|
||||
RadiusType m_radius;
|
||||
radius_type m_radius;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,371 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2018-2019 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_SPHERICAL_DISTANCE_SEGMENT_BOX_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_DISTANCE_SEGMENT_BOX_HPP
|
||||
|
||||
#include <boost/geometry/algorithms/detail/distance/segment_to_box.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/distance.hpp>
|
||||
#include <boost/geometry/strategies/normalize.hpp>
|
||||
#include <boost/geometry/strategies/spherical/disjoint_box_box.hpp>
|
||||
#include <boost/geometry/strategies/spherical/distance_cross_track.hpp>
|
||||
#include <boost/geometry/strategies/spherical/point_in_point.hpp>
|
||||
#include <boost/geometry/strategies/cartesian/point_in_box.hpp> // spherical
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
|
||||
namespace strategy { namespace distance
|
||||
{
|
||||
|
||||
struct generic_segment_box
|
||||
{
|
||||
template
|
||||
<
|
||||
typename LessEqual,
|
||||
typename ReturnType,
|
||||
typename SegmentPoint,
|
||||
typename BoxPoint,
|
||||
typename SegmentBoxStrategy,
|
||||
typename AzimuthStrategy,
|
||||
typename EnvelopeSegmentStrategy,
|
||||
typename NormalizePointStrategy,
|
||||
typename DisjointPointBoxStrategy,
|
||||
typename DisjointBoxBoxStrategy
|
||||
>
|
||||
static inline ReturnType segment_below_of_box(
|
||||
SegmentPoint const& p0,
|
||||
SegmentPoint const& p1,
|
||||
BoxPoint const&,
|
||||
BoxPoint const& top_right,
|
||||
BoxPoint const& bottom_left,
|
||||
BoxPoint const& bottom_right,
|
||||
SegmentBoxStrategy const& sb_strategy,
|
||||
AzimuthStrategy const& az_strategy,
|
||||
EnvelopeSegmentStrategy const& es_strategy,
|
||||
NormalizePointStrategy const& np_strategy,
|
||||
DisjointPointBoxStrategy const& dpb_strategy,
|
||||
DisjointBoxBoxStrategy const& dbb_strategy)
|
||||
{
|
||||
ReturnType result;
|
||||
typename LessEqual::other less_equal;
|
||||
typedef geometry::model::segment<SegmentPoint> Segment;
|
||||
typedef typename cs_tag<Segment>::type segment_cs_type;
|
||||
typedef geometry::detail::disjoint::
|
||||
disjoint_segment_box_sphere_or_spheroid<segment_cs_type>
|
||||
disjoint_sb;
|
||||
typedef typename disjoint_sb::disjoint_info disjoint_info_type;
|
||||
|
||||
Segment seg(p0, p1);
|
||||
|
||||
geometry::model::box<BoxPoint> input_box;
|
||||
geometry::set_from_radian<geometry::min_corner, 0>
|
||||
(input_box, geometry::get_as_radian<0>(bottom_left));
|
||||
geometry::set_from_radian<geometry::min_corner, 1>
|
||||
(input_box, geometry::get_as_radian<1>(bottom_left));
|
||||
geometry::set_from_radian<geometry::max_corner, 0>
|
||||
(input_box, geometry::get_as_radian<0>(top_right));
|
||||
geometry::set_from_radian<geometry::max_corner, 1>
|
||||
(input_box, geometry::get_as_radian<1>(top_right));
|
||||
|
||||
SegmentPoint p_max;
|
||||
|
||||
disjoint_info_type disjoint_result = disjoint_sb::
|
||||
apply(seg, input_box, p_max,
|
||||
az_strategy, np_strategy, dpb_strategy, dbb_strategy);
|
||||
|
||||
if (disjoint_result == disjoint_info_type::intersect) //intersect
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
// disjoint but vertex not computed
|
||||
if (disjoint_result == disjoint_info_type::disjoint_no_vertex)
|
||||
{
|
||||
typedef typename coordinate_type<SegmentPoint>::type CT;
|
||||
|
||||
geometry::model::box<SegmentPoint> mbr;
|
||||
geometry::envelope(seg, mbr, es_strategy);
|
||||
|
||||
CT lon1 = geometry::get_as_radian<0>(p0);
|
||||
CT lat1 = geometry::get_as_radian<1>(p0);
|
||||
CT lon2 = geometry::get_as_radian<0>(p1);
|
||||
CT lat2 = geometry::get_as_radian<1>(p1);
|
||||
|
||||
if (lon1 > lon2)
|
||||
{
|
||||
std::swap(lon1, lon2);
|
||||
std::swap(lat1, lat2);
|
||||
}
|
||||
|
||||
CT vertex_lat;
|
||||
CT lat_sum = lat1 + lat2;
|
||||
if (lat_sum > CT(0))
|
||||
{
|
||||
vertex_lat = geometry::get_as_radian<geometry::max_corner, 1>(mbr);
|
||||
} else {
|
||||
vertex_lat = geometry::get_as_radian<geometry::min_corner, 1>(mbr);
|
||||
}
|
||||
|
||||
CT alp1;
|
||||
az_strategy.apply(lon1, lat1, lon2, lat2, alp1);
|
||||
CT vertex_lon = geometry::formula::vertex_longitude
|
||||
<
|
||||
CT,
|
||||
segment_cs_type
|
||||
>::apply(lon1, lat1, lon2, lat2,
|
||||
vertex_lat, alp1, az_strategy);
|
||||
|
||||
geometry::set_from_radian<0>(p_max, vertex_lon);
|
||||
geometry::set_from_radian<1>(p_max, vertex_lat);
|
||||
}
|
||||
//otherwise disjoint and vertex computed inside disjoint
|
||||
|
||||
if (less_equal(geometry::get_as_radian<0>(bottom_left),
|
||||
geometry::get_as_radian<0>(p_max)))
|
||||
{
|
||||
result = boost::numeric_cast<ReturnType>(typename
|
||||
SegmentBoxStrategy::distance_ps_strategy::type().apply(bottom_left, p0, p1));
|
||||
}
|
||||
else
|
||||
{
|
||||
result = geometry::detail::distance::segment_to_box_2D
|
||||
<
|
||||
ReturnType,
|
||||
SegmentPoint,
|
||||
BoxPoint,
|
||||
SegmentBoxStrategy
|
||||
>::template call_above_of_box
|
||||
<
|
||||
typename LessEqual::other
|
||||
>(p1, p0, p_max, bottom_right, sb_strategy);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename SPoint, typename BPoint>
|
||||
static void mirror(SPoint& p0,
|
||||
SPoint& p1,
|
||||
BPoint& bottom_left,
|
||||
BPoint& bottom_right,
|
||||
BPoint& top_left,
|
||||
BPoint& top_right)
|
||||
{
|
||||
//if segment's vertex is the southest point then mirror geometries
|
||||
if (geometry::get<1>(p0) + geometry::get<1>(p1) < 0)
|
||||
{
|
||||
BPoint bl = bottom_left;
|
||||
BPoint br = bottom_right;
|
||||
geometry::set<1>(p0, geometry::get<1>(p0) * -1);
|
||||
geometry::set<1>(p1, geometry::get<1>(p1) * -1);
|
||||
geometry::set<1>(bottom_left, geometry::get<1>(top_left) * -1);
|
||||
geometry::set<1>(top_left, geometry::get<1>(bl) * -1);
|
||||
geometry::set<1>(bottom_right, geometry::get<1>(top_right) * -1);
|
||||
geometry::set<1>(top_right, geometry::get<1>(br) * -1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//===========================================================================
|
||||
|
||||
template
|
||||
<
|
||||
typename CalculationType = void,
|
||||
typename Strategy = haversine<double, CalculationType>
|
||||
>
|
||||
struct spherical_segment_box
|
||||
{
|
||||
template <typename PointOfSegment, typename PointOfBox>
|
||||
struct calculation_type
|
||||
: promote_floating_point
|
||||
<
|
||||
typename strategy::distance::services::return_type
|
||||
<
|
||||
Strategy,
|
||||
PointOfSegment,
|
||||
PointOfBox
|
||||
>::type
|
||||
>
|
||||
{};
|
||||
|
||||
// strategy getters
|
||||
|
||||
// point-point strategy getters
|
||||
struct distance_pp_strategy
|
||||
{
|
||||
typedef Strategy type;
|
||||
};
|
||||
|
||||
inline typename distance_pp_strategy::type get_distance_pp_strategy() const
|
||||
{
|
||||
return typename distance_pp_strategy::type();
|
||||
}
|
||||
// point-segment strategy getters
|
||||
struct distance_ps_strategy
|
||||
{
|
||||
typedef cross_track<CalculationType, Strategy> type;
|
||||
};
|
||||
|
||||
inline typename distance_ps_strategy::type get_distance_ps_strategy() const
|
||||
{
|
||||
return typename distance_ps_strategy::type();
|
||||
}
|
||||
|
||||
typedef within::spherical_point_point equals_point_point_strategy_type;
|
||||
|
||||
static inline equals_point_point_strategy_type get_equals_point_point_strategy()
|
||||
{
|
||||
return equals_point_point_strategy_type();
|
||||
}
|
||||
|
||||
// methods
|
||||
|
||||
template <typename LessEqual, typename ReturnType,
|
||||
typename SegmentPoint, typename BoxPoint>
|
||||
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) const
|
||||
{
|
||||
typedef typename azimuth::spherical<CalculationType> azimuth_strategy_type;
|
||||
azimuth_strategy_type az_strategy;
|
||||
|
||||
typedef typename envelope::spherical_segment<CalculationType>
|
||||
envelope_segment_strategy_type;
|
||||
envelope_segment_strategy_type es_strategy;
|
||||
|
||||
return generic_segment_box::segment_below_of_box
|
||||
<
|
||||
LessEqual,
|
||||
ReturnType
|
||||
>(p0,p1,top_left,top_right,bottom_left,bottom_right,
|
||||
spherical_segment_box<CalculationType>(),
|
||||
az_strategy, es_strategy,
|
||||
normalize::spherical_point(),
|
||||
covered_by::spherical_point_box(),
|
||||
disjoint::spherical_box_box());
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
namespace services
|
||||
{
|
||||
|
||||
template <typename CalculationType, typename Strategy>
|
||||
struct tag<spherical_segment_box<CalculationType, Strategy> >
|
||||
{
|
||||
typedef strategy_tag_distance_segment_box type;
|
||||
};
|
||||
|
||||
template <typename CalculationType, typename Strategy, typename PS, typename PB>
|
||||
struct return_type<spherical_segment_box<CalculationType, Strategy>, PS, PB>
|
||||
: spherical_segment_box<CalculationType, Strategy>::template calculation_type<PS, PB>
|
||||
{};
|
||||
|
||||
template <typename CalculationType, typename Strategy>
|
||||
struct comparable_type<spherical_segment_box<CalculationType, Strategy> >
|
||||
{
|
||||
// Define a cartesian_segment_box strategy with its underlying point-segment
|
||||
// strategy being comparable
|
||||
typedef spherical_segment_box
|
||||
<
|
||||
CalculationType,
|
||||
typename comparable_type<Strategy>::type
|
||||
> type;
|
||||
};
|
||||
|
||||
|
||||
template <typename CalculationType, typename Strategy>
|
||||
struct get_comparable<spherical_segment_box<CalculationType, Strategy> >
|
||||
{
|
||||
typedef typename comparable_type
|
||||
<
|
||||
spherical_segment_box<CalculationType, Strategy>
|
||||
>::type comparable_type;
|
||||
public :
|
||||
static inline comparable_type apply(spherical_segment_box<CalculationType, Strategy> const& )
|
||||
{
|
||||
return comparable_type();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename CalculationType, typename Strategy, typename PS, typename PB>
|
||||
struct result_from_distance<spherical_segment_box<CalculationType, Strategy>, PS, PB>
|
||||
{
|
||||
private :
|
||||
typedef typename return_type<
|
||||
spherical_segment_box
|
||||
<
|
||||
CalculationType,
|
||||
Strategy
|
||||
>,
|
||||
PS,
|
||||
PB
|
||||
>::type return_type;
|
||||
public :
|
||||
template <typename T>
|
||||
static inline return_type apply(spherical_segment_box<CalculationType,
|
||||
Strategy> const& ,
|
||||
T const& value)
|
||||
{
|
||||
Strategy s;
|
||||
return result_from_distance<Strategy, PS, PB>::apply(s, value);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Segment, typename Box>
|
||||
struct default_strategy
|
||||
<
|
||||
segment_tag, box_tag, Segment, Box,
|
||||
spherical_equatorial_tag, spherical_equatorial_tag
|
||||
>
|
||||
{
|
||||
typedef spherical_segment_box<> type;
|
||||
};
|
||||
|
||||
template <typename Box, typename Segment>
|
||||
struct default_strategy
|
||||
<
|
||||
box_tag, segment_tag, Box, Segment,
|
||||
spherical_equatorial_tag, spherical_equatorial_tag
|
||||
>
|
||||
{
|
||||
typedef typename default_strategy
|
||||
<
|
||||
segment_tag, box_tag, Segment, Box,
|
||||
spherical_equatorial_tag, spherical_equatorial_tag
|
||||
>::type type;
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
}} // namespace strategy::distance
|
||||
|
||||
}} // namespace boost::geometry
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_DISTANCE_SEGMENT_BOX_HPP
|
||||
146
winx64/include/boost/geometry/strategies/spherical/envelope.hpp
Normal file
146
winx64/include/boost/geometry/strategies/spherical/envelope.hpp
Normal file
@@ -0,0 +1,146 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
|
||||
|
||||
// This file was modified by Oracle on 2015, 2016, 2018.
|
||||
// Modifications copyright (c) 2015-2018, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
||||
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
||||
|
||||
// Distributed under 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_SPHERICAL_ENVELOPE_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_HPP
|
||||
|
||||
#include <boost/geometry/algorithms/detail/envelope/initialize.hpp>
|
||||
#include <boost/geometry/algorithms/detail/envelope/range_of_boxes.hpp>
|
||||
|
||||
#include <boost/geometry/iterators/segment_iterator.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/spherical/envelope_box.hpp>
|
||||
#include <boost/geometry/strategies/spherical/envelope_segment.hpp>
|
||||
#include <boost/geometry/strategies/spherical/expand_box.hpp>
|
||||
#include <boost/geometry/strategies/spherical/expand_segment.hpp>
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace envelope
|
||||
{
|
||||
|
||||
template <typename CalculationType = void>
|
||||
class spherical
|
||||
{
|
||||
public:
|
||||
typedef spherical_segment<CalculationType> element_envelope_strategy_type;
|
||||
static inline element_envelope_strategy_type get_element_envelope_strategy()
|
||||
{
|
||||
return element_envelope_strategy_type();
|
||||
}
|
||||
|
||||
typedef expand::spherical_segment<CalculationType> element_expand_strategy_type;
|
||||
static inline element_expand_strategy_type get_element_expand_strategy()
|
||||
{
|
||||
return element_expand_strategy_type();
|
||||
}
|
||||
|
||||
typedef strategy::expand::spherical_box box_expand_strategy_type;
|
||||
static inline box_expand_strategy_type get_box_expand_strategy()
|
||||
{
|
||||
return box_expand_strategy_type();
|
||||
}
|
||||
|
||||
// Linestring, Ring, Polygon
|
||||
|
||||
template <typename Range>
|
||||
static inline geometry::segment_iterator<Range const> begin(Range const& range)
|
||||
{
|
||||
return geometry::segments_begin(range);
|
||||
}
|
||||
|
||||
template <typename Range>
|
||||
static inline geometry::segment_iterator<Range const> end(Range const& range)
|
||||
{
|
||||
return geometry::segments_end(range);
|
||||
}
|
||||
|
||||
// MultiLinestring, MultiPolygon
|
||||
|
||||
template <typename Box>
|
||||
struct multi_state
|
||||
{
|
||||
void apply(Box const& single_box)
|
||||
{
|
||||
m_boxes.push_back(single_box);
|
||||
}
|
||||
|
||||
void result(Box & box)
|
||||
{
|
||||
if (!m_boxes.empty())
|
||||
{
|
||||
geometry::detail::envelope::envelope_range_of_boxes::apply(m_boxes, box);
|
||||
}
|
||||
else
|
||||
{
|
||||
geometry::detail::envelope::initialize<Box, 0, dimension<Box>::value>::apply(box);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<Box> m_boxes;
|
||||
};
|
||||
|
||||
// Segment
|
||||
|
||||
template <typename Point1, typename Point2, typename Box>
|
||||
static inline void apply(Point1 const& point1, Point2 const& point2,
|
||||
Box& box)
|
||||
{
|
||||
spherical_segment<CalculationType>::apply(point1, point2, box);
|
||||
}
|
||||
|
||||
// Box
|
||||
|
||||
template <typename BoxIn, typename Box>
|
||||
static inline void apply(BoxIn const& box_in, Box& box)
|
||||
{
|
||||
spherical_box::apply(box_in, box);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
namespace services
|
||||
{
|
||||
|
||||
template <typename Tag, typename CalculationType>
|
||||
struct default_strategy<Tag, spherical_equatorial_tag, CalculationType>
|
||||
{
|
||||
typedef strategy::envelope::spherical<CalculationType> type;
|
||||
};
|
||||
|
||||
template <typename Tag, typename CalculationType>
|
||||
struct default_strategy<Tag, spherical_polar_tag, CalculationType>
|
||||
{
|
||||
typedef strategy::envelope::spherical<CalculationType> type;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
|
||||
}} // namespace strategy::envelope
|
||||
|
||||
}} //namepsace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_HPP
|
||||
@@ -0,0 +1,145 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
|
||||
|
||||
// This file was modified by Oracle on 2015-2018.
|
||||
// Modifications copyright (c) 2015-2018, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Distributed under 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_SPHERICAL_ENVELOPE_BOX_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_BOX_HPP
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <boost/geometry/core/cs.hpp>
|
||||
#include <boost/geometry/core/coordinate_dimension.hpp>
|
||||
#include <boost/geometry/core/coordinate_system.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/views/detail/indexed_point_view.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/convert_point_to_point.hpp>
|
||||
#include <boost/geometry/algorithms/detail/normalize.hpp>
|
||||
#include <boost/geometry/algorithms/detail/envelope/transform_units.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/dispatch/envelope.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/envelope.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace envelope
|
||||
{
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
std::size_t Index,
|
||||
std::size_t DimensionCount
|
||||
>
|
||||
struct envelope_indexed_box_on_spheroid
|
||||
{
|
||||
template <typename BoxIn, typename BoxOut>
|
||||
static inline void apply(BoxIn const& box_in, BoxOut& mbr)
|
||||
{
|
||||
// transform() does not work with boxes of dimension higher
|
||||
// than 2; to account for such boxes we transform the min/max
|
||||
// points of the boxes using the indexed_point_view
|
||||
detail::indexed_point_view<BoxIn const, Index> box_in_corner(box_in);
|
||||
detail::indexed_point_view<BoxOut, Index> mbr_corner(mbr);
|
||||
|
||||
// first transform the units
|
||||
transform_units(box_in_corner, mbr_corner);
|
||||
|
||||
// now transform the remaining coordinates
|
||||
detail::conversion::point_to_point
|
||||
<
|
||||
detail::indexed_point_view<BoxIn const, Index>,
|
||||
detail::indexed_point_view<BoxOut, Index>,
|
||||
2,
|
||||
DimensionCount
|
||||
>::apply(box_in_corner, mbr_corner);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}} // namespace detail::envelope
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
namespace strategy { namespace envelope
|
||||
{
|
||||
|
||||
|
||||
struct spherical_box
|
||||
{
|
||||
template <typename BoxIn, typename BoxOut>
|
||||
static inline void apply(BoxIn const& box_in, BoxOut& mbr)
|
||||
{
|
||||
BoxIn box_in_normalized = box_in;
|
||||
|
||||
if (!is_inverse_spheroidal_coordinates(box_in))
|
||||
{
|
||||
strategy::normalize::spherical_box::apply(box_in, box_in_normalized);
|
||||
}
|
||||
|
||||
geometry::detail::envelope::envelope_indexed_box_on_spheroid
|
||||
<
|
||||
min_corner, dimension<BoxIn>::value
|
||||
>::apply(box_in_normalized, mbr);
|
||||
|
||||
geometry::detail::envelope::envelope_indexed_box_on_spheroid
|
||||
<
|
||||
max_corner, dimension<BoxIn>::value
|
||||
>::apply(box_in_normalized, mbr);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
namespace services
|
||||
{
|
||||
|
||||
template <typename CalculationType>
|
||||
struct default_strategy<box_tag, spherical_equatorial_tag, CalculationType>
|
||||
{
|
||||
typedef strategy::envelope::spherical_box type;
|
||||
};
|
||||
|
||||
template <typename CalculationType>
|
||||
struct default_strategy<box_tag, spherical_polar_tag, CalculationType>
|
||||
{
|
||||
typedef strategy::envelope::spherical_box type;
|
||||
};
|
||||
|
||||
template <typename CalculationType>
|
||||
struct default_strategy<box_tag, geographic_tag, CalculationType>
|
||||
{
|
||||
typedef strategy::envelope::spherical_box type;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
|
||||
}} // namespace strategy::envelope
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_BOX_HPP
|
||||
@@ -0,0 +1,379 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2015-2018, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Distributed under 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_SPHERICAL_ENVELOPE_MULTIPOINT_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_MULTIPOINT_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/algorithm/minmax_element.hpp>
|
||||
#include <boost/range.hpp>
|
||||
|
||||
#include <boost/geometry/core/access.hpp>
|
||||
#include <boost/geometry/core/assert.hpp>
|
||||
#include <boost/geometry/core/coordinate_system.hpp>
|
||||
#include <boost/geometry/core/coordinate_type.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
#include <boost/geometry/util/range.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/helper_geometry.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/envelope/box.hpp>
|
||||
#include <boost/geometry/algorithms/detail/envelope/initialize.hpp>
|
||||
#include <boost/geometry/algorithms/detail/envelope/range.hpp>
|
||||
#include <boost/geometry/algorithms/detail/expand/point.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/cartesian/envelope_point.hpp>
|
||||
#include <boost/geometry/strategies/normalize.hpp>
|
||||
#include <boost/geometry/strategies/spherical/envelope_box.hpp>
|
||||
#include <boost/geometry/strategies/spherical/envelope_point.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace envelope
|
||||
{
|
||||
|
||||
class spherical_multipoint
|
||||
{
|
||||
private:
|
||||
template <std::size_t Dim>
|
||||
struct coordinate_less
|
||||
{
|
||||
template <typename Point>
|
||||
inline bool operator()(Point const& point1, Point const& point2) const
|
||||
{
|
||||
return math::smaller(geometry::get<Dim>(point1),
|
||||
geometry::get<Dim>(point2));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Constants, typename MultiPoint, typename OutputIterator>
|
||||
static inline void analyze_point_coordinates(MultiPoint const& multipoint,
|
||||
bool& has_south_pole,
|
||||
bool& has_north_pole,
|
||||
OutputIterator oit)
|
||||
{
|
||||
typedef typename boost::range_value<MultiPoint>::type point_type;
|
||||
typedef typename boost::range_iterator
|
||||
<
|
||||
MultiPoint const
|
||||
>::type iterator_type;
|
||||
|
||||
// analyze point coordinates:
|
||||
// (1) normalize point coordinates
|
||||
// (2) check if any point is the north or the south pole
|
||||
// (3) put all non-pole points in a container
|
||||
//
|
||||
// notice that at this point in the algorithm, we have at
|
||||
// least two points on the spheroid
|
||||
has_south_pole = false;
|
||||
has_north_pole = false;
|
||||
|
||||
for (iterator_type it = boost::begin(multipoint);
|
||||
it != boost::end(multipoint);
|
||||
++it)
|
||||
{
|
||||
point_type point;
|
||||
normalize::spherical_point::apply(*it, point);
|
||||
|
||||
if (math::equals(geometry::get<1>(point),
|
||||
Constants::min_latitude()))
|
||||
{
|
||||
has_south_pole = true;
|
||||
}
|
||||
else if (math::equals(geometry::get<1>(point),
|
||||
Constants::max_latitude()))
|
||||
{
|
||||
has_north_pole = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
*oit++ = point;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename SortedRange, typename Value>
|
||||
static inline Value maximum_gap(SortedRange const& sorted_range,
|
||||
Value& max_gap_left,
|
||||
Value& max_gap_right)
|
||||
{
|
||||
typedef typename boost::range_iterator
|
||||
<
|
||||
SortedRange const
|
||||
>::type iterator_type;
|
||||
|
||||
iterator_type it1 = boost::begin(sorted_range), it2 = it1;
|
||||
++it2;
|
||||
max_gap_left = geometry::get<0>(*it1);
|
||||
max_gap_right = geometry::get<0>(*it2);
|
||||
|
||||
Value max_gap = max_gap_right - max_gap_left;
|
||||
for (++it1, ++it2; it2 != boost::end(sorted_range); ++it1, ++it2)
|
||||
{
|
||||
Value gap = geometry::get<0>(*it2) - geometry::get<0>(*it1);
|
||||
if (math::larger(gap, max_gap))
|
||||
{
|
||||
max_gap_left = geometry::get<0>(*it1);
|
||||
max_gap_right = geometry::get<0>(*it2);
|
||||
max_gap = gap;
|
||||
}
|
||||
}
|
||||
|
||||
return max_gap;
|
||||
}
|
||||
|
||||
template
|
||||
<
|
||||
typename Constants,
|
||||
typename PointRange,
|
||||
typename LongitudeLess,
|
||||
typename CoordinateType
|
||||
>
|
||||
static inline void get_min_max_longitudes(PointRange& range,
|
||||
LongitudeLess const& lon_less,
|
||||
CoordinateType& lon_min,
|
||||
CoordinateType& lon_max)
|
||||
{
|
||||
typedef typename boost::range_iterator
|
||||
<
|
||||
PointRange const
|
||||
>::type iterator_type;
|
||||
|
||||
// compute min and max longitude values
|
||||
std::pair<iterator_type, iterator_type> min_max_longitudes
|
||||
= boost::minmax_element(boost::begin(range),
|
||||
boost::end(range),
|
||||
lon_less);
|
||||
|
||||
lon_min = geometry::get<0>(*min_max_longitudes.first);
|
||||
lon_max = geometry::get<0>(*min_max_longitudes.second);
|
||||
|
||||
// if the longitude span is "large" compute the true maximum gap
|
||||
if (math::larger(lon_max - lon_min, Constants::half_period()))
|
||||
{
|
||||
std::sort(boost::begin(range), boost::end(range), lon_less);
|
||||
|
||||
CoordinateType max_gap_left = 0, max_gap_right = 0;
|
||||
CoordinateType max_gap
|
||||
= maximum_gap(range, max_gap_left, max_gap_right);
|
||||
|
||||
CoordinateType complement_gap
|
||||
= Constants::period() + lon_min - lon_max;
|
||||
|
||||
if (math::larger(max_gap, complement_gap))
|
||||
{
|
||||
lon_min = max_gap_right;
|
||||
lon_max = max_gap_left + Constants::period();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template
|
||||
<
|
||||
typename Constants,
|
||||
typename Iterator,
|
||||
typename LatitudeLess,
|
||||
typename CoordinateType
|
||||
>
|
||||
static inline void get_min_max_latitudes(Iterator const first,
|
||||
Iterator const last,
|
||||
LatitudeLess const& lat_less,
|
||||
bool has_south_pole,
|
||||
bool has_north_pole,
|
||||
CoordinateType& lat_min,
|
||||
CoordinateType& lat_max)
|
||||
{
|
||||
if (has_south_pole && has_north_pole)
|
||||
{
|
||||
lat_min = Constants::min_latitude();
|
||||
lat_max = Constants::max_latitude();
|
||||
}
|
||||
else if (has_south_pole)
|
||||
{
|
||||
lat_min = Constants::min_latitude();
|
||||
lat_max
|
||||
= geometry::get<1>(*std::max_element(first, last, lat_less));
|
||||
}
|
||||
else if (has_north_pole)
|
||||
{
|
||||
lat_min
|
||||
= geometry::get<1>(*std::min_element(first, last, lat_less));
|
||||
lat_max = Constants::max_latitude();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::pair<Iterator, Iterator> min_max_latitudes
|
||||
= boost::minmax_element(first, last, lat_less);
|
||||
|
||||
lat_min = geometry::get<1>(*min_max_latitudes.first);
|
||||
lat_max = geometry::get<1>(*min_max_latitudes.second);
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
template <typename MultiPoint, typename Box>
|
||||
static inline void apply(MultiPoint const& multipoint, Box& mbr)
|
||||
{
|
||||
typedef typename point_type<MultiPoint>::type point_type;
|
||||
typedef typename coordinate_type<MultiPoint>::type coordinate_type;
|
||||
typedef typename boost::range_iterator
|
||||
<
|
||||
MultiPoint const
|
||||
>::type iterator_type;
|
||||
|
||||
typedef math::detail::constants_on_spheroid
|
||||
<
|
||||
coordinate_type,
|
||||
typename geometry::detail::cs_angular_units<MultiPoint>::type
|
||||
> constants;
|
||||
|
||||
if (boost::empty(multipoint))
|
||||
{
|
||||
geometry::detail::envelope::initialize<Box, 0, dimension<Box>::value>::apply(mbr);
|
||||
return;
|
||||
}
|
||||
|
||||
geometry::detail::envelope::initialize<Box, 0, 2>::apply(mbr);
|
||||
|
||||
if (boost::size(multipoint) == 1)
|
||||
{
|
||||
return dispatch::envelope
|
||||
<
|
||||
typename boost::range_value<MultiPoint>::type
|
||||
>::apply(range::front(multipoint), mbr, strategy::envelope::spherical_point());
|
||||
}
|
||||
|
||||
// analyze the points and put the non-pole ones in the
|
||||
// points vector
|
||||
std::vector<point_type> points;
|
||||
bool has_north_pole = false, has_south_pole = false;
|
||||
|
||||
analyze_point_coordinates<constants>(multipoint,
|
||||
has_south_pole, has_north_pole,
|
||||
std::back_inserter(points));
|
||||
|
||||
coordinate_type lon_min, lat_min, lon_max, lat_max;
|
||||
if (points.size() == 1)
|
||||
{
|
||||
// we have one non-pole point and at least one pole point
|
||||
lon_min = geometry::get<0>(range::front(points));
|
||||
lon_max = geometry::get<0>(range::front(points));
|
||||
lat_min = has_south_pole
|
||||
? constants::min_latitude()
|
||||
: constants::max_latitude();
|
||||
lat_max = has_north_pole
|
||||
? constants::max_latitude()
|
||||
: constants::min_latitude();
|
||||
}
|
||||
else if (points.empty())
|
||||
{
|
||||
// all points are pole points
|
||||
BOOST_GEOMETRY_ASSERT(has_south_pole || has_north_pole);
|
||||
lon_min = coordinate_type(0);
|
||||
lon_max = coordinate_type(0);
|
||||
lat_min = has_south_pole
|
||||
? constants::min_latitude()
|
||||
: constants::max_latitude();
|
||||
lat_max = (has_north_pole)
|
||||
? constants::max_latitude()
|
||||
: constants::min_latitude();
|
||||
}
|
||||
else
|
||||
{
|
||||
get_min_max_longitudes<constants>(points,
|
||||
coordinate_less<0>(),
|
||||
lon_min,
|
||||
lon_max);
|
||||
|
||||
get_min_max_latitudes<constants>(points.begin(),
|
||||
points.end(),
|
||||
coordinate_less<1>(),
|
||||
has_south_pole,
|
||||
has_north_pole,
|
||||
lat_min,
|
||||
lat_max);
|
||||
}
|
||||
|
||||
typedef typename helper_geometry
|
||||
<
|
||||
Box,
|
||||
coordinate_type,
|
||||
typename geometry::detail::cs_angular_units<MultiPoint>::type
|
||||
>::type helper_box_type;
|
||||
|
||||
helper_box_type helper_mbr;
|
||||
|
||||
geometry::set<min_corner, 0>(helper_mbr, lon_min);
|
||||
geometry::set<min_corner, 1>(helper_mbr, lat_min);
|
||||
geometry::set<max_corner, 0>(helper_mbr, lon_max);
|
||||
geometry::set<max_corner, 1>(helper_mbr, lat_max);
|
||||
|
||||
// now transform to output MBR (per index)
|
||||
geometry::detail::envelope::envelope_indexed_box_on_spheroid<min_corner, 2>::apply(helper_mbr, mbr);
|
||||
geometry::detail::envelope::envelope_indexed_box_on_spheroid<max_corner, 2>::apply(helper_mbr, mbr);
|
||||
|
||||
// compute envelope for higher coordinates
|
||||
iterator_type it = boost::begin(multipoint);
|
||||
geometry::detail::envelope::envelope_one_point<2, dimension<Box>::value>::apply(*it, mbr);
|
||||
|
||||
for (++it; it != boost::end(multipoint); ++it)
|
||||
{
|
||||
strategy::expand::detail::point_loop
|
||||
<
|
||||
2, dimension<Box>::value
|
||||
>::apply(mbr, *it);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
namespace services
|
||||
{
|
||||
|
||||
template <typename CalculationType>
|
||||
struct default_strategy<multi_point_tag, spherical_equatorial_tag, CalculationType>
|
||||
{
|
||||
typedef strategy::envelope::spherical_multipoint type;
|
||||
};
|
||||
|
||||
template <typename CalculationType>
|
||||
struct default_strategy<multi_point_tag, spherical_polar_tag, CalculationType>
|
||||
{
|
||||
typedef strategy::envelope::spherical_multipoint type;
|
||||
};
|
||||
|
||||
template <typename CalculationType>
|
||||
struct default_strategy<multi_point_tag, geographic_tag, CalculationType>
|
||||
{
|
||||
typedef strategy::envelope::spherical_multipoint type;
|
||||
};
|
||||
|
||||
} // namespace services
|
||||
|
||||
#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
|
||||
}} // namespace strategy::envelope
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_MULTIPOINT_HPP
|
||||
@@ -0,0 +1,111 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
|
||||
|
||||
// This file was modified by Oracle on 2015, 2016, 2017, 2018.
|
||||
// Modifications copyright (c) 2015-2018, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Distributed under 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_SPHERICAL_ENVELOPE_POINT_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_POINT_HPP
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <boost/geometry/core/access.hpp>
|
||||
#include <boost/geometry/core/cs.hpp>
|
||||
#include <boost/geometry/core/coordinate_dimension.hpp>
|
||||
#include <boost/geometry/core/coordinate_system.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/views/detail/indexed_point_view.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/convert_point_to_point.hpp>
|
||||
#include <boost/geometry/algorithms/detail/normalize.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/envelope/transform_units.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/cartesian/envelope_point.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/envelope.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace envelope
|
||||
{
|
||||
|
||||
struct spherical_point
|
||||
{
|
||||
template<typename Point, typename Box>
|
||||
static inline void apply(Point const& point, Box& mbr)
|
||||
{
|
||||
Point normalized_point;
|
||||
strategy::normalize::spherical_point::apply(point, normalized_point);
|
||||
|
||||
typename point_type<Box>::type box_point;
|
||||
|
||||
// transform units of input point to units of a box point
|
||||
geometry::detail::envelope::transform_units(normalized_point, box_point);
|
||||
|
||||
geometry::set<min_corner, 0>(mbr, geometry::get<0>(box_point));
|
||||
geometry::set<min_corner, 1>(mbr, geometry::get<1>(box_point));
|
||||
|
||||
geometry::set<max_corner, 0>(mbr, geometry::get<0>(box_point));
|
||||
geometry::set<max_corner, 1>(mbr, geometry::get<1>(box_point));
|
||||
|
||||
typedef geometry::detail::envelope::envelope_one_point
|
||||
<
|
||||
2, dimension<Point>::value
|
||||
> per_corner;
|
||||
per_corner::template apply<min_corner>(normalized_point, mbr);
|
||||
per_corner::template apply<max_corner>(normalized_point, mbr);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
namespace services
|
||||
{
|
||||
|
||||
template <typename CalculationType>
|
||||
struct default_strategy<point_tag, spherical_equatorial_tag, CalculationType>
|
||||
{
|
||||
typedef strategy::envelope::spherical_point type;
|
||||
};
|
||||
|
||||
template <typename CalculationType>
|
||||
struct default_strategy<point_tag, spherical_polar_tag, CalculationType>
|
||||
{
|
||||
typedef strategy::envelope::spherical_point type;
|
||||
};
|
||||
|
||||
template <typename CalculationType>
|
||||
struct default_strategy<point_tag, geographic_tag, CalculationType>
|
||||
{
|
||||
typedef strategy::envelope::spherical_point type;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
|
||||
}} // namespace strategy::envelope
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_POINT_HPP
|
||||
@@ -1,6 +1,6 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2017 Oracle and/or its affiliates.
|
||||
// Copyright (c) 2017-2018 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
|
||||
|
||||
@@ -11,47 +11,406 @@
|
||||
#ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_SEGMENT_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_SEGMENT_HPP
|
||||
|
||||
#include <boost/geometry/algorithms/detail/envelope/segment.hpp>
|
||||
#include <boost/geometry/algorithms/detail/normalize.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
#include <boost/core/ignore_unused.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/numeric/conversion/cast.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/envelope/transform_units.hpp>
|
||||
|
||||
#include <boost/geometry/core/assert.hpp>
|
||||
#include <boost/geometry/core/coordinate_system.hpp>
|
||||
#include <boost/geometry/core/coordinate_type.hpp>
|
||||
#include <boost/geometry/core/cs.hpp>
|
||||
#include <boost/geometry/core/point_type.hpp>
|
||||
#include <boost/geometry/core/radian_access.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/formulas/meridian_segment.hpp>
|
||||
#include <boost/geometry/formulas/vertex_latitude.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/helper_geometry.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/cartesian/envelope_segment.hpp>
|
||||
#include <boost/geometry/strategies/envelope.hpp>
|
||||
#include <boost/geometry/strategies/normalize.hpp>
|
||||
#include <boost/geometry/strategies/spherical/azimuth.hpp>
|
||||
#include <boost/geometry/strategies/spherical/expand_box.hpp>
|
||||
|
||||
namespace boost { namespace geometry
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace strategy { namespace envelope
|
||||
{
|
||||
|
||||
namespace strategy { namespace envelope
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <typename CalculationType, typename CS_Tag>
|
||||
struct envelope_segment_call_vertex_latitude
|
||||
{
|
||||
template <typename T1, typename T2, typename Strategy>
|
||||
static inline CalculationType apply(T1 const& lat1,
|
||||
T2 const& alp1,
|
||||
Strategy const& )
|
||||
{
|
||||
return geometry::formula::vertex_latitude<CalculationType, CS_Tag>
|
||||
::apply(lat1, alp1);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename CalculationType>
|
||||
struct envelope_segment_call_vertex_latitude<CalculationType, geographic_tag>
|
||||
{
|
||||
template <typename T1, typename T2, typename Strategy>
|
||||
static inline CalculationType apply(T1 const& lat1,
|
||||
T2 const& alp1,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return geometry::formula::vertex_latitude<CalculationType, geographic_tag>
|
||||
::apply(lat1, alp1, strategy.model());
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Units, typename CS_Tag>
|
||||
struct envelope_segment_convert_polar
|
||||
{
|
||||
template <typename T>
|
||||
static inline void pre(T & , T & ) {}
|
||||
|
||||
template <typename T>
|
||||
static inline void post(T & , T & ) {}
|
||||
};
|
||||
|
||||
template <typename Units>
|
||||
struct envelope_segment_convert_polar<Units, spherical_polar_tag>
|
||||
{
|
||||
template <typename T>
|
||||
static inline void pre(T & lat1, T & lat2)
|
||||
{
|
||||
lat1 = math::latitude_convert_ep<Units>(lat1);
|
||||
lat2 = math::latitude_convert_ep<Units>(lat2);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static inline void post(T & lat1, T & lat2)
|
||||
{
|
||||
lat1 = math::latitude_convert_ep<Units>(lat1);
|
||||
lat2 = math::latitude_convert_ep<Units>(lat2);
|
||||
std::swap(lat1, lat2);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename CS_Tag>
|
||||
class envelope_segment_impl
|
||||
{
|
||||
private:
|
||||
|
||||
// degrees or radians
|
||||
template <typename CalculationType>
|
||||
static inline void swap(CalculationType& lon1,
|
||||
CalculationType& lat1,
|
||||
CalculationType& lon2,
|
||||
CalculationType& lat2)
|
||||
{
|
||||
std::swap(lon1, lon2);
|
||||
std::swap(lat1, lat2);
|
||||
}
|
||||
|
||||
// radians
|
||||
template <typename CalculationType>
|
||||
static inline bool contains_pi_half(CalculationType const& a1,
|
||||
CalculationType const& a2)
|
||||
{
|
||||
// azimuths a1 and a2 are assumed to be in radians
|
||||
BOOST_GEOMETRY_ASSERT(! math::equals(a1, a2));
|
||||
|
||||
static CalculationType const pi_half = math::half_pi<CalculationType>();
|
||||
|
||||
return (a1 < a2)
|
||||
? (a1 < pi_half && pi_half < a2)
|
||||
: (a1 > pi_half && pi_half > a2);
|
||||
}
|
||||
|
||||
// radians or degrees
|
||||
template <typename Units, typename CoordinateType>
|
||||
static inline bool crosses_antimeridian(CoordinateType const& lon1,
|
||||
CoordinateType const& lon2)
|
||||
{
|
||||
typedef math::detail::constants_on_spheroid
|
||||
<
|
||||
CoordinateType, Units
|
||||
> constants;
|
||||
|
||||
return math::abs(lon1 - lon2) > constants::half_period(); // > pi
|
||||
}
|
||||
|
||||
// degrees or radians
|
||||
template <typename Units, typename CalculationType, typename Strategy>
|
||||
static inline void compute_box_corners(CalculationType& lon1,
|
||||
CalculationType& lat1,
|
||||
CalculationType& lon2,
|
||||
CalculationType& lat2,
|
||||
CalculationType a1,
|
||||
CalculationType a2,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
// coordinates are assumed to be in radians
|
||||
BOOST_GEOMETRY_ASSERT(lon1 <= lon2);
|
||||
boost::ignore_unused(lon1, lon2);
|
||||
|
||||
CalculationType lat1_rad = math::as_radian<Units>(lat1);
|
||||
CalculationType lat2_rad = math::as_radian<Units>(lat2);
|
||||
|
||||
if (math::equals(a1, a2))
|
||||
{
|
||||
// the segment must lie on the equator or is very short or is meridian
|
||||
return;
|
||||
}
|
||||
|
||||
if (lat1 > lat2)
|
||||
{
|
||||
std::swap(lat1, lat2);
|
||||
std::swap(lat1_rad, lat2_rad);
|
||||
std::swap(a1, a2);
|
||||
}
|
||||
|
||||
if (contains_pi_half(a1, a2))
|
||||
{
|
||||
CalculationType p_max = envelope_segment_call_vertex_latitude
|
||||
<CalculationType, CS_Tag>::apply(lat1_rad, a1, strategy);
|
||||
|
||||
CalculationType const mid_lat = lat1 + lat2;
|
||||
if (mid_lat < 0)
|
||||
{
|
||||
// update using min latitude
|
||||
CalculationType const lat_min_rad = -p_max;
|
||||
CalculationType const lat_min
|
||||
= math::from_radian<Units>(lat_min_rad);
|
||||
|
||||
if (lat1 > lat_min)
|
||||
{
|
||||
lat1 = lat_min;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// update using max latitude
|
||||
CalculationType const lat_max_rad = p_max;
|
||||
CalculationType const lat_max
|
||||
= math::from_radian<Units>(lat_max_rad);
|
||||
|
||||
if (lat2 < lat_max)
|
||||
{
|
||||
lat2 = lat_max;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Units, typename CalculationType>
|
||||
static inline void special_cases(CalculationType& lon1,
|
||||
CalculationType& lat1,
|
||||
CalculationType& lon2,
|
||||
CalculationType& lat2)
|
||||
{
|
||||
typedef math::detail::constants_on_spheroid
|
||||
<
|
||||
CalculationType, Units
|
||||
> constants;
|
||||
|
||||
bool is_pole1 = math::equals(math::abs(lat1), constants::max_latitude());
|
||||
bool is_pole2 = math::equals(math::abs(lat2), constants::max_latitude());
|
||||
|
||||
if (is_pole1 && is_pole2)
|
||||
{
|
||||
// both points are poles; nothing more to do:
|
||||
// longitudes are already normalized to 0
|
||||
// but just in case
|
||||
lon1 = 0;
|
||||
lon2 = 0;
|
||||
}
|
||||
else if (is_pole1 && !is_pole2)
|
||||
{
|
||||
// first point is a pole, second point is not:
|
||||
// make the longitude of the first point the same as that
|
||||
// of the second point
|
||||
lon1 = lon2;
|
||||
}
|
||||
else if (!is_pole1 && is_pole2)
|
||||
{
|
||||
// second point is a pole, first point is not:
|
||||
// make the longitude of the second point the same as that
|
||||
// of the first point
|
||||
lon2 = lon1;
|
||||
}
|
||||
|
||||
if (lon1 == lon2)
|
||||
{
|
||||
// segment lies on a meridian
|
||||
if (lat1 > lat2)
|
||||
{
|
||||
std::swap(lat1, lat2);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
BOOST_GEOMETRY_ASSERT(!is_pole1 && !is_pole2);
|
||||
|
||||
if (lon1 > lon2)
|
||||
{
|
||||
swap(lon1, lat1, lon2, lat2);
|
||||
}
|
||||
|
||||
if (crosses_antimeridian<Units>(lon1, lon2))
|
||||
{
|
||||
lon1 += constants::period();
|
||||
swap(lon1, lat1, lon2, lat2);
|
||||
}
|
||||
}
|
||||
|
||||
template
|
||||
<
|
||||
typename Units,
|
||||
typename CalculationType,
|
||||
typename Box
|
||||
>
|
||||
static inline void create_box(CalculationType lon1,
|
||||
CalculationType lat1,
|
||||
CalculationType lon2,
|
||||
CalculationType lat2,
|
||||
Box& mbr)
|
||||
{
|
||||
typedef typename coordinate_type<Box>::type box_coordinate_type;
|
||||
|
||||
typedef typename helper_geometry
|
||||
<
|
||||
Box, box_coordinate_type, Units
|
||||
>::type helper_box_type;
|
||||
|
||||
helper_box_type helper_mbr;
|
||||
|
||||
geometry::set
|
||||
<
|
||||
min_corner, 0
|
||||
>(helper_mbr, boost::numeric_cast<box_coordinate_type>(lon1));
|
||||
|
||||
geometry::set
|
||||
<
|
||||
min_corner, 1
|
||||
>(helper_mbr, boost::numeric_cast<box_coordinate_type>(lat1));
|
||||
|
||||
geometry::set
|
||||
<
|
||||
max_corner, 0
|
||||
>(helper_mbr, boost::numeric_cast<box_coordinate_type>(lon2));
|
||||
|
||||
geometry::set
|
||||
<
|
||||
max_corner, 1
|
||||
>(helper_mbr, boost::numeric_cast<box_coordinate_type>(lat2));
|
||||
|
||||
geometry::detail::envelope::transform_units(helper_mbr, mbr);
|
||||
}
|
||||
|
||||
|
||||
template <typename Units, typename CalculationType, typename Strategy>
|
||||
static inline void apply(CalculationType& lon1,
|
||||
CalculationType& lat1,
|
||||
CalculationType& lon2,
|
||||
CalculationType& lat2,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
special_cases<Units>(lon1, lat1, lon2, lat2);
|
||||
|
||||
CalculationType lon1_rad = math::as_radian<Units>(lon1);
|
||||
CalculationType lat1_rad = math::as_radian<Units>(lat1);
|
||||
CalculationType lon2_rad = math::as_radian<Units>(lon2);
|
||||
CalculationType lat2_rad = math::as_radian<Units>(lat2);
|
||||
CalculationType alp1, alp2;
|
||||
strategy.apply(lon1_rad, lat1_rad, lon2_rad, lat2_rad, alp1, alp2);
|
||||
|
||||
compute_box_corners<Units>(lon1, lat1, lon2, lat2, alp1, alp2, strategy);
|
||||
}
|
||||
|
||||
public:
|
||||
template
|
||||
<
|
||||
typename Units,
|
||||
typename CalculationType,
|
||||
typename Box,
|
||||
typename Strategy
|
||||
>
|
||||
static inline void apply(CalculationType lon1,
|
||||
CalculationType lat1,
|
||||
CalculationType lon2,
|
||||
CalculationType lat2,
|
||||
Box& mbr,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
typedef envelope_segment_convert_polar<Units, typename cs_tag<Box>::type> convert_polar;
|
||||
|
||||
convert_polar::pre(lat1, lat2);
|
||||
|
||||
apply<Units>(lon1, lat1, lon2, lat2, strategy);
|
||||
|
||||
convert_polar::post(lat1, lat2);
|
||||
|
||||
create_box<Units>(lon1, lat1, lon2, lat2, mbr);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
typename CalculationType = void
|
||||
>
|
||||
class spherical_segment
|
||||
{
|
||||
public :
|
||||
|
||||
inline spherical_segment()
|
||||
{}
|
||||
|
||||
template <typename Point1, typename Point2, typename Box>
|
||||
inline void
|
||||
apply(Point1 const& point1, Point2 const& point2, Box& box) const
|
||||
public:
|
||||
typedef strategy::expand::spherical_box box_expand_strategy_type;
|
||||
static inline box_expand_strategy_type get_box_expand_strategy()
|
||||
{
|
||||
Point1 p1_normalized = detail::return_normalized<Point1>(point1);
|
||||
Point2 p2_normalized = detail::return_normalized<Point2>(point2);
|
||||
return box_expand_strategy_type();
|
||||
}
|
||||
|
||||
template <typename Point, typename Box>
|
||||
static inline void apply(Point const& point1, Point const& point2,
|
||||
Box& box)
|
||||
{
|
||||
Point p1_normalized, p2_normalized;
|
||||
strategy::normalize::spherical_point::apply(point1, p1_normalized);
|
||||
strategy::normalize::spherical_point::apply(point2, p2_normalized);
|
||||
|
||||
geometry::strategy::azimuth::spherical<CalculationType> azimuth_spherical;
|
||||
|
||||
typedef typename coordinate_system<Point1>::type::units units_type;
|
||||
typedef typename geometry::detail::cs_angular_units<Point>::type units_type;
|
||||
|
||||
geometry::detail::envelope::envelope_segment_impl<spherical_equatorial_tag>
|
||||
::template apply<units_type>(geometry::get<0>(p1_normalized),
|
||||
geometry::get<1>(p1_normalized),
|
||||
geometry::get<0>(p2_normalized),
|
||||
geometry::get<1>(p2_normalized),
|
||||
box,
|
||||
azimuth_spherical);
|
||||
// first compute the envelope range for the first two coordinates
|
||||
strategy::envelope::detail::envelope_segment_impl
|
||||
<
|
||||
spherical_equatorial_tag
|
||||
>::template apply<units_type>(geometry::get<0>(p1_normalized),
|
||||
geometry::get<1>(p1_normalized),
|
||||
geometry::get<0>(p2_normalized),
|
||||
geometry::get<1>(p2_normalized),
|
||||
box,
|
||||
azimuth_spherical);
|
||||
|
||||
// now compute the envelope range for coordinates of
|
||||
// dimension 2 and higher
|
||||
strategy::envelope::detail::envelope_one_segment
|
||||
<
|
||||
2, dimension<Point>::value
|
||||
>::apply(point1, point2, box);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -61,14 +420,14 @@ namespace services
|
||||
{
|
||||
|
||||
template <typename CalculationType>
|
||||
struct default_strategy<spherical_equatorial_tag, CalculationType>
|
||||
struct default_strategy<segment_tag, spherical_equatorial_tag, CalculationType>
|
||||
{
|
||||
typedef strategy::envelope::spherical_segment<CalculationType> type;
|
||||
};
|
||||
|
||||
|
||||
template <typename CalculationType>
|
||||
struct default_strategy<spherical_polar_tag, CalculationType>
|
||||
struct default_strategy<segment_tag, spherical_polar_tag, CalculationType>
|
||||
{
|
||||
typedef strategy::envelope::spherical_segment<CalculationType> type;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
|
||||
// Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France.
|
||||
|
||||
// This file was modified by Oracle on 2015, 2016, 2017, 2018.
|
||||
// Modifications copyright (c) 2015-2018, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Distributed under 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_SPHERICAL_EXPAND_BOX_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_EXPAND_BOX_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <algorithm>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/envelope/box.hpp>
|
||||
#include <boost/geometry/algorithms/detail/envelope/range_of_boxes.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/expand.hpp>
|
||||
#include <boost/geometry/strategies/spherical/envelope_box.hpp>
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace expand
|
||||
{
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
struct box_on_spheroid
|
||||
{
|
||||
template <typename BoxOut, typename BoxIn>
|
||||
static inline void apply(BoxOut& box_out, BoxIn const& box_in)
|
||||
{
|
||||
// normalize both boxes and convert box-in to be of type of box-out
|
||||
BoxOut mbrs[2];
|
||||
strategy::envelope::spherical_box::apply(box_in, mbrs[0]);
|
||||
strategy::envelope::spherical_box::apply(box_out, mbrs[1]);
|
||||
|
||||
// compute the envelope of the two boxes
|
||||
geometry::detail::envelope::envelope_range_of_boxes::apply(mbrs, box_out);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace detail
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
struct spherical_box
|
||||
: detail::box_on_spheroid
|
||||
{};
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
namespace services
|
||||
{
|
||||
|
||||
template <typename CalculationType>
|
||||
struct default_strategy<box_tag, spherical_equatorial_tag, CalculationType>
|
||||
{
|
||||
typedef spherical_box type;
|
||||
};
|
||||
|
||||
template <typename CalculationType>
|
||||
struct default_strategy<box_tag, spherical_polar_tag, CalculationType>
|
||||
{
|
||||
typedef spherical_box type;
|
||||
};
|
||||
|
||||
template <typename CalculationType>
|
||||
struct default_strategy<box_tag, geographic_tag, CalculationType>
|
||||
{
|
||||
typedef spherical_box type;
|
||||
};
|
||||
|
||||
} // namespace services
|
||||
|
||||
#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
|
||||
}} // namespace strategy::expand
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_EXPAND_BOX_HPP
|
||||
@@ -0,0 +1,233 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
|
||||
// Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France.
|
||||
|
||||
// This file was modified by Oracle on 2015-2018.
|
||||
// Modifications copyright (c) 2015-2018, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
||||
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
||||
|
||||
// Distributed under 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_SPHERICAL_EXPAND_POINT_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_EXPAND_POINT_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
#include <boost/geometry/core/access.hpp>
|
||||
#include <boost/geometry/core/coordinate_dimension.hpp>
|
||||
#include <boost/geometry/core/coordinate_system.hpp>
|
||||
#include <boost/geometry/core/coordinate_type.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/util/is_inverse_spheroidal_coordinates.hpp>
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
#include <boost/geometry/util/select_coordinate_type.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/normalize.hpp>
|
||||
#include <boost/geometry/algorithms/detail/envelope/transform_units.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/expand.hpp>
|
||||
#include <boost/geometry/strategies/cartesian/expand_point.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace expand
|
||||
{
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// implementation for the spherical and geographic coordinate systems
|
||||
template <std::size_t DimensionCount, bool IsEquatorial>
|
||||
struct point_loop_on_spheroid
|
||||
{
|
||||
template <typename Box, typename Point>
|
||||
static inline void apply(Box& box, Point const& point)
|
||||
{
|
||||
typedef typename point_type<Box>::type box_point_type;
|
||||
typedef typename coordinate_type<Box>::type box_coordinate_type;
|
||||
typedef typename geometry::detail::cs_angular_units<Box>::type units_type;
|
||||
|
||||
typedef math::detail::constants_on_spheroid
|
||||
<
|
||||
box_coordinate_type,
|
||||
units_type
|
||||
> constants;
|
||||
|
||||
// normalize input point and input box
|
||||
Point p_normalized;
|
||||
strategy::normalize::spherical_point::apply(point, p_normalized);
|
||||
|
||||
// transform input point to be of the same type as the box point
|
||||
box_point_type box_point;
|
||||
geometry::detail::envelope::transform_units(p_normalized, box_point);
|
||||
|
||||
if (is_inverse_spheroidal_coordinates(box))
|
||||
{
|
||||
geometry::set_from_radian<min_corner, 0>(box, geometry::get_as_radian<0>(p_normalized));
|
||||
geometry::set_from_radian<min_corner, 1>(box, geometry::get_as_radian<1>(p_normalized));
|
||||
geometry::set_from_radian<max_corner, 0>(box, geometry::get_as_radian<0>(p_normalized));
|
||||
geometry::set_from_radian<max_corner, 1>(box, geometry::get_as_radian<1>(p_normalized));
|
||||
|
||||
} else {
|
||||
|
||||
strategy::normalize::spherical_box::apply(box, box);
|
||||
|
||||
box_coordinate_type p_lon = geometry::get<0>(box_point);
|
||||
box_coordinate_type p_lat = geometry::get<1>(box_point);
|
||||
|
||||
typename coordinate_type<Box>::type
|
||||
b_lon_min = geometry::get<min_corner, 0>(box),
|
||||
b_lat_min = geometry::get<min_corner, 1>(box),
|
||||
b_lon_max = geometry::get<max_corner, 0>(box),
|
||||
b_lat_max = geometry::get<max_corner, 1>(box);
|
||||
|
||||
if (math::is_latitude_pole<units_type, IsEquatorial>(p_lat))
|
||||
{
|
||||
// the point of expansion is the either the north or the
|
||||
// south pole; the only important coordinate here is the
|
||||
// pole's latitude, as the longitude can be anything;
|
||||
// we, thus, take into account the point's latitude only and return
|
||||
geometry::set<min_corner, 1>(box, (std::min)(p_lat, b_lat_min));
|
||||
geometry::set<max_corner, 1>(box, (std::max)(p_lat, b_lat_max));
|
||||
return;
|
||||
}
|
||||
|
||||
if (math::equals(b_lat_min, b_lat_max)
|
||||
&& math::is_latitude_pole<units_type, IsEquatorial>(b_lat_min))
|
||||
{
|
||||
// the box degenerates to either the north or the south pole;
|
||||
// the only important coordinate here is the pole's latitude,
|
||||
// as the longitude can be anything;
|
||||
// we thus take into account the box's latitude only and return
|
||||
geometry::set<min_corner, 0>(box, p_lon);
|
||||
geometry::set<min_corner, 1>(box, (std::min)(p_lat, b_lat_min));
|
||||
geometry::set<max_corner, 0>(box, p_lon);
|
||||
geometry::set<max_corner, 1>(box, (std::max)(p_lat, b_lat_max));
|
||||
return;
|
||||
}
|
||||
|
||||
// update latitudes
|
||||
b_lat_min = (std::min)(b_lat_min, p_lat);
|
||||
b_lat_max = (std::max)(b_lat_max, p_lat);
|
||||
|
||||
// update longitudes
|
||||
if (math::smaller(p_lon, b_lon_min))
|
||||
{
|
||||
box_coordinate_type p_lon_shifted = p_lon + constants::period();
|
||||
|
||||
if (math::larger(p_lon_shifted, b_lon_max))
|
||||
{
|
||||
// here we could check using: ! math::larger(.., ..)
|
||||
if (math::smaller(b_lon_min - p_lon, p_lon_shifted - b_lon_max))
|
||||
{
|
||||
b_lon_min = p_lon;
|
||||
}
|
||||
else
|
||||
{
|
||||
b_lon_max = p_lon_shifted;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (math::larger(p_lon, b_lon_max))
|
||||
{
|
||||
// in this case, and since p_lon is normalized in the range
|
||||
// (-180, 180], we must have that b_lon_max <= 180
|
||||
if (b_lon_min < 0
|
||||
&& math::larger(p_lon - b_lon_max,
|
||||
constants::period() - p_lon + b_lon_min))
|
||||
{
|
||||
b_lon_min = p_lon;
|
||||
b_lon_max += constants::period();
|
||||
}
|
||||
else
|
||||
{
|
||||
b_lon_max = p_lon;
|
||||
}
|
||||
}
|
||||
|
||||
geometry::set<min_corner, 0>(box, b_lon_min);
|
||||
geometry::set<min_corner, 1>(box, b_lat_min);
|
||||
geometry::set<max_corner, 0>(box, b_lon_max);
|
||||
geometry::set<max_corner, 1>(box, b_lat_max);
|
||||
}
|
||||
|
||||
point_loop
|
||||
<
|
||||
2, DimensionCount
|
||||
>::apply(box, point);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace detail
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
struct spherical_point
|
||||
{
|
||||
template <typename Box, typename Point>
|
||||
static void apply(Box & box, Point const& point)
|
||||
{
|
||||
expand::detail::point_loop_on_spheroid
|
||||
<
|
||||
dimension<Point>::value,
|
||||
! boost::is_same<typename cs_tag<Point>::type, spherical_polar_tag>::value
|
||||
>::apply(box, point);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
namespace services
|
||||
{
|
||||
|
||||
template <typename CalculationType>
|
||||
struct default_strategy<point_tag, spherical_equatorial_tag, CalculationType>
|
||||
{
|
||||
typedef spherical_point type;
|
||||
};
|
||||
|
||||
template <typename CalculationType>
|
||||
struct default_strategy<point_tag, spherical_polar_tag, CalculationType>
|
||||
{
|
||||
typedef spherical_point type;
|
||||
};
|
||||
|
||||
template <typename CalculationType>
|
||||
struct default_strategy<point_tag, geographic_tag, CalculationType>
|
||||
{
|
||||
typedef spherical_point type;
|
||||
};
|
||||
|
||||
|
||||
} // namespace services
|
||||
|
||||
#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
|
||||
}} // namespace strategy::expand
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_EXPAND_POINT_HPP
|
||||
@@ -0,0 +1,118 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
|
||||
// Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France.
|
||||
|
||||
// This file was modified by Oracle on 2015, 2016, 2017, 2018.
|
||||
// Modifications copyright (c) 2015-2018, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Distributed under 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_SPHERICAL_EXPAND_SEGMENT_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_EXPAND_SEGMENT_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
|
||||
#include <boost/geometry/core/access.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/util/select_coordinate_type.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/envelope/box.hpp>
|
||||
#include <boost/geometry/algorithms/detail/envelope/range_of_boxes.hpp>
|
||||
#include <boost/geometry/algorithms/detail/envelope/segment.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/expand.hpp>
|
||||
#include <boost/geometry/strategies/spherical/envelope_segment.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace expand
|
||||
{
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
struct segment_on_spheroid
|
||||
{
|
||||
template <typename Box, typename Segment, typename EnvelopeStrategy>
|
||||
static inline void apply(Box& box, Segment const& segment, EnvelopeStrategy const& strategy)
|
||||
{
|
||||
Box mbrs[2];
|
||||
|
||||
// compute the envelope of the segment
|
||||
typename point_type<Segment>::type p[2];
|
||||
geometry::detail::assign_point_from_index<0>(segment, p[0]);
|
||||
geometry::detail::assign_point_from_index<1>(segment, p[1]);
|
||||
geometry::detail::envelope::envelope_segment
|
||||
<
|
||||
dimension<Segment>::value
|
||||
>::apply(p[0], p[1], mbrs[0], strategy);
|
||||
|
||||
// normalize the box
|
||||
strategy::envelope::spherical_box::apply(box, mbrs[1]);
|
||||
|
||||
// compute the envelope of the two boxes
|
||||
geometry::detail::envelope::envelope_range_of_boxes::apply(mbrs, box);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
typename CalculationType = void
|
||||
>
|
||||
class spherical_segment
|
||||
{
|
||||
public:
|
||||
template <typename Box, typename Segment>
|
||||
static inline void apply(Box& box, Segment const& segment)
|
||||
{
|
||||
detail::segment_on_spheroid::apply(box, segment,
|
||||
strategy::envelope::spherical_segment<CalculationType>());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
namespace services
|
||||
{
|
||||
|
||||
template <typename CalculationType>
|
||||
struct default_strategy<segment_tag, spherical_equatorial_tag, CalculationType>
|
||||
{
|
||||
typedef spherical_segment<CalculationType> type;
|
||||
};
|
||||
|
||||
template <typename CalculationType>
|
||||
struct default_strategy<segment_tag, spherical_polar_tag, CalculationType>
|
||||
{
|
||||
typedef spherical_segment<CalculationType> type;
|
||||
};
|
||||
|
||||
} // namespace services
|
||||
|
||||
#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
|
||||
}} // namespace strategy::expand
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_EXPAND_SEGMENT_HPP
|
||||
@@ -0,0 +1,81 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// Copyright (c) 2016-2018 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_SPHERICAL_GET_RADIUS_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_GET_RADIUS_HPP
|
||||
|
||||
|
||||
#include <boost/geometry/core/coordinate_type.hpp>
|
||||
#include <boost/geometry/core/radius.hpp>
|
||||
#include <boost/geometry/core/tag.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
#include <boost/geometry/util/select_most_precise.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace strategy_detail
|
||||
{
|
||||
|
||||
template
|
||||
<
|
||||
typename RadiusTypeOrSphere,
|
||||
typename Tag = typename tag<RadiusTypeOrSphere>::type
|
||||
>
|
||||
struct get_radius
|
||||
{
|
||||
typedef typename geometry::radius_type<RadiusTypeOrSphere>::type type;
|
||||
static type apply(RadiusTypeOrSphere const& sphere)
|
||||
{
|
||||
return geometry::get_radius<0>(sphere);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename RadiusTypeOrSphere>
|
||||
struct get_radius<RadiusTypeOrSphere, void>
|
||||
{
|
||||
typedef RadiusTypeOrSphere type;
|
||||
static type apply(RadiusTypeOrSphere const& radius)
|
||||
{
|
||||
return radius;
|
||||
}
|
||||
};
|
||||
|
||||
// For backward compatibility
|
||||
template <typename Point>
|
||||
struct get_radius<Point, point_tag>
|
||||
{
|
||||
typedef typename select_most_precise
|
||||
<
|
||||
typename coordinate_type<Point>::type,
|
||||
double
|
||||
>::type type;
|
||||
|
||||
template <typename RadiusOrSphere>
|
||||
static typename get_radius<RadiusOrSphere>::type
|
||||
apply(RadiusOrSphere const& radius_or_sphere)
|
||||
{
|
||||
return get_radius<RadiusOrSphere>::apply(radius_or_sphere);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace strategy_detail
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_GET_RADIUS_HPP
|
||||
@@ -1,6 +1,8 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2016-2017, Oracle and/or its affiliates.
|
||||
// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// Copyright (c) 2016-2019, 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,
|
||||
@@ -33,14 +35,19 @@
|
||||
|
||||
#include <boost/geometry/policies/robustness/segment_ratio.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/agnostic/point_in_poly_winding.hpp>
|
||||
#include <boost/geometry/strategies/covered_by.hpp>
|
||||
#include <boost/geometry/strategies/intersection.hpp>
|
||||
#include <boost/geometry/strategies/intersection_result.hpp>
|
||||
#include <boost/geometry/strategies/side.hpp>
|
||||
#include <boost/geometry/strategies/side_info.hpp>
|
||||
#include <boost/geometry/strategies/spherical/area.hpp>
|
||||
#include <boost/geometry/strategies/spherical/disjoint_box_box.hpp>
|
||||
#include <boost/geometry/strategies/spherical/disjoint_segment_box.hpp>
|
||||
#include <boost/geometry/strategies/spherical/distance_haversine.hpp>
|
||||
#include <boost/geometry/strategies/spherical/envelope.hpp>
|
||||
#include <boost/geometry/strategies/spherical/expand_box.hpp>
|
||||
#include <boost/geometry/strategies/spherical/point_in_point.hpp>
|
||||
#include <boost/geometry/strategies/spherical/point_in_poly_winding.hpp>
|
||||
#include <boost/geometry/strategies/spherical/ssf.hpp>
|
||||
#include <boost/geometry/strategies/within.hpp>
|
||||
|
||||
@@ -93,11 +100,10 @@ struct ecef_segments
|
||||
template <typename Geometry1, typename Geometry2>
|
||||
struct point_in_geometry_strategy
|
||||
{
|
||||
typedef strategy::within::winding
|
||||
typedef strategy::within::spherical_winding
|
||||
<
|
||||
typename point_type<Geometry1>::type,
|
||||
typename point_type<Geometry2>::type,
|
||||
side_strategy_type,
|
||||
CalculationType
|
||||
> type;
|
||||
};
|
||||
@@ -118,7 +124,7 @@ struct ecef_segments
|
||||
{
|
||||
typedef area::spherical
|
||||
<
|
||||
typename point_type<Geometry>::type,
|
||||
typename coordinate_type<Geometry>::type,
|
||||
CalculationType
|
||||
> type;
|
||||
};
|
||||
@@ -147,44 +153,65 @@ struct ecef_segments
|
||||
return strategy_type();
|
||||
}
|
||||
|
||||
typedef envelope::spherical<CalculationType>
|
||||
envelope_strategy_type;
|
||||
|
||||
static inline envelope_strategy_type get_envelope_strategy()
|
||||
{
|
||||
return envelope_strategy_type();
|
||||
}
|
||||
|
||||
typedef expand::spherical_segment<CalculationType>
|
||||
expand_strategy_type;
|
||||
|
||||
static inline expand_strategy_type get_expand_strategy()
|
||||
{
|
||||
return expand_strategy_type();
|
||||
}
|
||||
|
||||
typedef within::spherical_point_point point_in_point_strategy_type;
|
||||
|
||||
static inline point_in_point_strategy_type get_point_in_point_strategy()
|
||||
{
|
||||
return point_in_point_strategy_type();
|
||||
}
|
||||
|
||||
typedef within::spherical_point_point equals_point_point_strategy_type;
|
||||
|
||||
static inline equals_point_point_strategy_type get_equals_point_point_strategy()
|
||||
{
|
||||
return equals_point_point_strategy_type();
|
||||
}
|
||||
|
||||
typedef disjoint::spherical_box_box disjoint_box_box_strategy_type;
|
||||
|
||||
static inline disjoint_box_box_strategy_type get_disjoint_box_box_strategy()
|
||||
{
|
||||
return disjoint_box_box_strategy_type();
|
||||
}
|
||||
|
||||
typedef disjoint::segment_box_spherical disjoint_segment_box_strategy_type;
|
||||
|
||||
static inline disjoint_segment_box_strategy_type get_disjoint_segment_box_strategy()
|
||||
{
|
||||
return disjoint_segment_box_strategy_type();
|
||||
}
|
||||
|
||||
typedef covered_by::spherical_point_box disjoint_point_box_strategy_type;
|
||||
typedef expand::spherical_box expand_box_strategy_type;
|
||||
|
||||
enum intersection_point_flag { ipi_inters = 0, ipi_at_a1, ipi_at_a2, ipi_at_b1, ipi_at_b2 };
|
||||
|
||||
// segment_intersection_info cannot outlive relate_ecef_segments
|
||||
template <typename CoordinateType, typename SegmentRatio, typename Vector3d>
|
||||
struct segment_intersection_info
|
||||
{
|
||||
typedef typename select_most_precise
|
||||
<
|
||||
CoordinateType, double
|
||||
>::type promoted_type;
|
||||
|
||||
segment_intersection_info(CalcPolicy const& calc)
|
||||
: calc_policy(calc)
|
||||
{}
|
||||
|
||||
promoted_type comparable_length_a() const
|
||||
{
|
||||
return robust_ra.denominator();
|
||||
}
|
||||
|
||||
promoted_type comparable_length_b() const
|
||||
{
|
||||
return robust_rb.denominator();
|
||||
}
|
||||
|
||||
template <typename Point, typename Segment1, typename Segment2>
|
||||
void assign_a(Point& point, Segment1 const& a, Segment2 const& b) const
|
||||
{
|
||||
assign(point, a, b);
|
||||
}
|
||||
template <typename Point, typename Segment1, typename Segment2>
|
||||
void assign_b(Point& point, Segment1 const& a, Segment2 const& b) const
|
||||
{
|
||||
assign(point, a, b);
|
||||
}
|
||||
|
||||
template <typename Point, typename Segment1, typename Segment2>
|
||||
void assign(Point& point, Segment1 const& a, Segment2 const& b) const
|
||||
void calculate(Point& point, Segment1 const& a, Segment2 const& b) const
|
||||
{
|
||||
if (ip_flag == ipi_inters)
|
||||
{
|
||||
@@ -268,7 +295,6 @@ struct ecef_segments
|
||||
BOOST_CONCEPT_ASSERT( (concepts::ConstSegment<Segment2>) );
|
||||
|
||||
// TODO: check only 2 first coordinates here?
|
||||
using geometry::detail::equals::equals_point_point;
|
||||
bool a_is_point = equals_point_point(a1, a2);
|
||||
bool b_is_point = equals_point_point(b1, b2);
|
||||
|
||||
@@ -293,36 +319,64 @@ struct ecef_segments
|
||||
vec3d_t const b1v = calc_policy.template to_cart3d<vec3d_t>(b1);
|
||||
vec3d_t const b2v = calc_policy.template to_cart3d<vec3d_t>(b2);
|
||||
|
||||
bool degen_neq_coords = false;
|
||||
side_info sides;
|
||||
|
||||
typename CalcPolicy::template plane<vec3d_t>
|
||||
plane2 = calc_policy.get_plane(b1v, b2v);
|
||||
|
||||
// not normalized normals, the same as in side strategy
|
||||
sides.set<0>(plane2.side_value(a1v), plane2.side_value(a2v));
|
||||
if (sides.same<0>())
|
||||
calc_t dist_b1_b2 = 0;
|
||||
if (! b_is_point)
|
||||
{
|
||||
// Both points are at same side of other segment, we can leave
|
||||
return Policy::disjoint();
|
||||
calculate_dist(b1v, b2v, plane2, dist_b1_b2);
|
||||
if (math::equals(dist_b1_b2, c0))
|
||||
{
|
||||
degen_neq_coords = true;
|
||||
b_is_point = true;
|
||||
dist_b1_b2 = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// not normalized normals, the same as in side strategy
|
||||
sides.set<0>(plane2.side_value(a1v), plane2.side_value(a2v));
|
||||
if (sides.same<0>())
|
||||
{
|
||||
// Both points are at same side of other segment, we can leave
|
||||
return Policy::disjoint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typename CalcPolicy::template plane<vec3d_t>
|
||||
plane1 = calc_policy.get_plane(a1v, a2v);
|
||||
|
||||
// not normalized normals, the same as in side strategy
|
||||
sides.set<1>(plane1.side_value(b1v), plane1.side_value(b2v));
|
||||
if (sides.same<1>())
|
||||
calc_t dist_a1_a2 = 0;
|
||||
if (! a_is_point)
|
||||
{
|
||||
// Both points are at same side of other segment, we can leave
|
||||
return Policy::disjoint();
|
||||
calculate_dist(a1v, a2v, plane1, dist_a1_a2);
|
||||
if (math::equals(dist_a1_a2, c0))
|
||||
{
|
||||
degen_neq_coords = true;
|
||||
a_is_point = true;
|
||||
dist_a1_a2 = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// not normalized normals, the same as in side strategy
|
||||
sides.set<1>(plane1.side_value(b1v), plane1.side_value(b2v));
|
||||
if (sides.same<1>())
|
||||
{
|
||||
// Both points are at same side of other segment, we can leave
|
||||
return Policy::disjoint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: at this point the segments may still be disjoint
|
||||
|
||||
calc_t len1, len2;
|
||||
|
||||
calc_t len1 = 0;
|
||||
// point or opposite sides of a sphere/spheroid, assume point
|
||||
if (! detail::vec_normalize(plane1.normal, len1))
|
||||
if (! a_is_point && ! detail::vec_normalize(plane1.normal, len1))
|
||||
{
|
||||
a_is_point = true;
|
||||
if (sides.get<0, 0>() == 0 || sides.get<0, 1>() == 0)
|
||||
@@ -331,7 +385,8 @@ struct ecef_segments
|
||||
}
|
||||
}
|
||||
|
||||
if (! detail::vec_normalize(plane2.normal, len2))
|
||||
calc_t len2 = 0;
|
||||
if (! b_is_point && ! detail::vec_normalize(plane2.normal, len2))
|
||||
{
|
||||
b_is_point = true;
|
||||
if (sides.get<1, 0>() == 0 || sides.get<1, 1>() == 0)
|
||||
@@ -395,30 +450,32 @@ struct ecef_segments
|
||||
{
|
||||
if (a_is_point)
|
||||
{
|
||||
return collinear_one_degenerated<Policy, calc_t>(a, true, b1, b2, a1, a2, b1v, b2v, plane2, a1v);
|
||||
return collinear_one_degenerated<Policy, calc_t>(a, true, b1, b2, a1, a2, b1v, b2v,
|
||||
plane2, a1v, a2v, dist_b1_b2, degen_neq_coords);
|
||||
}
|
||||
else if (b_is_point)
|
||||
{
|
||||
// b2 used to be consistent with (degenerated) checks above (is it needed?)
|
||||
return collinear_one_degenerated<Policy, calc_t>(b, false, a1, a2, b1, b2, a1v, a2v, plane1, b1v);
|
||||
return collinear_one_degenerated<Policy, calc_t>(b, false, a1, a2, b1, b2, a1v, a2v,
|
||||
plane1, b1v, b2v, dist_a1_a2, 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;
|
||||
calc_t dist_a1_b1, dist_a1_b2;
|
||||
calc_t dist_b1_a1, dist_b1_a2;
|
||||
// use shorter segment
|
||||
if (len1 <= len2)
|
||||
{
|
||||
calculate_collinear_data(a1, a2, b1, b2, a1v, a2v, plane1, b1v, dist_a1_a2, dist_a1_b1);
|
||||
calculate_collinear_data(a1, a2, b1, b2, a1v, a2v, plane1, b2v, dist_a1_a2, dist_a1_b2);
|
||||
calculate_collinear_data(a1, a2, b1, b2, a1v, a2v, plane1, b1v, b2v, dist_a1_a2, dist_a1_b1);
|
||||
calculate_collinear_data(a1, a2, b2, b1, a1v, a2v, plane1, b2v, b1v, 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, b1v, b2v, plane2, a1v, dist_b1_b2, dist_b1_a1);
|
||||
calculate_collinear_data(b1, b2, a1, a2, b1v, b2v, plane2, a2v, dist_b1_b2, dist_b1_a2);
|
||||
calculate_collinear_data(b1, b2, a1, a2, b1v, b2v, plane2, a1v, a2v, dist_b1_b2, dist_b1_a1);
|
||||
calculate_collinear_data(b1, b2, a2, a1, b1v, b2v, plane2, a2v, a1v, 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;
|
||||
@@ -478,10 +535,11 @@ struct ecef_segments
|
||||
|
||||
vec3d_t i1;
|
||||
intersection_point_flag ip_flag;
|
||||
calc_t dist_a1_a2, dist_a1_i1, dist_b1_b2, dist_b1_i1;
|
||||
calc_t dist_a1_i1, dist_b1_i1;
|
||||
if (calculate_ip_data(a1, a2, b1, b2, a1v, a2v, b1v, b2v,
|
||||
plane1, plane2, calc_policy, sides,
|
||||
i1, dist_a1_a2, dist_a1_i1, dist_b1_b2, dist_b1_i1, ip_flag))
|
||||
plane1, plane2, calc_policy,
|
||||
sides, dist_a1_a2, dist_b1_b2,
|
||||
i1, dist_a1_i1, dist_b1_i1, ip_flag))
|
||||
{
|
||||
// intersects
|
||||
segment_intersection_info
|
||||
@@ -511,43 +569,68 @@ private:
|
||||
collinear_one_degenerated(Segment const& segment, bool degenerated_a,
|
||||
Point1 const& a1, Point1 const& a2,
|
||||
Point2 const& b1, Point2 const& b2,
|
||||
Vec3d const& v1, Vec3d const& v2,
|
||||
Vec3d const& a1v, Vec3d const& a2v,
|
||||
Plane const& plane,
|
||||
Vec3d const& vother)
|
||||
Vec3d const& b1v, Vec3d const& b2v,
|
||||
CalcT const& dist_1_2,
|
||||
bool degen_neq_coords)
|
||||
{
|
||||
CalcT dist_1_2, dist_1_o;
|
||||
return ! calculate_collinear_data(a1, a2, b1, b2, v1, v2, plane, vother, dist_1_2, dist_1_o)
|
||||
CalcT dist_1_o;
|
||||
return ! calculate_collinear_data(a1, a2, b1, b2, a1v, a2v, plane, b1v, b2v, dist_1_2, dist_1_o, degen_neq_coords)
|
||||
? Policy::disjoint()
|
||||
: Policy::one_degenerate(segment, segment_ratio<CalcT>(dist_1_o, dist_1_2), degenerated_a);
|
||||
}
|
||||
|
||||
template <typename Point1, typename Point2, typename Vec3d, typename Plane, typename CalcT>
|
||||
static inline bool calculate_collinear_data(Point1 const& a1, Point1 const& a2, // in
|
||||
Point2 const& b1, Point2 const& b2, // in
|
||||
Point2 const& b1, Point2 const& /*b2*/, // in
|
||||
Vec3d const& a1v, // in
|
||||
Vec3d const& a2v, // in
|
||||
Plane const& plane1, // in
|
||||
Vec3d const& b1v_or_b2v, // in
|
||||
CalcT& dist_a1_a2, CalcT& dist_a1_i1) // out
|
||||
Vec3d const& b1v, // in
|
||||
Vec3d const& b2v, // in
|
||||
CalcT const& dist_a1_a2, // in
|
||||
CalcT& dist_a1_b1, // out
|
||||
bool degen_neq_coords = false) // in
|
||||
{
|
||||
// calculate dist_a1_a2 and dist_a1_i1
|
||||
calculate_dists(a1v, a2v, plane1, b1v_or_b2v, dist_a1_a2, dist_a1_i1);
|
||||
// calculate dist_a1_b1
|
||||
calculate_dist(a1v, a2v, plane1, b1v, dist_a1_b1);
|
||||
|
||||
// if i1 is close to a1 and b1 or b2 is equal to a1
|
||||
if (is_endpoint_equal(dist_a1_i1, a1, b1, b2))
|
||||
// if b1 is equal to a1
|
||||
if (is_endpoint_equal(dist_a1_b1, a1, b1))
|
||||
{
|
||||
dist_a1_i1 = 0;
|
||||
dist_a1_b1 = 0;
|
||||
return true;
|
||||
}
|
||||
// or i1 is close to a2 and b1 or b2 is equal to a2
|
||||
else if (is_endpoint_equal(dist_a1_a2 - dist_a1_i1, a2, b1, b2))
|
||||
// or b1 is equal to a2
|
||||
else if (is_endpoint_equal(dist_a1_a2 - dist_a1_b1, a2, b1))
|
||||
{
|
||||
dist_a1_i1 = dist_a1_a2;
|
||||
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;
|
||||
|
||||
CalcT dist_a1_b2 = 0;
|
||||
calculate_dist(a1v, a2v, plane1, b2v, dist_a1_b2);
|
||||
|
||||
if (math::equals(dist_a1_b2, c0))
|
||||
{
|
||||
dist_a1_b1 = 0;
|
||||
return true;
|
||||
}
|
||||
else if (math::equals(dist_a1_a2 - dist_a1_b2, c0))
|
||||
{
|
||||
dist_a1_b1 = dist_a1_a2;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// or i1 is on b
|
||||
return segment_ratio<CalcT>(dist_a1_i1, dist_a1_a2).on_segment();
|
||||
return segment_ratio<CalcT>(dist_a1_b1, dist_a1_a2).on_segment();
|
||||
}
|
||||
|
||||
template <typename Point1, typename Point2, typename Vec3d, typename Plane, typename CalcT>
|
||||
@@ -559,15 +642,17 @@ private:
|
||||
Plane const& plane2, // in
|
||||
CalcPolicy const& calc_policy, // in
|
||||
side_info const& sides, // in
|
||||
Vec3d & ip, // 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
|
||||
CalcT const& dist_a1_a2, // in
|
||||
CalcT const& dist_b1_b2, // in
|
||||
Vec3d & ip, // out
|
||||
CalcT& dist_a1_ip, // out
|
||||
CalcT& dist_b1_ip, // out
|
||||
intersection_point_flag& ip_flag) // out
|
||||
{
|
||||
Vec3d ip1, ip2;
|
||||
calc_policy.intersection_points(plane1, plane2, ip1, ip2);
|
||||
|
||||
calculate_dists(a1v, a2v, plane1, ip1, dist_a1_a2, dist_a1_ip);
|
||||
calculate_dist(a1v, a2v, plane1, ip1, dist_a1_ip);
|
||||
ip = ip1;
|
||||
|
||||
// choose the opposite side of the globe if the distance is shorter
|
||||
@@ -593,7 +678,7 @@ private:
|
||||
return false;
|
||||
}
|
||||
|
||||
calculate_dists(b1v, b2v, plane2, ip, dist_b1_b2, dist_b1_ip);
|
||||
calculate_dist(b1v, b2v, plane2, ip, dist_b1_ip);
|
||||
|
||||
bool is_on_b = false, is_near_b1 = false, is_near_b2 = false;
|
||||
if (! is_potentially_crossing(dist_b1_b2, dist_b1_ip, is_on_b, is_near_b1, is_near_b2))
|
||||
@@ -602,7 +687,6 @@ private:
|
||||
}
|
||||
|
||||
// reassign the IP if some endpoints overlap
|
||||
using geometry::detail::equals::equals_point_point;
|
||||
if (is_near_a1)
|
||||
{
|
||||
if (is_near_b1 && equals_point_point(a1, b1))
|
||||
@@ -692,20 +776,26 @@ private:
|
||||
}
|
||||
|
||||
template <typename Vec3d, typename Plane, typename CalcT>
|
||||
static inline void calculate_dists(Vec3d const& a1v, // in
|
||||
Vec3d const& a2v, // in
|
||||
Plane const& plane1, // in
|
||||
Vec3d const& i1, // in
|
||||
CalcT& dist_a1_a2, // out
|
||||
CalcT& dist_a1_i1) // out
|
||||
static inline void calculate_dist(Vec3d const& a1v, // in
|
||||
Vec3d const& a2v, // in
|
||||
Plane const& plane1, // in
|
||||
CalcT& dist_a1_a2) // out
|
||||
{
|
||||
//CalcT const c0 = 0;
|
||||
CalcT const c1 = 1;
|
||||
CalcT const c2 = 2;
|
||||
CalcT const c4 = 4;
|
||||
|
||||
CalcT cos_a1_a2 = plane1.cos_angle_between(a1v, a2v);
|
||||
static CalcT const c1 = 1;
|
||||
CalcT const cos_a1_a2 = plane1.cos_angle_between(a1v, a2v);
|
||||
dist_a1_a2 = -cos_a1_a2 + c1; // [1, -1] -> [0, 2] representing [0, pi]
|
||||
}
|
||||
|
||||
template <typename Vec3d, typename Plane, typename CalcT>
|
||||
static inline void calculate_dist(Vec3d const& a1v, // in
|
||||
Vec3d const& /*a2v*/, // in
|
||||
Plane const& plane1, // in
|
||||
Vec3d const& i1, // in
|
||||
CalcT& dist_a1_i1) // out
|
||||
{
|
||||
static CalcT const c1 = 1;
|
||||
static CalcT const c2 = 2;
|
||||
static CalcT const c4 = 4;
|
||||
|
||||
bool is_forward = true;
|
||||
CalcT cos_a1_i1 = plane1.cos_angle_between(a1v, i1, is_forward);
|
||||
@@ -719,7 +809,19 @@ private:
|
||||
dist_a1_i1 += c4; // += 2pi
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
template <typename Vec3d, typename Plane, typename CalcT>
|
||||
static inline void calculate_dists(Vec3d const& a1v, // in
|
||||
Vec3d const& a2v, // in
|
||||
Plane const& plane1, // in
|
||||
Vec3d const& i1, // in
|
||||
CalcT& dist_a1_a2, // out
|
||||
CalcT& dist_a1_i1) // out
|
||||
{
|
||||
calculate_dist(a1v, a2v, plane1, dist_a1_a2);
|
||||
calculate_dist(a1v, a2v, plane1, i1, dist_a1_i1);
|
||||
}
|
||||
*/
|
||||
// the dist of the ip on the other side of the sphere
|
||||
template <typename CalcT>
|
||||
static inline CalcT dist_of_i2(CalcT const& dist_a1_i1)
|
||||
@@ -758,10 +860,10 @@ private:
|
||||
|
||||
template <typename CalcT, typename P1, typename P2>
|
||||
static inline bool is_endpoint_equal(CalcT const& dist,
|
||||
P1 const& ai, P2 const& b1, P2 const& b2)
|
||||
P1 const& ai, P2 const& b1)
|
||||
{
|
||||
using geometry::detail::equals::equals_point_point;
|
||||
return is_near(dist) && (equals_point_point(ai, b1) || equals_point_point(ai, b2));
|
||||
static CalcT const c0 = 0;
|
||||
return is_near(dist) && (math::equals(dist, c0) || equals_point_point(ai, b1));
|
||||
}
|
||||
|
||||
template <typename CalcT>
|
||||
@@ -788,6 +890,13 @@ private:
|
||||
: ca1 < cb2 ? 4
|
||||
: 2 );
|
||||
}
|
||||
|
||||
template <typename Point1, typename Point2>
|
||||
static inline bool equals_point_point(Point1 const& point1, Point2 const& point2)
|
||||
{
|
||||
return detail::equals::equals_point_point(point1, point2,
|
||||
point_in_point_strategy_type());
|
||||
}
|
||||
};
|
||||
|
||||
struct spherical_segments_calc_policy
|
||||
@@ -859,7 +968,7 @@ struct spherical_segments_calc_policy
|
||||
multiply_value(ip2, coord_t(-1));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2018, 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_SPHERICAL_LINE_INTERPOLATE_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_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/formulas/interpolate_point_spherical.hpp>
|
||||
#include <boost/geometry/srs/spheroid.hpp>
|
||||
#include <boost/geometry/strategies/line_interpolate.hpp>
|
||||
#include <boost/geometry/strategies/spherical/distance_haversine.hpp>
|
||||
#include <boost/geometry/util/select_calculation_type.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace line_interpolate
|
||||
{
|
||||
|
||||
|
||||
/*!
|
||||
\brief Interpolate point on a spherical segment.
|
||||
\ingroup strategies
|
||||
\tparam CalculationType \tparam_calculation
|
||||
\tparam DistanceStrategy The underlying point-point distance strategy
|
||||
|
||||
\qbk{
|
||||
[heading See also]
|
||||
\* [link geometry.reference.algorithms.line_interpolate.line_interpolate_4_with_strategy line_interpolate (with strategy)]
|
||||
}
|
||||
|
||||
*/
|
||||
template
|
||||
<
|
||||
typename CalculationType = void,
|
||||
typename DistanceStrategy = distance::haversine<double, CalculationType>
|
||||
>
|
||||
class spherical
|
||||
{
|
||||
public:
|
||||
|
||||
typedef typename DistanceStrategy::radius_type radius_type;
|
||||
|
||||
inline spherical()
|
||||
{}
|
||||
|
||||
explicit inline spherical(typename DistanceStrategy::radius_type const& r)
|
||||
: m_strategy(r)
|
||||
{}
|
||||
|
||||
inline spherical(DistanceStrategy const& s)
|
||||
: m_strategy(s)
|
||||
{}
|
||||
|
||||
// point-point strategy getters
|
||||
struct distance_pp_strategy
|
||||
{
|
||||
typedef DistanceStrategy type;
|
||||
};
|
||||
|
||||
inline typename distance_pp_strategy::type get_distance_pp_strategy() const
|
||||
{
|
||||
return m_strategy;
|
||||
}
|
||||
|
||||
template <typename Point, typename Fraction, typename Distance>
|
||||
inline void apply(Point const& p0,
|
||||
Point const& p1,
|
||||
Fraction const& fraction,
|
||||
Point & p,
|
||||
Distance const&) const
|
||||
{
|
||||
typedef typename select_calculation_type_alt
|
||||
<
|
||||
CalculationType,
|
||||
Point
|
||||
>::type calc_t;
|
||||
|
||||
formula::interpolate_point_spherical<calc_t> formula;
|
||||
|
||||
calc_t angle01;
|
||||
formula.compute_angle(p0, p1, angle01);
|
||||
formula.compute_axis(p0, angle01);
|
||||
|
||||
calc_t a = angle01 * fraction;
|
||||
formula.compute_point(a, p);
|
||||
}
|
||||
private :
|
||||
DistanceStrategy m_strategy;
|
||||
};
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
namespace services
|
||||
{
|
||||
|
||||
template <>
|
||||
struct default_strategy<spherical_equatorial_tag>
|
||||
{
|
||||
typedef strategy::line_interpolate::spherical<> type;
|
||||
};
|
||||
|
||||
|
||||
} // namespace services
|
||||
#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
|
||||
}} // namespace strategy::line_interpolate
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_LINE_INTERPOLATE_HPP
|
||||
@@ -0,0 +1,172 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
|
||||
// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland
|
||||
|
||||
// This file was modified by Oracle on 2013, 2014, 2015, 2017, 2018.
|
||||
// Modifications copyright (c) 2013-2018, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
|
||||
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
||||
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
|
||||
#ifndef BOOST_GEOMETRY_STRATEGY_SPHERICAL_POINT_IN_POINT_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGY_SPHERICAL_POINT_IN_POINT_HPP
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <boost/geometry/core/access.hpp>
|
||||
#include <boost/geometry/core/radian_access.hpp>
|
||||
#include <boost/geometry/core/coordinate_dimension.hpp>
|
||||
#include <boost/geometry/core/coordinate_system.hpp>
|
||||
#include <boost/geometry/core/coordinate_type.hpp>
|
||||
#include <boost/geometry/core/cs.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/normalize.hpp>
|
||||
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
|
||||
#include <boost/geometry/algorithms/transform.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/helper_geometry.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/cartesian/point_in_point.hpp>
|
||||
#include <boost/geometry/strategies/covered_by.hpp>
|
||||
#include <boost/geometry/strategies/strategy_transform.hpp>
|
||||
#include <boost/geometry/strategies/within.hpp>
|
||||
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
#include <boost/geometry/util/select_most_precise.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace within
|
||||
{
|
||||
|
||||
class point_point_on_spheroid
|
||||
{
|
||||
private:
|
||||
template <typename Point1, typename Point2, bool SameUnits>
|
||||
struct are_same_points
|
||||
{
|
||||
static inline bool apply(Point1 const& point1, Point2 const& point2)
|
||||
{
|
||||
typedef typename helper_geometry<Point1>::type helper_point_type1;
|
||||
typedef typename helper_geometry<Point2>::type helper_point_type2;
|
||||
|
||||
helper_point_type1 point1_normalized;
|
||||
strategy::normalize::spherical_point::apply(point1, point1_normalized);
|
||||
helper_point_type2 point2_normalized;
|
||||
strategy::normalize::spherical_point::apply(point2, point2_normalized);
|
||||
|
||||
return point_point_generic
|
||||
<
|
||||
0, dimension<Point1>::value
|
||||
>::apply(point1_normalized, point2_normalized);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Point1, typename Point2>
|
||||
struct are_same_points<Point1, Point2, false> // points have different units
|
||||
{
|
||||
static inline bool apply(Point1 const& point1, Point2 const& point2)
|
||||
{
|
||||
typedef typename geometry::select_most_precise
|
||||
<
|
||||
typename fp_coordinate_type<Point1>::type,
|
||||
typename fp_coordinate_type<Point2>::type
|
||||
>::type calculation_type;
|
||||
|
||||
typename helper_geometry
|
||||
<
|
||||
Point1, calculation_type, radian
|
||||
>::type helper_point1, helper_point2;
|
||||
|
||||
Point1 point1_normalized = return_normalized<Point1>(point1);
|
||||
Point2 point2_normalized = return_normalized<Point2>(point2);
|
||||
|
||||
geometry::transform(point1_normalized, helper_point1);
|
||||
geometry::transform(point2_normalized, helper_point2);
|
||||
|
||||
return point_point_generic
|
||||
<
|
||||
0, dimension<Point1>::value
|
||||
>::apply(helper_point1, helper_point2);
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
template <typename Point1, typename Point2>
|
||||
static inline bool apply(Point1 const& point1, Point2 const& point2)
|
||||
{
|
||||
return are_same_points
|
||||
<
|
||||
Point1,
|
||||
Point2,
|
||||
boost::is_same
|
||||
<
|
||||
typename detail::cs_angular_units<Point1>::type,
|
||||
typename detail::cs_angular_units<Point2>::type
|
||||
>::value
|
||||
>::apply(point1, point2);
|
||||
}
|
||||
};
|
||||
|
||||
}} // namespace detail::within
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
namespace strategy { namespace within
|
||||
{
|
||||
|
||||
struct spherical_point_point
|
||||
: geometry::detail::within::point_point_on_spheroid
|
||||
{};
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
namespace services
|
||||
{
|
||||
|
||||
template <typename PointLike1, typename PointLike2, typename Tag1, typename Tag2>
|
||||
struct default_strategy<PointLike1, PointLike2, Tag1, Tag2, pointlike_tag, pointlike_tag, spherical_tag, spherical_tag>
|
||||
{
|
||||
typedef strategy::within::spherical_point_point type;
|
||||
};
|
||||
|
||||
} // namespace services
|
||||
#endif
|
||||
|
||||
|
||||
}} // namespace strategy::within
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
namespace strategy { namespace covered_by { namespace services
|
||||
{
|
||||
|
||||
template <typename PointLike1, typename PointLike2, typename Tag1, typename Tag2>
|
||||
struct default_strategy<PointLike1, PointLike2, Tag1, Tag2, pointlike_tag, pointlike_tag, spherical_tag, spherical_tag>
|
||||
{
|
||||
typedef strategy::within::spherical_point_point type;
|
||||
};
|
||||
|
||||
}}} // namespace strategy::covered_by::services
|
||||
#endif
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGY_SPHERICAL_POINT_IN_POINT_HPP
|
||||
@@ -0,0 +1,596 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2013-2017 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2013, 2014, 2016, 2017, 2018.
|
||||
// Modifications copyright (c) 2013-2018 Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
||||
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_GEOMETRY_STRATEGY_SPHERICAL_POINT_IN_POLY_WINDING_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGY_SPHERICAL_POINT_IN_POLY_WINDING_HPP
|
||||
|
||||
|
||||
#include <boost/geometry/core/access.hpp>
|
||||
#include <boost/geometry/core/coordinate_system.hpp>
|
||||
#include <boost/geometry/core/cs.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
#include <boost/geometry/util/select_calculation_type.hpp>
|
||||
#include <boost/geometry/util/normalize_spheroidal_coordinates.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/cartesian/point_in_box.hpp>
|
||||
#include <boost/geometry/strategies/covered_by.hpp>
|
||||
#include <boost/geometry/strategies/side.hpp>
|
||||
#include <boost/geometry/strategies/spherical/disjoint_box_box.hpp>
|
||||
#include <boost/geometry/strategies/spherical/ssf.hpp>
|
||||
#include <boost/geometry/strategies/within.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace within
|
||||
{
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template
|
||||
<
|
||||
typename Point,
|
||||
typename PointOfSegment = Point,
|
||||
typename SideStrategy = typename strategy::side::services::default_strategy
|
||||
<
|
||||
typename cs_tag<Point>::type
|
||||
>::type,
|
||||
typename CalculationType = void
|
||||
>
|
||||
class spherical_winding_base
|
||||
{
|
||||
typedef typename select_calculation_type
|
||||
<
|
||||
Point,
|
||||
PointOfSegment,
|
||||
CalculationType
|
||||
>::type calculation_type;
|
||||
|
||||
typedef typename geometry::detail::cs_angular_units<Point>::type units_t;
|
||||
typedef math::detail::constants_on_spheroid<calculation_type, units_t> constants;
|
||||
|
||||
/*! subclass to keep state */
|
||||
class counter
|
||||
{
|
||||
int m_count;
|
||||
//int m_count_n;
|
||||
int m_count_s;
|
||||
int m_raw_count;
|
||||
int m_raw_count_anti;
|
||||
bool m_touches;
|
||||
|
||||
inline int code() const
|
||||
{
|
||||
if (m_touches)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (m_raw_count != 0 && m_raw_count_anti != 0)
|
||||
{
|
||||
if (m_raw_count > 0) // right, wrap around south pole
|
||||
{
|
||||
return (m_count + m_count_s) == 0 ? -1 : 1;
|
||||
}
|
||||
else // left, wrap around north pole
|
||||
{
|
||||
//return (m_count + m_count_n) == 0 ? -1 : 1;
|
||||
// m_count_n is 0
|
||||
return m_count == 0 ? -1 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
return m_count == 0 ? -1 : 1;
|
||||
}
|
||||
|
||||
public :
|
||||
friend class spherical_winding_base;
|
||||
|
||||
inline counter()
|
||||
: m_count(0)
|
||||
//, m_count_n(0)
|
||||
, m_count_s(0)
|
||||
, m_raw_count(0)
|
||||
, m_raw_count_anti(0)
|
||||
, m_touches(false)
|
||||
{}
|
||||
|
||||
};
|
||||
|
||||
struct count_info
|
||||
{
|
||||
explicit count_info(int c = 0, bool ia = false)
|
||||
: count(c)
|
||||
, is_anti(ia)
|
||||
{}
|
||||
|
||||
int count;
|
||||
bool is_anti;
|
||||
};
|
||||
|
||||
public:
|
||||
typedef typename SideStrategy::envelope_strategy_type envelope_strategy_type;
|
||||
|
||||
inline envelope_strategy_type get_envelope_strategy() const
|
||||
{
|
||||
return m_side_strategy.get_envelope_strategy();
|
||||
}
|
||||
|
||||
typedef typename SideStrategy::disjoint_strategy_type disjoint_strategy_type;
|
||||
|
||||
inline disjoint_strategy_type get_disjoint_strategy() const
|
||||
{
|
||||
return m_side_strategy.get_disjoint_strategy();
|
||||
}
|
||||
|
||||
typedef typename SideStrategy::equals_point_point_strategy_type equals_point_point_strategy_type;
|
||||
inline equals_point_point_strategy_type get_equals_point_point_strategy() const
|
||||
{
|
||||
return m_side_strategy.get_equals_point_point_strategy();
|
||||
}
|
||||
|
||||
typedef disjoint::spherical_box_box disjoint_box_box_strategy_type;
|
||||
static inline disjoint_box_box_strategy_type get_disjoint_box_box_strategy()
|
||||
{
|
||||
return disjoint_box_box_strategy_type();
|
||||
}
|
||||
|
||||
typedef covered_by::spherical_point_box disjoint_point_box_strategy_type;
|
||||
|
||||
spherical_winding_base()
|
||||
{}
|
||||
|
||||
template <typename Model>
|
||||
explicit spherical_winding_base(Model const& model)
|
||||
: m_side_strategy(model)
|
||||
{}
|
||||
|
||||
// Typedefs and static methods to fulfill the concept
|
||||
typedef Point point_type;
|
||||
typedef PointOfSegment segment_point_type;
|
||||
typedef counter state_type;
|
||||
|
||||
inline bool apply(Point const& point,
|
||||
PointOfSegment const& s1, PointOfSegment const& s2,
|
||||
counter& state) const
|
||||
{
|
||||
bool eq1 = false;
|
||||
bool eq2 = false;
|
||||
bool s_antipodal = false;
|
||||
|
||||
count_info ci = check_segment(point, s1, s2, state, eq1, eq2, s_antipodal);
|
||||
if (ci.count != 0)
|
||||
{
|
||||
if (! ci.is_anti)
|
||||
{
|
||||
int side = 0;
|
||||
if (ci.count == 1 || ci.count == -1)
|
||||
{
|
||||
side = side_equal(point, eq1 ? s1 : s2, ci);
|
||||
}
|
||||
else // count == 2 || count == -2
|
||||
{
|
||||
if (! s_antipodal)
|
||||
{
|
||||
// 1 left, -1 right
|
||||
side = m_side_strategy.apply(s1, s2, point);
|
||||
}
|
||||
else
|
||||
{
|
||||
calculation_type const pi = constants::half_period();
|
||||
calculation_type const s1_lat = get<1>(s1);
|
||||
calculation_type const s2_lat = get<1>(s2);
|
||||
|
||||
side = math::sign(ci.count)
|
||||
* (pi - s1_lat - s2_lat <= pi // segment goes through north pole
|
||||
? -1 // going right all points will be on right side
|
||||
: 1); // going right all points will be on left side
|
||||
}
|
||||
}
|
||||
|
||||
if (side == 0)
|
||||
{
|
||||
// Point is lying on segment
|
||||
state.m_touches = true;
|
||||
state.m_count = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Side is NEG for right, POS for left.
|
||||
// The count is -2 for left, 2 for right (or -1/1)
|
||||
// Side positive thus means RIGHT and LEFTSIDE or LEFT and RIGHTSIDE
|
||||
// See accompagnying figure (TODO)
|
||||
if (side * ci.count > 0)
|
||||
{
|
||||
state.m_count += ci.count;
|
||||
}
|
||||
|
||||
state.m_raw_count += ci.count;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Count negated because the segment is on the other side of the globe
|
||||
// so it is reversed to match this side of the globe
|
||||
|
||||
// Assuming geometry wraps around north pole, for segments on the other side of the globe
|
||||
// the point will always be RIGHT+RIGHTSIDE or LEFT+LEFTSIDE, so side*-count always < 0
|
||||
//state.m_count_n -= 0;
|
||||
|
||||
// Assuming geometry wraps around south pole, for segments on the other side of the globe
|
||||
// the point will always be RIGHT+LEFTSIDE or LEFT+RIGHTSIDE, so side*-count always > 0
|
||||
state.m_count_s -= ci.count;
|
||||
|
||||
state.m_raw_count_anti -= ci.count;
|
||||
}
|
||||
}
|
||||
return ! state.m_touches;
|
||||
}
|
||||
|
||||
static inline int result(counter const& state)
|
||||
{
|
||||
return state.code();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
static inline count_info check_segment(Point const& point,
|
||||
PointOfSegment const& seg1,
|
||||
PointOfSegment const& seg2,
|
||||
counter& state,
|
||||
bool& eq1, bool& eq2, bool& s_antipodal)
|
||||
{
|
||||
if (check_touch(point, seg1, seg2, state, eq1, eq2, s_antipodal))
|
||||
{
|
||||
return count_info(0, false);
|
||||
}
|
||||
|
||||
return calculate_count(point, seg1, seg2, eq1, eq2, s_antipodal);
|
||||
}
|
||||
|
||||
static inline int check_touch(Point const& point,
|
||||
PointOfSegment const& seg1,
|
||||
PointOfSegment const& seg2,
|
||||
counter& state,
|
||||
bool& eq1,
|
||||
bool& eq2,
|
||||
bool& s_antipodal)
|
||||
{
|
||||
calculation_type const c0 = 0;
|
||||
calculation_type const c2 = 2;
|
||||
calculation_type const pi = constants::half_period();
|
||||
calculation_type const half_pi = pi / c2;
|
||||
|
||||
calculation_type const p_lon = get<0>(point);
|
||||
calculation_type const s1_lon = get<0>(seg1);
|
||||
calculation_type const s2_lon = get<0>(seg2);
|
||||
calculation_type const p_lat = get<1>(point);
|
||||
calculation_type const s1_lat = get<1>(seg1);
|
||||
calculation_type const s2_lat = get<1>(seg2);
|
||||
|
||||
// NOTE: lat in {-90, 90} and arbitrary lon
|
||||
// it doesn't matter what lon it is if it's a pole
|
||||
// so e.g. if one of the segment endpoints is a pole
|
||||
// then only the other lon matters
|
||||
|
||||
bool eq1_strict = longitudes_equal(s1_lon, p_lon);
|
||||
bool eq2_strict = longitudes_equal(s2_lon, p_lon);
|
||||
bool eq1_anti = false;
|
||||
bool eq2_anti = false;
|
||||
|
||||
calculation_type const anti_p_lon = p_lon + (p_lon <= c0 ? pi : -pi);
|
||||
|
||||
eq1 = eq1_strict // lon strictly equal to s1
|
||||
|| (eq1_anti = longitudes_equal(s1_lon, anti_p_lon)) // anti-lon strictly equal to s1
|
||||
|| math::equals(math::abs(s1_lat), half_pi); // s1 is pole
|
||||
eq2 = eq2_strict // lon strictly equal to s2
|
||||
|| (eq2_anti = longitudes_equal(s2_lon, anti_p_lon)) // anti-lon strictly equal to s2
|
||||
|| math::equals(math::abs(s2_lat), half_pi); // s2 is pole
|
||||
|
||||
// segment overlapping pole
|
||||
calculation_type const s_lon_diff = math::longitude_distance_signed<units_t>(s1_lon, s2_lon);
|
||||
s_antipodal = math::equals(s_lon_diff, pi);
|
||||
if (s_antipodal)
|
||||
{
|
||||
eq1 = eq2 = eq1 || eq2;
|
||||
|
||||
// segment overlapping pole and point is pole
|
||||
if (math::equals(math::abs(p_lat), half_pi))
|
||||
{
|
||||
eq1 = eq2 = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Both equal p -> segment vertical
|
||||
// The only thing which has to be done is check if point is ON segment
|
||||
if (eq1 && eq2)
|
||||
{
|
||||
// segment endpoints on the same sides of the globe
|
||||
if (! s_antipodal)
|
||||
{
|
||||
// p's lat between segment endpoints' lats
|
||||
if ( (s1_lat <= p_lat && s2_lat >= p_lat) || (s2_lat <= p_lat && s1_lat >= p_lat) )
|
||||
{
|
||||
if (!eq1_anti || !eq2_anti)
|
||||
{
|
||||
state.m_touches = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// going through north or south pole?
|
||||
if (pi - s1_lat - s2_lat <= pi)
|
||||
{
|
||||
if ( (eq1_strict && s1_lat <= p_lat) || (eq2_strict && s2_lat <= p_lat) // north
|
||||
|| math::equals(p_lat, half_pi) ) // point on north pole
|
||||
{
|
||||
state.m_touches = true;
|
||||
}
|
||||
else if (! eq1_strict && ! eq2_strict && math::equals(p_lat, -half_pi) ) // point on south pole
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else // south pole
|
||||
{
|
||||
if ( (eq1_strict && s1_lat >= p_lat) || (eq2_strict && s2_lat >= p_lat) // south
|
||||
|| math::equals(p_lat, -half_pi) ) // point on south pole
|
||||
{
|
||||
state.m_touches = true;
|
||||
}
|
||||
else if (! eq1_strict && ! eq2_strict && math::equals(p_lat, half_pi) ) // point on north pole
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Called if point is not aligned with a vertical segment
|
||||
static inline count_info calculate_count(Point const& point,
|
||||
PointOfSegment const& seg1,
|
||||
PointOfSegment const& seg2,
|
||||
bool eq1, bool eq2, bool s_antipodal)
|
||||
{
|
||||
// If both segment endpoints were poles below checks wouldn't be enough
|
||||
// but this means that either both are the same or that they are N/S poles
|
||||
// and therefore the segment is not valid.
|
||||
// If needed (eq1 && eq2 ? 0) could be returned
|
||||
|
||||
calculation_type const c0 = 0;
|
||||
calculation_type const pi = constants::half_period();
|
||||
|
||||
calculation_type const p = get<0>(point);
|
||||
calculation_type const s1 = get<0>(seg1);
|
||||
calculation_type const s2 = get<0>(seg2);
|
||||
|
||||
calculation_type const s1_p = math::longitude_distance_signed<units_t>(s1, p);
|
||||
|
||||
if (s_antipodal)
|
||||
{
|
||||
return count_info(s1_p < c0 ? -2 : 2, false); // choose W/E
|
||||
}
|
||||
|
||||
calculation_type const s1_s2 = math::longitude_distance_signed<units_t>(s1, s2);
|
||||
|
||||
if (eq1 || eq2) // Point on level s1 or s2
|
||||
{
|
||||
return count_info(s1_s2 < c0 ? -1 : 1, // choose W/E
|
||||
longitudes_equal(p + pi, (eq1 ? s1 : s2)));
|
||||
}
|
||||
|
||||
// Point between s1 and s2
|
||||
if ( math::sign(s1_p) == math::sign(s1_s2)
|
||||
&& math::abs(s1_p) < math::abs(s1_s2) )
|
||||
{
|
||||
return count_info(s1_s2 < c0 ? -2 : 2, false); // choose W/E
|
||||
}
|
||||
|
||||
calculation_type const s1_p_anti = math::longitude_distance_signed<units_t>(s1, p + pi);
|
||||
|
||||
// Anti-Point between s1 and s2
|
||||
if ( math::sign(s1_p_anti) == math::sign(s1_s2)
|
||||
&& math::abs(s1_p_anti) < math::abs(s1_s2) )
|
||||
{
|
||||
return count_info(s1_s2 < c0 ? -2 : 2, true); // choose W/E
|
||||
}
|
||||
|
||||
return count_info(0, false);
|
||||
}
|
||||
|
||||
|
||||
// Fix for https://svn.boost.org/trac/boost/ticket/9628
|
||||
// For floating point coordinates, the <D> coordinate of a point is compared
|
||||
// with the segment's points using some EPS. If the coordinates are "equal"
|
||||
// the sides are calculated. Therefore we can treat a segment as a long areal
|
||||
// geometry having some width. There is a small ~triangular area somewhere
|
||||
// between the segment's effective area and a segment's line used in sides
|
||||
// calculation where the segment is on the one side of the line but on the
|
||||
// other side of a segment (due to the width).
|
||||
// Below picture assuming D = 1, if D = 0 horiz<->vert, E<->N, RIGHT<->UP.
|
||||
// For the s1 of a segment going NE the real side is RIGHT but the point may
|
||||
// be detected as LEFT, like this:
|
||||
// RIGHT
|
||||
// ___----->
|
||||
// ^ O Pt __ __
|
||||
// EPS __ __
|
||||
// v__ __ BUT DETECTED AS LEFT OF THIS LINE
|
||||
// _____7
|
||||
// _____/
|
||||
// _____/
|
||||
// In the code below actually D = 0, so segments are nearly-vertical
|
||||
// Called when the point is on the same level as one of the segment's points
|
||||
// but the point is not aligned with a vertical segment
|
||||
inline int side_equal(Point const& point,
|
||||
PointOfSegment const& se,
|
||||
count_info const& ci) const
|
||||
{
|
||||
typedef typename coordinate_type<PointOfSegment>::type scoord_t;
|
||||
typedef typename geometry::detail::cs_angular_units<PointOfSegment>::type units_t;
|
||||
|
||||
if (math::equals(get<1>(point), get<1>(se)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Create a horizontal segment intersecting the original segment's endpoint
|
||||
// equal to the point, with the derived direction (E/W).
|
||||
PointOfSegment ss1, ss2;
|
||||
set<1>(ss1, get<1>(se));
|
||||
set<0>(ss1, get<0>(se));
|
||||
set<1>(ss2, get<1>(se));
|
||||
scoord_t ss20 = get<0>(se);
|
||||
if (ci.count > 0)
|
||||
{
|
||||
ss20 += small_angle();
|
||||
}
|
||||
else
|
||||
{
|
||||
ss20 -= small_angle();
|
||||
}
|
||||
math::normalize_longitude<units_t>(ss20);
|
||||
set<0>(ss2, ss20);
|
||||
|
||||
// Check the side using this vertical segment
|
||||
return m_side_strategy.apply(ss1, ss2, point);
|
||||
}
|
||||
|
||||
// 1 deg or pi/180 rad
|
||||
static inline calculation_type small_angle()
|
||||
{
|
||||
return constants::half_period() / calculation_type(180);
|
||||
};
|
||||
|
||||
static inline bool longitudes_equal(calculation_type const& lon1, calculation_type const& lon2)
|
||||
{
|
||||
return math::equals(
|
||||
math::longitude_distance_signed<units_t>(lon1, lon2),
|
||||
calculation_type(0));
|
||||
}
|
||||
|
||||
SideStrategy m_side_strategy;
|
||||
};
|
||||
|
||||
|
||||
} // namespace detail
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
/*!
|
||||
\brief Within detection using winding rule in spherical coordinate system.
|
||||
\ingroup strategies
|
||||
\tparam Point \tparam_point
|
||||
\tparam PointOfSegment \tparam_segment_point
|
||||
\tparam CalculationType \tparam_calculation
|
||||
|
||||
\qbk{
|
||||
[heading See also]
|
||||
[link geometry.reference.algorithms.within.within_3_with_strategy within (with strategy)]
|
||||
}
|
||||
*/
|
||||
template
|
||||
<
|
||||
typename Point,
|
||||
typename PointOfSegment = Point,
|
||||
typename CalculationType = void
|
||||
>
|
||||
class spherical_winding
|
||||
: public within::detail::spherical_winding_base
|
||||
<
|
||||
Point,
|
||||
PointOfSegment,
|
||||
side::spherical_side_formula<CalculationType>,
|
||||
CalculationType
|
||||
>
|
||||
{};
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
namespace services
|
||||
{
|
||||
|
||||
template <typename PointLike, typename Geometry, typename AnyTag1, typename AnyTag2>
|
||||
struct default_strategy<PointLike, Geometry, AnyTag1, AnyTag2, pointlike_tag, polygonal_tag, spherical_tag, spherical_tag>
|
||||
{
|
||||
typedef within::detail::spherical_winding_base
|
||||
<
|
||||
typename geometry::point_type<PointLike>::type,
|
||||
typename geometry::point_type<Geometry>::type
|
||||
> type;
|
||||
};
|
||||
|
||||
template <typename PointLike, typename Geometry, typename AnyTag1, typename AnyTag2>
|
||||
struct default_strategy<PointLike, Geometry, AnyTag1, AnyTag2, pointlike_tag, linear_tag, spherical_tag, spherical_tag>
|
||||
{
|
||||
typedef within::detail::spherical_winding_base
|
||||
<
|
||||
typename geometry::point_type<PointLike>::type,
|
||||
typename geometry::point_type<Geometry>::type
|
||||
> type;
|
||||
};
|
||||
|
||||
} // namespace services
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
}} // namespace strategy::within
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
namespace strategy { namespace covered_by { namespace services
|
||||
{
|
||||
|
||||
template <typename PointLike, typename Geometry, typename AnyTag1, typename AnyTag2>
|
||||
struct default_strategy<PointLike, Geometry, AnyTag1, AnyTag2, pointlike_tag, polygonal_tag, spherical_tag, spherical_tag>
|
||||
{
|
||||
typedef within::detail::spherical_winding_base
|
||||
<
|
||||
typename geometry::point_type<PointLike>::type,
|
||||
typename geometry::point_type<Geometry>::type
|
||||
> type;
|
||||
};
|
||||
|
||||
template <typename PointLike, typename Geometry, typename AnyTag1, typename AnyTag2>
|
||||
struct default_strategy<PointLike, Geometry, AnyTag1, AnyTag2, pointlike_tag, linear_tag, spherical_tag, spherical_tag>
|
||||
{
|
||||
typedef within::detail::spherical_winding_base
|
||||
<
|
||||
typename geometry::point_type<PointLike>::type,
|
||||
typename geometry::point_type<Geometry>::type
|
||||
> type;
|
||||
};
|
||||
|
||||
}}} // namespace strategy::covered_by::services
|
||||
#endif
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGY_SPHERICAL_POINT_IN_POLY_WINDING_HPP
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2014.
|
||||
// Modifications copyright (c) 2014, Oracle and/or its affiliates.
|
||||
// This file was modified by Oracle on 2014-2017.
|
||||
// Modifications copyright (c) 2014-2017, 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,
|
||||
@@ -18,7 +19,7 @@
|
||||
#include <boost/geometry/core/access.hpp>
|
||||
#include <boost/geometry/core/radian_access.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/course.hpp>
|
||||
#include <boost/geometry/formulas/spherical.hpp>
|
||||
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
#include <boost/geometry/util/promote_floating_point.hpp>
|
||||
@@ -59,8 +60,20 @@ public :
|
||||
>::type calc_t;
|
||||
|
||||
calc_t d1 = 0.001; // m_strategy.apply(sp1, p);
|
||||
calc_t crs_AD = geometry::detail::course<calc_t>(p1, p);
|
||||
calc_t crs_AB = geometry::detail::course<calc_t>(p1, p2);
|
||||
|
||||
calc_t lon1 = geometry::get_as_radian<0>(p1);
|
||||
calc_t lat1 = geometry::get_as_radian<1>(p1);
|
||||
calc_t lon2 = geometry::get_as_radian<0>(p2);
|
||||
calc_t lat2 = geometry::get_as_radian<1>(p2);
|
||||
calc_t lon = geometry::get_as_radian<0>(p);
|
||||
calc_t lat = geometry::get_as_radian<1>(p);
|
||||
|
||||
calc_t crs_AD = geometry::formula::spherical_azimuth<calc_t, false>
|
||||
(lon1, lat1, lon, lat).azimuth;
|
||||
|
||||
calc_t crs_AB = geometry::formula::spherical_azimuth<calc_t, false>
|
||||
(lon1, lat1, lon2, lat2).azimuth;
|
||||
|
||||
calc_t XTD = asin(sin(d1) * sin(crs_AD - crs_AB));
|
||||
|
||||
return math::equals(XTD, 0) ? 0 : XTD < 0 ? 1 : -1;
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2016.
|
||||
// Modifications copyright (c) 2016, Oracle and/or its affiliates.
|
||||
// This file was modified by Oracle on 2016, 2018.
|
||||
// Modifications copyright (c) 2016-2018, 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,
|
||||
@@ -23,7 +23,10 @@
|
||||
#include <boost/geometry/util/select_calculation_type.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/side.hpp>
|
||||
#include <boost/geometry/strategies/spherical/disjoint_segment_box.hpp>
|
||||
#include <boost/geometry/strategies/spherical/envelope.hpp>
|
||||
//#include <boost/geometry/strategies/concepts/side_concept.hpp>
|
||||
#include <boost/geometry/strategies/spherical/point_in_point.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
@@ -82,6 +85,26 @@ class spherical_side_formula
|
||||
{
|
||||
|
||||
public :
|
||||
typedef strategy::envelope::spherical<CalculationType> envelope_strategy_type;
|
||||
|
||||
static inline envelope_strategy_type get_envelope_strategy()
|
||||
{
|
||||
return envelope_strategy_type();
|
||||
}
|
||||
|
||||
typedef strategy::disjoint::segment_box_spherical disjoint_strategy_type;
|
||||
|
||||
static inline disjoint_strategy_type get_disjoint_strategy()
|
||||
{
|
||||
return disjoint_strategy_type();
|
||||
}
|
||||
|
||||
typedef strategy::within::spherical_point_point equals_point_point_strategy_type;
|
||||
static inline equals_point_point_strategy_type get_equals_point_point_strategy()
|
||||
{
|
||||
return equals_point_point_strategy_type();
|
||||
}
|
||||
|
||||
template <typename P1, typename P2, typename P>
|
||||
static inline int apply(P1 const& p1, P2 const& p2, P const& p)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user