[formulas][strategies] Move updating of state from area formulas to strategy where it should be. This also fixes conversion warning.

This commit is contained in:
Adam Wulkiewicz
2017-11-23 15:32:54 +01:00
parent 0e7614f27d
commit 48d2d99b2b
3 changed files with 17 additions and 19 deletions

View File

@@ -1,8 +1,9 @@
// Boost.Geometry
// Copyright (c) 2015-2016 Oracle and/or its affiliates.
// Copyright (c) 2015-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,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@@ -540,12 +541,11 @@ public:
return result;
}
// Keep track whenever a segment crosses the prime meridian
// Check whenever a segment crosses the prime meridian
// First normalize to [0,360)
template <typename PointOfSegment, typename StateType>
static inline int crosses_prime_meridian(PointOfSegment const& p1,
PointOfSegment const& p2,
StateType& state)
template <typename PointOfSegment>
static inline bool crosses_prime_meridian(PointOfSegment const& p1,
PointOfSegment const& p2)
{
CT const pi
= geometry::math::pi<CT>();
@@ -562,12 +562,7 @@ public:
CT max_lon = (std::max)(p1_lon, p2_lon);
CT min_lon = (std::min)(p1_lon, p2_lon);
if(max_lon > pi && min_lon < pi && max_lon - min_lon > pi)
{
state.m_crosses_prime_meridian++;
}
return state.m_crosses_prime_meridian;
return max_lon > pi && min_lon < pi && max_lon - min_lon > pi;
}
};

View File

@@ -174,8 +174,10 @@ public :
state.m_correction_sum += result.ellipsoidal_term;
// 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))
{
state.m_crosses_prime_meridian++;
}
}
}

View File

@@ -127,14 +127,15 @@ public :
{
if (! geometry::math::equals(get<0>(p1), get<0>(p2)))
{
typedef geometry::formula::area_formulas<CT> area_formulas;
state.m_sum += geometry::formula::area_formulas
<CT>::template spherical<LongSegment>(p1, p2);
state.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))
{
state.m_crosses_prime_meridian++;
}
}
}