Skip to content

Commit

Permalink
test: add set_ops_areal_areal which tests all operations
Browse files Browse the repository at this point in the history
  • Loading branch information
barendgehrels committed Dec 10, 2024
1 parent 54b300a commit 82ef735
Show file tree
Hide file tree
Showing 11 changed files with 244 additions and 112 deletions.
18 changes: 12 additions & 6 deletions test/algorithms/overlay/multi_overlay_cases.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1594,18 +1594,24 @@ static std::string issue_1288[3] =
"POLYGON((-0.5 -1.49999999, -2.0 -0.1, -1.99999999 -1.5))"
};

static std::string bug_21155501[2] =
{
"MULTIPOLYGON(((-8.3935546875 27.449790329784214,4.9658203125 18.729501999072138,11.8212890625 23.563987128451217,9.7119140625 25.48295117535531,9.8876953125 31.728167146023935,8.3056640625 32.99023555965106,8.5693359375 37.16031654673677,-1.8896484375 35.60371874069731,-0.5712890625 32.02670629333614,-8.9208984375 29.458731185355344,-8.3935546875 27.449790329784214)))",
"MULTIPOLYGON(((4.9658203125 18.729501999072138,-3.4868710311820115 24.246968623627644,8.3589904332912 33.833614418115445,8.3056640625 32.99023555965106,9.8876953125 31.728167146023935,9.7119140625 25.48295117535531,11.8212890625 23.563987128451217,4.9658203125 18.729501999072138)),((-3.88714525609152 24.508246314579743,-8.3935546875 27.449790329784214,-8.9208984375 29.458731185355344,-0.5712890625 32.02670629333614,-1.8896484375 35.60371874069731,8.5693359375 37.16031654673677,8.362166569827938 33.883846345901595,-3.88714525609152 24.508246314579743)))",
};

static std::string issue_1299[2] =
{
"MULTIPOLYGON(((1.2549999979079400 0.85000000411847698, -1.2550000020920500 0.84999999897038103, -1.2549999999999999 -0.85000000102961903, 1.2549999999999999 -0.84999999999999998)))",
"MULTIPOLYGON(((-0.87500000000000000 -0.84999999999999998, -0.87500000000000000 -0.070000000000000201, -1.2549999999999999 -0.070000000000000201, -1.2549999999999999 -0.84999999999999998)))"
};

static std::string issue_1350_comment[2] =
{
"MULTIPOLYGON(((2 10,2 8,0 8,0 10,2 10)),((10 8,10 2,8 2,8 0,0 0,0 4,2 4,2 8,4 8,4 10,6 10,6 8,6 6,8 6,8 8,10 8),(8 2,8 4,4 4,4 2,8 2)))",
"MULTIPOLYGON(((2 6,2 4,2 2,2 0,0 0,0 6,2 6)),((2 10,2 8,0 8,0 10,2 10)),((6 8,6 6,2 6,2 8,6 8)),((8 4,8 2,6 2,6 4,8 4)),((10 8,10 6,8 6,8 8,10 8)),((8 10,8 8,6 8,6 10,8 10)))"
};

static std::string bug_21155501[2] =
{
"MULTIPOLYGON(((-8.3935546875 27.449790329784214,4.9658203125 18.729501999072138,11.8212890625 23.563987128451217,9.7119140625 25.48295117535531,9.8876953125 31.728167146023935,8.3056640625 32.99023555965106,8.5693359375 37.16031654673677,-1.8896484375 35.60371874069731,-0.5712890625 32.02670629333614,-8.9208984375 29.458731185355344,-8.3935546875 27.449790329784214)))",
"MULTIPOLYGON(((4.9658203125 18.729501999072138,-3.4868710311820115 24.246968623627644,8.3589904332912 33.833614418115445,8.3056640625 32.99023555965106,9.8876953125 31.728167146023935,9.7119140625 25.48295117535531,11.8212890625 23.563987128451217,4.9658203125 18.729501999072138)),((-3.88714525609152 24.508246314579743,-8.3935546875 27.449790329784214,-8.9208984375 29.458731185355344,-0.5712890625 32.02670629333614,-1.8896484375 35.60371874069731,8.5693359375 37.16031654673677,8.362166569827938 33.883846345901595,-3.88714525609152 24.508246314579743)))",
};

static std::string mysql_21965285_b[2] =
{
"MULTIPOLYGON(((3 0, -19 -19, -7 3, -2 10, 15 0, 3 0)))",
Expand Down
3 changes: 2 additions & 1 deletion test/algorithms/overlay/overlay_cases.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,8 @@ static std::string issue_1226[2] =
"POLYGON((-0.91943242964602156508 0.55292377741135378955,-0.90478776881879174887 0.51756843862590162786,-0.91 0.48,-0.91943242964602156508 0.55292377741135378955))"
};

// Triangle, nearly a line
// Triangle, nearly a line.
// Still gives an error in difference
static std::string issue_1229[2] =
{
"POLYGON((38436.758 22765.61,930.538 -10523.68,925.121 -10507.965,38436.758 22765.61))",
Expand Down
6 changes: 6 additions & 0 deletions test/algorithms/set_operations/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ add_subdirectory(union)
add_subdirectory(intersection)
add_subdirectory(difference)
add_subdirectory(sym_difference)

foreach(item IN ITEMS
set_ops_areal_areal
)
boost_geometry_add_unit_test("algorithms" ${item})
endforeach()
7 changes: 6 additions & 1 deletion test/algorithms/set_operations/Jamfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Boost.Geometry (aka GGL, Generic Geometry Library)
#
# Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
# Copyright (c) 2007-2024 Barend Gehrels, Amsterdam, the Netherlands.
# Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
# Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
#
Expand All @@ -14,6 +14,11 @@
# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)

test-suite boost-geometry-algorithms
:
[ run set_ops_areal_areal.cpp : : : : algorithms_set_ops_areal_areal ]
;

build-project difference ;
build-project intersection ;
build-project sym_difference ;
Expand Down
37 changes: 0 additions & 37 deletions test/algorithms/set_operations/difference/difference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,43 +562,6 @@ void test_all()

TEST_DIFFERENCE(issue_1138, 1, 203161.751, 2, 1237551.0171, 1);

{
ut_settings settings;
settings.set_test_validity(false);
settings.validity_of_sym = false;
TEST_DIFFERENCE_WITH(issue_1226, 1, 0.238037722, 0, 0.0, 1, settings);
}

TEST_DIFFERENCE(issue_1231, 2, 36.798659456837477, 3, 195.2986, 5);

TEST_DIFFERENCE(issue_1244, 3, 8, 3, 2, 6);

{
// The symmetric difference reports an invalidity since the choice of
// discarding start/touch turns.
// This might be a false negative.
// Clockwise: "method: t; operations: u/x"
// CCW: "method: m; operations: i/x"
ut_settings settings;
settings.validity_of_sym = false;
TEST_DIFFERENCE_WITH(issue_1293, 1, 1.40999, 1, 2.318951, 2, settings);
}

#if defined(BOOST_GEOMETRY_TEST_FAILURES)
// Difference fails for this case. This was not reported for this case.
// Reported as a failing intersection, which is fixed.
// The failing difference should be investigated more thoroughly.
TEST_DIFFERENCE(issue_1295, 1, 9.999, 1, 9.999, 1);
#endif

TEST_DIFFERENCE(issue_1326, 3, 6.7128537626409130468, 6, 0.00372806966532758478, 9);

TEST_DIFFERENCE(issue_1342_a, 2, 5.762381026454777, 0, 0.0, 2);
TEST_DIFFERENCE(issue_1342_b, 2, 5.762381026454777, 1, 2.55e-14, 3);

TEST_DIFFERENCE(issue_1345_a, 1, 0.059308854, 0, 0.0, 1);
TEST_DIFFERENCE(issue_1345_b, 2, 0.024048025, 0, 0.0, 2);

TEST_DIFFERENCE(mysql_21977775, 2, 160.856568913, 2, 92.3565689126, 4);
TEST_DIFFERENCE(mysql_21965285, 1, 92.0, 1, 14.0, 1);
TEST_DIFFERENCE(mysql_23023665_1, 1, 92.0, 1, 142.5, 2);
Expand Down
12 changes: 0 additions & 12 deletions test/algorithms/set_operations/difference/difference_multi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,6 @@ void test_areal()

TEST_DIFFERENCE(issue_900, 0, 0.0, 2, 35, 2);

TEST_DIFFERENCE(issue_1222, 2, 32.0, 1, 4.0, 1);
{
// "method: t; operations: c/c;" still happening in the result
// for multi/multi
ut_settings settings;
settings.set_test_validity(BG_IF_TEST_FAILURES);
settings.validity_of_sym = BG_IF_TEST_FAILURES;
TEST_DIFFERENCE_WITH(0, 1, issue_1288, 2, 10.95, 0, 0.0, 2);
}

// Areas and #clips correspond with POSTGIS (except sym case)
test_one<Polygon, MultiPolygon, MultiPolygon>("case_101_multi",
case_101_multi[0], case_101_multi[1],
Expand Down Expand Up @@ -371,8 +361,6 @@ void test_areal()
TEST_DIFFERENCE(mysql_regression_1_65_2017_08_31,
optional(), optional_sliver(1e-6),
3, 152.064185, count_set(3, 4));

TEST_DIFFERENCE(issue_1299, 1, 3.9706, 0, 0, 1);
}


Expand Down
15 changes: 0 additions & 15 deletions test/algorithms/set_operations/intersection/intersection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,23 +293,8 @@ void test_areal()

TEST_INTERSECTION(issue_893, 1, -1, 473001.5082956461);

TEST_INTERSECTION(issue_1226, 1, -1, 0.00036722862);
TEST_INTERSECTION(issue_1229, 0, -1, 0);

TEST_INTERSECTION(issue_1231, 1, -1, 54.701340543162516);

TEST_INTERSECTION(issue_1244, 1, -1, 7);

TEST_INTERSECTION(issue_1293, 1, -1, 1.49123);
TEST_INTERSECTION(issue_1295, 1, -1, 4.90121);
TEST_INTERSECTION(issue_1326, 1, -1, 16.4844);

TEST_INTERSECTION(issue_1342_a, 1, -1, 43.05575);
TEST_INTERSECTION(issue_1342_b, 1, -1, 43.05575);

TEST_INTERSECTION(issue_1345_a, 1, -1, 0.00062682687);
TEST_INTERSECTION(issue_1345_b, 1, -1, 0.010896761);

test_one<Polygon, Polygon, Polygon>("buffer_mp1", buffer_mp1[0], buffer_mp1[1],
1, 31, 2.271707796);
test_one<Polygon, Polygon, Polygon>("buffer_mp2", buffer_mp2[0], buffer_mp2[1],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,14 +362,9 @@ void test_areal()
TEST_INTERSECTION(issue_888_34, 7, -1, 0.0256838);
TEST_INTERSECTION(issue_888_37, 13, -1, 0.0567043);

TEST_INTERSECTION(issue_1222, 1, -1, 4.0);
TEST_INTERSECTION(issue_1288, 1, -1, 1.05);

TEST_INTERSECTION(mysql_23023665_7, 2, 11, 9.80505786783);
TEST_INTERSECTION(mysql_23023665_12, 2, 0, 11.812440191387557);
TEST_INTERSECTION(mysql_regression_1_65_2017_08_31, 2, -1, 29.9022122);

TEST_INTERSECTION(issue_1299, 1, -1, 0.2964);
}

template <typename Polygon, typename MultiPolygon, typename Box>
Expand Down
Loading

0 comments on commit 82ef735

Please sign in to comment.