From eb5f82aecd81334f67958bbe83ba4d974ddb9260 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Wed, 14 May 2014 17:54:13 +0300 Subject: [PATCH 1/2] [test][distance] eliminate make_* functions in test_distance_common.hpp; replace occurrences of these functions with wkt descriptions of the geometries (boxes and segments) --- test/algorithms/distance_areal_areal.cpp | 40 +- test/algorithms/distance_linear_areal.cpp | 592 +++++++++--------- test/algorithms/distance_linear_linear.cpp | 24 +- test/algorithms/distance_pointlike_areal.cpp | 216 +++---- test/algorithms/distance_pointlike_linear.cpp | 8 +- test/algorithms/test_distance_common.hpp | 107 +--- 6 files changed, 454 insertions(+), 533 deletions(-) diff --git a/test/algorithms/distance_areal_areal.cpp b/test/algorithms/distance_areal_areal.cpp index e46e8c54c..162793425 100644 --- a/test/algorithms/distance_areal_areal.cpp +++ b/test/algorithms/distance_areal_areal.cpp @@ -125,28 +125,28 @@ void test_distance_box_box(Strategy const& strategy) typedef test_distance_of_geometries int_tester; typedef test_distance_of_geometries tester; - int_tester::apply(make_box2d(5, 5, 10, 10), - make_box2d(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(5, 5, 10, 10), - make_box2d(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(3, 8, 13, 18), - make_box2d(0, 0, 5, 5), + tester::apply("box(3 8,13 18)", + "box(0 0,5 5)", 3, 9, strategy); - tester::apply(make_box2d(5, 5, 10, 10), - make_box2d(0, 0, 5, 5), + tester::apply("box(5 5,10 10)", + "box(0 0,5 5)", 0, 0, strategy); - tester::apply(make_box2d(5, 5, 10, 10), - make_box2d(0, 0, 6, 6), + tester::apply("box(5 5,10 10)", + "box(0 0,6 6)", 0, 0, strategy); - tester::apply(make_box2d(3, 5, 13, 15), - make_box2d(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 tester; tester::apply("polygon((10 10,10 5,5 5,5 10,10 10))", - make_box2d(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(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(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(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(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(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(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(0, 0, 2.5, 2), + "box(0 0,2.5 2)", 0, 0, strategy); } diff --git a/test/algorithms/distance_linear_areal.cpp b/test/algorithms/distance_linear_areal.cpp index e00f3f288..b9184adae 100644 --- a/test/algorithms/distance_linear_areal.cpp +++ b/test/algorithms/distance_linear_areal.cpp @@ -47,19 +47,19 @@ void test_distance_segment_polygon(Strategy const& strategy) #endif typedef test_distance_of_geometries tester; - tester::apply(make_segment(-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(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(-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(-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(-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(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(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(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 itester; // segments that intersect the box - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(4, 0, 0, 4), - sqrt(2), 2, strategy); - itester::apply(make_box2d(0, 0, 1, 1), - make_segment(-4, 0, 0, -4), - sqrt(8), 8, strategy); - itester::apply(make_box2d(0, 0, 1, 1), - make_segment(-8, 4, 4, -8), - sqrt(8), 8, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(-4, 0, 0, 4), - 1.5 * sqrt(2), 4.5, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(-4, 0, 1, 5), - 1.5 * sqrt(2), 4.5, strategy); - itester::apply(make_box2d(0, 0, 1, 1), - make_segment(0, -2, 3, 1), - 0.5 * sqrt(2), 0.5, strategy); - itester::apply(make_box2d(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(-2, -1, -1, -1), - sqrt(2), 2, strategy); - itester::apply(make_box2d(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(1, -1, 2, -1), + tester::apply("box(0 0,1 1)", + "segment(1 -1,2 -1)", 1, 1, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(2, -1, 3, -1), - sqrt(2), 2, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(-2, 0, -1, 0), + tester::apply("box(0 0,1 1)", + "segment(-2 0,-1 0)", 1, 1, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(-1, 0, 0, 0), + tester::apply("box(0 0,1 1)", + "segment(-1 0,0 0)", 0, 0, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(1, 0, 2, 0), + tester::apply("box(0 0,1 1)", + "segment(1 0,2 0)", 0, 0, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(2, 0, 3, 0), + tester::apply("box(0 0,1 1)", + "segment(2 0,3 0)", 1, 1, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(-2, 0, 2, 0), + tester::apply("box(0 0,1 1)", + "segment(-2 0,2 0)", 0, 0, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(-2, 1, -1, 1), + tester::apply("box(0 0,1 1)", + "segment(-2 1,-1 1)", 1, 1, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(-1, 1, 0, 1), + tester::apply("box(0 0,1 1)", + "segment(-1 1,0 1)", 0, 0, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(1, 1, 2, 1), + tester::apply("box(0 0,1 1)", + "segment(1 1,2 1)", 0, 0, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(2, 1, 3, 1), + tester::apply("box(0 0,1 1)", + "segment(2 1,3 1)", 1, 1, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(-2, 1, 2, 1), + tester::apply("box(0 0,1 1)", + "segment(-2 1,2 1)", 0, 0, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(-2, 3, -1, 3), - sqrt(5), 5, strategy); - itester::apply(make_box2d(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(1, 3, 2, 3), + tester::apply("box(0 0,1 1)", + "segment(1 3,2 3)", 2, 4, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(2, 3, 3, 3), - sqrt(5), 5, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(-1, -2, -1, -1), - sqrt(2), 2, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(-1, 1, -1, 2), + tester::apply("box(0 0,1 1)", + "segment(-1 1,-1 2)", 1, 1, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(-1, 2, -1, 3), - sqrt(2), 2, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(0, -2, 0, -1), + tester::apply("box(0 0,1 1)", + "segment(0 -2,0 -1)", 1, 1, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(0, -1, 0, 0), + tester::apply("box(0 0,1 1)", + "segment(0 -1,0 0)", 0, 0, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(0, 1, 0, 2), + tester::apply("box(0 0,1 1)", + "segment(0 1,0 2)", 0, 0, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(0, 2, 0, 3), + tester::apply("box(0 0,1 1)", + "segment(0 2,0 3)", 1, 1, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(0, -2, 0, 2), + tester::apply("box(0 0,1 1)", + "segment(0 -2,0 2)", 0, 0, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(1, -2, 1, -1), + tester::apply("box(0 0,1 1)", + "segment(1 -2,1 -1)", 1, 1, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(1, -1, 1, 0), + tester::apply("box(0 0,1 1)", + "segment(1 -1,1 0)", 0, 0, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(1, 1, 1, 2), + tester::apply("box(0 0,1 1)", + "segment(1 1,1 2)", 0, 0, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(1, 2, 1, 3), + tester::apply("box(0 0,1 1)", + "segment(1 2,1 3)", 1, 1, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(1, -2, 1, 2), + tester::apply("box(0 0,1 1)", + "segment(1 -2,1 2)", 0, 0, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(3, -2, 3, -1), - sqrt(5), 5, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(3, 1, 3, 2), + tester::apply("box(0 0,1 1)", + "segment(3 1,3 2)", 2, 4, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(3, 2, 3, 3), - sqrt(5), 5, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(-2, -2, -1, -1), - sqrt(2), 2, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(-2, -2, 4, 2), + tester::apply("box(0 0,1 1)", + "segment(-2 -2,4 2)", 0, 0, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(-2, -2, 2, 4), + tester::apply("box(0 0,1 1)", + "segment(-2 -2,2 4)", 0, 0, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(-2, -2, 4, 3), + tester::apply("box(0 0,1 1)", + "segment(-2 -2,4 3)", 0, 0, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(-2, -2, 3, 4), + tester::apply("box(0 0,1 1)", + "segment(-2 -2,3 4)", 0, 0, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(-2, -2, -1, -3), - sqrt(8), 8, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(-3, -1, 0, -4), - sqrt(8), 8, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(0, 2, 2, 0), + tester::apply("box(0 0,1 1)", + "segment(0 2,2 0)", 0, 0, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(-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(0, 0, 1, 1), - make_segment(-1, 4, 0, 3), + tester::apply("box(0 0,1 1)", + "segment(-1 4,0 3)", 2, 4, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(-2, 5, -1, 4), + tester::apply("box(0 0,1 1)", + "segment(-2 5,-1 4)", sqrt(10), 10, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(3, -1, 4, -4), - sqrt(5), 5, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(1, 2, 2, 1), + 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(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(-1, -2, 0, -3), - sqrt(5), 5, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(-1, -2, 0.5, -3.5), - sqrt(5), 5, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(-1, -2, 0.5, -3.5), - sqrt(5), 5, strategy); - tester::apply(make_box2d(0, 0, 1, 1), - make_segment(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(0, 0, 1, 1), - make_segment(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(0, 0, 2, 2), - make_segment(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(0, 0, 1, 1), + "box(0 0,1 1)", 0, 0, strategy); tester::apply("linestring(-1 0.5,1.5 0.75)", - make_box2d(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(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(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(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(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(0, 0, 1, 1), - sqrt(2), 2, strategy); + "box(0 0,1 1)", + sqrt(2.0), 2, strategy); } //=========================================================================== diff --git a/test/algorithms/distance_linear_linear.cpp b/test/algorithms/distance_linear_linear.cpp index 5faeca69a..4eea09d1c 100644 --- a/test/algorithms/distance_linear_linear.cpp +++ b/test/algorithms/distance_linear_linear.cpp @@ -40,20 +40,20 @@ void test_distance_segment_segment(Strategy const& strategy) #endif typedef test_distance_of_geometries tester; - tester::apply(make_segment(0, 0, 10, 0), - make_segment(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(0, 0, 10, 0), - make_segment(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(0, 0, 10, 0), - make_segment(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(0, 0, 10, 0), - make_segment(-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 tester; - tester::apply(make_segment(-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(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(-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(1, 1, 2, 2), + tester::apply("segment(1 1,2 2)", "multilinestring((2 1,1 2),(4 0,4 10))", 0, 0, strategy); } diff --git a/test/algorithms/distance_pointlike_areal.cpp b/test/algorithms/distance_pointlike_areal.cpp index f8d68f30a..c8584db04 100644 --- a/test/algorithms/distance_pointlike_areal.cpp +++ b/test/algorithms/distance_pointlike_areal.cpp @@ -174,48 +174,48 @@ void test_distance_point_box_2d(Strategy const& strategy) typedef test_distance_of_geometries tester; // point inside box - tester::apply(make_box2d(-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(-1, -1, 1, 1), + tester::apply("box(-1 -1,1 1)", "point(-1 -1)", 0, 0, strategy); - tester::apply(make_box2d(-1, -1, 1, 1), + tester::apply("box(-1 -1,1 1)", "point(-1 1)", 0, 0, strategy); - tester::apply(make_box2d(-1, -1, 1, 1), + tester::apply("box(-1 -1,1 1)", "point(1 -1)", 0, 0, strategy); - tester::apply(make_box2d(-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(-1, -1, 1, 1), + tester::apply("box(-1 -1,1 1)", "point(0 -1)", 0, 0, strategy); - tester::apply(make_box2d(-1, -1, 1, 1), + tester::apply("box(-1 -1,1 1)", "point(-1 0)", 0, 0, strategy); - tester::apply(make_box2d(-1, -1, 1, 1), + tester::apply("box(-1 -1,1 1)", "point(1 0)", 0, 0, strategy); - tester::apply(make_box2d(-1, -1, 1, 1), + tester::apply("box(-1 -1,1 1)", "point(0 1)", 0, 0, strategy); // points outside box - tester::apply(make_box2d(-1, -1, 1, 1), + tester::apply("box(-1 -1,1 1)", "point(0 4)", 3, 9, strategy); - tester::apply(make_box2d(-1, -1, 1, 1), + tester::apply("box(-1 -1,1 1)", "point(0.5 4)", 3, 9, strategy); - tester::apply(make_box2d(-1, -1, 1, 1), + tester::apply("box(-1 -1,1 1)", "point(-0.5 5)", 4, 16, strategy); - tester::apply(make_box2d(-1, -1, 1, 1), + tester::apply("box(-1 -1,1 1)", "point(3 0.25)", 2, 4, strategy); - tester::apply(make_box2d(-1, -1, 1, 1), + tester::apply("box(-1 -1,1 1)", "point(-3 -0.25)", 2, 4, strategy); - tester::apply(make_box2d(-1, -1, 1, 1), - "point(3 5)", sqrt(20), 20, strategy); - tester::apply(make_box2d(-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(-1, -1, 1, 1), - "point(2 -2)", sqrt(2), 2, strategy); - tester::apply(make_box2d(-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(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(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(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(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(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(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 tester; // point inside box - tester::apply(make_box3d(-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(-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(-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(-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(-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(-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(-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(-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(-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(-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(-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(-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(-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(-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(-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(-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(-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(-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(-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(-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(-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(-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(-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(-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(-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(-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(-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(-1, -1, -1, 1, 1, 1), - "point(-2 -3 -4)", sqrt(14), 14, strategy); - tester::apply(make_box3d(-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(-1, -1, -1, 1, 1, 1), - "point(-2 5 -2)", sqrt(18), 18, strategy); - tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), - "point(-2 5 3)", sqrt(21), 21, strategy); - tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), - "point(4 -6 -3)", sqrt(38), 38, strategy); - tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), - "point(4 -6 4)", sqrt(43), 43, strategy); - tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), - "point(4 7 -2)", sqrt(46), 46, strategy); - tester::apply(make_box3d(-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(-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(-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(-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(-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(-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(-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(-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(-1, -1, -1, 1, 1, 1), - "point(0 -3 6)", sqrt(29), 29, strategy); - tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), - "point(0 2 -7)", sqrt(37), 37, strategy); - tester::apply(make_box3d(-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(-1, -1, -1, 1, 1, 1), + tester::apply("box(-1 -1 -1,1 1 1)", "point(-4 0 -4)", sqrt(18), 18, strategy); - tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), - "point(-3 0 5)", sqrt(20), 20, strategy); - tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), - "point(2 0 -6)", sqrt(26), 26, strategy); - tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), - "point(8 0 6)", sqrt(74), 74, 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(-1, -1, -1, 1, 1, 1), + tester::apply("box(-1 -1 -1,1 1 1)", "point(-5 -5 0)", sqrt(32), 32, strategy); - tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), - "point(-4 6 0)", sqrt(34), 34, strategy); - tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), - "point(3 -7 0)", sqrt(40), 40, strategy); - tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + 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 tester; // at least one point inside the box - tester::apply(make_box2d(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(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(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(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(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(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(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(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(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(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); } diff --git a/test/algorithms/distance_pointlike_linear.cpp b/test/algorithms/distance_pointlike_linear.cpp index 9a56f0460..099465d8e 100644 --- a/test/algorithms/distance_pointlike_linear.cpp +++ b/test/algorithms/distance_pointlike_linear.cpp @@ -169,16 +169,16 @@ void test_distance_multipoint_segment(Strategy const& strategy) typedef test_distance_of_geometries tester; tester::apply("multipoint(0 0,1 0,0 1,1 1)", - make_segment(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(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(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(3, 3, 4, 4), + "segment(3 3,4 4)", sqrt(8.0), 8, strategy); } diff --git a/test/algorithms/test_distance_common.hpp b/test/algorithms/test_distance_common.hpp index 826811cda..a3b000e67 100644 --- a/test/algorithms/test_distance_common.hpp +++ b/test/algorithms/test_distance_common.hpp @@ -66,43 +66,9 @@ void test_empty_input(Geometry1 const& geometry1, Geometry2 const& geometry2) -//======================================================================== -//======================================================================== //======================================================================== -// create geometries -- START -template -Segment make_segment(double x1, double y1, double x2, double y2) -{ - typename bg::point_type::type p(x1, y1), q(x2, y2); - return Segment(p, q); -} - - -template -Box make_box2d(double xmin, double ymin, double xmax, double ymax) -{ - typedef typename bg::point_type::type BoxPoint; - - return Box(BoxPoint(xmin, ymin), BoxPoint(xmax, ymax)); -} - -template -Box make_box3d(double xmin, double ymin, double zmin, - double xmax, double ymax, double zmax) -{ - typedef typename bg::point_type::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 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(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(wkt1); - - apply(geometry1, geometry2, - expected_distance, expected_comparable_distance, - strategy, test_reversed); - } template < @@ -435,38 +358,37 @@ struct test_distance_of_geometries }; -//======================================================================== //======================================================================== -template +template struct test_distance_of_geometries < - Geometry1, Geometry2, + Segment, Polygon, 92 /* segment */, 3 /* polygon */ > - : public test_distance_of_geometries + : public test_distance_of_geometries { - typedef test_distance_of_geometries base; + typedef test_distance_of_geometries base; - typedef typename bg::ring_type::type ring_type; + typedef typename bg::ring_type::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(wkt); + Segment segment = from_wkt(wkt_segment); + Polygon polygon = from_wkt(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); From 087a42e9fd6916f7ea8e6c817274839a3dacf83a Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Wed, 14 May 2014 17:58:46 +0300 Subject: [PATCH 2/2] [test][distance] make sure sqrt is called with a double argument (to avoid problems with VS2010 that does not promote ints to doubles in sqrt) --- test/algorithms/distance_linear_areal.cpp | 2 +- test/algorithms/distance_pointlike_areal.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/algorithms/distance_linear_areal.cpp b/test/algorithms/distance_linear_areal.cpp index b9184adae..a15117729 100644 --- a/test/algorithms/distance_linear_areal.cpp +++ b/test/algorithms/distance_linear_areal.cpp @@ -606,7 +606,7 @@ void test_distance_segment_box(Strategy const& strategy) 2, 4, strategy); tester::apply("box(0 0,1 1)", "segment(-2 5,-1 4)", - sqrt(10), 10, strategy); + sqrt(10.0), 10, strategy); tester::apply("box(0 0,1 1)", "segment(3 -1,4 -4)", sqrt(5.0), 5, strategy); diff --git a/test/algorithms/distance_pointlike_areal.cpp b/test/algorithms/distance_pointlike_areal.cpp index c8584db04..69b805476 100644 --- a/test/algorithms/distance_pointlike_areal.cpp +++ b/test/algorithms/distance_pointlike_areal.cpp @@ -395,7 +395,7 @@ void test_distance_point_box_3d(Strategy const& strategy) "point(0 8 7)", sqrt(85.0), 85, strategy); tester::apply("box(-1 -1 -1,1 1 1)", - "point(-4 0 -4)", sqrt(18), 18, strategy); + "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)", @@ -404,7 +404,7 @@ void test_distance_point_box_3d(Strategy const& strategy) "point(8 0 6)", sqrt(74.0), 74, strategy); tester::apply("box(-1 -1 -1,1 1 1)", - "point(-5 -5 0)", sqrt(32), 32, strategy); + "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)",