summaryrefslogtreecommitdiff
path: root/boost/geometry/algorithms/detail/disjoint/box_box.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/geometry/algorithms/detail/disjoint/box_box.hpp')
-rw-r--r--boost/geometry/algorithms/detail/disjoint/box_box.hpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/boost/geometry/algorithms/detail/disjoint/box_box.hpp b/boost/geometry/algorithms/detail/disjoint/box_box.hpp
index f830f8161c..87618939b8 100644
--- a/boost/geometry/algorithms/detail/disjoint/box_box.hpp
+++ b/boost/geometry/algorithms/detail/disjoint/box_box.hpp
@@ -121,9 +121,18 @@ struct box_box<Box1, Box2, 0, DimensionCount, spherical_tag>
// 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 (b2_min_transl > b1_max // b2_min right of b1_max
- && b2_min_transl - constants::period() + diff2 < b1_min) // b2_max left of b1_min
+ // 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;
}