mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-01 08:32:10 +00:00
Merge branch 'develop' into feature/disjoint_geo_new
This commit is contained in:
@@ -50,6 +50,7 @@
|
||||
|
||||
#include "test_envelope_expand_on_spheroid.hpp"
|
||||
|
||||
|
||||
template <
|
||||
template <typename, bool, bool, bool, bool, bool> class Inverse,
|
||||
typename CS_Tag
|
||||
@@ -152,11 +153,54 @@ private:
|
||||
BOOST_CHECK_MESSAGE(same_boxes, stream.str());
|
||||
}
|
||||
|
||||
template <typename Box, typename Geometry>
|
||||
template
|
||||
<
|
||||
typename Geometry, typename Box,
|
||||
typename T1, typename T2, typename T3, typename T4
|
||||
>
|
||||
static inline void check_message(bool same_boxes,
|
||||
std::string const& case_id,
|
||||
std::string const& units_str,
|
||||
Geometry const& geometry,
|
||||
T1 const& lon_min, T2 const& lat_min, double height_min,
|
||||
T3 const& lon_max, T4 const& lat_max, double height_max,
|
||||
Box const& detected)
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << "case ID: " << case_id << ", "
|
||||
<< "MBR units: " << units_str << "; "
|
||||
<< "geometry: ";
|
||||
|
||||
write_geometry<Geometry>::apply(stream, geometry);
|
||||
|
||||
stream << std::setprecision(17);
|
||||
|
||||
stream << "; " << "expected: ";
|
||||
|
||||
if (BOOST_GEOMETRY_CONDITION(bg::dimension<Box>::value == 2))
|
||||
{
|
||||
stream << "(" << lon_min << " " << lat_min
|
||||
<< ", " << lon_max << " " << lat_max << ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
stream << "(" << lon_min << " " << lat_min << " " << height_min
|
||||
<< ", " << lon_max << " " << lat_max << " " << height_max << ")";
|
||||
}
|
||||
stream << ", " << "detected: " << bg::dsv(detected);
|
||||
|
||||
BOOST_CHECK_MESSAGE(same_boxes, stream.str());
|
||||
}
|
||||
|
||||
template
|
||||
<
|
||||
typename Box, typename Geometry,
|
||||
typename T1, typename T2, typename T3, typename T4
|
||||
>
|
||||
static inline void base_test(std::string const& case_id,
|
||||
Geometry const& geometry,
|
||||
double lon_min, double lat_min, double height_min,
|
||||
double lon_max, double lat_max, double height_max,
|
||||
T1 const& lon_min, T2 const& lat_min, double height_min,
|
||||
T3 const& lon_max, T4 const& lat_max, double height_max,
|
||||
double tolerance)
|
||||
{
|
||||
typedef typename bg::coordinate_system<Box>::type::units box_units_type;
|
||||
@@ -168,27 +212,40 @@ private:
|
||||
typename bg::cs_tag<Geometry>::type
|
||||
>::apply(geometry, detected);
|
||||
|
||||
Box expected;
|
||||
initialize_box<Box>::apply(expected,
|
||||
lon_min, lat_min, height_min,
|
||||
lon_max, lat_max, height_max);
|
||||
|
||||
#ifdef BOOST_GEOMETRY_TEST_DEBUG
|
||||
std::cout << "geometry: ";
|
||||
write_geometry<Geometry>::apply(std::cout, geometry);
|
||||
|
||||
std::cout << std::endl
|
||||
<< "MBR units: " << units_str
|
||||
<< std::endl
|
||||
<< "expected: " << bg::dsv(expected)
|
||||
<< std::endl
|
||||
<< std::endl;
|
||||
std::cout << "expected: ";
|
||||
if (BOOST_GEOMETRY_CONDITION(bg::dimension<Box>::value == 2))
|
||||
{
|
||||
std::cout << "(" << lon_min << " " << lat_min
|
||||
<< ", " << lon_max << " " << lat_max << ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "(" << lon_min << " " << lat_min << " " << height_min
|
||||
<< ", " << lon_max << " " << lat_max << " " << height_max << ")";
|
||||
}
|
||||
std::cout << std::endl
|
||||
<< "detected: " << bg::dsv(detected)
|
||||
<< std::endl << std::endl;
|
||||
#endif
|
||||
|
||||
check_message(box_equals<Box>::apply(detected, expected, tolerance),
|
||||
bool check = box_check_equals<Box>::apply(detected,
|
||||
lon_min, lat_min, height_min,
|
||||
lon_max, lat_max, height_max,
|
||||
tolerance);
|
||||
|
||||
check_message(check,
|
||||
case_id, units_str,
|
||||
geometry, expected, detected);
|
||||
geometry,
|
||||
lon_min, lat_min, height_min,
|
||||
lon_max, lat_max, height_max,
|
||||
detected);
|
||||
|
||||
// if valid box is expected, check the validity
|
||||
if (lon_min <= lon_max && lat_min <= lat_max && height_min <= height_max)
|
||||
@@ -201,11 +258,15 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
template <typename Geometry>
|
||||
template
|
||||
<
|
||||
typename Geometry,
|
||||
typename T1, typename T2, typename T3, typename T4
|
||||
>
|
||||
static inline void apply(std::string const& case_id,
|
||||
Geometry const& geometry,
|
||||
double lon_min, double lat_min, double height_min,
|
||||
double lon_max, double lat_max, double height_max,
|
||||
T1 const& lon_min, T2 const& lat_min, double height_min,
|
||||
T3 const& lon_max, T4 const& lat_max, double height_max,
|
||||
double tolerance)
|
||||
{
|
||||
typedef other_system_info
|
||||
@@ -291,12 +352,14 @@ template
|
||||
>
|
||||
struct test_envelope_on_sphere_or_spheroid
|
||||
{
|
||||
template <typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6, typename T7, typename T8>
|
||||
static inline void apply(std::string const& case_id,
|
||||
Geometry const& geometry,
|
||||
double lon_min1, double lat_min1, double height_min1,
|
||||
double lon_max1, double lat_max1, double height_max1,
|
||||
double lon_min2, double lat_min2, double height_min2,
|
||||
double lon_max2, double lat_max2, double height_max2,
|
||||
T1 const& lon_min1, T2 const& lat_min1, double height_min1,
|
||||
T3 const& lon_max1, T4 const& lat_max1, double height_max1,
|
||||
T5 const& lon_min2, T6 const& lat_min2, double height_min2,
|
||||
T7 const& lon_max2, T8 const& lat_max2, double height_max2,
|
||||
double tolerance = std::numeric_limits<double>::epsilon())
|
||||
{
|
||||
envelope_on_spheroid_basic_tester
|
||||
@@ -328,12 +391,14 @@ struct test_envelope_on_sphere_or_spheroid
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6, typename T7, typename T8>
|
||||
static inline void apply(std::string const& case_id,
|
||||
Geometry const& geometry,
|
||||
double lon_min1, double lat_min1,
|
||||
double lon_max1, double lat_max1,
|
||||
double lon_min2, double lat_min2,
|
||||
double lon_max2, double lat_max2,
|
||||
T1 const& lon_min1, T2 const& lat_min1,
|
||||
T3 const& lon_max1, T4 const& lat_max1,
|
||||
T5 const& lon_min2, T6 const& lat_min2,
|
||||
T7 const& lon_max2, T8 const& lat_max2,
|
||||
double tolerance = std::numeric_limits<double>::epsilon())
|
||||
{
|
||||
apply(case_id, geometry,
|
||||
@@ -342,10 +407,11 @@ struct test_envelope_on_sphere_or_spheroid
|
||||
tolerance);
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
static inline void apply(std::string const& case_id,
|
||||
Geometry const& geometry,
|
||||
double lon_min, double lat_min, double height_min,
|
||||
double lon_max, double lat_max, double height_max,
|
||||
T1 const& lon_min, T2 const& lat_min, double height_min,
|
||||
T3 const& lon_max, T4 const& lat_max, double height_max,
|
||||
double tolerance = std::numeric_limits<double>::epsilon())
|
||||
{
|
||||
apply(case_id, geometry,
|
||||
@@ -356,10 +422,11 @@ struct test_envelope_on_sphere_or_spheroid
|
||||
tolerance);
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
static inline void apply(std::string const& case_id,
|
||||
Geometry const& geometry,
|
||||
double lon_min, double lat_min,
|
||||
double lon_max, double lat_max,
|
||||
T1 const& lon_min, T2 const& lat_min,
|
||||
T3 const& lon_max, T4 const& lat_max,
|
||||
double tolerance = std::numeric_limits<double>::epsilon())
|
||||
{
|
||||
apply(case_id, geometry,
|
||||
@@ -373,13 +440,15 @@ struct test_envelope_on_sphere_or_spheroid
|
||||
template <typename Geometry, typename MBR, bool TestReverse>
|
||||
struct test_envelope_on_sphere_or_spheroid<Geometry, MBR, bg::ring_tag, TestReverse>
|
||||
{
|
||||
template <typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6, typename T7, typename T8>
|
||||
static inline void apply(std::string const& case_id,
|
||||
Geometry const& geometry,
|
||||
double lon_min1, double lat_min1,
|
||||
double lon_max1, double lat_max1,
|
||||
double lon_min2, double lat_min2,
|
||||
double lon_max2, double lat_max2,
|
||||
double tolerance = std::numeric_limits<double>::epsilon())
|
||||
T1 const& lon_min1, T2 const& lat_min1,
|
||||
T3 const& lon_max1, T4 const& lat_max1,
|
||||
T5 const& lon_min2, T6 const& lat_min2,
|
||||
T7 const& lon_max2, T8 const& lat_max2,
|
||||
double const& tolerance = std::numeric_limits<double>::epsilon())
|
||||
{
|
||||
envelope_on_spheroid_basic_tester
|
||||
<
|
||||
@@ -409,10 +478,11 @@ struct test_envelope_on_sphere_or_spheroid<Geometry, MBR, bg::ring_tag, TestReve
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
static inline void apply(std::string const& case_id,
|
||||
Geometry const& geometry,
|
||||
double lon_min, double lat_min,
|
||||
double lon_max, double lat_max,
|
||||
T1 const& lon_min, T2 const& lat_min,
|
||||
T3 const& lon_max, T4 const& lat_max,
|
||||
double tolerance = std::numeric_limits<double>::epsilon())
|
||||
{
|
||||
apply(case_id, geometry,
|
||||
@@ -822,26 +892,24 @@ BOOST_AUTO_TEST_CASE( envelope_segment_spheroid )
|
||||
|
||||
tester::apply("s09",
|
||||
from_wkt<G>("SEGMENT(1 -45,179 30)"),
|
||||
1, -85.392785243526134, 179, 30,
|
||||
3 * eps);
|
||||
1, rng(-85.392785243526134, -85.392785243525253), 179, 30);
|
||||
|
||||
tester::apply("s09a",
|
||||
from_wkt<G>("SEGMENT(2 -45,181 30)"),
|
||||
2, -87.689300911353811, 181, 30);
|
||||
2, rng(-87.689300911353811, -87.689300911353371), 181, 30);
|
||||
|
||||
// very long segment
|
||||
tester::apply("s10",
|
||||
from_wkt<G>("SEGMENT(0 -45,181 30)"),
|
||||
-179, -87.689300911353797, 0, 30,
|
||||
2.0 * eps);
|
||||
-179, rng(-87.689300911353797, -87.689300911353385), 0, 30);
|
||||
|
||||
tester::apply("s11",
|
||||
from_wkt<G>("SEGMENT(260 30,20 45)"),
|
||||
-100, 30, 20, 57.990810958016965);
|
||||
-100, 30, 20, rng(57.990810958016482, 57.990810958016965));
|
||||
|
||||
tester::apply("s11a",
|
||||
from_wkt<G>("SEGMENT(260 45,20 30)"),
|
||||
-100, 30, 20, 57.990810958016965);
|
||||
-100, 30, 20, rng(57.990810958016453, 57.990810958016965));
|
||||
|
||||
// segment degenerating to the north pole
|
||||
tester::apply("s12",
|
||||
@@ -859,7 +927,7 @@ BOOST_AUTO_TEST_CASE( envelope_segment_spheroid )
|
||||
|
||||
tester::apply("s15",
|
||||
from_wkt<G>("SEGMENT(50 45,185 45)"),
|
||||
50, 45, 185, 69.098479073903178);
|
||||
50, 45, 185, rng(69.098479073902851, 69.098479073903178));
|
||||
|
||||
// segment that lies on the equator
|
||||
tester::apply("s16",
|
||||
@@ -924,7 +992,7 @@ BOOST_AUTO_TEST_CASE( envelope_segment_spheroid )
|
||||
1-heps, 1, 1, 1);
|
||||
tester::apply("s104",
|
||||
G(P(2, 1), P(1, 1-heps)),
|
||||
1, 1-heps, 2, 1.0000383271569036);
|
||||
1, 1-heps, 2, rng(1.0000383271568751, 1.0000383271569036));
|
||||
tester::apply("s105",
|
||||
G(P(1, 2), P(1-heps, 1)),
|
||||
1-heps, 1, 1, 2);
|
||||
@@ -940,13 +1008,11 @@ BOOST_AUTO_TEST_CASE( envelope_segment_spheroid_with_strategy_thomas )
|
||||
typedef test_envelope_on_sphere_or_spheroid
|
||||
<
|
||||
G, B,
|
||||
typename bg::tag<G>::type,
|
||||
bg::tag<G>::type,
|
||||
test_reverse_geometry<G>::value,
|
||||
bg::formula::thomas_inverse
|
||||
> tester;
|
||||
|
||||
double const eps = std::numeric_limits<double>::epsilon();
|
||||
|
||||
tester::apply("s01",
|
||||
from_wkt<G>("SEGMENT(10 10,40 40)"),
|
||||
10, 10, 40, 40);
|
||||
@@ -1011,26 +1077,24 @@ BOOST_AUTO_TEST_CASE( envelope_segment_spheroid_with_strategy_thomas )
|
||||
|
||||
tester::apply("s09",
|
||||
from_wkt<G>("SEGMENT(1 -45,179 30)"),
|
||||
1, -85.392785243526134, 179, 30,
|
||||
3 * eps);
|
||||
1, rng(-85.392785243526134, -85.392785243525253), 179, 30);
|
||||
|
||||
tester::apply("s09a",
|
||||
from_wkt<G>("SEGMENT(2 -45,181 30)"),
|
||||
2, -87.689300911353811, 181, 30);
|
||||
2, rng(-87.689300911353811, -87.689300911353371), 181, 30);
|
||||
|
||||
// very long segment
|
||||
tester::apply("s10",
|
||||
from_wkt<G>("SEGMENT(0 -45,181 30)"),
|
||||
-179, -87.689300911353797, 0, 30,
|
||||
2.0 * eps);
|
||||
-179, rng(-87.689300911353797, -87.689300911353385), 0, 30);
|
||||
|
||||
tester::apply("s11",
|
||||
from_wkt<G>("SEGMENT(260 30,20 45)"),
|
||||
-100, 30, 20, 57.990810958016965);
|
||||
-100, 30, 20, rng(57.990810958016482, 57.990810958016965));
|
||||
|
||||
tester::apply("s11a",
|
||||
from_wkt<G>("SEGMENT(260 45,20 30)"),
|
||||
-100, 30, 20, 57.990810958016965);
|
||||
-100, 30, 20, rng(57.990810958016453, 57.990810958016965));
|
||||
|
||||
// segment degenerating to the north pole
|
||||
tester::apply("s12",
|
||||
@@ -1048,7 +1112,7 @@ BOOST_AUTO_TEST_CASE( envelope_segment_spheroid_with_strategy_thomas )
|
||||
|
||||
tester::apply("s15",
|
||||
from_wkt<G>("SEGMENT(50 45,185 45)"),
|
||||
50, 45, 185, 69.098479073903178);
|
||||
50, 45, 185, rng(69.098479073902851, 69.098479073903178));
|
||||
|
||||
// segment that lies on the equator
|
||||
tester::apply("s16",
|
||||
@@ -1098,13 +1162,11 @@ BOOST_AUTO_TEST_CASE( envelope_segment_spheroid_with_strategy_andoyer )
|
||||
typedef test_envelope_on_sphere_or_spheroid
|
||||
<
|
||||
G, B,
|
||||
typename bg::tag<G>::type,
|
||||
bg::tag<G>::type,
|
||||
test_reverse_geometry<G>::value,
|
||||
bg::formula::andoyer_inverse
|
||||
> tester;
|
||||
|
||||
double const eps = std::numeric_limits<double>::epsilon();
|
||||
|
||||
tester::apply("s01",
|
||||
from_wkt<G>("SEGMENT(10 10,40 40)"),
|
||||
10, 10, 40, 40);
|
||||
@@ -1169,26 +1231,24 @@ BOOST_AUTO_TEST_CASE( envelope_segment_spheroid_with_strategy_andoyer )
|
||||
|
||||
tester::apply("s09",
|
||||
from_wkt<G>("SEGMENT(1 -45,179 30)"),
|
||||
1, -85.394745211091248, 179, 30,
|
||||
3 * eps);
|
||||
1, rng(-85.394745211091248, -85.394745211090353), 179, 30);
|
||||
|
||||
tester::apply("s09a",
|
||||
from_wkt<G>("SEGMENT(2 -45,181 30)"),
|
||||
2, -87.690317839849726, 181, 30);
|
||||
2, rng(-87.690317839849726, -87.690317839849271), 181, 30);
|
||||
|
||||
// very long segment
|
||||
tester::apply("s10",
|
||||
from_wkt<G>("SEGMENT(0 -45,181 30)"),
|
||||
-179, -87.69031783984974, 0, 30,
|
||||
2.0 * eps);
|
||||
-179, rng(-87.69031783984974, -87.690317839849271), 0, 30);
|
||||
|
||||
tester::apply("s11",
|
||||
from_wkt<G>("SEGMENT(260 30,20 45)"),
|
||||
-100, 30, 20, 57.990742552280153);
|
||||
-100, 30, 20, rng(57.990742552279649, 57.990742552280153));
|
||||
|
||||
tester::apply("s11a",
|
||||
from_wkt<G>("SEGMENT(260 45,20 30)"),
|
||||
-100, 30, 20, 57.990742552280118);
|
||||
-100, 30, 20, rng(57.99074255227962, 57.990742552280118));
|
||||
|
||||
// segment degenerating to the north pole
|
||||
tester::apply("s12",
|
||||
@@ -1206,7 +1266,7 @@ BOOST_AUTO_TEST_CASE( envelope_segment_spheroid_with_strategy_andoyer )
|
||||
|
||||
tester::apply("s15",
|
||||
from_wkt<G>("SEGMENT(50 45,185 45)"),
|
||||
50, 45, 185, 69.09844689340845);
|
||||
50, 45, 185, rng(69.098446893408124, 69.09844689340845));
|
||||
|
||||
// segment that lies on the equator
|
||||
tester::apply("s16",
|
||||
@@ -1256,36 +1316,34 @@ BOOST_AUTO_TEST_CASE( envelope_segment_spheroid_with_strategy_vincenty )
|
||||
typedef test_envelope_on_sphere_or_spheroid
|
||||
<
|
||||
G, B,
|
||||
typename bg::tag<G>::type,
|
||||
bg::tag<G>::type,
|
||||
test_reverse_geometry<G>::value,
|
||||
bg::formula::vincenty_inverse
|
||||
> tester;
|
||||
|
||||
double const eps = std::numeric_limits<double>::epsilon();
|
||||
|
||||
tester::apply("s01",
|
||||
from_wkt<G>("SEGMENT(10 10,40 40)"),
|
||||
10, 10, 40, 40);
|
||||
|
||||
tester::apply("s02",
|
||||
from_wkt<G>("SEGMENT(10 10,40 10)"),
|
||||
10, 10, 40, 10.347587628821941);
|
||||
10, 10, 40, rng(10.347587628821937, 10.347587628821941));
|
||||
|
||||
tester::apply("s02a",
|
||||
from_wkt<G>("SEGMENT(40 10,10 10)"),
|
||||
10, 10, 40, 10.347587628821941);
|
||||
10, 10, 40, rng(10.347587628821937, 10.347587628821941));
|
||||
|
||||
tester::apply("s03",
|
||||
from_wkt<G>("SEGMENT(160 10,-170 10)"),
|
||||
160, 10, 190, 10.347587628821941);
|
||||
160, 10, 190, rng(10.347587628821937, 10.347587628821941));
|
||||
|
||||
tester::apply("s03a",
|
||||
from_wkt<G>("SEGMENT(-170 10,160 10)"),
|
||||
160, 10, 190, 10.347587628821941);
|
||||
160, 10, 190, rng(10.347587628821937, 10.347587628821941));
|
||||
|
||||
tester::apply("s03b",
|
||||
from_wkt<G>("SEGMENT(-170 -10,160 -10)"),
|
||||
160, -10.347587628821941, 190, -10);
|
||||
160, rng(-10.347587628821941, -10.347587628821937), 190, -10);
|
||||
|
||||
tester::apply("s04",
|
||||
from_wkt<G>("SEGMENT(-40 45,140 60)"),
|
||||
@@ -1327,26 +1385,24 @@ BOOST_AUTO_TEST_CASE( envelope_segment_spheroid_with_strategy_vincenty )
|
||||
|
||||
tester::apply("s09",
|
||||
from_wkt<G>("SEGMENT(1 -45,179 30)"),
|
||||
1, -85.392840929577218, 179, 30,
|
||||
3 * eps);
|
||||
1, rng(-85.392840929577218, -85.392840929576352), 179, 30);
|
||||
|
||||
tester::apply("s09a",
|
||||
from_wkt<G>("SEGMENT(2 -45,181 30)"),
|
||||
2, -87.689330275867817, 181, 30);
|
||||
2, rng(-87.689330275867817, -87.689330275867405), 181, 30);
|
||||
|
||||
// very long segment
|
||||
tester::apply("s10",
|
||||
from_wkt<G>("SEGMENT(0 -45,181 30)"),
|
||||
-179, -87.689330275867832, 0, 30,
|
||||
2.0 * eps);
|
||||
-179, rng(-87.689330275867832, -87.689330275867405), 0, 30);
|
||||
|
||||
tester::apply("s11",
|
||||
from_wkt<G>("SEGMENT(260 30,20 45)"),
|
||||
-100, 30, 20, 57.990810647057032);
|
||||
-100, 30, 20, rng(57.990810647056549, 57.990810647057032));
|
||||
|
||||
tester::apply("s11a",
|
||||
from_wkt<G>("SEGMENT(260 45,20 30)"),
|
||||
-100, 30, 20, 57.990810647057032);
|
||||
-100, 30, 20, rng(57.990810647056541, 57.990810647057032));
|
||||
|
||||
// segment degenerating to the north pole
|
||||
tester::apply("s12",
|
||||
@@ -1364,7 +1420,7 @@ BOOST_AUTO_TEST_CASE( envelope_segment_spheroid_with_strategy_vincenty )
|
||||
|
||||
tester::apply("s15",
|
||||
from_wkt<G>("SEGMENT(50 45,185 45)"),
|
||||
50, 45, 185, 69.098479136978497);
|
||||
50, 45, 185, rng(69.098479136978156, 69.098479136978497));
|
||||
|
||||
// segment that lies on the equator
|
||||
tester::apply("s16",
|
||||
@@ -2012,8 +2068,7 @@ BOOST_AUTO_TEST_CASE( envelope_spheroid_linestring )
|
||||
// linestring that circles the entire globe
|
||||
tester::apply("l03",
|
||||
from_wkt<G>("LINESTRING(-185 0,-170 25,-50 10,10 10,20 20,100 5,180 15)"),
|
||||
-180, 0, 180, 33.702476580413318,
|
||||
4.0 * std::numeric_limits<double>::epsilon());
|
||||
-180, 0, 180, rng(33.702476580412359, 33.702476580413318));
|
||||
|
||||
// linestring that crosses the antimeridian but staying close to it
|
||||
tester::apply("l04",
|
||||
@@ -2261,19 +2316,19 @@ BOOST_AUTO_TEST_CASE( envelope_spheroid_multilinestring )
|
||||
|
||||
tester::apply("ml04",
|
||||
from_wkt<G>("MULTILINESTRING((-150 40,-100 80),(10 35,100 80))"),
|
||||
-150, 35, 100, 80.082544902477267);
|
||||
-150, 35, 100, rng(80.07385383411011, 80.082544902477267));
|
||||
|
||||
tester::apply("ml04a",
|
||||
from_wkt<G>("MULTILINESTRING((-150 40,-100 80),(10 35,100 80),(170 25,-160 80))"),
|
||||
10, 25, 260, 80.082544902477267);
|
||||
10, 25, 260, rng(80.07385383411011, 80.082544902477267));
|
||||
|
||||
tester::apply("ml05",
|
||||
from_wkt<G>("MULTILINESTRING((-140 40,-100 80),(10 35,100 80))"),
|
||||
-140, 35, 100, 80.082544902477267);
|
||||
-140, 35, 100, rng(80.07385383411011, 80.082544902477267));
|
||||
|
||||
tester::apply("ml05a",
|
||||
from_wkt<G>("MULTILINESTRING((-140 40,-100 80),(10 35,100 80),(170 25,-160 80))"),
|
||||
10, 25, 260, 80.082544902477267);
|
||||
10, 25, 260, rng(80.07385383411011, 80.082544902477267));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,9 +11,11 @@
|
||||
#ifndef BOOST_GEOMETRY_TEST_ENVELOPE_EXPAND_ON_SPHEROID_HPP
|
||||
#define BOOST_GEOMETRY_TEST_ENVELOPE_EXPAND_ON_SPHEROID_HPP
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstddef>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
@@ -29,6 +31,37 @@
|
||||
#include <boost/geometry/algorithms/assign.hpp>
|
||||
|
||||
|
||||
struct rng
|
||||
{
|
||||
typedef double type;
|
||||
|
||||
rng(double l, double h)
|
||||
: lo(l), hi(h)
|
||||
{
|
||||
BOOST_GEOMETRY_ASSERT(lo <= hi);
|
||||
}
|
||||
|
||||
friend rng operator*(rng const& l, double v) { return rng(l.lo * v, l.hi * v); }
|
||||
|
||||
friend bool operator<=(rng const& l, rng const& r) { return l.lo <= r.hi; }
|
||||
friend bool operator<=(double l, rng const& r) { return l <= r.hi; }
|
||||
friend bool operator<=(rng const& l, double r) { return l.lo <= r; }
|
||||
|
||||
friend bool operator<(rng const& l, rng const& r) { return !operator<=(r, l); }
|
||||
friend bool operator<(double l, rng const& r) { return !operator<=(r, l); }
|
||||
friend bool operator<(rng const& l, double r) { return !operator<=(r, l); }
|
||||
|
||||
friend bool operator==(double l, rng const& r) { return r.lo <= l && l <= r.hi; }
|
||||
|
||||
friend std::ostream & operator<<(std::ostream & os, rng const& v)
|
||||
{
|
||||
return (os << "[" << v.lo << ", " << v.hi << "]");
|
||||
}
|
||||
|
||||
double lo, hi;
|
||||
};
|
||||
|
||||
|
||||
template <typename Units>
|
||||
char const* units2string()
|
||||
{
|
||||
@@ -49,10 +82,14 @@ struct other_system_info<bg::cs::spherical_equatorial<bg::radian> >
|
||||
typedef bg::degree units;
|
||||
typedef bg::cs::spherical_equatorial<units> type;
|
||||
|
||||
template <typename T>
|
||||
static inline T convert(T const& value)
|
||||
static inline double convert(double value)
|
||||
{
|
||||
return value * bg::math::r2d<T>();
|
||||
return value * bg::math::r2d<double>();
|
||||
}
|
||||
|
||||
static inline rng convert(rng const& value)
|
||||
{
|
||||
return value * bg::math::r2d<double>();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -62,10 +99,14 @@ struct other_system_info<bg::cs::spherical_equatorial<bg::degree> >
|
||||
typedef bg::radian units;
|
||||
typedef bg::cs::spherical_equatorial<units> type;
|
||||
|
||||
template <typename T>
|
||||
static inline T convert(T const& value)
|
||||
static inline double convert(double value)
|
||||
{
|
||||
return value * bg::math::d2r<T>();
|
||||
return value * bg::math::d2r<double>();
|
||||
}
|
||||
|
||||
static inline rng convert(rng const& value)
|
||||
{
|
||||
return value * bg::math::d2r<double>();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -75,10 +116,14 @@ struct other_system_info<bg::cs::geographic<bg::radian> >
|
||||
typedef bg::degree units;
|
||||
typedef bg::cs::geographic<units> type;
|
||||
|
||||
template <typename T>
|
||||
static inline T convert(T const& value)
|
||||
static inline double convert(double value)
|
||||
{
|
||||
return value * bg::math::r2d<T>();
|
||||
return value * bg::math::r2d<double>();
|
||||
}
|
||||
|
||||
static inline rng convert(rng const& value)
|
||||
{
|
||||
return value * bg::math::r2d<double>();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -88,15 +133,18 @@ struct other_system_info<bg::cs::geographic<bg::degree> >
|
||||
typedef bg::radian units;
|
||||
typedef bg::cs::geographic<units> type;
|
||||
|
||||
template <typename T>
|
||||
static inline T convert(T const& value)
|
||||
static inline double convert(double value)
|
||||
{
|
||||
return value * bg::math::d2r<T>();
|
||||
return value * bg::math::d2r<double>();
|
||||
}
|
||||
|
||||
static inline rng convert(rng const& value)
|
||||
{
|
||||
return value * bg::math::d2r<double>();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class equals_with_tolerance
|
||||
{
|
||||
private:
|
||||
@@ -118,11 +166,99 @@ private:
|
||||
public:
|
||||
equals_with_tolerance(double tolerence) : m_tolerence(tolerence) {}
|
||||
|
||||
template <typename T>
|
||||
inline bool operator()(T const& value1, T const& value2) const
|
||||
inline bool operator()(double value1, double value2) const
|
||||
{
|
||||
return check_close(value1, value2, m_tolerence);
|
||||
}
|
||||
|
||||
inline bool operator()(double l, rng const& r) const
|
||||
{
|
||||
return (r.lo < l && l < r.hi)
|
||||
|| check_close(l, r.lo, m_tolerence)
|
||||
|| check_close(l, r.hi, m_tolerence);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
bool equals_with_eps(double l, double r)
|
||||
{
|
||||
return bg::math::equals(l, r);
|
||||
}
|
||||
|
||||
bool equals_with_eps(double l, rng r)
|
||||
{
|
||||
return (r.lo < l && l < r.hi)
|
||||
|| bg::math::equals(l, r.lo)
|
||||
|| bg::math::equals(l, r.hi);
|
||||
}
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
typename Box,
|
||||
std::size_t DimensionCount = bg::dimension<Box>::value
|
||||
>
|
||||
struct box_check_equals
|
||||
{
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
static inline bool apply(Box const& box,
|
||||
T1 const& lon_min, T2 const& lat_min, double,
|
||||
T3 const& lon_max, T4 const& lat_max, double,
|
||||
double tol)
|
||||
{
|
||||
equals_with_tolerance equals(tol);
|
||||
|
||||
#ifndef BOOST_GEOMETRY_TEST_ENABLE_FAILING
|
||||
// check latitude with tolerance when necessary
|
||||
return equals_with_eps(bg::get<0, 0>(box), lon_min)
|
||||
&& (bg::get<0, 1>(box) < 0
|
||||
? equals(bg::get<0, 1>(box), lat_min)
|
||||
: equals_with_eps(bg::get<0, 1>(box), lat_min))
|
||||
&& equals_with_eps(bg::get<1, 0>(box), lon_max)
|
||||
&& (bg::get<1, 1>(box) > 0
|
||||
? equals(bg::get<1, 1>(box), lat_max)
|
||||
: equals_with_eps(bg::get<1, 1>(box), lat_max));
|
||||
#else
|
||||
// check latitude with tolerance when necessary
|
||||
return bg::get<0, 0>(box) == lon_min
|
||||
&& (bg::get<0, 1>(box) < 0
|
||||
? equals(bg::get<0, 1>(box), lat_min)
|
||||
: bg::get<0, 1>(box) == lat_min)
|
||||
&& bg::get<1, 0>(box) == lon_max
|
||||
&& (bg::get<1, 1>(box) > 0
|
||||
? equals(bg::get<1, 1>(box), lat_max)
|
||||
: bg::get<1, 1>(box) == lat_max);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Box>
|
||||
struct box_check_equals<Box, 3>
|
||||
{
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
static inline bool apply(Box const& box,
|
||||
T1 const& lon_min, T2 const& lat_min, double height_min,
|
||||
T3 const& lon_max, T4 const& lat_max, double height_max,
|
||||
double tol)
|
||||
{
|
||||
#ifndef BOOST_GEOMETRY_TEST_ENABLE_FAILING
|
||||
equals_with_tolerance equals(tol);
|
||||
|
||||
return box_check_equals<Box, 2>::apply(box,
|
||||
lon_min, lat_min, height_min,
|
||||
lon_max, lat_max, height_max,
|
||||
tol)
|
||||
&& equals(bg::get<0, 2>(box), height_min)
|
||||
&& equals(bg::get<1, 2>(box), height_max);
|
||||
#else
|
||||
return box_equals<Box, 2>::apply(box,
|
||||
lon_min, lat_min, height_min,
|
||||
lon_max, lat_max, height_max,
|
||||
tol)
|
||||
&& bg::get<0, 2>(box) == height_min
|
||||
&& bg::get<1, 2>(box) == height_max;
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -136,48 +272,22 @@ struct box_equals
|
||||
{
|
||||
static inline bool apply(Box1 const& box1, Box2 const& box2, double tol)
|
||||
{
|
||||
equals_with_tolerance equals(tol);
|
||||
|
||||
#ifndef BOOST_GEOMETRY_TEST_ENABLE_FAILING
|
||||
// check latitude with tolerance when necessary
|
||||
return bg::math::equals(bg::get<0, 0>(box1), bg::get<0, 0>(box2))
|
||||
&& (bg::get<0, 1>(box1) < 0
|
||||
? equals(bg::get<0, 1>(box1), bg::get<0, 1>(box2))
|
||||
: bg::math::equals(bg::get<0, 1>(box1), bg::get<0, 1>(box2)))
|
||||
&& bg::math::equals(bg::get<1, 0>(box1), bg::get<1, 0>(box2))
|
||||
&& (bg::get<1, 1>(box1) > 0
|
||||
? equals(bg::get<1, 1>(box1), bg::get<1, 1>(box2))
|
||||
: bg::math::equals(bg::get<1, 1>(box1), bg::get<1, 1>(box2)));
|
||||
#else
|
||||
// check latitude with tolerance when necessary
|
||||
return bg::get<0, 0>(box1) == bg::get<0, 0>(box2)
|
||||
&& (bg::get<0, 1>(box1) < 0
|
||||
? equals(bg::get<0, 1>(box1), bg::get<0, 1>(box2))
|
||||
: bg::get<0, 1>(box1) == bg::get<0, 1>(box2))
|
||||
&& bg::get<1, 0>(box1) == bg::get<1, 0>(box2)
|
||||
&& (bg::get<1, 1>(box1) > 0
|
||||
? equals(bg::get<1, 1>(box1), bg::get<1, 1>(box2))
|
||||
: bg::get<1, 1>(box1) == bg::get<1, 1>(box2));
|
||||
#endif
|
||||
return box_check_equals<Box1>::apply(box1,
|
||||
bg::get<0, 0>(box2), bg::get<0, 1>(box2), 0.0,
|
||||
bg::get<1, 0>(box2), bg::get<1, 1>(box2), 0.0,
|
||||
tol);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Box1, typename Box2>
|
||||
template<typename Box1, typename Box2>
|
||||
struct box_equals<Box1, Box2, 3>
|
||||
{
|
||||
static inline bool apply(Box1 const& box1, Box2 const& box2, double tol)
|
||||
{
|
||||
#ifndef BOOST_GEOMETRY_TEST_ENABLE_FAILING
|
||||
equals_with_tolerance equals(tol);
|
||||
|
||||
return box_equals<Box1, Box2, 2>::apply(box1, box2, tol)
|
||||
&& equals(bg::get<0, 2>(box1), bg::get<0, 2>(box2))
|
||||
&& equals(bg::get<1, 2>(box1), bg::get<1, 2>(box2));
|
||||
#else
|
||||
return box_equals<Box1, Box2, 2>::apply(box1, box2, tol)
|
||||
&& bg::get<0, 2>(box1) == bg::get<0, 2>(box2)
|
||||
&& bg::get<1, 2>(box1) == bg::get<1, 2>(box2);
|
||||
#endif
|
||||
return box_check_equals<Box1>::apply(box1,
|
||||
bg::get<0, 0>(box2), bg::get<0, 1>(box2), bg::get<0, 2>(box2),
|
||||
bg::get<1, 0>(box2), bg::get<1, 1>(box2), bg::get<1, 2>(box2),
|
||||
tol);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// Unit Test
|
||||
|
||||
// Copyright (c) 2014-2015, Oracle and/or its affiliates.
|
||||
// Copyright (c) 2014-2017, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Licensed under the Boost Software License version 1.0.
|
||||
// http://www.boost.org/users/license.html
|
||||
@@ -63,7 +64,7 @@ typedef bg::model::box<point_type> box_type;
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
template <typename Geometry>
|
||||
template <typename CSTag, typename Geometry>
|
||||
void test_simple(Geometry const& geometry, bool expected_result,
|
||||
bool check_validity = true)
|
||||
{
|
||||
@@ -72,12 +73,22 @@ void test_simple(Geometry const& geometry, bool expected_result,
|
||||
#endif
|
||||
|
||||
bool simple = bg::is_simple(geometry);
|
||||
|
||||
BOOST_ASSERT( ! check_validity || bg::is_valid(geometry) );
|
||||
BOOST_CHECK_MESSAGE( simple == expected_result,
|
||||
"Expected: " << expected_result
|
||||
<< " detected: " << simple
|
||||
<< " wkt: " << bg::wkt(geometry) );
|
||||
|
||||
typedef typename bg::strategy::intersection::services::default_strategy
|
||||
<
|
||||
CSTag
|
||||
>::type strategy_type;
|
||||
|
||||
bool simple_s = bg::is_simple(geometry, strategy_type());
|
||||
|
||||
BOOST_CHECK_EQUAL(simple, simple_s);
|
||||
|
||||
#ifdef BOOST_GEOMETRY_TEST_DEBUG
|
||||
std::cout << "Geometry: ";
|
||||
pretty_print_geometry<Geometry>::apply(std::cout, geometry);
|
||||
@@ -92,6 +103,26 @@ void test_simple(Geometry const& geometry, bool expected_result,
|
||||
}
|
||||
|
||||
|
||||
template <typename Geometry>
|
||||
void test_simple(Geometry const& geometry,
|
||||
bool expected_result,
|
||||
bool check_validity = true)
|
||||
{
|
||||
typedef typename bg::cs_tag<Geometry>::type cs_tag;
|
||||
test_simple<cs_tag>(geometry, expected_result, check_validity);
|
||||
}
|
||||
|
||||
template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
|
||||
void test_simple(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& variant_geometry,
|
||||
bool expected_result,
|
||||
bool check_validity = true)
|
||||
{
|
||||
typedef typename bg::cs_tag<T0>::type cs_tag;
|
||||
test_simple<cs_tag>(variant_geometry, expected_result, check_validity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ template <typename P>
|
||||
void test_vincenty()
|
||||
{
|
||||
typename geo_strategies<P>::vincenty_type vincenty;
|
||||
test_with_strategy<P>(1116828.8624 + 1116161.625, vincenty);
|
||||
test_with_strategy<P>(1116825.857 + 1116159.144, vincenty);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
|
||||
@@ -83,7 +83,7 @@ template <typename P>
|
||||
void test_vincenty()
|
||||
{
|
||||
typename geo_strategies<P>::vincenty_type vincenty;
|
||||
test_with_strategy<P>(1116828.8624 + 1116161.625, vincenty);
|
||||
test_with_strategy<P>(1116825.857 + 1116159.144, vincenty);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2016.
|
||||
// Modifications copyright (c) 2016, Oracle and/or its affiliates.
|
||||
// This file was modified by Oracle on 2016, 2017.
|
||||
// Modifications copyright (c) 2016-2017, 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,
|
||||
@@ -131,20 +131,28 @@ std::string test_difference(std::string const& caseid, G1 const& g1, G2 const& g
|
||||
typedef typename bg::coordinate_type<G1>::type coordinate_type;
|
||||
boost::ignore_unused<coordinate_type>();
|
||||
|
||||
bg::model::multi_polygon<OutputType> result;
|
||||
bg::model::multi_polygon<OutputType> result, result_s;
|
||||
|
||||
typedef typename bg::strategy::relate::services::default_strategy
|
||||
<
|
||||
G1, G2
|
||||
>::type strategy_type;
|
||||
|
||||
if (sym)
|
||||
{
|
||||
bg::sym_difference(g1, g2, result);
|
||||
bg::sym_difference(g1, g2, result_s, strategy_type());
|
||||
}
|
||||
else
|
||||
{
|
||||
bg::difference(g1, g2, result);
|
||||
bg::difference(g1, g2, result_s, strategy_type());
|
||||
}
|
||||
|
||||
if (settings.remove_spikes)
|
||||
{
|
||||
bg::remove_spikes(result);
|
||||
bg::remove_spikes(result_s);
|
||||
}
|
||||
|
||||
std::ostringstream return_string;
|
||||
@@ -233,6 +241,8 @@ std::string test_difference(std::string const& caseid, G1 const& g1, G2 const& g
|
||||
}
|
||||
|
||||
BOOST_CHECK_CLOSE(area, expected_area, settings.percentage);
|
||||
|
||||
BOOST_CHECK_EQUAL(bg::num_points(result), bg::num_points(result_s));
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2014-2015, Oracle and/or its affiliates.
|
||||
// Copyright (c) 2014-2017, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Licensed under the Boost Software License version 1.0.
|
||||
// http://www.boost.org/users/license.html
|
||||
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
|
||||
#ifndef BOOST_GEOMETRY_TEST_DIFFERENCE_LINEAR_LINEAR_HPP
|
||||
#define BOOST_GEOMETRY_TEST_DIFFERENCE_LINEAR_LINEAR_HPP
|
||||
@@ -25,6 +26,23 @@
|
||||
//==================================================================
|
||||
//==================================================================
|
||||
|
||||
template <typename Geometry1, typename Geometry2, typename MultiLineString>
|
||||
inline void check_result(Geometry1 const& geometry1,
|
||||
Geometry2 const& geometry2,
|
||||
MultiLineString const& mls_output,
|
||||
MultiLineString const& mls_diff,
|
||||
std::string const& case_id,
|
||||
double tolerance)
|
||||
{
|
||||
BOOST_CHECK_MESSAGE( equals::apply(mls_diff, mls_output, tolerance),
|
||||
"case id: " << case_id
|
||||
<< ", difference L/L: " << bg::wkt(geometry1)
|
||||
<< " " << bg::wkt(geometry2)
|
||||
<< " -> Expected: " << bg::wkt(mls_diff)
|
||||
<< std::setprecision(20)
|
||||
<< " computed: " << bg::wkt(mls_output) );
|
||||
}
|
||||
|
||||
template
|
||||
<
|
||||
typename Geometry1, typename Geometry2,
|
||||
@@ -52,6 +70,22 @@ private:
|
||||
linestring_vector ls_vector_output;
|
||||
linestring_deque ls_deque_output;
|
||||
|
||||
// Check strategy passed explicitly
|
||||
typedef typename bg::strategy::relate::services::default_strategy
|
||||
<
|
||||
Geometry1, Geometry2
|
||||
>::type strategy_type;
|
||||
bg::difference(geometry1, geometry2, mls_output, strategy_type());
|
||||
|
||||
if (reverse_output_for_checking)
|
||||
{
|
||||
bg::reverse(mls_output);
|
||||
}
|
||||
|
||||
check_result(geometry1, geometry2, mls_output, mls_diff, case_id, tolerance);
|
||||
|
||||
// Check normal behaviour
|
||||
bg::clear(mls_output);
|
||||
bg::difference(geometry1, geometry2, mls_output);
|
||||
|
||||
if ( reverse_output_for_checking )
|
||||
@@ -59,14 +93,8 @@ private:
|
||||
bg::reverse(mls_output);
|
||||
}
|
||||
|
||||
BOOST_CHECK_MESSAGE( equals::apply(mls_diff, mls_output, tolerance),
|
||||
"case id: " << case_id
|
||||
<< ", difference L/L: " << bg::wkt(geometry1)
|
||||
<< " " << bg::wkt(geometry2)
|
||||
<< " -> Expected: " << bg::wkt(mls_diff)
|
||||
<< std::setprecision(20)
|
||||
<< " computed: " << bg::wkt(mls_output) );
|
||||
|
||||
check_result(geometry1, geometry2, mls_output, mls_diff, case_id, tolerance);
|
||||
|
||||
set_operation_output("difference", case_id,
|
||||
geometry1, geometry2, mls_output);
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2016.
|
||||
// Modifications copyright (c) 2016, Oracle and/or its affiliates.
|
||||
// This file was modified by Oracle on 2016, 2017.
|
||||
// Modifications copyright (c) 2016-2017, 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,
|
||||
@@ -189,6 +189,18 @@ typename bg::default_area_result<G1>::type test_intersection(std::string const&
|
||||
result_type intersection_output;
|
||||
bg::intersection(g1, g2, intersection_output);
|
||||
|
||||
check_result<G1, G2>(intersection_output, caseid, expected_count,
|
||||
expected_holes_count, expected_point_count, expected_length_or_area,
|
||||
settings);
|
||||
|
||||
// Check strategy passed explicitly
|
||||
typedef typename bg::strategy::relate::services::default_strategy
|
||||
<
|
||||
G1, G2
|
||||
>::type strategy_type;
|
||||
intersection_output.clear();
|
||||
bg::intersection(g1, g2, intersection_output, strategy_type());
|
||||
|
||||
check_result<G1, G2>(intersection_output, caseid, expected_count,
|
||||
expected_holes_count, expected_point_count, expected_length_or_area,
|
||||
settings);
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2014-2015, Oracle and/or its affiliates.
|
||||
// Copyright (c) 2014-2017, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Licensed under the Boost Software License version 1.0.
|
||||
// http://www.boost.org/users/license.html
|
||||
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
|
||||
#ifndef BOOST_GEOMETRY_TEST_INTERSECTION_LINEAR_LINEAR_HPP
|
||||
#define BOOST_GEOMETRY_TEST_INTERSECTION_LINEAR_LINEAR_HPP
|
||||
@@ -26,6 +27,25 @@
|
||||
//==================================================================
|
||||
//==================================================================
|
||||
|
||||
template <typename Geometry1, typename Geometry2, typename MultiLineString>
|
||||
inline void check_result(Geometry1 const& geometry1,
|
||||
Geometry2 const& geometry2,
|
||||
MultiLineString const& mls_output,
|
||||
MultiLineString const& mls_int1,
|
||||
MultiLineString const& mls_int2,
|
||||
std::string const& case_id,
|
||||
double tolerance)
|
||||
{
|
||||
BOOST_CHECK_MESSAGE( equals::apply(mls_int1, mls_output, tolerance)
|
||||
|| equals::apply(mls_int2, mls_output, tolerance),
|
||||
"case id: " << case_id
|
||||
<< ", intersection L/L: " << bg::wkt(geometry1)
|
||||
<< " " << bg::wkt(geometry2)
|
||||
<< " -> Expected: " << bg::wkt(mls_int1)
|
||||
<< " or: " << bg::wkt(mls_int2)
|
||||
<< " computed: " << bg::wkt(mls_output) );
|
||||
}
|
||||
|
||||
template
|
||||
<
|
||||
typename Geometry1, typename Geometry2,
|
||||
@@ -53,16 +73,20 @@ private:
|
||||
linestring_vector ls_vector_output;
|
||||
linestring_deque ls_deque_output;
|
||||
|
||||
// Check normal behaviour
|
||||
bg::intersection(geometry1, geometry2, mls_output);
|
||||
|
||||
BOOST_CHECK_MESSAGE( equals::apply(mls_int1, mls_output, tolerance)
|
||||
|| equals::apply(mls_int2, mls_output, tolerance),
|
||||
"case id: " << case_id
|
||||
<< ", intersection L/L: " << bg::wkt(geometry1)
|
||||
<< " " << bg::wkt(geometry2)
|
||||
<< " -> Expected: " << bg::wkt(mls_int1)
|
||||
<< " or: " << bg::wkt(mls_int2)
|
||||
<< " computed: " << bg::wkt(mls_output) );
|
||||
check_result(geometry1, geometry2, mls_output, mls_int1, mls_int2, case_id, tolerance);
|
||||
|
||||
// Check strategy passed explicitly
|
||||
typedef typename bg::strategy::relate::services::default_strategy
|
||||
<
|
||||
Geometry1, Geometry2
|
||||
>::type strategy_type;
|
||||
bg::clear(mls_output);
|
||||
bg::intersection(geometry1, geometry2, mls_output, strategy_type());
|
||||
|
||||
check_result(geometry1, geometry2, mls_output, mls_int1, mls_int2, case_id, tolerance);
|
||||
|
||||
set_operation_output("intersection", case_id,
|
||||
geometry1, geometry2, mls_output);
|
||||
@@ -109,14 +133,7 @@ private:
|
||||
bg::clear(mls_output);
|
||||
bg::intersection(geometry2, geometry1, mls_output);
|
||||
|
||||
BOOST_CHECK_MESSAGE( equals::apply(mls_int1, mls_output, tolerance)
|
||||
|| equals::apply(mls_int2, mls_output, tolerance),
|
||||
"case id: " << case_id
|
||||
<< ", intersection L/L: " << bg::wkt(geometry1)
|
||||
<< " " << bg::wkt(geometry2)
|
||||
<< " -> Expected: " << bg::wkt(mls_int1)
|
||||
<< " or: " << bg::wkt(mls_int2)
|
||||
<< " computed: " << bg::wkt(mls_output) );
|
||||
check_result(geometry1, geometry2, mls_output, mls_int1, mls_int2, case_id, tolerance);
|
||||
|
||||
#ifdef BOOST_GEOMETRY_TEST_DEBUG
|
||||
std::cout << "Geometry #1: " << bg::wkt(geometry2) << std::endl;
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2014-2015, Oracle and/or its affiliates.
|
||||
// Copyright (c) 2014-2017, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Licensed under the Boost Software License version 1.0.
|
||||
// http://www.boost.org/users/license.html
|
||||
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
|
||||
#ifndef BOOST_GEOMETRY_TEST_SYM_DIFFERENCE_LINEAR_LINEAR_HPP
|
||||
#define BOOST_GEOMETRY_TEST_SYM_DIFFERENCE_LINEAR_LINEAR_HPP
|
||||
@@ -24,6 +25,22 @@
|
||||
//==================================================================
|
||||
//==================================================================
|
||||
|
||||
template <typename Geometry1, typename Geometry2, typename MultiLineString>
|
||||
inline void check_result(Geometry1 const& geometry1,
|
||||
Geometry2 const& geometry2,
|
||||
MultiLineString const& mls_output,
|
||||
MultiLineString const& mls_sym_diff,
|
||||
std::string const& case_id,
|
||||
double tolerance)
|
||||
{
|
||||
BOOST_CHECK_MESSAGE( equals::apply(mls_sym_diff, mls_output, tolerance),
|
||||
"case id: " << case_id
|
||||
<< ", sym diff L/L: " << bg::wkt(geometry1)
|
||||
<< " " << bg::wkt(geometry2)
|
||||
<< " -> Expected: " << bg::wkt(mls_sym_diff)
|
||||
<< " computed: " << bg::wkt(mls_output) );
|
||||
}
|
||||
|
||||
template
|
||||
<
|
||||
typename Geometry1, typename Geometry2,
|
||||
@@ -50,15 +67,20 @@ private:
|
||||
linestring_vector ls_vector_output;
|
||||
linestring_deque ls_deque_output;
|
||||
|
||||
// Check strategy passed explicitly
|
||||
typedef typename bg::strategy::relate::services::default_strategy
|
||||
<
|
||||
Geometry1, Geometry2
|
||||
>::type strategy_type;
|
||||
bg::sym_difference(geometry1, geometry2, mls_output, strategy_type());
|
||||
|
||||
check_result(geometry1, geometry2, mls_output, mls_sym_diff, case_id, tolerance);
|
||||
|
||||
// Check normal behaviour
|
||||
bg::clear(mls_output);
|
||||
bg::sym_difference(geometry1, geometry2, mls_output);
|
||||
|
||||
BOOST_CHECK_MESSAGE( equals::apply(mls_sym_diff, mls_output, tolerance),
|
||||
"case id: " << case_id
|
||||
<< ", sym diff L/L: " << bg::wkt(geometry1)
|
||||
<< " " << bg::wkt(geometry2)
|
||||
<< " -> Expected: " << bg::wkt(mls_sym_diff)
|
||||
<< " computed: " << bg::wkt(mls_output) );
|
||||
|
||||
check_result(geometry1, geometry2, mls_output, mls_sym_diff, case_id, tolerance);
|
||||
|
||||
set_operation_output("sym_difference", case_id,
|
||||
geometry1, geometry2, mls_output);
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2015, 2016.
|
||||
// Modifications copyright (c) 2015-2016 Oracle and/or its affiliates.
|
||||
// This file was modified by Oracle on 2015, 2016, 2017.
|
||||
// Modifications copyright (c) 2015-2017 Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
@@ -70,6 +70,18 @@ inline void check_input_validity(std::string const& caseid, int case_index,
|
||||
}
|
||||
#endif
|
||||
|
||||
template <typename Range>
|
||||
inline std::size_t num_points(Range const& rng, bool add_for_open = false)
|
||||
{
|
||||
std::size_t result = 0;
|
||||
for (typename boost::range_iterator<Range const>::type it = boost::begin(rng);
|
||||
it != boost::end(rng); ++it)
|
||||
{
|
||||
result += bg::num_points(*it, add_for_open);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename OutputType, typename G1, typename G2>
|
||||
void test_union(std::string const& caseid, G1 const& g1, G2 const& g2,
|
||||
int expected_count, int expected_hole_count,
|
||||
@@ -82,7 +94,7 @@ void test_union(std::string const& caseid, G1 const& g1, G2 const& g2,
|
||||
|
||||
// Declare output (vector of rings or multi_polygon)
|
||||
typedef typename setop_output_type<OutputType>::type result_type;
|
||||
result_type clip;
|
||||
result_type clip, clip_s;
|
||||
|
||||
#if defined(BOOST_GEOMETRY_DEBUG_ROBUSTNESS)
|
||||
std::cout << "*** UNION " << caseid << std::endl;
|
||||
@@ -93,8 +105,16 @@ void test_union(std::string const& caseid, G1 const& g1, G2 const& g2,
|
||||
check_input_validity(caseid, 1, g2);
|
||||
#endif
|
||||
|
||||
// Check normal behaviour
|
||||
bg::union_(g1, g2, clip);
|
||||
|
||||
// Check strategy passed explicitly
|
||||
typedef typename bg::strategy::intersection::services::default_strategy
|
||||
<
|
||||
typename bg::cs_tag<OutputType>::type
|
||||
>::type strategy_type;
|
||||
bg::union_(g1, g2, clip_s, strategy_type());
|
||||
|
||||
typename bg::default_area_result<OutputType>::type area = 0;
|
||||
std::size_t n = 0;
|
||||
std::size_t holes = 0;
|
||||
@@ -178,6 +198,8 @@ void test_union(std::string const& caseid, G1 const& g1, G2 const& g2,
|
||||
|
||||
BOOST_CHECK_CLOSE(area, expected_area, settings.percentage);
|
||||
|
||||
BOOST_CHECK_EQUAL(num_points(clip), num_points(clip_s));
|
||||
|
||||
#if defined(TEST_WITH_SVG)
|
||||
{
|
||||
bool const ccw =
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2014-2015, Oracle and/or its affiliates.
|
||||
// Copyright (c) 2014-2017, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Licensed under the Boost Software License version 1.0.
|
||||
// http://www.boost.org/users/license.html
|
||||
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
|
||||
#ifndef BOOST_GEOMETRY_TEST_UNION_LINEAR_LINEAR_HPP
|
||||
#define BOOST_GEOMETRY_TEST_UNION_LINEAR_LINEAR_HPP
|
||||
@@ -24,6 +25,22 @@
|
||||
//==================================================================
|
||||
//==================================================================
|
||||
|
||||
template <typename Geometry1, typename Geometry2, typename MultiLineString>
|
||||
inline void check_result(Geometry1 const& geometry1,
|
||||
Geometry2 const& geometry2,
|
||||
MultiLineString const& mls_output,
|
||||
MultiLineString const& mls_union,
|
||||
std::string const& case_id,
|
||||
double tolerance)
|
||||
{
|
||||
BOOST_CHECK_MESSAGE( equals::apply(mls_union, mls_output, tolerance),
|
||||
"case id: " << case_id
|
||||
<< ", union L/L: " << bg::wkt(geometry1)
|
||||
<< " " << bg::wkt(geometry2)
|
||||
<< " -> Expected: " << bg::wkt(mls_union)
|
||||
<< " computed: " << bg::wkt(mls_output) );
|
||||
}
|
||||
|
||||
template
|
||||
<
|
||||
typename Geometry1, typename Geometry2,
|
||||
@@ -51,14 +68,20 @@ private:
|
||||
linestring_vector ls_vector_output;
|
||||
linestring_deque ls_deque_output;
|
||||
|
||||
// Check strategy passed explicitly
|
||||
typedef typename bg::strategy::relate::services::default_strategy
|
||||
<
|
||||
Geometry1, Geometry2
|
||||
>::type strategy_type;
|
||||
bg::union_(geometry1, geometry2, mls_output, strategy_type());
|
||||
|
||||
check_result(geometry1, geometry2, mls_output, mls_union1, case_id, tolerance);
|
||||
|
||||
// Check normal behaviour
|
||||
bg::clear(mls_output);
|
||||
bg::union_(geometry1, geometry2, mls_output);
|
||||
|
||||
BOOST_CHECK_MESSAGE( equals::apply(mls_union1, mls_output, tolerance),
|
||||
"case id: " << case_id
|
||||
<< ", union L/L: " << bg::wkt(geometry1)
|
||||
<< " " << bg::wkt(geometry2)
|
||||
<< " -> Expected: " << bg::wkt(mls_union1)
|
||||
<< " computed: " << bg::wkt(mls_output) );
|
||||
check_result(geometry1, geometry2, mls_output, mls_union1, case_id, tolerance);
|
||||
|
||||
set_operation_output("union", case_id,
|
||||
geometry1, geometry2, mls_output);
|
||||
@@ -101,17 +124,12 @@ private:
|
||||
#endif
|
||||
}
|
||||
|
||||
// check the symmetric difference where the order of the two
|
||||
// check the union where the order of the two
|
||||
// geometries is reversed
|
||||
bg::clear(mls_output);
|
||||
bg::union_(geometry2, geometry1, mls_output);
|
||||
|
||||
BOOST_CHECK_MESSAGE( equals::apply(mls_union2, mls_output, tolerance),
|
||||
"case id: " << case_id
|
||||
<< ", union L/L: " << bg::wkt(geometry2)
|
||||
<< " " << bg::wkt(geometry1)
|
||||
<< " -> Expected: " << bg::wkt(mls_union2)
|
||||
<< " computed: " << bg::wkt(mls_output) );
|
||||
check_result(geometry1, geometry2, mls_output, mls_union2, case_id, tolerance);
|
||||
|
||||
#ifdef BOOST_GEOMETRY_TEST_DEBUG
|
||||
std::cout << "Geometry #1: " << bg::wkt(geometry2) << std::endl;
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// Unit Test
|
||||
|
||||
// Copyright (c) 2014-2015, Oracle and/or its affiliates.
|
||||
// Copyright (c) 2014-2017, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Licensed under the Boost Software License version 1.0.
|
||||
// http://www.boost.org/users/license.html
|
||||
@@ -287,7 +288,7 @@ struct validity_tester_linear
|
||||
{
|
||||
bool const irrelevant = true;
|
||||
bg::is_valid_default_policy<irrelevant, AllowSpikes> visitor;
|
||||
return bg::is_valid(geometry, visitor);
|
||||
return bg::is_valid(geometry, visitor, bg::default_strategy());
|
||||
}
|
||||
|
||||
template <typename Geometry>
|
||||
@@ -296,7 +297,7 @@ struct validity_tester_linear
|
||||
bool const irrelevant = true;
|
||||
std::ostringstream oss;
|
||||
bg::failing_reason_policy<irrelevant, AllowSpikes> visitor(oss);
|
||||
bg::is_valid(geometry, visitor);
|
||||
bg::is_valid(geometry, visitor, bg::default_strategy());
|
||||
return oss.str();
|
||||
}
|
||||
};
|
||||
@@ -309,7 +310,7 @@ struct validity_tester_areal
|
||||
static inline bool apply(Geometry const& geometry)
|
||||
{
|
||||
bg::is_valid_default_policy<AllowDuplicates> visitor;
|
||||
return bg::is_valid(geometry, visitor);
|
||||
return bg::is_valid(geometry, visitor, bg::default_strategy());
|
||||
}
|
||||
|
||||
template <typename Geometry>
|
||||
@@ -317,7 +318,7 @@ struct validity_tester_areal
|
||||
{
|
||||
std::ostringstream oss;
|
||||
bg::failing_reason_policy<AllowDuplicates> visitor(oss);
|
||||
bg::is_valid(geometry, visitor);
|
||||
bg::is_valid(geometry, visitor, bg::default_strategy());
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user