mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-01 08:32:10 +00:00
[formulas] [strategies] Meridian crossing pole methods for consistency
This commit is contained in:
@@ -46,14 +46,28 @@ public :
|
||||
bool meridian;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
static bool meridian_not_crossing_pole(T lat1, T lat2, CT diff)
|
||||
{
|
||||
CT half_pi = math::pi<CT>()/CT(2);
|
||||
return math::equals(diff, CT(0)) ||
|
||||
(math::equals(lat2, half_pi) && math::equals(lat1, -half_pi));
|
||||
}
|
||||
|
||||
static bool meridian_crossing_pole(CT diff)
|
||||
{
|
||||
return math::equals(math::abs(diff), math::pi<CT>());
|
||||
}
|
||||
|
||||
|
||||
template <typename T, typename Spheroid>
|
||||
static CT meridian_not_crossing_pole(T lat1, T lat2, Spheroid const& spheroid)
|
||||
static CT meridian_not_crossing_pole_dist(T lat1, T lat2, Spheroid const& spheroid)
|
||||
{
|
||||
return math::abs(apply(lat2, spheroid) - apply(lat1, spheroid));
|
||||
}
|
||||
|
||||
template <typename T, typename Spheroid>
|
||||
static CT meridian_crossing_pole(T lat1, T lat2, Spheroid const& spheroid)
|
||||
static CT meridian_crossing_pole_dist(T lat1, T lat2, Spheroid const& spheroid)
|
||||
{
|
||||
CT c0 = 0;
|
||||
CT half_pi = math::pi<CT>()/CT(2);
|
||||
@@ -71,9 +85,6 @@ public :
|
||||
{
|
||||
result res;
|
||||
|
||||
CT c0 = 0;
|
||||
CT pi = math::pi<CT>();
|
||||
CT half_pi = pi/CT(2);
|
||||
CT diff = geometry::math::longitude_distance_signed<geometry::radian>(lon1, lon2);
|
||||
|
||||
if (lat1 > lat2)
|
||||
@@ -81,16 +92,14 @@ public :
|
||||
std::swap(lat1, lat2);
|
||||
}
|
||||
|
||||
if ( math::equals(diff, c0) ||
|
||||
(math::equals(lat2, half_pi) && math::equals(lat1, -half_pi)) )
|
||||
if ( meridian_not_crossing_pole(lat1, lat2, diff) )
|
||||
{
|
||||
res.distance = meridian_not_crossing_pole(lat1, lat2, spheroid);
|
||||
res.distance = meridian_not_crossing_pole_dist(lat1, lat2, spheroid);
|
||||
res.meridian = true;
|
||||
}
|
||||
|
||||
if (math::equals(math::abs(diff), pi))
|
||||
else if ( meridian_crossing_pole(diff) )
|
||||
{
|
||||
res.distance = meridian_crossing_pole(lat1, lat2, spheroid);
|
||||
res.distance = meridian_crossing_pole_dist(lat1, lat2, spheroid);
|
||||
res.meridian = true;
|
||||
}
|
||||
return res;
|
||||
|
||||
@@ -120,8 +120,8 @@ public :
|
||||
CT, strategy::default_order<FormulaPolicy>::value
|
||||
> elliptic_arc_length;
|
||||
|
||||
return elliptic_arc_length::meridian_not_crossing_pole(lat1, lat2,
|
||||
m_spheroid);
|
||||
return elliptic_arc_length::meridian_not_crossing_pole_dist(lat1, lat2,
|
||||
m_spheroid);
|
||||
}
|
||||
|
||||
inline Spheroid const& model() const
|
||||
|
||||
@@ -238,8 +238,16 @@ private :
|
||||
//but pass by the pole
|
||||
CT diff = geometry::math::longitude_distance_signed<geometry::radian>(lon1, lon2);
|
||||
|
||||
bool meridian_crossing_pole = math::equals(math::abs(diff), pi);
|
||||
bool meridian_not_crossing_pole = math::equals(math::abs(diff), c0);
|
||||
typedef typename formula::elliptic_arc_length<CT> elliptic_arc_length;
|
||||
|
||||
bool meridian_not_crossing_pole =
|
||||
elliptic_arc_length::meridian_not_crossing_pole(lat1, lat2, diff);
|
||||
|
||||
bool meridian_crossing_pole =
|
||||
elliptic_arc_length::meridian_crossing_pole(diff);
|
||||
|
||||
//bool meridian_crossing_pole = math::equals(math::abs(diff), pi);
|
||||
//bool meridian_not_crossing_pole = math::equals(math::abs(diff), c0);
|
||||
|
||||
if (math::equals(lat1, c0) && math::equals(lat2, c0) && !meridian_crossing_pole)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user