[disjoint] [vertex_longitude] Reviewing cases of disjoint, create new tests, fix corner cases

This commit is contained in:
Vissarion Fysikopoulos
2017-05-02 18:44:26 +03:00
parent fe1c91577f
commit 5cdae7c693
5 changed files with 463 additions and 236 deletions

View File

@@ -11,6 +11,8 @@
#define BOOST_GEOMETRY_TEST_DEBUG
#include <iostream>
#include <boost/geometry/geometries/box.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/geometries.hpp>
@@ -30,6 +32,7 @@
#include "test_disjoint_seg_box.hpp"
namespace bg = boost::geometry;
//Tests for disjoint(point, box), disjoint(box, box) and disjoint(segment, box)
@@ -73,7 +76,6 @@ void disjoint_tests_1()
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(1 1,3 3)",
"SEGMENT(0 0, 4 0)",
true);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(1 1,3 3)",
"SEGMENT(2 2, 4 4)",
false);
@@ -122,25 +124,25 @@ template <typename P, typename CT>
void disjoint_tests_with_strategy(bool expected_result)
{
bg::strategy::disjoint::segment_box_geographic
<
bg::strategy::andoyer,
bg::srs::spheroid<CT>,
CT
> geographic_andoyer;
<
bg::strategy::andoyer,
bg::srs::spheroid<CT>,
CT
> geographic_andoyer;
bg::strategy::disjoint::segment_box_geographic
<
bg::strategy::thomas,
bg::srs::spheroid<CT>,
CT
> geographic_thomas;
<
bg::strategy::thomas,
bg::srs::spheroid<CT>,
CT
> geographic_thomas;
bg::strategy::disjoint::segment_box_geographic
<
bg::strategy::vincenty,
bg::srs::spheroid<CT>,
CT
> geographic_vincenty;
<
bg::strategy::vincenty,
bg::srs::spheroid<CT>,
CT
> geographic_vincenty;
test_disjoint_strategy<bg::model::box<P>, bg::model::segment<P> >
("BOX(1 1,3 3)", "SEGMENT(1 0.999, 10 0.999)",
@@ -153,6 +155,99 @@ void disjoint_tests_with_strategy(bool expected_result)
expected_result, geographic_vincenty);
}
template <typename P>
void disjoint_tests_sph_geo()
{
//Case A: box intersects without containing the vertex
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(0 6, 120 7)",
"SEGMENT(0 5, 120 5)",
false);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(0 -6, 120 -7)",
"SEGMENT(0 -5, 120 -5)",
false);
//Case B: box intersects and contains the vertex
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(0 9, 120 10)",
"SEGMENT(0 5, 120 5)",
false);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(0 -10, 120 -9)",
"SEGMENT(0 -5, 120 -5)",
false);
//Case C: bounding boxes disjoint
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(0 10, 10 20)",
"SEGMENT(0 5, 120 5)",
true);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(0 -20, 10 -10)",
"SEGMENT(0 -5, 120 -5)",
true);
//Case D: bounding boxes intersect but box segment are disjoint
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(0 9, 0.1 20)",
"SEGMENT(0 5, 120 5)",
true);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(0 -20, 0.1 -9)",
"SEGMENT(0 -5, 120 -5)",
true);
//Case E: geodesic intersects box but box segment are disjoint
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(121 0, 122 10)",
"SEGMENT(0 5, 120 5)",
true);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(121 -10, 122 0)",
"SEGMENT(0 -5, 120 -5)",
true);
//Case F: segment crosses box
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(100 0, 110 20)",
"SEGMENT(0 5, 120 5)",
false);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(100 -20, 110 0)",
"SEGMENT(0 -5, 120 -5)",
false);
//Case G: box contains one segment endpoint
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(110 0, 130 10)",
"SEGMENT(0 5, 120 5)",
false);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(110 -10, 130 0)",
"SEGMENT(0 -5, 120 -5)",
false);
//Case H: box below segment
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(50 0, 70 6)",
"SEGMENT(0 5, 120 5)",
true);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(50 -6, 70 0)",
"SEGMENT(0 -5, 120 -5)",
true);
//Case I: box contains segment
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(-10 0, 130 10)",
"SEGMENT(0 5, 120 5)",
false);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(-10 -10, 130 0)",
"SEGMENT(0 -5, 120 -5)",
false);
//ascending segment
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(0 10, 120 10.1)",
"SEGMENT(0 5, 120 5.1)",
false);
//descending segment
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(0 9.8, 120 10)",
"SEGMENT(0 5, 120 4.9)",
false);
//ascending segment both hemispheres
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(100 5, 120 6)",
"SEGMENT(0 -1, 120 4.9)",
false);
//descending segment both hemispheres
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(0 5, 20 6)",
"SEGMENT(0 4.9, 120 -1)",
false);
}
template <typename CT>
void test_all()
{
@@ -179,6 +274,9 @@ void test_all()
disjoint_tests_4<geo_point>(false);
disjoint_tests_with_strategy<geo_point, CT>(false);
disjoint_tests_sph_geo<sph_point>();
disjoint_tests_sph_geo<geo_point>();
}