mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-12 12:12:10 +00:00
Merge branch 'develop' into feature/gc3
This commit is contained in:
@@ -430,7 +430,7 @@ int test_main(int, char* [])
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_GEOMETRY_TEST_FAILURES)
|
||||
BoostGeometryWriteExpectedFailures(2, 4, 9, 4);
|
||||
BoostGeometryWriteExpectedFailures(2, 4, 11, 3);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -686,7 +686,7 @@ int test_main(int, char* [])
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_GEOMETRY_TEST_FAILURES)
|
||||
BoostGeometryWriteExpectedFailures(5, 1, 3, 4);
|
||||
BoostGeometryWriteExpectedFailures(3, 1, 3, 3);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// This file was modified by Oracle on 2014-2021.
|
||||
// Modifications copyright (c) 2014-2021 Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
|
||||
@@ -31,8 +32,10 @@
|
||||
#include <boost/geometry/strategies/strategies.hpp>
|
||||
#include <boost/geometry/strategies/spherical/side_by_cross_track.hpp>
|
||||
|
||||
#include <boost/geometry/strategy/cartesian/side_robust.hpp>
|
||||
#include <boost/geometry/strategy/cartesian/precise_area.hpp>
|
||||
#include <boost/geometry/strategy/cartesian/side_by_triangle.hpp>
|
||||
#include <boost/geometry/strategy/cartesian/side_non_robust.hpp>
|
||||
#include <boost/geometry/strategy/cartesian/side_robust.hpp>
|
||||
#include <boost/geometry/strategy/cartesian/precise_area.hpp>
|
||||
|
||||
#include <boost/geometry/io/wkt/wkt.hpp>
|
||||
@@ -44,7 +47,11 @@ struct robust_cartesian : boost::geometry::strategies::convex_hull::cartesian<>
|
||||
{
|
||||
static auto side()
|
||||
{
|
||||
return boost::geometry::strategy::side::side_robust<>();
|
||||
return boost::geometry::strategy::side::side_robust
|
||||
<
|
||||
double,
|
||||
boost::geometry::strategy::side::fp_equals_policy
|
||||
>();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -75,6 +82,7 @@ struct sphrerical_side_by_cross_track : boost::geometry::strategies::convex_hull
|
||||
|
||||
struct precise_cartesian : boost::geometry::strategies::area::cartesian<>
|
||||
{
|
||||
// Technically this should be enabled only for non-boxes
|
||||
template <typename Geometry>
|
||||
static auto area(Geometry const&)
|
||||
{
|
||||
@@ -147,6 +155,7 @@ struct test_convex_hull
|
||||
check_convex_hull(geometry, hull, size_original, size_hull,
|
||||
expected_area, expected_perimeter, false, AreaStrategy());
|
||||
|
||||
bg::clear(hull);
|
||||
bg::convex_hull(geometry, hull, Strategy());
|
||||
|
||||
using point_t = typename bg::point_type<Hull>::type;
|
||||
@@ -207,7 +216,34 @@ struct test_convex_hull<Hull, robust_cartesian, AreaStrategy>
|
||||
bg::convex_hull(geometry, hull.outer(), robust_cartesian());
|
||||
check_convex_hull(geometry, hull, size_original, size_hull, expected_area,
|
||||
expected_perimeter, false, AreaStrategy());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
typename Hull
|
||||
>
|
||||
struct test_convex_hull<Hull, robust_cartesian, precise_cartesian>
|
||||
{
|
||||
template <typename Geometry>
|
||||
static void apply(Geometry const& geometry,
|
||||
std::size_t size_original,
|
||||
std::size_t size_hull_closed,
|
||||
double expected_area,
|
||||
double expected_perimeter,
|
||||
bool )
|
||||
{
|
||||
static bool const is_hull_closed = bg::closure<Hull>::value != bg::open;
|
||||
std::size_t const size_hull = is_hull_closed ? size_hull_closed :
|
||||
size_hull_closed - 1;
|
||||
|
||||
// Test version with strategy
|
||||
Hull hull;
|
||||
bg::convex_hull(geometry, hull.outer(), robust_cartesian());
|
||||
|
||||
check_convex_hull(geometry, hull, size_original, size_hull, expected_area,
|
||||
expected_perimeter, false, precise_cartesian());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -236,7 +272,6 @@ void test_geometry_order(std::string const& wkt,
|
||||
Geometry geometry;
|
||||
bg::read_wkt(wkt, geometry);
|
||||
|
||||
|
||||
test_convex_hull<hull_type, Strategy, AreaStrategy>::apply(geometry, size_original,
|
||||
size_hull_closed, expected_area, expected_perimeter, !Clockwise);
|
||||
|
||||
@@ -307,5 +342,4 @@ void test_empty_input()
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -284,21 +284,12 @@ void test_all()
|
||||
"LINESTRING(2 8,4 0.4,8 1,0 5)",
|
||||
expected("iuu++")("mui=+")("tiu+="));
|
||||
|
||||
#if ! ( defined(BOOST_CLANG) && defined(BOOST_GEOMETRY_COMPILER_MODE_RELEASE) )
|
||||
|
||||
// In clang/release mode this testcase gives other results
|
||||
|
||||
// assertion failure in 1.57
|
||||
// FAILING - no assertion failure but the result is not very good
|
||||
test_geometry<ls, ls>("LINESTRING(-2305843009213693956 4611686018427387906, -33 -92, 78 83)",
|
||||
"LINESTRING(31 -97, -46 57, -20 -4)",
|
||||
expected("")(""));
|
||||
expected("iuu++"));
|
||||
test_geometry<ls, ls>("LINESTRING(31 -97, -46 57, -20 -4)",
|
||||
"LINESTRING(-2305843009213693956 4611686018427387906, -33 -92, 78 83)",
|
||||
expected("")(""));
|
||||
|
||||
#endif
|
||||
|
||||
expected("iuu++"));
|
||||
}
|
||||
|
||||
// In 1.57 the results of those combinations was different for MinGW
|
||||
|
||||
@@ -27,9 +27,11 @@
|
||||
# include <boost/geometry/io/svg/svg_mapper.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/geometry/strategy/cartesian/side_robust.hpp>
|
||||
#include <boost/geometry/strategies/cartesian/side_by_triangle.hpp>
|
||||
#include <boost/geometry/strategies/side.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/side.hpp>
|
||||
|
||||
template <typename P, typename T>
|
||||
void test_with_point(std::string const& /*caseid*/,
|
||||
|
||||
@@ -46,8 +46,6 @@ void test_all()
|
||||
{
|
||||
typedef bg::model::polygon<P> polygon;
|
||||
|
||||
typedef typename bg::coordinate_type<P>::type ct;
|
||||
|
||||
test_one<polygon, polygon, polygon>("simplex_normal",
|
||||
simplex_normal[0], simplex_normal[1],
|
||||
3, 12, 2.52636706856656,
|
||||
@@ -68,10 +66,15 @@ void test_all()
|
||||
1, 5, 8.0,
|
||||
1, 5, 8.0);
|
||||
|
||||
test_one<polygon, polygon, polygon>("star_comb_15",
|
||||
star_comb_15[0], star_comb_15[1],
|
||||
30, -1, 227.658275102812,
|
||||
30, -1, 480.485775259312);
|
||||
{
|
||||
ut_settings settings;
|
||||
settings.validity_false_negative_sym = true;
|
||||
test_one<polygon, polygon, polygon>("star_comb_15",
|
||||
star_comb_15[0], star_comb_15[1],
|
||||
30, -1, 227.658275102812,
|
||||
30, -1, 480.485775259312,
|
||||
settings);
|
||||
}
|
||||
|
||||
test_one<polygon, polygon, polygon>("new_hole",
|
||||
new_hole[0], new_hole[1],
|
||||
@@ -106,7 +109,7 @@ void test_all()
|
||||
|
||||
{
|
||||
ut_settings settings;
|
||||
settings.sym_difference_validity = BG_IF_RESCALED(true, false);
|
||||
settings.validity_false_negative_sym = true;
|
||||
|
||||
test_one<polygon, polygon, polygon>("only_hole_intersections1",
|
||||
only_hole_intersections[0], only_hole_intersections[1],
|
||||
@@ -114,7 +117,7 @@ void test_all()
|
||||
4, 16, 10.9090909,
|
||||
settings);
|
||||
|
||||
test_one<polygon, polygon, polygon>("only_hole_intersection2",
|
||||
test_one<polygon, polygon, polygon>("only_hole_intersections2",
|
||||
only_hole_intersections[0], only_hole_intersections[2],
|
||||
3, 20, 30.9090909,
|
||||
4, 16, 10.9090909,
|
||||
@@ -144,7 +147,7 @@ void test_all()
|
||||
|
||||
{
|
||||
ut_settings settings;
|
||||
settings.sym_difference_validity = BG_IF_RESCALED(false, true);
|
||||
settings.validity_of_sym = BG_IF_RESCALED(false, true);
|
||||
test_one<polygon, polygon, polygon>("intersect_holes_intersect_and_disjoint",
|
||||
intersect_holes_intersect_and_disjoint[0], intersect_holes_intersect_and_disjoint[1],
|
||||
2, 16, 15.75,
|
||||
@@ -180,7 +183,6 @@ void test_all()
|
||||
|
||||
{
|
||||
ut_settings settings;
|
||||
settings.sym_difference_validity = BG_IF_RESCALED(false, true);
|
||||
test_one<polygon, polygon, polygon>("intersect_holes_intersect",
|
||||
intersect_holes_intersect[0], intersect_holes_intersect[1],
|
||||
2, 16, 15.75,
|
||||
@@ -295,10 +297,9 @@ void test_all()
|
||||
1, 61, 10.2717,
|
||||
1, 61, 10.2717);
|
||||
|
||||
if ( BOOST_GEOMETRY_CONDITION((std::is_same<ct, double>::value)) )
|
||||
{
|
||||
ut_settings settings;
|
||||
settings.sym_difference_validity = BG_IF_RESCALED(true, false);
|
||||
settings.validity_false_negative_sym = true;
|
||||
TEST_DIFFERENCE_WITH(buffer_mp2, 1, 12.09857, 1, 24.19714,
|
||||
count_set(1, 2), settings);
|
||||
}
|
||||
@@ -319,7 +320,7 @@ void test_all()
|
||||
ut_settings settings;
|
||||
settings.percentage = BG_IF_RESCALED(0.001, 0.1);
|
||||
settings.set_test_validity(BG_IF_RESCALED(true, false));
|
||||
settings.sym_difference = BG_IF_RESCALED(true, false);
|
||||
settings.sym_difference = false;
|
||||
|
||||
// Isovist - the # output polygons differ per compiler/pointtype, (very) small
|
||||
// rings might be discarded. We check area only
|
||||
@@ -330,18 +331,24 @@ void test_all()
|
||||
|
||||
test_one<polygon, polygon, polygon>("isovist",
|
||||
isovist1[0], isovist1[1],
|
||||
ignore_count(), -1, 0.279132,
|
||||
ignore_count(), -1, expectation_limits(0.279128, 0.279132),
|
||||
ignore_count(), -1, 224.8892,
|
||||
settings);
|
||||
}
|
||||
|
||||
#if ! defined(BOOST_GEOMETRY_USE_RESCALING) || defined(BOOST_GEOMETRY_TEST_FAILURES)
|
||||
// SQL Server gives: 0.28937764436705 and 0.000786406897532288 with 44/35 rings
|
||||
// PostGIS gives: 0.30859375 and 0.033203125 with 35/35 rings
|
||||
TEST_DIFFERENCE_WITH(geos_1,
|
||||
ignore_count(), expectation_limits(0.20705, 0.29172),
|
||||
ignore_count(), expectation_limits(0.00060440758, 0.00076856),
|
||||
ignore_count(), ut_settings(0.1, false));
|
||||
{
|
||||
ut_settings settings(0.1);
|
||||
settings.set_test_validity(BG_IF_RESCALED(false, true));
|
||||
settings.validity_false_negative_sym = BG_IF_RESCALED(true, false);
|
||||
|
||||
// SQL Server gives: 0.28937764436705 and 0.000786406897532288 with 44/35 rings
|
||||
// PostGIS gives: 0.30859375 and 0.033203125 with 35/35 rings
|
||||
TEST_DIFFERENCE_WITH(geos_1,
|
||||
ignore_count(), expectation_limits(0.20705, 0.29172),
|
||||
ignore_count(), expectation_limits(0.00060440758, 0.00076856),
|
||||
ignore_count(), settings);
|
||||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
@@ -425,7 +432,7 @@ void test_all()
|
||||
// With rescaling, difference of output a-b and a sym b is invalid
|
||||
ut_settings settings;
|
||||
settings.set_test_validity(BG_IF_RESCALED(false, true));
|
||||
settings.sym_difference_validity = BG_IF_RESCALED(false, true);
|
||||
settings.validity_of_sym = BG_IF_RESCALED(false, true);
|
||||
TEST_DIFFERENCE_WITH(ggl_list_20190307_matthieu_1,
|
||||
count_set(1, 2), 0.18461532,
|
||||
count_set(1, 2), 0.617978,
|
||||
@@ -563,6 +570,7 @@ void test_all()
|
||||
{
|
||||
ut_settings settings;
|
||||
settings.set_test_validity(BG_IF_RESCALED(true, false));
|
||||
settings.validity_false_negative_a = true;
|
||||
TEST_DIFFERENCE_WITH(issue_838,
|
||||
count_set(1, 2), expectation_limits(0.000026, 0.0002823),
|
||||
count_set(1, 2), expectation_limits(0.67257, 0.67499),
|
||||
@@ -583,12 +591,16 @@ void test_all()
|
||||
TEST_DIFFERENCE(mysql_23023665_3, 1, 225.0, 1, 66.0, 2);
|
||||
TEST_DIFFERENCE(mysql_23023665_5, 2, 165.23735, 2, 105.73735, 4);
|
||||
{
|
||||
// Without recaling it is invalid
|
||||
// Without rescaling it is invalid
|
||||
ut_settings settings;
|
||||
settings.set_test_validity(BG_IF_RESCALED(true, false));
|
||||
settings.set_test_validity(true);
|
||||
TEST_DIFFERENCE_WITH(mysql_23023665_6, 2, 105.68756, 3, 10.18756, 5, settings);
|
||||
}
|
||||
TEST_DIFFERENCE(mysql_23023665_13, 3, 99.74526, 3, 37.74526, 6);
|
||||
{
|
||||
ut_settings settings;
|
||||
settings.validity_false_negative_sym = true;
|
||||
TEST_DIFFERENCE_WITH(mysql_23023665_13, 3, 99.74526, 3, 37.74526, 6, settings);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -633,7 +645,7 @@ int test_main(int, char* [])
|
||||
// Not yet fully tested for float and long double.
|
||||
// The difference algorithm can generate (additional) slivers
|
||||
// Many of the failures are self-intersection points.
|
||||
BoostGeometryWriteExpectedFailures(19, 10, 17, 12);
|
||||
BoostGeometryWriteExpectedFailures(15, 5, 17, 10);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -240,8 +240,8 @@ int test_main(int, char* [])
|
||||
test_all<bg::model::d2::point_xy<double> >();
|
||||
|
||||
test_ticket_10835<int>
|
||||
("MULTILINESTRING((5239 2113,5233 2114),(4794 2205,1020 2986))",
|
||||
"MULTILINESTRING((5239 2113,5233 2114),(4794 2205,1460 2895))");
|
||||
("MULTILINESTRING((5239 2113,5232 2115),(4794 2205,1020 2986))",
|
||||
"MULTILINESTRING((5239 2113,5232 2115),(4794 2205,1460 2895))");
|
||||
|
||||
test_ticket_10835<double>
|
||||
("MULTILINESTRING((5239 2113,5232.52 2114.34),(4794.39 2205,1020 2986))",
|
||||
|
||||
@@ -155,10 +155,12 @@ void test_areal()
|
||||
#if ! defined(BOOST_GEOMETRY_USE_RESCALING) || defined(BOOST_GEOMETRY_TEST_FAILURES)
|
||||
{
|
||||
// 1: Very small sliver for B (discarded when rescaling)
|
||||
// 2: sym difference is not considered as valid
|
||||
// 2: sym difference is not considered as valid (without rescaling
|
||||
// this is a false negative)
|
||||
// 3: with rescaling A is considered as invalid (robustness problem)
|
||||
ut_settings settings;
|
||||
settings.sym_difference_validity = false;
|
||||
settings.validity_of_sym = BG_IF_RESCALED(false, true);
|
||||
settings.validity_false_negative_sym = true;
|
||||
TEST_DIFFERENCE_WITH(0, 1, bug_21155501,
|
||||
(count_set(1, 4)), expectation_limits(3.75893, 3.75894),
|
||||
(count_set(1, 4)), (expectation_limits(1.776357e-15, 7.661281e-15)),
|
||||
@@ -172,7 +174,7 @@ void test_areal()
|
||||
// Without rescaling, one ring is missing (for a and s)
|
||||
ut_settings settings;
|
||||
settings.set_test_validity(BG_IF_RESCALED(false, true));
|
||||
settings.sym_difference_validity = BG_IF_RESCALED(false, true);
|
||||
settings.validity_of_sym = BG_IF_RESCALED(false, true);
|
||||
TEST_DIFFERENCE_WITH(0, 1, ticket_9081,
|
||||
2, 0.0907392476356186,
|
||||
4, 0.126018011439877,
|
||||
@@ -211,9 +213,12 @@ void test_areal()
|
||||
TEST_DIFFERENCE(issue_888_34, 22, 0.2506824, 6, 0.0253798, 28); // a went wrong
|
||||
TEST_DIFFERENCE(issue_888_37, 15, 0.0451408, 65, 0.3014843, 80); // b went wrong
|
||||
|
||||
#if defined(BOOST_GEOMETRY_TEST_FAILURES)
|
||||
TEST_DIFFERENCE(issue_888_53, 117, 0.2973268, 17, 0.0525798, 134); // a goes wrong
|
||||
#endif
|
||||
{
|
||||
ut_settings settings;
|
||||
settings.validity_false_negative_a = true;
|
||||
settings.validity_false_negative_sym = true;
|
||||
TEST_DIFFERENCE_WITH(0, 1, issue_888_53, 117, 0.2973268, 17, 0.0525798, 134);
|
||||
}
|
||||
|
||||
// Areas and #clips correspond with POSTGIS (except sym case)
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_101_multi",
|
||||
@@ -472,24 +477,29 @@ void test_specific_areal()
|
||||
|
||||
{
|
||||
const std::string a_min_b =
|
||||
TEST_DIFFERENCE(ticket_10661, 2, 1441632.5, 2, 13167454, 4);
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("ticket_10661",
|
||||
ticket_10661[0], ticket_10661[1],
|
||||
2, -1, expectation_limits(1441632, 1441855),
|
||||
2, -1, expectation_limits(13167454, 13182415),
|
||||
count_set(3, 4));
|
||||
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("ticket_10661_2",
|
||||
a_min_b, ticket_10661[2],
|
||||
1, 8, 825192.0,
|
||||
1, 10, expectation_limits(27226370, 27842812),
|
||||
1, -1, 825192.0 + 27226370.5);
|
||||
1, 10, expectation_limits(27226148, 27842812),
|
||||
count_set(1, 2));
|
||||
}
|
||||
|
||||
{
|
||||
ut_settings settings;
|
||||
settings.sym_difference = false;
|
||||
|
||||
TEST_DIFFERENCE_WITH(0, 1, ticket_9942, 4, expectation_limits(7427727.5), 4,
|
||||
expectation_limits(130083, 131507), 4);
|
||||
TEST_DIFFERENCE_WITH(0, 1, ticket_9942, 4,
|
||||
expectation_limits(7427727, 7428108), 4,
|
||||
expectation_limits(130083, 131823), 4);
|
||||
TEST_DIFFERENCE_WITH(0, 1, ticket_9942a, 2,
|
||||
expectation_limits(412676, 413184), 2,
|
||||
expectation_limits(76779, 76925), 4);
|
||||
expectation_limits(412676, 413469), 2,
|
||||
expectation_limits(76779, 77038), 4);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -516,7 +526,7 @@ int test_main(int, char* [])
|
||||
#if defined(BOOST_GEOMETRY_TEST_FAILURES)
|
||||
// Not yet fully tested for float.
|
||||
// The difference algorithm can generate (additional) slivers
|
||||
BoostGeometryWriteExpectedFailures(28, 15, 19, 10);
|
||||
BoostGeometryWriteExpectedFailures(24, 11, 21, 7);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -20,6 +20,7 @@ void test_spikes_in_ticket_8364()
|
||||
{
|
||||
ut_settings ignore_validity;
|
||||
ignore_validity.set_test_validity(false);
|
||||
ignore_validity.validity_of_sym = false;
|
||||
|
||||
// See: https://svn.boost.org/trac/boost/ticket/8364
|
||||
//_TPolygon<T> polygon( "MULTIPOLYGON(((1031 1056,3232 1056,3232 2856,1031 2856)))" );
|
||||
@@ -30,44 +31,27 @@ void test_spikes_in_ticket_8364()
|
||||
//polygon -= _TPolygon<T>( "MULTIPOLYGON(((1032 2556,1032 2130,1778 2556)),((3234 2580,2136 2760,1778 2556,3234 2556)))" ); USED IN STEP 4
|
||||
// NOTE: polygons below are closed and clockwise
|
||||
|
||||
typedef typename bg::coordinate_type<P>::type ct;
|
||||
typedef bg::model::polygon<P, ClockWise, Closed> polygon;
|
||||
typedef bg::model::multi_polygon<polygon> multi_polygon;
|
||||
|
||||
// The difference of polygons below result in a spike. The spike should be there, it was also generated in ttmath,
|
||||
// and (e.g.) in SQL Server. However, using int-coordinates, the spike makes the polygon invalid. Therefore it is now (since August 2013) checked and removed.
|
||||
|
||||
#ifdef BOOST_GEOMETRY_TEST_FAILURES
|
||||
// TODO: commented working at ii/validity, this changes the area slightly, to be checked
|
||||
// So using int's, the spike is removed automatically. Therefore there is one polygon less, and less points. Also area differs
|
||||
test_one<polygon, multi_polygon, multi_polygon>("ticket_8364_step3",
|
||||
"MULTIPOLYGON(((3232 2532,2136 2790,1032 1764,1032 1458,1032 1212,2136 2328,3232 2220,3232 1056,1031 1056,1031 2856,3232 2856,3232 2532)))",
|
||||
"MULTIPOLYGON(((1032 2130,2052 2712,1032 1764,1032 2130)),((3234 2580,3234 2532,2558 2690,3234 2580)),((2558 2690,2136 2760,2052 2712,2136 2790,2558 2690)))",
|
||||
2,
|
||||
if_typed<ct, int>(19, 22),
|
||||
if_typed<ct, int>(2775595.5, 2775256.487954), // SQL Server: 2775256.47588724
|
||||
3,
|
||||
-1, // don't check point-count
|
||||
if_typed<ct, int>(7893.0, 7810.487954), // SQL Server: 7810.48711165739
|
||||
if_typed<ct, int>(1, 5),
|
||||
-1,
|
||||
if_typed<ct, int>(2783349.5, 2775256.487954 + 7810.487954),
|
||||
ignore_validity);
|
||||
#endif
|
||||
count_set(2, 3), -1, expectation_limits(2775256, 2775610), // SQL Server: 2775256.47588724
|
||||
3, -1, expectation_limits(7810, 7893), // SQL Server: 7810.48711165739
|
||||
count_set(2, 6), ignore_validity);
|
||||
|
||||
// TODO: behaviour is not good yet. It is changed at introduction of self-turns.
|
||||
test_one<polygon, multi_polygon, multi_polygon>("ticket_8364_step4",
|
||||
"MULTIPOLYGON(((2567 2688,2136 2790,2052 2712,1032 2130,1032 1764,1032 1458,1032 1212,2136 2328,3232 2220,3232 1056,1031 1056,1031 2856,3232 2856,3232 2580,2567 2688)))",
|
||||
"MULTIPOLYGON(((1032 2556,1778 2556,1032 2130,1032 2556)),((3234 2580,3234 2556,1778 2556,2136 2760,3234 2580)))",
|
||||
if_typed<ct, int>(1, 2),
|
||||
if_typed<ct, int>(17, 20),
|
||||
if_typed<ct, int>(2615783.5, 2616029.559567), // SQL Server: 2616029.55616044
|
||||
1,
|
||||
if_typed<ct, int>(9, 11),
|
||||
if_typed<ct, int>(161133.5, 161054.559567), // SQL Server: 161054.560110092
|
||||
if_typed<ct, int>(1, 3),
|
||||
if_typed<ct, int>(25, 31),
|
||||
if_typed<ct, int>(2776875.5, 2616029.559567 + 161054.559567));
|
||||
count_set(1, 2), -1, expectation_limits(2615783, 2616030), // SQL Server: 2616029.55616044
|
||||
1, -1, expectation_limits(161054, 161134), // SQL Server: 161054.560110092
|
||||
count_set(1, 3));
|
||||
}
|
||||
|
||||
template <typename P, bool ClockWise, bool Closed>
|
||||
@@ -76,7 +60,6 @@ void test_spikes_in_ticket_8365()
|
||||
// See: https://svn.boost.org/trac/boost/ticket/8365
|
||||
// NOTE: polygons below are closed and clockwise
|
||||
|
||||
typedef typename bg::coordinate_type<P>::type ct;
|
||||
typedef bg::model::polygon<P, ClockWise, Closed> polygon;
|
||||
typedef bg::model::multi_polygon<polygon> multi_polygon;
|
||||
|
||||
@@ -85,13 +68,11 @@ void test_spikes_in_ticket_8365()
|
||||
"MULTIPOLYGON(((5388 1560,4650 1722,3912 1884,4650 1398)),((2442 3186,1704 3348,966 2700,1704 3024)))",
|
||||
2,
|
||||
18,
|
||||
if_typed<ct, int>(7975092.5, 7975207.6047877), // SQL Server:
|
||||
expectation_limits(7975092.5, 7975207.6047877),
|
||||
2,
|
||||
-1,
|
||||
if_typed<ct, int>(196.5, 197.1047877), // SQL Server:
|
||||
if_typed<ct, int>(3, 4),
|
||||
-1,
|
||||
if_typed<ct, int>(7975092.5 + 196.5, 7975207.6047877 + 197.1047877));
|
||||
expectation_limits(196.5, 198.5),
|
||||
count_set(2, 4));
|
||||
}
|
||||
|
||||
|
||||
@@ -109,6 +90,7 @@ int test_main(int, char* [])
|
||||
test_spikes_in_ticket_8364<bg::model::d2::point_xy<int>, false, false>();
|
||||
test_spikes_in_ticket_8365<bg::model::d2::point_xy<int>, true, true >();
|
||||
test_spikes_in_ticket_8365<bg::model::d2::point_xy<int>, false, false >();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,20 +59,45 @@
|
||||
# include <boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp>
|
||||
#endif
|
||||
|
||||
enum difference_type
|
||||
{
|
||||
difference_a, difference_b, difference_sym
|
||||
};
|
||||
|
||||
struct ut_settings : ut_base_settings
|
||||
{
|
||||
double percentage;
|
||||
bool sym_difference;
|
||||
bool sym_difference_validity = true;
|
||||
bool validity_of_sym = true;
|
||||
bool remove_spikes = false;
|
||||
|
||||
// The validity check gives sometimes false negatives.
|
||||
// boost::geometry::is_valid can return FALSE while it is valid.
|
||||
// (especially at touch in combination with a u/u turn)
|
||||
// For now, the cases where this is the case are skipped for validity check.
|
||||
bool validity_false_negative_a = false;
|
||||
bool validity_false_negative_b = false;
|
||||
bool validity_false_negative_sym = false;
|
||||
|
||||
explicit ut_settings(double p = 0.0001, bool validity = true, bool sd = true)
|
||||
: ut_base_settings(validity)
|
||||
, percentage(p)
|
||||
, sym_difference(sd)
|
||||
{}
|
||||
|
||||
bool test_validity_of_diff(difference_type dtype) const
|
||||
{
|
||||
bool const sym = dtype == difference_sym;
|
||||
bool const a = dtype == difference_a;
|
||||
bool const b = dtype == difference_b;
|
||||
|
||||
return sym && validity_false_negative_sym ? false
|
||||
: a && validity_false_negative_a ? false
|
||||
: b && validity_false_negative_b ? false
|
||||
: sym ? (validity_of_sym || BG_IF_TEST_FAILURES)
|
||||
: test_validity();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
inline ut_settings tolerance(double percentage)
|
||||
@@ -137,7 +162,7 @@ std::string test_difference(std::string const& caseid, G1 const& g1, G2 const& g
|
||||
const count_set& expected_count,
|
||||
int expected_rings_count, int expected_point_count,
|
||||
expectation_limits const& expected_area,
|
||||
bool sym,
|
||||
difference_type dtype,
|
||||
ut_settings const& settings)
|
||||
{
|
||||
typedef typename bg::coordinate_type<G1>::type coordinate_type;
|
||||
@@ -145,8 +170,7 @@ std::string test_difference(std::string const& caseid, G1 const& g1, G2 const& g
|
||||
|
||||
bg::model::multi_polygon<OutputType> result;
|
||||
|
||||
|
||||
if (sym)
|
||||
if (dtype == difference_sym)
|
||||
{
|
||||
bg::sym_difference(g1, g2, result);
|
||||
}
|
||||
@@ -167,7 +191,7 @@ std::string test_difference(std::string const& caseid, G1 const& g1, G2 const& g
|
||||
<
|
||||
G1, G2
|
||||
>::type strategy_type;
|
||||
if (sym)
|
||||
if (dtype == difference_sym)
|
||||
{
|
||||
bg::sym_difference(g1, g2, result_s, strategy_type());
|
||||
}
|
||||
@@ -191,12 +215,7 @@ std::string test_difference(std::string const& caseid, G1 const& g1, G2 const& g
|
||||
typename bg::default_area_result<G1>::type const area = bg::area(result);
|
||||
|
||||
#if ! defined(BOOST_GEOMETRY_NO_BOOST_TEST)
|
||||
bool const test_validity
|
||||
= sym
|
||||
? (settings.sym_difference_validity || BG_IF_TEST_FAILURES)
|
||||
: settings.test_validity();
|
||||
|
||||
if (test_validity)
|
||||
if (settings.test_validity_of_diff(dtype))
|
||||
{
|
||||
// std::cout << bg::dsv(result) << std::endl;
|
||||
typedef bg::model::multi_polygon<OutputType> result_type;
|
||||
@@ -218,7 +237,7 @@ std::string test_difference(std::string const& caseid, G1 const& g1, G2 const& g
|
||||
typename setop_output_type<OutputType>::type
|
||||
inserted, array_with_one_empty_geometry;
|
||||
array_with_one_empty_geometry.push_back(OutputType());
|
||||
if (sym)
|
||||
if (dtype == difference_sym)
|
||||
{
|
||||
boost::copy(array_with_one_empty_geometry,
|
||||
bg::detail::sym_difference::sym_difference_insert<OutputType>
|
||||
@@ -287,12 +306,12 @@ template <typename OutputType, typename G1, typename G2>
|
||||
std::string test_difference(std::string const& caseid, G1 const& g1, G2 const& g2,
|
||||
const count_set& expected_count, int expected_point_count,
|
||||
expectation_limits const& expected_area,
|
||||
bool sym,
|
||||
difference_type dtype,
|
||||
ut_settings const& settings)
|
||||
{
|
||||
return test_difference<OutputType>(caseid, g1, g2,
|
||||
expected_count, -1, expected_point_count, expected_area,
|
||||
sym, settings);
|
||||
dtype, settings);
|
||||
}
|
||||
|
||||
#ifdef BOOST_GEOMETRY_CHECK_WITH_POSTGIS
|
||||
@@ -331,7 +350,7 @@ std::string test_one(std::string const& caseid,
|
||||
#if ! defined(BOOST_GEOMETRY_TEST_DIFFERENCE_ONLY_B)
|
||||
result = test_difference<OutputType>(caseid + "_a", g1, g2,
|
||||
expected_count1, expected_rings_count1, expected_point_count1,
|
||||
expected_area1, false, settings);
|
||||
expected_area1, difference_a, settings);
|
||||
#endif
|
||||
#if defined(BOOST_GEOMETRY_TEST_DIFFERENCE_ONLY_A)
|
||||
return result;
|
||||
@@ -339,7 +358,7 @@ std::string test_one(std::string const& caseid,
|
||||
|
||||
test_difference<OutputType>(caseid + "_b", g2, g1,
|
||||
expected_count2, expected_rings_count2, expected_point_count2,
|
||||
expected_area2, false, settings);
|
||||
expected_area2, difference_b, settings);
|
||||
|
||||
#if defined(BOOST_GEOMETRY_TEST_DIFFERENCE_ONLY_B)
|
||||
return result;
|
||||
@@ -354,7 +373,7 @@ std::string test_one(std::string const& caseid,
|
||||
expected_rings_count_s,
|
||||
expected_point_count_s,
|
||||
expected_area_s,
|
||||
true, settings);
|
||||
difference_sym, settings);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -383,6 +402,7 @@ std::string test_one(std::string const& caseid,
|
||||
settings);
|
||||
}
|
||||
|
||||
// Version with expectations of symmetric: all specified
|
||||
template <typename OutputType, typename G1, typename G2>
|
||||
std::string test_one(std::string const& caseid,
|
||||
std::string const& wkt1, std::string const& wkt2,
|
||||
@@ -404,6 +424,30 @@ std::string test_one(std::string const& caseid,
|
||||
settings);
|
||||
}
|
||||
|
||||
// Version with expectations of symmetric: specify only count
|
||||
template <typename OutputType, typename G1, typename G2>
|
||||
std::string test_one(std::string const& caseid,
|
||||
std::string const& wkt1, std::string const& wkt2,
|
||||
const count_set& expected_count1,
|
||||
int expected_point_count1,
|
||||
expectation_limits const& expected_area1,
|
||||
const count_set& expected_count2,
|
||||
int expected_point_count2,
|
||||
expectation_limits const& expected_area2,
|
||||
const count_set& expected_count_s,
|
||||
ut_settings const& settings = ut_settings())
|
||||
{
|
||||
return test_one<OutputType, G1, G2>(caseid, wkt1, wkt2,
|
||||
expected_count1, -1, expected_point_count1, expected_area1,
|
||||
expected_count2, -1, expected_point_count2, expected_area2,
|
||||
expected_count_s, -1,
|
||||
expected_point_count1 >= 0 && expected_point_count2 >= 0
|
||||
? (expected_point_count1 + expected_point_count2) : -1,
|
||||
expected_area1 + expected_area2,
|
||||
settings);
|
||||
}
|
||||
|
||||
// Version with expectations of symmetric: all automatically
|
||||
template <typename OutputType, typename G1, typename G2>
|
||||
std::string test_one(std::string const& caseid,
|
||||
std::string const& wkt1, std::string const& wkt2,
|
||||
|
||||
@@ -75,7 +75,7 @@ struct test_sym_difference_of_areal_geometries
|
||||
PolygonOut
|
||||
>(case_id, areal1, areal2,
|
||||
expected_polygon_count, expected_point_count, expected_area,
|
||||
true, settings);
|
||||
difference_sym, settings);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -348,7 +348,7 @@ inline void test_aa()
|
||||
"MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0),(0 0, 4 1, 4 4, 1 4, 0 0)),"
|
||||
"((2 6, 2 8, 8 8, 8 5, 7 5, 7 6, 2 6)))",
|
||||
"MULTIPOLYGON(((0 0, 1 4, 5 4, 5 1, 4 1, 0 0),(0 0, 2 1, 2 2, 1 2, 0 0)),"
|
||||
"((5 0, 5 1, 6 1, 6 4, 5 4, 3 6, 2 5, 2 7, 7 7, 7 0 5 0)))",
|
||||
"((5 0, 5 1, 6 1, 6 4, 5 4, 3 6, 2 5, 2 7, 7 7, 7 0, 5 0)))",
|
||||
"MULTIPOINT()",
|
||||
"MULTILINESTRING()",
|
||||
"MULTIPOLYGON(((0 0,0 5,4 5,3 6,7 6,7 7,2 7,2 8,8 8,8 5,7 5,7 0,0 0),"
|
||||
|
||||
Reference in New Issue
Block a user