Merge branch 'develop' into feature/buffer_point_geographic

This commit is contained in:
Barend Gehrels
2019-02-09 17:03:40 +01:00
191 changed files with 1957 additions and 619 deletions

View File

@@ -58,7 +58,8 @@ ps_distance(std::string const& wkt1,
template <typename Strategy_pp, typename Strategy_ps>
void test_distance_point_segment(Strategy_pp const& strategy_pp,
Strategy_ps const& strategy_ps)
Strategy_ps const& strategy_ps,
bool WGS84)
{
#ifdef BOOST_GEOMETRY_TEST_DEBUG
@@ -97,16 +98,19 @@ void test_distance_point_segment(Strategy_pp const& strategy_pp,
"SEGMENT(2 0,3 0)",
pp_distance("POINT(3 0)", "POINT(3.5 3)", strategy_pp),
strategy_ps, true, true);
tester::apply("p-s-07",
"POINT(15 80)",
"SEGMENT(10 15,30 15)",
7204174.8264546748,
strategy_ps, true, true);
tester::apply("p-s-08",
"POINT(15 10)",
"SEGMENT(10 15,30 15)",
571412.71247283253,
strategy_ps, true, true);
if(WGS84)
{
tester::apply("p-s-07",
"POINT(15 80)",
"SEGMENT(10 15,30 15)",
7204174.8264546748,
strategy_ps, true, true);
tester::apply("p-s-08",
"POINT(15 10)",
"SEGMENT(10 15,30 15)",
571412.71247283253,
strategy_ps, true, true);
}
tester::apply("p-s-09",
"POINT(5 10)",
"SEGMENT(10 15,30 15)",
@@ -624,9 +628,10 @@ void test_distance_multipoint_segment(Strategy_pp const& strategy_pp,
//===========================================================================
template <typename Strategy_pp, typename Strategy_ps>
void test_all_pl_l(Strategy_pp pp_strategy, Strategy_ps ps_strategy)
void test_all_pl_l(Strategy_pp pp_strategy, Strategy_ps ps_strategy,
bool WGS84 = true)
{
test_distance_point_segment(pp_strategy, ps_strategy);
test_distance_point_segment(pp_strategy, ps_strategy, WGS84);
test_distance_point_linestring(pp_strategy, ps_strategy);
test_distance_point_multilinestring(pp_strategy, ps_strategy);
test_distance_linestring_multipoint(pp_strategy, ps_strategy);
@@ -642,6 +647,10 @@ BOOST_AUTO_TEST_CASE( test_all_pointlike_linear )
test_all_pl_l(thomas_pp(), thomas_ps());
test_all_pl_l(andoyer_pp(), andoyer_ps());
// test with different spheroid
stype spheroid(6372000, 6370000);
test_all_pl_l(andoyer_pp(spheroid), andoyer_ps(spheroid), false);
test_distance_point_segment_no_thomas(vincenty_pp(), vincenty_ps());
//test_distance_point_segment_no_thomas(thomas_pp(), thomas_ps());
test_distance_point_segment_no_thomas(andoyer_pp(), andoyer_ps());

View File

@@ -935,4 +935,9 @@ BOOST_AUTO_TEST_CASE( test_all_areal_areal )
test_all_ar_ar<geo_point>(vincenty_pp(), vincenty_ps(), vincenty_bb(), vincenty_sb());
test_all_ar_ar<geo_point>(thomas_pp(), thomas_ps(), thomas_bb(), thomas_sb());
test_all_ar_ar<geo_point>(andoyer_pp(), andoyer_ps(), andoyer_bb(), andoyer_sb());
// test with different spheroid
stype spheroid(6372000, 6370000);
test_all_ar_ar<geo_point>(andoyer_pp(spheroid), andoyer_ps(spheroid),
andoyer_bb(spheroid), andoyer_sb(spheroid));
}

View File

@@ -63,11 +63,9 @@ void test_distance_point_ring(Strategy_pp const& strategy_pp,
template
<
typename Point,
typename Strategy_pp,
typename Strategy_ps
>
void test_distance_multipoint_ring(Strategy_pp const& strategy_pp,
Strategy_ps const& strategy_ps)
void test_distance_multipoint_ring(Strategy_ps const& strategy_ps)
{
#ifdef BOOST_GEOMETRY_TEST_DEBUG
@@ -649,7 +647,7 @@ void test_all_pl_ar(Strategy_pp pp_strategy,
Strategy_pb pb_strategy)
{
test_distance_point_ring<Point>(pp_strategy, ps_strategy);
test_distance_multipoint_ring<Point>(pp_strategy, ps_strategy);
test_distance_multipoint_ring<Point>(ps_strategy);
test_distance_point_polygon<Point>(pp_strategy, ps_strategy);
test_distance_multipoint_polygon<Point>(pp_strategy, ps_strategy);
@@ -682,4 +680,8 @@ BOOST_AUTO_TEST_CASE( test_all_pointlike_areal )
test_all_pl_ar<geo_point>(vincenty_pp(), vincenty_ps(), vincenty_pb());
test_all_pl_ar<geo_point>(thomas_pp(), thomas_ps(), thomas_pb());
test_all_pl_ar<geo_point>(andoyer_pp(), andoyer_ps(), andoyer_pb());
// test with different spheroid
stype spheroid(6372000, 6370000);
test_all_pl_ar<geo_point>(andoyer_pp(spheroid), andoyer_ps(spheroid), andoyer_pb(spheroid));
}

View File

@@ -117,4 +117,6 @@ BOOST_AUTO_TEST_CASE( test_all_pointlike_pointlike )
test_all_pl_pl<geo_point>(vincenty_pp());
test_all_pl_pl<geo_point>(thomas_pp());
test_all_pl_pl<geo_point>(andoyer_pp());
test_all_pl_pl<geo_point>(andoyer_pp(stype(5000000,6000000)));
}

View File

@@ -1323,6 +1323,18 @@ static std::string pie_7_2_1_0_15[2] =
"MULTIPOLYGON(((2500 2500,2791 3586,3062 3474,2500 2500)),((2500 2500,3474 3062,3586 2791,3625 2500,3586 2208,3474 1937,3295 1704,3062 1525,2791 1413,2499 1375,2208 1413,1937 1525,1704 1704,1525 1937,1413 2208,1375 2500,2500 2500)))"
};
static std::string case_precision_m1[2] =
{
"MULTIPOLYGON(((0 0,0 4,2 4,2 3,4 3,4 0,0 0)))",
"MULTIPOLYGON(((-1 -1,-1 8,2 8,2 7,2 3,4.0000005 2.9999995,4 7,4 8,8 8,8 -1,-1 -1)))"
};
static std::string case_precision_m2[2] =
{
"MULTIPOLYGON(((0 0,0 4,2 4,2 3,4 3,4 0,0 0)),((3 6,3 7.5,4.5 7.5,4.5 6,3 6)))",
"MULTIPOLYGON(((-1 -1,-1 8,8 8,8 -1,-1 -1),(2 7,2 3,4.0000005 2.9999995,4 7,2 7)))"
};
// Case, not literally on this list but derived, to mix polygon/multipolygon in call to difference
static std::string ggl_list_20111025_vd[4] =
{
@@ -1361,6 +1373,16 @@ static std::string ggl_list_20140212_sybren[2] =
"MULTIPOLYGON(((0.4951091661995328 0.6614133543986973,0.495396 0.625263,0.50092 0.6492750000000001,0.494964 0.679709,0.477258 0.698703,0.4951091661995328 0.6614133543986973)),((0.452167 0.706562,0.433379 0.696888,0.442673 0.65792,0.464729 0.671387,0.452167 0.706562)))"
};
static std::string mail_2019_01_21_johan[4] =
{
// Contains a, b, both a and b (should have been merged), c (clip)
"MULTIPOLYGON(((1.2036811113357544 0.7535473108291626,1.1699721813201904 0.7535473108291626,1.1699721813201904 0.7663263082504272,1.2033243179321289 0.7672826647758484,1.2036811113357544 0.7535473108291626)))",
"MULTIPOLYGON(((1.2036811113357544 0.7535473108291626,1.2038091421127319 0.7486215233802795,1.1713759899139404 0.7495520114898682,1.1713759899139404 0.7535472512245178,1.2036811113357544 0.7535473108291626)))",
"MULTIPOLYGON(((1.2036811113357544 0.7535473108291626,1.1699721813201904 0.7535473108291626,1.1699721813201904 0.7663263082504272,1.2033243179321289 0.7672826647758484,1.2036811113357544 0.7535473108291626)),"
"((1.2036811113357544 0.7535473108291626,1.2038091421127319 0.7486215233802795,1.1713759899139404 0.7495520114898682,1.1713759899139404 0.7535472512245178,1.2036811113357544 0.7535473108291626)))",
"MULTIPOLYGON(((0 0,2 0,2 2,0 2,0 0)))"
};
static std::string ticket_9081[2] =
{
"MULTIPOLYGON(((0.5489109414010371 0.5774835110050927,0.4099611282054447 0.4644351568071598,0.4294011278595494 0.4843224236729239,0.4205359995313906 0.5115225580860201,0.4441572412013468 0.5184999851878852,0.5489109414010371 0.5774835110050927)),((0.562085028126843 0.5882018328808966,0.5644349663154944 0.591180348361206,0.568218114394707 0.5970364466647042,0.5838690879677763 0.6212632646137447,0.5873787029417971 0.6412877041753083,0.468699602592386 0.5866280231830688,0.4171010902425981 0.5220616039851281,0.4059124592966251 0.5563907478354578,0.3909547828925878 0.6022841397455458,0.520859401226844 0.9508041627246925,0.8595233008819849 0.8301950132755517,0.562085028126843 0.5882018328808966)))",

View File

@@ -700,6 +700,88 @@ static std::string dz_4[2] = {
"POLYGON((20.486696243286133 60.650150299072266,24.282432556152344 49.304500579833984,34.362251281738281 55.748767852783203,30.764263153076172 44.3388671875,42.706855773925781 43.627620697021484,33.089447021484375 36.511661529541016,42.333145141601563 28.916570663452148,30.369846343994141 28.81260871887207,33.383872985839844 17.234743118286133,23.644252777099609 24.182485580444336,19.277351379394531 13.044195175170898,15.48161506652832 24.389842987060547,5.40179443359375 17.945577621459961,8.9997835159301758 29.355476379394531,-2.9428071975708008 30.06672477722168,6.6745977401733398 37.182682037353516,-2.5690991878509521 44.777774810791016,9.394200325012207 44.881736755371094,6.3801741600036621 56.459602355957031,16.119794845581055 49.511859893798828,20.486696243286133 60.650150299072266))"
};
static std::string case_precision_1[2] =
{
"POLYGON((0 0,0 4,2 4,2 3,4 3,4 0,0 0))",
"POLYGON((2 7,4 7,4.000005 2.99999,2 3,2 7))"
};
static std::string case_precision_2[2] =
{
"POLYGON((0 0,0 4,2 4,2 3,4 3,4 0,0 0))",
"POLYGON((2 7,4 7,4 2.999995,2 3,2 7))"
};
static std::string case_precision_3[2] =
{
"POLYGON((0 0,0 4,2 4,2 3,4 3,4 0,0 0))",
"POLYGON((2 7,4 7,4.0000001 2.99999995,2 3,2 7))"
};
static std::string case_precision_4[2] =
{
"POLYGON((0 0,0 4,2 4,2 3,4 3,4 0,0 0))",
"POLYGON((2 7,4 7,4 3.00000001,2 3,2 7))"
};
static std::string case_precision_5[2] =
{
"POLYGON((0 0,0 4,2 4,2 3,4 3,4 0,0 0))",
"POLYGON((2 7,4 7,4 3,2.0000005 2.9999995,2 7))"
};
static std::string case_precision_6[2] =
{
"POLYGON((0 0,0 4,2 4,2 3,4 3,4 0,0 0))",
"POLYGON((-1 -1,-1 8,2 8,2 7,2 3,4.0000005 2.9999995,4 7,4 8,8 8,8 -1,-1 -1))"
};
static std::string case_precision_7[2] =
{
// Needs larger margin for sectionalize (long double only)
"POLYGON((0 0,0 4,2 4,2 3,4 3,4 0,0 0))",
"POLYGON((2 7,4 7,4 3.00000002,2 3,2 7))"
};
static std::string case_precision_8[2] =
{
"POLYGON((0 0,0 4,2 4,2 3,4 3,4 0,0 0))",
"POLYGON((-1 -1,-1 8,8 8,8 -1,-1 -1),(2 7,2 3,4.00000006 3.00000009,4 7,2 7))"
};
static std::string case_precision_9[2] =
{
"POLYGON((0 0,0 4,2 4,2 3,4 3,4 0,0 0))",
"POLYGON((-1 -1,-1 8,8 8,8 -1,-1 -1),(2 7,2 3,3.99999 2.999995,4 7,2 7))"
};
static std::string case_precision_10[2] =
{
// Needs 1.0e-5 for threshold in double
"POLYGON((0 0,0 4,2 4,2 3,4 3,4 0,0 0))",
"POLYGON((-1 -1,-1 8,8 8,8 -1,-1 -1),(2 7,2 3,4.000006 2.999991,4 7,2 7))"
};
static std::string case_precision_11[2] =
{
// Needs ~0.5 for threshold in side_by_generic_form
"POLYGON((0 0,0 4,2 4,2 3,4 3,4 0,0 0))",
"POLYGON((-1 -1,-1 8,8 8,8 -1,-1 -1),(2 7,2 3,4.00000000000000089 2.99999999999999201,4 7,2 7))"
};
static std::string case_precision_12[2] =
{
// Needs threshold for threshold a2
"POLYGON((0 0,0 4,2 4,2 3,4 3,4 0,0 0))",
"POLYGON((1 1,2.99999999999999731e-12 1.00000000001,2.99999999999999731e-12 3.00000000001,1 3,1 1))"
};
static std::string case_precision_13[2] =
{
// Needs threshold for threshold a2
"POLYGON((0 0,0 4,2 4,2 3,4 3,4 0,0 0))",
"POLYGON((1 1,9.99999999999999912e-06 1,9.99999999999999912e-06 3,1 3,1 1))"
};
// ticket_17 is keyholed, so has a hole formed by an deliberate intersection
// This will fail the intersection/traversal process

View File

@@ -63,6 +63,11 @@ void test_all()
sym_settings.sym_difference = false;
#endif
ut_settings ignore_validity_settings;
#ifndef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS
ignore_validity_settings.test_validity = false;
#endif
test_one<polygon, polygon, polygon>("simplex_normal",
simplex_normal[0], simplex_normal[1],
3, 12, 2.52636706856656,
@@ -156,12 +161,14 @@ void test_all()
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,
3, 17, 6.75);
3, 17, 6.75,
ignore_validity_settings);
test_one<polygon, polygon, polygon>("intersect_holes_intersect_and_touch",
intersect_holes_intersect_and_touch[0], intersect_holes_intersect_and_touch[1],
3, 21, 16.25,
3, 17, 6.25);
3, 17, 6.25,
ignore_validity_settings);
{
ut_settings settings = sym_settings;
@@ -186,7 +193,8 @@ void test_all()
test_one<polygon, polygon, polygon>("intersect_holes_intersect",
intersect_holes_intersect[0], intersect_holes_intersect[1],
2, 16, 15.75,
2, 12, 5.75);
2, 12, 5.75,
ignore_validity_settings);
test_one<polygon, polygon, polygon>(
"case4", case_4[0], case_4[1],
@@ -296,15 +304,17 @@ void test_all()
// Isovist - the # output polygons differ per compiler/pointtype, (very) small
// rings might be discarded. We check area only
// SQL Server gives: 0.279121891701124 and 224.889211358929
// PostGIS gives: 0.279121991127244 and 224.889205853156
// No robustness gives: 0.279121991127106 and 224.825363749290
test_one<polygon, polygon, polygon>("isovist",
isovist1[0], isovist1[1],
-1, -1, 0.279132,
-1, -1, 224.8892,
settings);
}
// SQL Server gives: 0.279121891701124 and 224.889211358929
// PostGIS gives: 0.279121991127244 and 224.889205853156
// No robustness gives: 0.279121991127106 and 224.825363749290
#ifdef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS
test_one<polygon, polygon, polygon>("geos_1",

View File

@@ -175,12 +175,19 @@ void test_areal()
TEST_DIFFERENCE_WITH(0, 1, bug_21155501, 1, 3.758937, 1, 1.7763568394002505e-15, 2);
}
#else
// With no-robustness this one misses one of the outputs
test_one<Polygon, MultiPolygon, MultiPolygon>("ticket_9081",
ticket_9081[0], ticket_9081[1],
{
// With no-robustness this one misses one of the outputs
ut_settings settings;
settings.percentage = 0.001; // tolerance
#if !defined(BOOST_GEOMETRY_NO_ROBUSTNESS) && !defined(BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS)
settings.test_validity = false;
#endif
test_one<Polygon, MultiPolygon, MultiPolygon>("ticket_9081",
ticket_9081[0], ticket_9081[1],
2, 28, 0.0907392476356186, 4, 25, 0.126018011439877,
4, 42, 0.0907392476356186 + 0.126018011439877,
tolerance(0.001));
settings);
}
// With rescaling, A is invalid (this is a robustness problem) and the other
// output is discarded because of zero (rescaled) area
@@ -456,6 +463,11 @@ void test_areal()
TEST_DIFFERENCE(case_recursive_boxes_87, 4, 2.0, 4, 2.5, 8);
TEST_DIFFERENCE(case_recursive_boxes_88, 3, 4.75, 5, 6.75, 4);
// Output of A can be 0 or 1 polygons (with a very small area)
TEST_DIFFERENCE(case_precision_m1, -1, 0.0, 1, 57.0, -1);
// Output of A can be 1 or 2 polygons (one with a very small area)
TEST_DIFFERENCE(case_precision_m2, -1, 1.0, 1, 57.75, -1);
{
ut_settings sym_settings;
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)

View File

@@ -273,7 +273,15 @@ std::string test_difference(std::string const& caseid, G1 const& g1, G2 const& g
);
}
BOOST_CHECK_CLOSE(area, expected_area, settings.percentage);
if (expected_area > 0)
{
BOOST_CHECK_CLOSE(area, expected_area, settings.percentage);
}
else
{
// Compare 0 with 0 or a very small detected area
BOOST_CHECK_LE(area, settings.percentage);
}
#endif

View File

@@ -46,6 +46,16 @@ BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::vector)
(test_one<Polygon, Polygon, Polygon>) \
( #caseid, caseid[0], caseid[1], clips, points, area)
#define TEST_INTERSECTION_REV(caseid, clips, points, area) \
(test_one<Polygon, Polygon, Polygon>) \
( #caseid "_rev", caseid[1], caseid[0], clips, points, area)
#define TEST_INTERSECTION_WITH(caseid, index1, index2, \
clips, points, area, settings) \
(test_one<Polygon, Polygon, Polygon>) \
( #caseid #index1 "_" #index2, caseid[index1], caseid[index2], \
clips, points, area, settings)
#if defined(BOOST_GEOMETRY_NO_SELF_TURNS)
#define TEST_INTERSECTION_IGNORE(caseid, clips, points, area) \
{ ut_settings ignore_validity; ignore_validity.test_validity = false; \
@@ -197,8 +207,7 @@ void test_areal()
// In most cases: 0 (no intersection)
// In some cases: 1.430511474609375e-05 (clang/gcc on Xubuntu using b2)
// In some cases: 5.6022983000000002e-05 (powerpc64le-gcc-6-0)
test_one<Polygon, Polygon, Polygon>("geos_2",
geos_2[0], geos_2[1],
test_one<Polygon, Polygon, Polygon>("geos_2", geos_2[0], geos_2[1],
0, 0, 6.0e-5, ut_settings(-1.0)); // -1 denotes: compare with <=
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
@@ -276,12 +285,12 @@ void test_areal()
test_one<Polygon, Polygon, Polygon>("ticket_8652", ticket_8652[0], ticket_8652[1],
1, 4, 0.0003);
test_one<Polygon, Polygon, Polygon>("ticket_8310a", ticket_8310a[0], ticket_8310a[1],
1, 5, 0.3843747);
test_one<Polygon, Polygon, Polygon>("ticket_8310b", ticket_8310b[0], ticket_8310b[1],
1, 5, 0.3734379);
test_one<Polygon, Polygon, Polygon>("ticket_8310c", ticket_8310c[0], ticket_8310c[1],
1, 5, 0.4689541);
TEST_INTERSECTION(ticket_8310a, 1, 5, 0.3843747);
TEST_INTERSECTION(ticket_8310b, 1, 5, 0.3734379);
TEST_INTERSECTION(ticket_8310c, 1, 5, 0.4689541);
TEST_INTERSECTION_REV(ticket_8310a, 1, 5, 0.3843747);
TEST_INTERSECTION_REV(ticket_8310b, 1, 5, 0.3734379);
TEST_INTERSECTION_REV(ticket_8310c, 1, 5, 0.4689541);
test_one<Polygon, Polygon, Polygon>("ticket_9081_15",
ticket_9081_15[0], ticket_9081_15[1],
@@ -296,7 +305,7 @@ void test_areal()
// mingw 5.6022954e-5
test_one<Polygon, Polygon, Polygon>("ticket_10108_b",
ticket_10108_b[0], ticket_10108_b[1],
0, 0, 5.6022983e-5);
0, 0, 5.6022983e-5, ut_settings(-1.0));
#endif
test_one<Polygon, Polygon, Polygon>("ticket_10747_a",
@@ -355,6 +364,37 @@ void test_areal()
TEST_INTERSECTION(case_105, 1, 34, 76.0);
TEST_INTERSECTION(case_precision_1, 0, 0, 0.0);
TEST_INTERSECTION(case_precision_2, 0, 0, 0.0);
TEST_INTERSECTION(case_precision_3, 0, 0, 0.0);
TEST_INTERSECTION(case_precision_4, 0, 0, 0.0);
TEST_INTERSECTION(case_precision_5, 0, 0, 0.0);
TEST_INTERSECTION(case_precision_6, 1, -1, 14.0);
TEST_INTERSECTION(case_precision_7, 0, -1, 0.0);
TEST_INTERSECTION(case_precision_8, 1, -1, 14.0);
TEST_INTERSECTION(case_precision_9, 1, -1, 14.0);
TEST_INTERSECTION(case_precision_10, 1, -1, 14.0);
TEST_INTERSECTION(case_precision_11, 1, -1, 14.0);
TEST_INTERSECTION_REV(case_precision_1, 0, 0, 0.0);
TEST_INTERSECTION_REV(case_precision_2, 0, 0, 0.0);
TEST_INTERSECTION_REV(case_precision_3, 0, 0, 0.0);
TEST_INTERSECTION_REV(case_precision_4, 0, 0, 0.0);
TEST_INTERSECTION_REV(case_precision_5, 0, 0, 0.0);
TEST_INTERSECTION_REV(case_precision_6, 1, -1, 14.0);
TEST_INTERSECTION_REV(case_precision_7, 0, -1, 0.0);
TEST_INTERSECTION_REV(case_precision_8, 1, -1, 14.0);
TEST_INTERSECTION_REV(case_precision_9, 1, -1, 14.0);
TEST_INTERSECTION_REV(case_precision_10, 1, -1, 14.0);
TEST_INTERSECTION_REV(case_precision_11, 1, -1, 14.0);
{
ut_settings settings(0.01);
TEST_INTERSECTION_WITH(case_precision_12, 0, 1, 1, -1, 2.0, settings);
TEST_INTERSECTION_WITH(case_precision_13, 0, 1, 1, -1, 2.0, settings);
TEST_INTERSECTION_WITH(case_precision_12, 1, 0, 1, -1, 2.0, settings);
TEST_INTERSECTION_WITH(case_precision_13, 1, 0, 1, -1, 2.0, settings);
}
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
TEST_INTERSECTION(case_106, 2, -1, 3.5);
TEST_INTERSECTION(case_107, 3, -1, 3.0);
@@ -890,7 +930,6 @@ int test_main(int, char* [])
test_all<bg::model::d2::point_xy<ttmath_big> >();
#endif
#endif
// Commented, because exception is now disabled:
// test_exception<bg::model::d2::point_xy<double> >();
@@ -918,6 +957,7 @@ int test_main(int, char* [])
#if defined(BOOST_HAS_LONG_LONG)
test_ticket_10868<boost::long_long_type>("MULTIPOLYGON(((33520458 6878575,33480192 14931538,31446819 18947953,30772384 19615678,30101303 19612322,30114725 16928001,33520458 6878575)))");
#endif
#endif
#endif
return 0;

View File

@@ -32,6 +32,10 @@
(test_one<Polygon, MultiPolygon, MultiPolygon>) \
( #caseid, caseid[0], caseid[1], clips, points, area)
#define TEST_INTERSECTION_REV(caseid, clips, points, area) \
(test_one<Polygon, MultiPolygon, MultiPolygon>) \
( #caseid "_rev", caseid[1], caseid[0], clips, points, area)
#define TEST_INTERSECTION_IGNORE(caseid, clips, points, area) \
{ ut_settings ignore_validity; ignore_validity.test_validity = false; \
(test_one<Polygon, MultiPolygon, MultiPolygon>) \
@@ -368,6 +372,17 @@ void test_areal()
TEST_INTERSECTION(case_recursive_boxes_87, 0, -1, 0.0);
TEST_INTERSECTION(case_recursive_boxes_88, 4, -1, 3.5);
#ifndef BOOST_GEOMETRY_NO_ROBUSTNESS
TEST_INTERSECTION(case_precision_m1, 1, -1, 14.0);
TEST_INTERSECTION(case_precision_m2, 2, -1, 15.25);
TEST_INTERSECTION_REV(case_precision_m1, 1, -1, 14.0);
TEST_INTERSECTION_REV(case_precision_m2, 2, -1, 15.25);
#else
// Validity: false positives (very small triangles looking like a line)
TEST_INTERSECTION_IGNORE(case_precision_m1, 1, -1, 14.0);
TEST_INTERSECTION_IGNORE(case_precision_m2, 2, -1, 15.25);
#endif
test_one<Polygon, MultiPolygon, MultiPolygon>("ggl_list_20120915_h2_a",
ggl_list_20120915_h2[0], ggl_list_20120915_h2[1],
2, 10, 6.0); // Area from SQL Server
@@ -379,6 +394,11 @@ void test_areal()
ticket_9081[0], ticket_9081[1],
2, 10, 0.0019812556);
// Should generate output, even for <float>
test_one<Polygon, MultiPolygon, MultiPolygon>("mail_2019_01_21_johan",
mail_2019_01_21_johan[2], mail_2019_01_21_johan[3],
2, -1, 0.0005889587);
// qcc-arm reports 1.7791215549400884e-14
test_one<Polygon, MultiPolygon, MultiPolygon>("ticket_11018",
ticket_11018[0], ticket_11018[1],

View File

@@ -151,7 +151,15 @@ check_result(
double const detected_length_or_area = boost::numeric_cast<double>(length_or_area);
if (settings.percentage > 0.0)
{
BOOST_CHECK_CLOSE(detected_length_or_area, expected_length_or_area, settings.percentage);
if (expected_length_or_area > 0)
{
BOOST_CHECK_CLOSE(detected_length_or_area, expected_length_or_area, settings.percentage);
}
else
{
// Compare 0 with 0 or a very small detected area
BOOST_CHECK_LE(detected_length_or_area, settings.percentage);
}
}
else
{

View File

@@ -26,6 +26,14 @@
#include <boost/geometry/geometries/point_xy.hpp>
#define TEST_UNION(caseid, clips, holes, points, area) \
(test_one<Polygon, Polygon, Polygon>) \
( #caseid, caseid[0], caseid[1], clips, holes, points, area)
#define TEST_UNION_REV(caseid, clips, holes, points, area) \
(test_one<Polygon, Polygon, Polygon>) \
( #caseid "_rev", caseid[1], caseid[0], clips, holes, points, area)
template <typename Ring, typename Polygon>
void test_areal()
@@ -247,6 +255,34 @@ void test_areal()
test_one<Polygon, Polygon, Polygon>("108",
case_108[0], case_108[1], 1, 0, 13, 5.0);
TEST_UNION(case_precision_1, 1, 0, -1, 22.0);
TEST_UNION(case_precision_2, 1, 0, -1, 22.0);
TEST_UNION(case_precision_3, 1, 0, -1, 22.0);
TEST_UNION(case_precision_4, 1, 0, -1, 22.0);
TEST_UNION(case_precision_5, 1, 0, -1, 22.0);
TEST_UNION(case_precision_6, 1, 0, -1, 71.0);
TEST_UNION(case_precision_7, 1, 0, -1, 22.0);
TEST_UNION(case_precision_8, 1, 1, -1, 73.0);
TEST_UNION(case_precision_9, 1, 1, -1, 73.0);
TEST_UNION(case_precision_10, 1, 1, -1, 73.0);
TEST_UNION(case_precision_11, 1, 1, -1, 73.0);
TEST_UNION(case_precision_12, 1, 0, -1, 14.0);
TEST_UNION(case_precision_13, 1, 0, -1, 14.0);
TEST_UNION_REV(case_precision_1, 1, 0, -1, 22.0);
TEST_UNION_REV(case_precision_2, 1, 0, -1, 22.0);
TEST_UNION_REV(case_precision_3, 1, 0, -1, 22.0);
TEST_UNION_REV(case_precision_4, 1, 0, -1, 22.0);
TEST_UNION_REV(case_precision_5, 1, 0, -1, 22.0);
TEST_UNION_REV(case_precision_6, 1, 0, -1, 71.0);
TEST_UNION_REV(case_precision_7, 1, 0, -1, 22.0);
TEST_UNION_REV(case_precision_8, 1, 1, -1, 73.0);
TEST_UNION_REV(case_precision_9, 1, 1, -1, 73.0);
TEST_UNION_REV(case_precision_10, 1, 1, -1, 73.0);
TEST_UNION_REV(case_precision_11, 1, 1, -1, 73.0);
TEST_UNION_REV(case_precision_12, 1, 0, -1, 14.0);
TEST_UNION_REV(case_precision_13, 1, 0, -1, 14.0);
/*
test_one<Polygon, Polygon, Polygon>(102,
simplex_normal[0], simplex_reversed[1],
@@ -342,22 +378,23 @@ void test_areal()
ticket_5103[0], ticket_5103[1],
1, 0, 25, 2515271327070.5);
test_one<Polygon, Polygon, Polygon>("ticket_8310a", ticket_8310a[0], ticket_8310a[1],
1, 0, 5, 10.5000019595);
test_one<Polygon, Polygon, Polygon>("ticket_8310b", ticket_8310b[0], ticket_8310b[1],
1, 0, 5, 10.5000019595);
test_one<Polygon, Polygon, Polygon>("ticket_8310c", ticket_8310c[0], ticket_8310c[1],
1, 0, 5, 10.5000019595);
TEST_UNION(ticket_8310a, 1, 0, 5, 10.5000019595);
TEST_UNION(ticket_8310b, 1, 0, 5, 10.5000019595);
TEST_UNION(ticket_8310c, 1, 0, 5, 10.5000019595);
TEST_UNION_REV(ticket_8310a, 1, 0, 5, 10.5000019595);
TEST_UNION_REV(ticket_8310b, 1, 0, 5, 10.5000019595);
TEST_UNION_REV(ticket_8310c, 1, 0, 5, 10.5000019595);
test_one<Polygon, Polygon, Polygon>("ticket_9081_15",
ticket_9081_15[0], ticket_9081_15[1],
1, 0, 10, 0.0403425433);
1, 0, -1, 0.0403425433);
test_one<Polygon, Polygon, Polygon>("ticket_9563", ticket_9563[0], ticket_9563[1],
1, 0, 13, 150.0);
// Float result is OK but a bit larger
test_one<Polygon, Polygon, Polygon>("ticket_9756", ticket_9756[0], ticket_9756[1],
1, 0, 10, 1289.08374);
1, 0, 10, if_typed<ct, float>(1291.5469, 1289.08374));
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
test_one<Polygon, Polygon, Polygon>("ticket_10108_a", ticket_10108_a[0], ticket_10108_a[1],
@@ -373,7 +410,7 @@ void test_areal()
#endif
test_one<Polygon, Polygon, Polygon>("ticket_10866", ticket_10866[0], ticket_10866[1],
1, 0, 14, 332760303.5);
1, 0, 14, if_typed<ct, float>(332752493.0, 332760303.5));
test_one<Polygon, Polygon, Polygon>("ticket_11725", ticket_11725[0], ticket_11725[1],
1, 1, 10, 7.5);
@@ -398,17 +435,17 @@ void test_areal()
// Robustness issues, followed out buffer-robustness-tests, test them also reverse
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
test_one<Polygon, Polygon, Polygon>("buffer_rt_f", buffer_rt_f[0], buffer_rt_f[1],
1, 0, 15, 4.60853);
1, 0, -1, 4.60853);
test_one<Polygon, Polygon, Polygon>("buffer_rt_f_rev", buffer_rt_f[1], buffer_rt_f[0],
1, 0, 15, 4.60853);
1, 0, -1, 4.60853);
test_one<Polygon, Polygon, Polygon>("buffer_rt_g", buffer_rt_g[0], buffer_rt_g[1],
1, 0, if_typed<ct, float>(16, 11), 16.571);
1, 0, -1, 16.571);
test_one<Polygon, Polygon, Polygon>("buffer_rt_g_rev", buffer_rt_g[1], buffer_rt_g[0],
1, 0, if_typed<ct, float>(16, 11), 16.571);
1, 0, -1, 16.571);
test_one<Polygon, Polygon, Polygon>("buffer_rt_i", buffer_rt_i[0], buffer_rt_i[1],
1, 0, if_typed<ct, float>(11, 13), 13.6569);
1, 0, -1, 13.6569);
test_one<Polygon, Polygon, Polygon>("buffer_rt_i_rev", buffer_rt_i[1], buffer_rt_i[0],
1, 0, 13, 13.6569);
1, 0, -1, 13.6569);
#endif
test_one<Polygon, Polygon, Polygon>("buffer_rt_j", buffer_rt_j[0], buffer_rt_j[1],
@@ -429,23 +466,23 @@ void test_areal()
1, 0, 9, 19.4852);
test_one<Polygon, Polygon, Polygon>("buffer_rt_m2", buffer_rt_m2[0], buffer_rt_m2[1],
1, 0, 12, 21.4853);
1, 0, -1, 21.4853);
test_one<Polygon, Polygon, Polygon>("buffer_rt_m2_rev", buffer_rt_m2[1], buffer_rt_m2[0],
1, 0, 15, 21.4853);
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
test_one<Polygon, Polygon, Polygon>("buffer_rt_q", buffer_rt_q[0], buffer_rt_q[1],
1, 0, if_typed<ct, float>(16, 12), 18.5710);
1, 0, -1, 18.5710);
test_one<Polygon, Polygon, Polygon>("buffer_rt_q_rev", buffer_rt_q[1], buffer_rt_q[0],
1, 0, if_typed<ct, float>(16, 12), 18.5710);
1, 0, -1, 18.5710);
test_one<Polygon, Polygon, Polygon>("buffer_rt_r", buffer_rt_r[0], buffer_rt_r[1],
1, 0, if_typed<ct, float>(18, 14), 21.07612);
1, 0, -1, 21.07612);
test_one<Polygon, Polygon, Polygon>("buffer_rt_r_rev", buffer_rt_r[1], buffer_rt_r[0],
1, 0, if_typed<ct, float>(18, 14), 21.07612);
1, 0, -1, 21.07612);
test_one<Polygon, Polygon, Polygon>("buffer_rt_t", buffer_rt_t[0], buffer_rt_t[1],
1, 0, 9, 15.6569);
1, 0, -1, 15.6569);
test_one<Polygon, Polygon, Polygon>("buffer_rt_t_rev", buffer_rt_t[1], buffer_rt_t[0],
1, 0, 10, 15.6569);
1, 0, -1, 15.6569);
#endif
test_one<Polygon, Polygon, Polygon>("buffer_mp1", buffer_mp1[0], buffer_mp1[1],

View File

@@ -431,14 +431,22 @@ void test_areal()
ggl_list_20140212_sybren[0], ggl_list_20140212_sybren[1],
2, 0, 16, 0.002471626);
test_one<Polygon, MultiPolygon, MultiPolygon>("ticket_9081",
ticket_9081[0], ticket_9081[1],
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
3,
#else
4,
{
ut_settings settings;
#if !defined(BOOST_GEOMETRY_NO_ROBUSTNESS) && !defined(BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS)
settings.test_validity = false;
#endif
0, 31, 0.2187385);
test_one<Polygon, MultiPolygon, MultiPolygon>("ticket_9081",
ticket_9081[0], ticket_9081[1],
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
3,
#else
4,
#endif
0, 31, 0.2187385,
settings);
}
test_one<Polygon, MultiPolygon, MultiPolygon>("ticket_10803",
ticket_10803[0], ticket_10803[1],
@@ -460,6 +468,9 @@ void test_areal()
TEST_UNION(ticket_12503, 42, 1, -1, 945.625);
// Generates two polygons, which should (without rescaling) be merged into one
TEST_UNION(mail_2019_01_21_johan, 2, 0, -1, 0.00058896);
#ifndef BOOST_GEOMETRY_NO_SELF_TURNS
TEST_UNION(mysql_23023665_7, 1, 1, -1, 99.19494);
#else

View File

@@ -2,7 +2,12 @@
// Copyright (c) 2018 Yaghyavardhan Singh Khangarot, Hyderabad, India.
// Contributed and/or modified by Yaghyavardhan Singh Khangarot, as part of Google Summer of Code 2018 program.
// Contributed and/or modified by Yaghyavardhan Singh Khangarot,
// as part of Google Summer of Code 2018 program.
// This file was modified by Oracle on 2018.
// Modifications copyright (c) 2018 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@@ -13,6 +18,8 @@
#include <boost/geometry/geometries/linestring.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/geometries/multi_linestring.hpp>
#include <boost/geometry/geometries/multi_point.hpp>
#include "test_hausdorff_distance.hpp"

View File

@@ -4,8 +4,8 @@
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland.
// This file was modified by Oracle on 2014, 2015, 2017.
// Modifications copyright (c) 2014-2017 Oracle and/or its affiliates.
// This file was modified by Oracle on 2014, 2015, 2017, 2019.
// Modifications copyright (c) 2014-2019 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
@@ -21,6 +21,7 @@
#include <geometry_test_common.hpp>
#include <boost/geometry/algorithms/covered_by.hpp>
#include <boost/geometry/algorithms/within.hpp>
#include <boost/geometry/core/ring_type.hpp>
#include <boost/geometry/geometries/ring.hpp>

View File

@@ -1,6 +1,6 @@
// Boost.Geometry
// Copyright (c) 2017-2018, Oracle and/or its affiliates.
// Copyright (c) 2017-2019, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
@@ -52,8 +52,8 @@ struct pj_projection
template <typename In, typename Out>
void forward(In const& in, Out & out) const
{
double x = bg::get_as_radian<0>(in);
double y = bg::get_as_radian<1>(in);
double x = boost::geometry::get_as_radian<0>(in);
double y = boost::geometry::get_as_radian<1>(in);
projUV p1;
projUV p2;
@@ -63,15 +63,15 @@ struct pj_projection
p2 = pj_fwd(p1, m_ptr.get());
bg::set_from_radian<0>(out, p2.u);
bg::set_from_radian<1>(out, p2.v);
boost::geometry::set_from_radian<0>(out, p2.u);
boost::geometry::set_from_radian<1>(out, p2.v);
}
template <typename In, typename Out>
void inverse(In const& in, Out & out) const
{
double lon = bg::get_as_radian<0>(in);
double lat = bg::get_as_radian<1>(in);
double lon = boost::geometry::get_as_radian<0>(in);
double lat = boost::geometry::get_as_radian<1>(in);
projUV p1;
projUV p2;
@@ -79,10 +79,10 @@ struct pj_projection
p1.u = lon;
p1.v = lat;
p2 = pj_inv(p1, pj_prj.get());
p2 = pj_inv(p1, m_ptr.get());
bg::set_from_radian<0>(out, p2.u);
bg::set_from_radian<1>(out, p2.v);
boost::geometry::set_from_radian<0>(out, p2.u);
boost::geometry::set_from_radian<1>(out, p2.v);
}
private:
@@ -99,13 +99,13 @@ struct pj_transformation
template <typename In, typename Out>
void forward(In const& in, Out & out) const
{
double x = bg::get_as_radian<0>(in);
double y = bg::get_as_radian<1>(in);
double x = boost::geometry::get_as_radian<0>(in);
double y = boost::geometry::get_as_radian<1>(in);
pj_transform(m_from.get(), m_to.get(), 1, 0, &x, &y, NULL);
bg::set_from_radian<0>(out, x);
bg::set_from_radian<1>(out, y);
boost::geometry::set_from_radian<0>(out, x);
boost::geometry::set_from_radian<1>(out, y);
}
void forward(std::vector<double> in_x,
@@ -115,8 +115,24 @@ struct pj_transformation
{
assert(in_x.size() == in_y.size());
pj_transform(m_from.get(), m_to.get(), in_x.size(), 1, &in_x[0], &in_y[0], NULL);
out_x = in_x;
out_y = in_y;
out_x = std::move(in_x);
out_y = std::move(in_y);
}
void forward(std::vector<double> in_xy,
std::vector<double> & out_xy) const
{
assert(in_xy.size() % 2 == 0);
pj_transform(m_from.get(), m_to.get(), in_xy.size() / 2, 2, &in_xy[0], &in_xy[1], NULL);
out_xy = std::move(in_xy);
}
void forward(std::vector<std::vector<double> > const& in_xy,
std::vector<std::vector<double> > & out_xy) const
{
out_xy.resize(in_xy.size());
for (size_t i = 0 ; i < in_xy.size(); ++i)
forward(in_xy[i], out_xy[i]);
}
private: