mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-11 21:44:04 +00:00
Merge branch 'feature_box_box_fix' into feature_box_seg
This commit is contained in:
commit
51a3a6b78c
@ -44,6 +44,31 @@ class cross_track_box_box_generic
|
||||
{
|
||||
public :
|
||||
|
||||
template <typename Point, typename Strategy>
|
||||
ReturnType static inline diagonal_case(Point topA,
|
||||
Point topB,
|
||||
Point bottomA,
|
||||
Point bottomB,
|
||||
bool north_shortest,
|
||||
bool non_overlap,
|
||||
Strategy ps_strategy)
|
||||
{
|
||||
if (north_shortest && non_overlap)
|
||||
{
|
||||
return ps_strategy.get_distance_strategy().apply(topA, bottomB);
|
||||
}
|
||||
if (north_shortest && !non_overlap)
|
||||
{
|
||||
return ps_strategy.apply(topA, topB, bottomB);
|
||||
}
|
||||
if (!north_shortest && non_overlap)
|
||||
{
|
||||
return ps_strategy.get_distance_strategy().apply(bottomA, topB);
|
||||
}
|
||||
return ps_strategy.apply(bottomA, topB, bottomB);
|
||||
}
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
typename Box1,
|
||||
@ -162,9 +187,12 @@ public :
|
||||
ReturnType bottom_common = (std::max)(lat_min1, lat_min2);
|
||||
|
||||
// true if the closest points are on northern hemisphere
|
||||
bool north_shortest = math::abs(top_common) > math::abs(bottom_common)
|
||||
|| lat_max1 <= lat_min2
|
||||
|| lat_min1 >= lat_max2;
|
||||
bool north_shortest = top_common + bottom_common > 0;
|
||||
//|| top_common < bottom_common;
|
||||
//math::abs(top_common) > math::abs(bottom_common)
|
||||
//|| lat_max1 <= lat_min2
|
||||
//|| lat_min1 >= lat_max2;
|
||||
bool non_overlap = top_common < bottom_common;
|
||||
|
||||
if (north_shortest)
|
||||
{
|
||||
@ -183,6 +211,10 @@ public :
|
||||
#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,
|
||||
ps_strategy);
|
||||
if (north_shortest)
|
||||
{
|
||||
return ps_strategy.apply(top_right2, top_left1, bottom_left1);
|
||||
@ -194,6 +226,10 @@ public :
|
||||
#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,
|
||||
ps_strategy);
|
||||
if (north_shortest)
|
||||
{
|
||||
return ps_strategy.apply(top_left2, top_right1, bottom_right1);
|
||||
@ -205,6 +241,10 @@ public :
|
||||
#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,
|
||||
ps_strategy);
|
||||
if (north_shortest)
|
||||
{
|
||||
return ps_strategy.apply(top_left1, top_right2, bottom_right2);
|
||||
@ -216,6 +256,10 @@ public :
|
||||
#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,
|
||||
ps_strategy);
|
||||
if (north_shortest)
|
||||
{
|
||||
return ps_strategy.apply(top_right1, top_left2, bottom_left2);
|
||||
|
@ -8,6 +8,8 @@
|
||||
// Licensed under the Boost Software License version 1.0.
|
||||
// http://www.boost.org/users/license.html
|
||||
|
||||
#define BOOST_GEOMETRY_TEST_DEBUG
|
||||
|
||||
#ifndef BOOST_TEST_MODULE
|
||||
#define BOOST_TEST_MODULE test_distance_geographic_box_box
|
||||
#endif
|
||||
@ -235,14 +237,24 @@ void test_distance_box_box(Strategy_pp const& strategy_pp,
|
||||
strategy_bb);
|
||||
|
||||
// case 10
|
||||
tester::apply("bb10", box1, "BOX(4 18, 8 22)",
|
||||
tester::apply("bb10a", box1, "BOX(4 18, 8 22)",
|
||||
ps_distance("POINT(10 20)", "SEGMENT(8 18, 8 22)", strategy_ps),
|
||||
strategy_bb);
|
||||
|
||||
tester::apply("bb10", box1, "BOX(4 20, 8 22)",
|
||||
std::string const box1m = "BOX(10 -20,20 -10)";
|
||||
tester::apply("bb10am", box1m, "BOX(4 -22, 8 -18)",
|
||||
ps_distance("POINT(10 20)", "SEGMENT(8 18, 8 22)", strategy_ps),
|
||||
strategy_bb);
|
||||
|
||||
tester::apply("bb10b", box1, "BOX(4 20, 8 22)",
|
||||
ps_distance("POINT(10 20)", "SEGMENT(8 20, 8 22)", strategy_ps),
|
||||
strategy_bb);
|
||||
|
||||
tester::apply("bb10bm", box1m, "BOX(4 -22, 8 -20)",
|
||||
ps_distance("POINT(10 20)", "SEGMENT(8 22, 8 20)", strategy_ps),
|
||||
//ps_distance("POINT(10 -20)", "SEGMENT(8 -20, 8 -22)", strategy_ps),
|
||||
strategy_bb);
|
||||
|
||||
// case 11
|
||||
tester::apply("bb11", box1, "BOX(4 22, 8 24)",
|
||||
pp_distance("POINT(8 22)", "POINT(10 20)", strategy_pp),
|
||||
@ -299,6 +311,14 @@ void test_distance_box_box(Strategy_pp const& strategy_pp,
|
||||
ps_distance("POINT(20 25)", "SEGMENT(30 -15, 30 30)", strategy_ps),
|
||||
strategy_bb);
|
||||
|
||||
tester::apply("bb-eq1b", "BOX(30 -15, 40 30)", "BOX(10 -20, 20 10)",
|
||||
ps_distance("POINT(30 -15)", "SEGMENT(20 10, 20 -20)", strategy_ps),
|
||||
strategy_bb);
|
||||
|
||||
tester::apply("bb-eq1bm", "BOX(30 -30, 40 15)", "BOX(10 -10, 20 20)",
|
||||
ps_distance("POINT(30 15)", "SEGMENT(20 -10, 20 20)", strategy_ps),
|
||||
strategy_bb);
|
||||
|
||||
tester::apply("bb-eq2", "BOX(30 -15, 40 20)", "BOX(10 -20, 20 25)",
|
||||
ps_distance("POINT(30 20)", "SEGMENT(20 -20, 20 25)", strategy_ps),
|
||||
strategy_bb);
|
||||
|
Loading…
x
Reference in New Issue
Block a user