Merge pull request #29 from mkaravel/feature/distance

Feature/distance
This commit is contained in:
Adam Wulkiewicz
2014-05-14 17:04:10 +02:00
6 changed files with 457 additions and 536 deletions

View File

@@ -125,28 +125,28 @@ void test_distance_box_box(Strategy const& strategy)
typedef test_distance_of_geometries<int_box_type, int_box_type> int_tester;
typedef test_distance_of_geometries<box_type, box_type> tester;
int_tester::apply(make_box2d<int_box_type>(5, 5, 10, 10),
make_box2d<int_box_type>(0, 0, 1, 1),
int_tester::apply("box(5 5,10 10)",
"box(0 0,1 1)",
sqrt(32.0), 32, strategy);
tester::apply(make_box2d<box_type>(5, 5, 10, 10),
make_box2d<box_type>(0, 0, 1, 1),
tester::apply("box(5 5,10 10)",
"box(0 0,1 1)",
sqrt(32.0), 32, strategy);
tester::apply(make_box2d<box_type>(3, 8, 13, 18),
make_box2d<box_type>(0, 0, 5, 5),
tester::apply("box(3 8,13 18)",
"box(0 0,5 5)",
3, 9, strategy);
tester::apply(make_box2d<box_type>(5, 5, 10, 10),
make_box2d<box_type>(0, 0, 5, 5),
tester::apply("box(5 5,10 10)",
"box(0 0,5 5)",
0, 0, strategy);
tester::apply(make_box2d<box_type>(5, 5, 10, 10),
make_box2d<box_type>(0, 0, 6, 6),
tester::apply("box(5 5,10 10)",
"box(0 0,6 6)",
0, 0, strategy);
tester::apply(make_box2d<box_type>(3, 5, 13, 15),
make_box2d<box_type>(0, 0, 5, 5),
tester::apply("box(3 5,13 15)",
"box(0 0,5 5)",
0, 0, strategy);
}
@@ -162,23 +162,23 @@ void test_distance_polygon_box(Strategy const& strategy)
typedef test_distance_of_geometries<polygon_type, box_type> tester;
tester::apply("polygon((10 10,10 5,5 5,5 10,10 10))",
make_box2d<box_type>(0, 0, 1, 1),
"box(0 0,1 1)",
sqrt(32.0), 32, strategy);
tester::apply("polygon((10 10,10 5,5 5,5 10,10 10))",
make_box2d<box_type>(0, 0, 5, 5),
"box(0 0,5 5)",
0, 0, strategy);
tester::apply("polygon((10 10,10 5,5 5,5 10,10 10))",
make_box2d<box_type>(0, 0, 6, 6),
"box(0 0,6 6)",
0, 0, strategy);
tester::apply("polygon((10 10,15 5,10 0,5 5,10 10))",
make_box2d<box_type>(5, 0, 7.5, 2.5),
"box(5 0,7.5 2.5)",
0, 0, strategy);
tester::apply("polygon((10 10,15 5,10 0,5 5,10 10))",
make_box2d<box_type>(5, 0, 6, 1),
"box(5 0,6 1)",
sqrt(4.5), 4.5, strategy);
}
@@ -195,17 +195,17 @@ void test_distance_multipolygon_box(Strategy const& strategy)
tester::apply("multipolygon(((-10 -10,-10 -9,-9 -9,-9 -10,-10 -10)),\
((2 2,2 3,3 3,3 2,2 2)))",
make_box2d<box_type>(0, 0, 1, 1),
"box(0 0,1 1)",
sqrt(2.0), 2, strategy);
tester::apply("multipolygon(((-10 -10,-10 -9,-9 -9,-9 -10,-10 -10)),\
((2 2,2 3,3 3,3 2,2 2)))",
make_box2d<box_type>(0, 0, 2, 2),
"box(0 0,2 2)",
0, 0, strategy);
tester::apply("multipolygon(((-10 -10,-10 -9,-9 -9,-9 -10,-10 -10)),\
((2 2,2 3,3 3,3 2,2 2)))",
make_box2d<box_type>(0, 0, 2.5, 2),
"box(0 0,2.5 2)",
0, 0, strategy);
}

View File

@@ -47,19 +47,19 @@ void test_distance_segment_polygon(Strategy const& strategy)
#endif
typedef test_distance_of_geometries<segment_type, polygon_type> tester;
tester::apply(make_segment<segment_type>(-1, 20, 1, 20),
tester::apply("segment(-1 20,1 20)",
"polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))",
10, 100, strategy);
tester::apply(make_segment<segment_type>(1, 20, 2, 40),
tester::apply("segment(1 20,2 40)",
"polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))",
10, 100, strategy);
tester::apply(make_segment<segment_type>(-1, 20, -1, 5),
tester::apply("segment(-1 20,-1 5)",
"polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))",
0, 0, strategy);
tester::apply(make_segment<segment_type>(-1, 20, -1, -20),
tester::apply("segment(-1 20,-1 -20)",
"polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))",
0, 0, strategy);
}
@@ -129,22 +129,22 @@ void test_distance_segment_multipolygon(Strategy const& strategy)
segment_type, multi_polygon_type
> tester;
tester::apply(make_segment<segment_type>(-1, 20, 1, 20),
tester::apply("segment(-1 20,1 20)",
"multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\
((0 22,-1 30, 2 40,0 22)))",
2, 4, strategy);
tester::apply(make_segment<segment_type>(12, 0, 14, 0),
tester::apply("segment(12 0,14 0)",
"multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\
((20 -1,21 2,30 -10,20 -1)))",
2, 4, strategy);
tester::apply(make_segment<segment_type>(12, 0, 20.5, 0.5),
tester::apply("segment(12 0,20.5 0.5)",
"multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\
((20 -1,21 2,30 -10,20 -1)))",
0, 0, strategy);
tester::apply(make_segment<segment_type>(12, 0, 50, 0),
tester::apply("segment(12 0,50 0)",
"multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\
((20 -1,21 2,30 -10,20 -1)))",
0, 0, strategy);
@@ -227,414 +227,414 @@ void test_distance_segment_box(Strategy const& strategy)
typedef test_distance_of_geometries<B, IS> itester;
// segments that intersect the box
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-1, 0.5, 0.5, 0.75),
tester::apply("box(0 0,1 1)",
"segment(-1 0.5,0.5 0.75)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-1, 0.5, 1.5, 0.75),
tester::apply("box(0 0,1 1)",
"segment(-1 0.5,1.5 0.75)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0.5, -1, 0.5, 2),
tester::apply("box(0 0,1 1)",
"segment(0.5 -1,0.5 2)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(1, 1, 1.5, 0.75),
tester::apply("box(0 0,1 1)",
"segment(1 1,1.5 0.75)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(2, 0, 0, 2),
tester::apply("box(0 0,1 1)",
"segment(2 0,0 2)",
0, 0, strategy);
// segment that has closest point on box boundary
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(4, 0.5, 5, 0.75),
tester::apply("box(0 0,1 1)",
"segment(4 0.5,5 0.75)",
3, 9, strategy);
// segment that has closest point on box corner
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(4, 0, 0, 4),
sqrt(2), 2, strategy);
itester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<IS>(-4, 0, 0, -4),
sqrt(8), 8, strategy);
itester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<IS>(-8, 4, 4, -8),
sqrt(8), 8, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-4, 0, 0, 4),
1.5 * sqrt(2), 4.5, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-4, 0, 1, 5),
1.5 * sqrt(2), 4.5, strategy);
itester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<IS>(0, -2, 3, 1),
0.5 * sqrt(2), 0.5, strategy);
itester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<IS>(0, -2, 2, 2),
tester::apply("box(0 0,1 1)",
"segment(4 0,0 4)",
sqrt(2.0), 2, strategy);
itester::apply("box(0 0,1 1)",
"segment(-4 0,0 -4)",
sqrt(8.0), 8, strategy);
itester::apply("box(0 0,1 1)",
"segment(-8 4,4 -8)",
sqrt(8.0), 8, strategy);
tester::apply("box(0 0,1 1)",
"segment(-4 0,0 4)",
1.5 * sqrt(2.0), 4.5, strategy);
tester::apply("box(0 0,1 1)",
"segment(-4 0,1 5)",
1.5 * sqrt(2.0), 4.5, strategy);
itester::apply("box(0 0,1 1)",
"segment(0 -2,3 1)",
0.5 * sqrt(2.0), 0.5, strategy);
itester::apply("box(0 0,1 1)",
"segment(0 -2,2 2)",
0, 0, strategy);
// horizontal segments
itester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<IS>(-2, -1, -1, -1),
sqrt(2), 2, strategy);
itester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<IS>(-1, -1, 0, -1),
itester::apply("box(0 0,1 1)",
"segment(-2 -1,-1 -1)",
sqrt(2.0), 2, strategy);
itester::apply("box(0 0,1 1)",
"segment(-1 -1,0 -1)",
1, 1, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-0.5, -1, 0.5, -1),
tester::apply("box(0 0,1 1)",
"segment(-0.5 -1,0.5 -1)",
1, 1, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0.5, -1, 0.75, -1),
tester::apply("box(0 0,1 1)",
"segment(0.5 -1,0.75 -1)",
1, 1, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0.5, -1, 1.25, -1),
tester::apply("box(0 0,1 1)",
"segment(0.5 -1,1.25 -1)",
1, 1, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(1, -1, 2, -1),
tester::apply("box(0 0,1 1)",
"segment(1 -1,2 -1)",
1, 1, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(2, -1, 3, -1),
sqrt(2), 2, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-2, -1, 2, -1),
tester::apply("box(0 0,1 1)",
"segment(2 -1,3 -1)",
sqrt(2.0), 2, strategy);
tester::apply("box(0 0,1 1)",
"segment(-2 -1,2 -1)",
1, 1, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-2, 0, -1, 0),
tester::apply("box(0 0,1 1)",
"segment(-2 0,-1 0)",
1, 1, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-1, 0, 0, 0),
tester::apply("box(0 0,1 1)",
"segment(-1 0,0 0)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-0.5, 0, 0.5, 0),
tester::apply("box(0 0,1 1)",
"segment(-0.5 0,0.5 0)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0.5, 0, 0.75, 0),
tester::apply("box(0 0,1 1)",
"segment(0.5 0,0.75 0)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0.5, 0, 1.25, 0),
tester::apply("box(0 0,1 1)",
"segment(0.5 0,1.25 0)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(1, 0, 2, 0),
tester::apply("box(0 0,1 1)",
"segment(1 0,2 0)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(2, 0, 3, 0),
tester::apply("box(0 0,1 1)",
"segment(2 0,3 0)",
1, 1, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-2, 0, 2, 0),
tester::apply("box(0 0,1 1)",
"segment(-2 0,2 0)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-2, 0.5, -1, 0.5),
tester::apply("box(0 0,1 1)",
"segment(-2 0.5,-1 0.5)",
1, 1, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-1, 0.5, 0, 0.5),
tester::apply("box(0 0,1 1)",
"segment(-1 0.5,0 0.5)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-0.5, 0.5, 0.5, 0.5),
tester::apply("box(0 0,1 1)",
"segment(-0.5 0.5,0.5 0.5)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0.5, 0.5, 0.75, 0.5),
tester::apply("box(0 0,1 1)",
"segment(0.5 0.5,0.75 0.5)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0.5, 0.5, 1.25, 0.5),
tester::apply("box(0 0,1 1)",
"segment(0.5 0.5,1.25 0.5)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(1, 0.5, 2, 0.5),
tester::apply("box(0 0,1 1)",
"segment(1 0.5,2 0.5)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(2, 0.5, 3, 0.5),
tester::apply("box(0 0,1 1)",
"segment(2 0.5,3 0.5)",
1, 1, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-2, 0.5, 2, 0.5),
tester::apply("box(0 0,1 1)",
"segment(-2 0.5,2 0.5)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-2, 1, -1, 1),
tester::apply("box(0 0,1 1)",
"segment(-2 1,-1 1)",
1, 1, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-1, 1, 0, 1),
tester::apply("box(0 0,1 1)",
"segment(-1 1,0 1)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-0.5, 1, 0.5, 1),
tester::apply("box(0 0,1 1)",
"segment(-0.5 1,0.5 1)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0.5, 1, 0.75, 1),
tester::apply("box(0 0,1 1)",
"segment(0.5 1,0.75 1)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0.5, 1, 1.25, 1),
tester::apply("box(0 0,1 1)",
"segment(0.5 1,1.25 1)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(1, 1, 2, 1),
tester::apply("box(0 0,1 1)",
"segment(1 1,2 1)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(2, 1, 3, 1),
tester::apply("box(0 0,1 1)",
"segment(2 1,3 1)",
1, 1, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-2, 1, 2, 1),
tester::apply("box(0 0,1 1)",
"segment(-2 1,2 1)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-2, 3, -1, 3),
sqrt(5), 5, strategy);
itester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<IS>(-1, 3, 0, 3),
tester::apply("box(0 0,1 1)",
"segment(-2 3,-1 3)",
sqrt(5.0), 5, strategy);
itester::apply("box(0 0,1 1)",
"segment(-1 3,0 3)",
2, 4, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-0.5, 3, 0.5, 3),
tester::apply("box(0 0,1 1)",
"segment(-0.5 3,0.5 3)",
2, 4, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0.5, 3, 0.75, 3),
tester::apply("box(0 0,1 1)",
"segment(0.5 3,0.75 3)",
2, 4, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0.5, 3, 1.25, 3),
tester::apply("box(0 0,1 1)",
"segment(0.5 3,1.25 3)",
2, 4, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(1, 3, 2, 3),
tester::apply("box(0 0,1 1)",
"segment(1 3,2 3)",
2, 4, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(2, 3, 3, 3),
sqrt(5), 5, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-2, 3, 2, 3),
tester::apply("box(0 0,1 1)",
"segment(2 3,3 3)",
sqrt(5.0), 5, strategy);
tester::apply("box(0 0,1 1)",
"segment(-2 3,2 3)",
2, 4, strategy);
// vertical segments
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-1, -2, -1, -1),
sqrt(2), 2, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-1, -1, -1, 0),
tester::apply("box(0 0,1 1)",
"segment(-1 -2,-1 -1)",
sqrt(2.0), 2, strategy);
tester::apply("box(0 0,1 1)",
"segment(-1 -1,-1 0)",
1, 1, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-1, -0.5, -1, 0.5),
tester::apply("box(0 0,1 1)",
"segment(-1 -0.5,-1 0.5)",
1, 1, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-1, 0.5, -1, 0.75),
tester::apply("box(0 0,1 1)",
"segment(-1 0.5,-1 0.75)",
1, 1, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-1, 0.5, -1, 1.25),
tester::apply("box(0 0,1 1)",
"segment(-1 0.5,-1 1.25)",
1, 1, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-1, 1, -1, 2),
tester::apply("box(0 0,1 1)",
"segment(-1 1,-1 2)",
1, 1, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-1, 2, -1, 3),
sqrt(2), 2, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-1, -2, -1, 2),
tester::apply("box(0 0,1 1)",
"segment(-1 2,-1 3)",
sqrt(2.0), 2, strategy);
tester::apply("box(0 0,1 1)",
"segment(-1 -2,-1 2)",
1, 1, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0, -2, 0, -1),
tester::apply("box(0 0,1 1)",
"segment(0 -2,0 -1)",
1, 1, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0, -1, 0, 0),
tester::apply("box(0 0,1 1)",
"segment(0 -1,0 0)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0, -0.5, 0, 0.5),
tester::apply("box(0 0,1 1)",
"segment(0 -0.5,0 0.5)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0, 0.5, 0, 0.75),
tester::apply("box(0 0,1 1)",
"segment(0 0.5,0 0.75)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0, 0.5, 0, 1.25),
tester::apply("box(0 0,1 1)",
"segment(0 0.5,0 1.25)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0, 1, 0, 2),
tester::apply("box(0 0,1 1)",
"segment(0 1,0 2)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0, 2, 0, 3),
tester::apply("box(0 0,1 1)",
"segment(0 2,0 3)",
1, 1, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0, -2, 0, 2),
tester::apply("box(0 0,1 1)",
"segment(0 -2,0 2)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0.5, -2, 0.5, -1),
tester::apply("box(0 0,1 1)",
"segment(0.5 -2,0.5 -1)",
1, 1, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0.5, -1, 0.5, 0),
tester::apply("box(0 0,1 1)",
"segment(0.5 -1,0.5 0)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0.5, -0.5, 0.5, 0.5),
tester::apply("box(0 0,1 1)",
"segment(0.5 -0.5,0.5 0.5)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0.5, 0.5, 0.5, 0.75),
tester::apply("box(0 0,1 1)",
"segment(0.5 0.5,0.5 0.75)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0.5, 0.5, 0.5, 1.25),
tester::apply("box(0 0,1 1)",
"segment(0.5 0.5,0.5 1.25)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0.5, 1, 0.5, 2),
tester::apply("box(0 0,1 1)",
"segment(0.5 1,0.5 2)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0.5, 2, 0.5, 3),
tester::apply("box(0 0,1 1)",
"segment(0.5 2,0.5 3)",
1, 1, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0.5, -2, 0.5, 2),
tester::apply("box(0 0,1 1)",
"segment(0.5 -2,0.5 2)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(1, -2, 1, -1),
tester::apply("box(0 0,1 1)",
"segment(1 -2,1 -1)",
1, 1, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(1, -1, 1, 0),
tester::apply("box(0 0,1 1)",
"segment(1 -1,1 0)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(1, -0.5, 1, 0.5),
tester::apply("box(0 0,1 1)",
"segment(1 -0.5,1 0.5)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(1, 0.5, 1, 0.75),
tester::apply("box(0 0,1 1)",
"segment(1 0.5,1 0.75)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(1, 0.5, 1, 1.25),
tester::apply("box(0 0,1 1)",
"segment(1 0.5,1 1.25)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(1, 1, 1, 2),
tester::apply("box(0 0,1 1)",
"segment(1 1,1 2)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(1, 2, 1, 3),
tester::apply("box(0 0,1 1)",
"segment(1 2,1 3)",
1, 1, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(1, -2, 1, 2),
tester::apply("box(0 0,1 1)",
"segment(1 -2,1 2)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(3, -2, 3, -1),
sqrt(5), 5, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(3, -1, 3, 0),
tester::apply("box(0 0,1 1)",
"segment(3 -2,3 -1)",
sqrt(5.0), 5, strategy);
tester::apply("box(0 0,1 1)",
"segment(3 -1,3 0)",
2, 4, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(3, -0.5, 3, 0.5),
tester::apply("box(0 0,1 1)",
"segment(3 -0.5,3 0.5)",
2, 4, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(3, 0.5, 3, 0.75),
tester::apply("box(0 0,1 1)",
"segment(3 0.5,3 0.75)",
2, 4, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(3, 0.5, 3, 1.25),
tester::apply("box(0 0,1 1)",
"segment(3 0.5,3 1.25)",
2, 4, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(3, 1, 3, 2),
tester::apply("box(0 0,1 1)",
"segment(3 1,3 2)",
2, 4, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(3, 2, 3, 3),
sqrt(5), 5, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(3, -2, 3, 2),
tester::apply("box(0 0,1 1)",
"segment(3 2,3 3)",
sqrt(5.0), 5, strategy);
tester::apply("box(0 0,1 1)",
"segment(3 -2,3 2)",
2, 4, strategy);
// positive slope
itester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<IS>(-2, -2, -1, -1),
sqrt(2), 2, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-2, -2, 0, -0.5),
itester::apply("box(0 0,1 1)",
"segment(-2 -2,-1 -1)",
sqrt(2.0), 2, strategy);
tester::apply("box(0 0,1 1)",
"segment(-2 -2,0 -0.5)",
0.5, 0.25, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-2, -2, 0.5, -0.5),
tester::apply("box(0 0,1 1)",
"segment(-2 -2,0.5 -0.5)",
0.5, 0.25, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-2, -2, 1, -0.5),
tester::apply("box(0 0,1 1)",
"segment(-2 -2,1 -0.5)",
0.5, 0.25, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-2, -2, 2, 0),
tester::apply("box(0 0,1 1)",
"segment(-2 -2,2 0)",
sqrt(0.2), 0.2, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-2, -2, 4, 1),
tester::apply("box(0 0,1 1)",
"segment(-2 -2,4 1)",
sqrt(0.2), 0.2, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-2, -2, -1.5, 0),
tester::apply("box(0 0,1 1)",
"segment(-2 -2,-1.5 0)",
1.5, 2.25, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-2, -2, -1.5, 0.5),
tester::apply("box(0 0,1 1)",
"segment(-2 -2,-1.5 0.5)",
1.5, 2.25, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-2, -2, -1.5, 1),
tester::apply("box(0 0,1 1)",
"segment(-2 -2,-1.5 1)",
1.5, 2.25, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-2, -2, 0, 2),
tester::apply("box(0 0,1 1)",
"segment(-2 -2,0 2)",
sqrt(0.2), 0.2, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-2, -2, 1, 4),
tester::apply("box(0 0,1 1)",
"segment(-2 -2,1 4)",
sqrt(0.2), 0.2, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-2, -2, 4, 2),
tester::apply("box(0 0,1 1)",
"segment(-2 -2,4 2)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-2, -2, 2, 4),
tester::apply("box(0 0,1 1)",
"segment(-2 -2,2 4)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-2, -2, 4, 3),
tester::apply("box(0 0,1 1)",
"segment(-2 -2,4 3)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-2, -2, 3, 4),
tester::apply("box(0 0,1 1)",
"segment(-2 -2,3 4)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-2, -2, 3, 3),
tester::apply("box(0 0,1 1)",
"segment(-2 -2,3 3)",
0, 0, strategy);
// negative slope
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-2, -2, -1, -3),
sqrt(8), 8, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-3, -1, 0, -4),
sqrt(8), 8, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-2, 0.75, -1.5, 0.5),
tester::apply("box(0 0,1 1)",
"segment(-2 -2,-1 -3)",
sqrt(8.0), 8, strategy);
tester::apply("box(0 0,1 1)",
"segment(-3 -1,0 -4)",
sqrt(8.0), 8, strategy);
tester::apply("box(0 0,1 1)",
"segment(-2 0.75,-1.5 0.5)",
1.5, 2.25, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-2, 1.5, -1.5, 0.5),
tester::apply("box(0 0,1 1)",
"segment(-2 1.5,-1.5 0.5)",
1.5, 2.25, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0.5, 2, 0.75, 1.5),
tester::apply("box(0 0,1 1)",
"segment(0.5 2,0.75 1.5)",
0.5, 0.25, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-1, 2, 0.75, 1.5),
tester::apply("box(0 0,1 1)",
"segment(-1 2,0.75 1.5)",
0.5, 0.25, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0, 2, 2, 0),
tester::apply("box(0 0,1 1)",
"segment(0 2,2 0)",
0, 0, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0, 3, 3, 0),
tester::apply("box(0 0,1 1)",
"segment(0 3,3 0)",
sqrt(0.5), 0.5, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-1, 4, 4, -1),
tester::apply("box(0 0,1 1)",
"segment(-1 4,4 -1)",
sqrt(0.5), 0.5, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-1, 4, 0, 3),
tester::apply("box(0 0,1 1)",
"segment(-1 4,0 3)",
2, 4, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-2, 5, -1, 4),
sqrt(10), 10, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(3, -1, 4, -4),
sqrt(5), 5, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(1, 2, 2, 1),
tester::apply("box(0 0,1 1)",
"segment(-2 5,-1 4)",
sqrt(10.0), 10, strategy);
tester::apply("box(0 0,1 1)",
"segment(3 -1,4 -4)",
sqrt(5.0), 5, strategy);
tester::apply("box(0 0,1 1)",
"segment(1 2,2 1)",
sqrt(0.5), 0.5, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0.5, -2, 2, -3),
tester::apply("box(0 0,1 1)",
"segment(0.5 -2,2 -3)",
2, 4, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-1, -2, 0, -3),
sqrt(5), 5, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-1, -2, 0.5, -3.5),
sqrt(5), 5, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(-1, -2, 0.5, -3.5),
sqrt(5), 5, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0.5, 3, 2.5, 2),
tester::apply("box(0 0,1 1)",
"segment(-1 -2,0 -3)",
sqrt(5.0), 5, strategy);
tester::apply("box(0 0,1 1)",
"segment(-1 -2,0.5 -3.5)",
sqrt(5.0), 5, strategy);
tester::apply("box(0 0,1 1)",
"segment(-1 -2,0.5 -3.5)",
sqrt(5.0), 5, strategy);
tester::apply("box(0 0,1 1)",
"segment(0.5 3,2.5 2)",
sqrt(2.45), 2.45, strategy);
tester::apply(make_box2d<B>(0, 0, 1, 1),
make_segment<S>(0.5, 1.5, 1.5, -1.5),
tester::apply("box(0 0,1 1)",
"segment(0.5 1.5,1.5 -1.5)",
0, 0, strategy);
// test degenerate segment
tester::apply(make_box2d<B>(0, 0, 2, 2),
make_segment<S>(4, 1, 4, 1),
tester::apply("box(0 0,2 2)",
"segment(4 1,4 1)",
2, 4, strategy);
}
@@ -651,21 +651,21 @@ void test_distance_linestring_box(Strategy const& strategy)
// linestrings that intersect the box
tester::apply("linestring(-1 0.5,0.5 0.75)",
make_box2d<box_type>(0, 0, 1, 1),
"box(0 0,1 1)",
0, 0, strategy);
tester::apply("linestring(-1 0.5,1.5 0.75)",
make_box2d<box_type>(0, 0, 1, 1),
"box(0 0,1 1)",
0, 0, strategy);
// linestring that has closest point on box boundary
tester::apply("linestring(4 0.5,5 0.75)",
make_box2d<box_type>(0, 0, 1, 1),
"box(0 0,1 1)",
3, 9, strategy);
// linestring that has closest point on box corner
tester::apply("linestring(4 0,0 4)",
make_box2d<box_type>(0, 0, 1, 1),
sqrt(2), 2, strategy);
"box(0 0,1 1)",
sqrt(2.0), 2, strategy);
}
//===========================================================================
@@ -681,18 +681,18 @@ void test_distance_multilinestring_box(Strategy const& strategy)
// multilinestring that intersects the box
tester::apply("multilinestring((-1 0.5,0.5 0.75),(4 0.5,5 0.75))",
make_box2d<box_type>(0, 0, 1, 1),
"box(0 0,1 1)",
0, 0, strategy);
// multilinestring that has closest point on box boundary
tester::apply("multilinestring((4 0.5,5 0.75))",
make_box2d<box_type>(0, 0, 1, 1),
"box(0 0,1 1)",
3, 9, strategy);
// multilinestring that has closest point on box corner
tester::apply("multilinestring((5 0,0 5),(4 0,0 4))",
make_box2d<box_type>(0, 0, 1, 1),
sqrt(2), 2, strategy);
"box(0 0,1 1)",
sqrt(2.0), 2, strategy);
}
//===========================================================================

View File

@@ -40,20 +40,20 @@ void test_distance_segment_segment(Strategy const& strategy)
#endif
typedef test_distance_of_geometries<segment_type, segment_type> tester;
tester::apply(make_segment<segment_type>(0, 0, 10, 0),
make_segment<segment_type>(4, 2, 4, 0.5),
tester::apply("segment(0 0,10 0)",
"segment(4 2,4 0.5)",
return_type(0.5), return_type(0.25), strategy);
tester::apply(make_segment<segment_type>(0, 0, 10, 0),
make_segment<segment_type>(4, 2, 4, -0.5),
tester::apply("segment(0 0,10 0)",
"segment(4 2,4 -0.5)",
return_type(0), return_type(0), strategy);
tester::apply(make_segment<segment_type>(0, 0, 10, 0),
make_segment<segment_type>(4, 2, 0, 0),
tester::apply("segment(0 0,10 0)",
"segment(4 2,0 0)",
return_type(0), return_type(0), strategy);
tester::apply(make_segment<segment_type>(0, 0, 10, 0),
make_segment<segment_type>(-2, 3, 1, 2),
tester::apply("segment(0 0,10 0)",
"segment(-2 3,1 2)",
return_type(2), return_type(4), strategy);
}
@@ -68,11 +68,11 @@ void test_distance_segment_linestring(Strategy const& strategy)
#endif
typedef test_distance_of_geometries<segment_type, linestring_type> tester;
tester::apply(make_segment<segment_type>(-1, -1, -2, -2),
tester::apply("segment(-1 -1,-2 -2)",
"linestring(2 1,1 2,4 0)",
sqrt(12.5), 12.5, strategy);
tester::apply(make_segment<segment_type>(1, 1, 2, 2),
tester::apply("segment(1 1,2 2)",
"linestring(2 1,1 2,4 0)",
0, 0, strategy);
}
@@ -148,11 +148,11 @@ void test_distance_segment_multilinestring(Strategy const& strategy)
segment_type, multi_linestring_type
> tester;
tester::apply(make_segment<segment_type>(-1, -1, -2, -2),
tester::apply("segment(-1 -1,-2 -2)",
"multilinestring((2 1,1 2),(4 0,4 10))",
sqrt(12.5), 12.5, strategy);
tester::apply(make_segment<segment_type>(1, 1, 2, 2),
tester::apply("segment(1 1,2 2)",
"multilinestring((2 1,1 2),(4 0,4 10))",
0, 0, strategy);
}

View File

@@ -174,48 +174,48 @@ void test_distance_point_box_2d(Strategy const& strategy)
typedef test_distance_of_geometries<box_type, point_type> tester;
// point inside box
tester::apply(make_box2d<box_type>(-1, -1, 1, 1),
tester::apply("box(-1 -1,1 1)",
"point(0 0)", 0, 0, strategy);
// points on box corners
tester::apply(make_box2d<box_type>(-1, -1, 1, 1),
tester::apply("box(-1 -1,1 1)",
"point(-1 -1)", 0, 0, strategy);
tester::apply(make_box2d<box_type>(-1, -1, 1, 1),
tester::apply("box(-1 -1,1 1)",
"point(-1 1)", 0, 0, strategy);
tester::apply(make_box2d<box_type>(-1, -1, 1, 1),
tester::apply("box(-1 -1,1 1)",
"point(1 -1)", 0, 0, strategy);
tester::apply(make_box2d<box_type>(-1, -1, 1, 1),
tester::apply("box(-1 -1,1 1)",
"point(1 1)", 0, 0, strategy);
// points on box boundary edges
tester::apply(make_box2d<box_type>(-1, -1, 1, 1),
tester::apply("box(-1 -1,1 1)",
"point(0 -1)", 0, 0, strategy);
tester::apply(make_box2d<box_type>(-1, -1, 1, 1),
tester::apply("box(-1 -1,1 1)",
"point(-1 0)", 0, 0, strategy);
tester::apply(make_box2d<box_type>(-1, -1, 1, 1),
tester::apply("box(-1 -1,1 1)",
"point(1 0)", 0, 0, strategy);
tester::apply(make_box2d<box_type>(-1, -1, 1, 1),
tester::apply("box(-1 -1,1 1)",
"point(0 1)", 0, 0, strategy);
// points outside box
tester::apply(make_box2d<box_type>(-1, -1, 1, 1),
tester::apply("box(-1 -1,1 1)",
"point(0 4)", 3, 9, strategy);
tester::apply(make_box2d<box_type>(-1, -1, 1, 1),
tester::apply("box(-1 -1,1 1)",
"point(0.5 4)", 3, 9, strategy);
tester::apply(make_box2d<box_type>(-1, -1, 1, 1),
tester::apply("box(-1 -1,1 1)",
"point(-0.5 5)", 4, 16, strategy);
tester::apply(make_box2d<box_type>(-1, -1, 1, 1),
tester::apply("box(-1 -1,1 1)",
"point(3 0.25)", 2, 4, strategy);
tester::apply(make_box2d<box_type>(-1, -1, 1, 1),
tester::apply("box(-1 -1,1 1)",
"point(-3 -0.25)", 2, 4, strategy);
tester::apply(make_box2d<box_type>(-1, -1, 1, 1),
"point(3 5)", sqrt(20), 20, strategy);
tester::apply(make_box2d<box_type>(-1, -1, 1, 1),
tester::apply("box(-1 -1,1 1)",
"point(3 5)", sqrt(20.0), 20, strategy);
tester::apply("box(-1 -1,1 1)",
"point(-5 -4)", 5, 25, strategy);
tester::apply(make_box2d<box_type>(-1, -1, 1, 1),
"point(2 -2)", sqrt(2), 2, strategy);
tester::apply(make_box2d<box_type>(-1, -1, 1, 1),
"point(-3 4)", sqrt(13), 13, strategy);
tester::apply("box(-1 -1,1 1)",
"point(2 -2)", sqrt(2.0), 2, strategy);
tester::apply("box(-1 -1,1 1)",
"point(-3 4)", sqrt(13.0), 13, strategy);
}
//===========================================================================
@@ -237,42 +237,42 @@ void test_distance_point_box_different_point_types(Strategy const& strategy)
<
int_point, int_box
>::apply("point(0 0)",
make_box2d<int_box>(1, 1, 2, 2),
sqrt(2), 2, strategy);
"box(1 1, 2 2)",
sqrt(2.0), 2, strategy);
test_distance_of_geometries
<
double_point, int_box
>::apply("point(0.5 0)",
make_box2d<int_box>(1, -1, 2, 1),
"box(1 -1,2 1)",
0.5, 0.25, strategy);
test_distance_of_geometries
<
double_point, double_box
>::apply("point(1.5 0)",
make_box2d<double_box>(1, -1, 2, 1),
"box(1 -1,2 1)",
0, 0, strategy);
test_distance_of_geometries
<
double_point, int_box
>::apply("point(1.5 0)",
make_box2d<int_box>(1, -1, 2, 1),
"box(1 -1,2 1)",
0, 0, strategy);
test_distance_of_geometries
<
int_point, double_box
>::apply("point(1 0)",
make_box2d<double_box>(0.5, -1, 1.5, 1),
"box(0.5 -1,1.5 1)",
0, 0, strategy);
test_distance_of_geometries
<
int_point, double_box
>::apply("point(0 0)",
make_box2d<double_box>(0.5, -1, 1.5, 1),
"box(0.5, -1,1.5, 1)",
0.5, 0.25, strategy);
}
@@ -288,128 +288,128 @@ void test_distance_point_box_3d(Strategy const& strategy)
typedef test_distance_of_geometries<box_type_3d, point_type_3d> tester;
// point inside box
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(0 0 0)", 0, 0, strategy);
// points on box corners
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(-1 -1 -1)", 0, 0, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(-1 -1 1)", 0, 0, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(-1 1 -1)", 0, 0, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(-1 1 1)", 0, 0, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(1 -1 -1)", 0, 0, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(1 -1 1)", 0, 0, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(1 1 -1)", 0, 0, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(1 1 1)", 0, 0, strategy);
// points on box boundary edges
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(0 -1 -1)", 0, 0, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(0 -1 1)", 0, 0, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(0 1 -1)", 0, 0, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(0 1 1)", 0, 0, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(-1 0 -1)", 0, 0, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(-1 0 1)", 0, 0, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(1 0 -1)", 0, 0, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(1 0 1)", 0, 0, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(-1 -1 0)", 0, 0, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(-1 1 0)", 0, 0, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(1 -1 0)", 0, 0, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(1 1 0)", 0, 0, strategy);
// point on box faces
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(0 0 -1)", 0, 0, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(0 0 1)", 0, 0, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(0 -1 0)", 0, 0, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(0 1 0)", 0, 0, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(-1 0 0)", 0, 0, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(1 0 0)", 0, 0, strategy);
// points outside box -- closer to box corners
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
"point(-2 -3 -4)", sqrt(14), 14, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(-2 -3 -4)", sqrt(14.0), 14, strategy);
tester::apply("box(-1 -1 -1,1 1 1)",
"point(-2 -3 3)", 3, 9, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
"point(-2 5 -2)", sqrt(18), 18, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
"point(-2 5 3)", sqrt(21), 21, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
"point(4 -6 -3)", sqrt(38), 38, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
"point(4 -6 4)", sqrt(43), 43, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
"point(4 7 -2)", sqrt(46), 46, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
"point(4 7 8)", sqrt(94), 94, strategy);
tester::apply("box(-1 -1 -1,1 1 1)",
"point(-2 5 -2)", sqrt(18.0), 18, strategy);
tester::apply("box(-1 -1 -1,1 1 1)",
"point(-2 5 3)", sqrt(21.0), 21, strategy);
tester::apply("box(-1 -1 -1,1 1 1)",
"point(4 -6 -3)", sqrt(38.0), 38, strategy);
tester::apply("box(-1 -1 -1,1 1 1)",
"point(4 -6 4)", sqrt(43.0), 43, strategy);
tester::apply("box(-1 -1 -1,1 1 1)",
"point(4 7 -2)", sqrt(46.0), 46, strategy);
tester::apply("box(-1 -1 -1,1 1 1)",
"point(4 7 8)", sqrt(94.0), 94, strategy);
// points closer to box facets
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(0 0 10)", 9, 81, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(0 0 -5)", 4, 16, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(0 7 0)", 6, 36, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(0 -6 0)", 5, 25, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(4 0 0)", 3, 9, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(-3 0 0)", 2, 4, strategy);
// points closer to box edges
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(0 -4 -5)", 5, 25, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
"point(0 -3 6)", sqrt(29), 29, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
"point(0 2 -7)", sqrt(37), 37, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
"point(0 8 7)", sqrt(85), 85, strategy);
tester::apply("box(-1 -1 -1,1 1 1)",
"point(0 -3 6)", sqrt(29.0), 29, strategy);
tester::apply("box(-1 -1 -1,1 1 1)",
"point(0 2 -7)", sqrt(37.0), 37, strategy);
tester::apply("box(-1 -1 -1,1 1 1)",
"point(0 8 7)", sqrt(85.0), 85, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
"point(-4 0 -4)", sqrt(18), 18, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
"point(-3 0 5)", sqrt(20), 20, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
"point(2 0 -6)", sqrt(26), 26, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
"point(8 0 6)", sqrt(74), 74, strategy);
tester::apply("box(-1 -1 -1,1 1 1)",
"point(-4 0 -4)", sqrt(18.0), 18, strategy);
tester::apply("box(-1 -1 -1,1 1 1)",
"point(-3 0 5)", sqrt(20.0), 20, strategy);
tester::apply("box(-1 -1 -1,1 1 1)",
"point(2 0 -6)", sqrt(26.0), 26, strategy);
tester::apply("box(-1 -1 -1,1 1 1)",
"point(8 0 6)", sqrt(74.0), 74, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
"point(-5 -5 0)", sqrt(32), 32, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
"point(-4 6 0)", sqrt(34), 34, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
"point(3 -7 0)", sqrt(40), 40, strategy);
tester::apply(make_box3d<box_type_3d>(-1, -1, -1, 1, 1, 1),
tester::apply("box(-1 -1 -1,1 1 1)",
"point(-5 -5 0)", sqrt(32.0), 32, strategy);
tester::apply("box(-1 -1 -1,1 1 1)",
"point(-4 6 0)", sqrt(34.0), 34, strategy);
tester::apply("box(-1 -1 -1,1 1 1)",
"point(3 -7 0)", sqrt(40.0), 40, strategy);
tester::apply("box(-1 -1 -1,1 1 1)",
"point(9 7 0)", 10, 100, strategy);
}
@@ -425,24 +425,24 @@ void test_distance_multipoint_box_2d(Strategy const& strategy)
typedef test_distance_of_geometries<box_type, multi_point_type> tester;
// at least one point inside the box
tester::apply(make_box2d<box_type>(0, 0, 10, 10),
tester::apply("box(0 0,10 10)",
"multipoint(0 0,-1 -1,20 20)",
0, 0, strategy);
tester::apply(make_box2d<box_type>(0, 0, 10, 10),
tester::apply("box(0 0,10 10)",
"multipoint(1 1,-1 -1,20 20)",
0, 0, strategy);
tester::apply(make_box2d<box_type>(0, 0, 10, 10),
tester::apply("box(0 0,10 10)",
"multipoint(1 1,2 2,3 3)",
0, 0, strategy);
// all points outside the box
tester::apply(make_box2d<box_type>(0, 0, 10, 10),
tester::apply("box(0 0,10 10)",
"multipoint(-1 -1,20 20)",
sqrt(2), 2, strategy);
sqrt(2.0), 2, strategy);
tester::apply(make_box2d<box_type>(0, 0, 10, 10),
tester::apply("box(0 0,10 10)",
"multipoint(5 13, 50 50)",
3, 9, strategy);
}
@@ -462,24 +462,24 @@ void test_distance_multipoint_box_3d(Strategy const& strategy)
> tester;
// at least one point inside the box
tester::apply(make_box3d<box_type_3d>(0, 0, 0, 10, 10, 10),
tester::apply("box(0 0 0,10 10 10)",
"multipoint(0 0 0,-1 -1 -1,20 20 20)",
0, 0, strategy);
tester::apply(make_box3d<box_type_3d>(0, 0, 0, 10, 10, 10),
tester::apply("box(0 0 0,10 10 10)",
"multipoint(1 1 1,-1 -1 -1,20 20 20)",
0, 0, strategy);
tester::apply(make_box3d<box_type_3d>(0, 0, 0, 10, 10, 10),
tester::apply("box(0 0 0,10 10 10)",
"multipoint(1 1 1,2 2 2,3 3 3)",
0, 0, strategy);
// all points outside the box
tester::apply(make_box3d<box_type_3d>(0, 0, 0, 10, 10, 10),
tester::apply("box(0 0 0,10 10 10)",
"multipoint(-1 -1 -1,20 20 20)",
sqrt(3), 3, strategy);
sqrt(3.0), 3, strategy);
tester::apply(make_box3d<box_type_3d>(0, 0, 0, 10, 10, 10),
tester::apply("box(0 0 0,10 10 10)",
"multipoint(5 5 13,50 50 50)",
3, 9, strategy);
}

View File

@@ -169,16 +169,16 @@ void test_distance_multipoint_segment(Strategy const& strategy)
typedef test_distance_of_geometries<multi_point_type, segment_type> tester;
tester::apply("multipoint(0 0,1 0,0 1,1 1)",
make_segment<segment_type>(2, 0, 0, 2),
"segment(2 0,0 2)",
0, 0, strategy);
tester::apply("multipoint(0 0,1 0,0 1,1 1)",
make_segment<segment_type>(4, 0, 0, 4),
"segment(4 0,0 4)",
sqrt(2.0), 2, strategy);
tester::apply("multipoint(0 0,1 0,0 1,1 1)",
make_segment<segment_type>(1, 1, 2, 2),
"segment(1 1,2 2)",
0, 0, strategy);
tester::apply("multipoint(0 0,1 0,0 1,1 1)",
make_segment<segment_type>(3, 3, 4, 4),
"segment(3 3,4 4)",
sqrt(8.0), 8, strategy);
}

View File

@@ -66,43 +66,9 @@ void test_empty_input(Geometry1 const& geometry1, Geometry2 const& geometry2)
//========================================================================
//========================================================================
//========================================================================
// create geometries -- START
template<typename Segment>
Segment make_segment(double x1, double y1, double x2, double y2)
{
typename bg::point_type<Segment>::type p(x1, y1), q(x2, y2);
return Segment(p, q);
}
template <typename Box>
Box make_box2d(double xmin, double ymin, double xmax, double ymax)
{
typedef typename bg::point_type<Box>::type BoxPoint;
return Box(BoxPoint(xmin, ymin), BoxPoint(xmax, ymax));
}
template <typename Box>
Box make_box3d(double xmin, double ymin, double zmin,
double xmax, double ymax, double zmax)
{
typedef typename bg::point_type<Box>::type BoxPoint;
return Box(BoxPoint(xmin, ymin, zmin), BoxPoint(xmax, ymax, zmax));
}
// create geometries -- END
//========================================================================
//========================================================================
//========================================================================
#ifdef GEOMETRY_TEST_DEBUG
// pretty print geometry -- START
@@ -156,8 +122,6 @@ struct pretty_print_geometry
#endif // GEOMETRY_TEST_DEBUG
//========================================================================
@@ -218,47 +182,6 @@ struct test_distance_of_geometries<Geometry1, Geometry2, 0, 0>
strategy, test_reversed);
}
template
<
typename DistanceType,
typename ComparableDistanceType,
typename Strategy
>
static inline
void apply(Geometry1 const& geometry1,
std::string const& wkt2,
DistanceType const& expected_distance,
ComparableDistanceType const& expected_comparable_distance,
Strategy const& strategy,
bool test_reversed = true)
{
Geometry2 geometry2 = from_wkt<Geometry2>(wkt2);
apply(geometry1, geometry2,
expected_distance, expected_comparable_distance,
strategy, test_reversed);
}
template
<
typename DistanceType,
typename ComparableDistanceType,
typename Strategy
>
static inline
void apply(std::string const& wkt1,
Geometry2 const& geometry2,
DistanceType const& expected_distance,
ComparableDistanceType const& expected_comparable_distance,
Strategy const& strategy,
bool test_reversed = true)
{
Geometry1 geometry1 = from_wkt<Geometry1>(wkt1);
apply(geometry1, geometry2,
expected_distance, expected_comparable_distance,
strategy, test_reversed);
}
template
<
@@ -435,38 +358,37 @@ struct test_distance_of_geometries<Geometry1, Geometry2, 0, 0>
};
//========================================================================
//========================================================================
template <typename Geometry1, typename Geometry2>
template <typename Segment, typename Polygon>
struct test_distance_of_geometries
<
Geometry1, Geometry2,
Segment, Polygon,
92 /* segment */, 3 /* polygon */
>
: public test_distance_of_geometries<Geometry1, Geometry2, 0, 0>
: public test_distance_of_geometries<Segment, Polygon, 0, 0>
{
typedef test_distance_of_geometries<Geometry1, Geometry2, 0, 0> base;
typedef test_distance_of_geometries<Segment, Polygon, 0, 0> base;
typedef typename bg::ring_type<Geometry2>::type ring_type;
typedef typename bg::ring_type<Polygon>::type ring_type;
template
<
typename Segment,
typename DistanceType,
typename ComparableDistanceType,
typename Strategy
>
static inline
void apply(Segment const& segment,
std::string const& wkt,
void apply(std::string const& wkt_segment,
std::string const& wkt_polygon,
DistanceType const& expected_distance,
ComparableDistanceType const& expected_comparable_distance,
Strategy const& strategy)
{
Geometry2 geometry = from_wkt<Geometry2>(wkt);
Segment segment = from_wkt<Segment>(wkt_segment);
Polygon polygon = from_wkt<Polygon>(wkt_polygon);
apply(segment,
geometry,
polygon,
expected_distance,
expected_comparable_distance,
strategy);
@@ -475,21 +397,20 @@ struct test_distance_of_geometries
template
<
typename Segment,
typename DistanceType,
typename ComparableDistanceType,
typename Strategy
>
static inline
void apply(Segment const& segment,
Geometry2 const& geometry,
Polygon const& polygon,
DistanceType const& expected_distance,
ComparableDistanceType const& expected_comparable_distance,
Strategy const& strategy)
{
base::apply(segment, geometry, expected_distance,
base::apply(segment, polygon, expected_distance,
expected_comparable_distance, strategy);
if ( bg::num_interior_rings(geometry) == 0 ) {
if ( bg::num_interior_rings(polygon) == 0 ) {
#ifdef GEOMETRY_TEST_DEBUG
std::cout << "... testing also exterior ring ..." << std::endl;
#endif
@@ -497,7 +418,7 @@ struct test_distance_of_geometries
<
Segment, ring_type
>::apply(segment,
bg::exterior_ring(geometry),
bg::exterior_ring(polygon),
expected_distance,
expected_comparable_distance,
strategy);