Merge branch 'bg-prepare'

This commit is contained in:
Adam Wulkiewicz 2019-03-28 04:47:42 +01:00
commit 737310e094
50 changed files with 716 additions and 439 deletions

View File

@ -30,6 +30,7 @@
[*Bugfixes]
* [@https://github.com/boostorg/geometry/pull/553 553] Pass spheroid correctly in geographic comparable strategies.
* [@https://github.com/boostorg/geometry/pull/571 571] Fix nan result in geographic distance.
[/=================]
[heading Boost 1.69]

View File

@ -37,52 +37,12 @@
#include <boost/geometry/geometries/box.hpp>
#include <boost/geometry/util/math.hpp>
#include <boost/geometry/algorithms/detail/buffer/buffer_box.hpp>
#include <boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace buffer
{
template <typename BoxIn, typename BoxOut, typename T, std::size_t C, std::size_t D, std::size_t N>
struct box_loop
{
typedef typename coordinate_type<BoxOut>::type coordinate_type;
static inline void apply(BoxIn const& box_in, T const& distance, BoxOut& box_out)
{
coordinate_type d = distance;
set<C, D>(box_out, get<C, D>(box_in) + d);
box_loop<BoxIn, BoxOut, T, C, D + 1, N>::apply(box_in, distance, box_out);
}
};
template <typename BoxIn, typename BoxOut, typename T, std::size_t C, std::size_t N>
struct box_loop<BoxIn, BoxOut, T, C, N, N>
{
static inline void apply(BoxIn const&, T const&, BoxOut&) {}
};
// Extends a box with the same amount in all directions
template<typename BoxIn, typename BoxOut, typename T>
inline void buffer_box(BoxIn const& box_in, T const& distance, BoxOut& box_out)
{
assert_dimension_equal<BoxIn, BoxOut>();
static const std::size_t N = dimension<BoxIn>::value;
box_loop<BoxIn, BoxOut, T, min_corner, 0, N>::apply(box_in, -distance, box_out);
box_loop<BoxIn, BoxOut, T, max_corner, 0, N>::apply(box_in, distance, box_out);
}
}} // namespace detail::buffer
#endif // DOXYGEN_NO_DETAIL
#ifndef DOXYGEN_NO_DISPATCH
namespace dispatch
{

View File

@ -0,0 +1,62 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2018-2019 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_BUFFER_BOX_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_BUFFER_BOX_HPP
#include <cstddef>
#include <boost/geometry/core/coordinate_dimension.hpp>
#include <boost/geometry/core/coordinate_type.hpp>
#include <boost/geometry/core/access.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace buffer
{
template <typename BoxIn, typename BoxOut, typename T, std::size_t C, std::size_t D, std::size_t N>
struct box_loop
{
typedef typename coordinate_type<BoxOut>::type coordinate_type;
static inline void apply(BoxIn const& box_in, T const& distance, BoxOut& box_out)
{
coordinate_type d = distance;
set<C, D>(box_out, get<C, D>(box_in) + d);
box_loop<BoxIn, BoxOut, T, C, D + 1, N>::apply(box_in, distance, box_out);
}
};
template <typename BoxIn, typename BoxOut, typename T, std::size_t C, std::size_t N>
struct box_loop<BoxIn, BoxOut, T, C, N, N>
{
static inline void apply(BoxIn const&, T const&, BoxOut&) {}
};
// Extends a box with the same amount in all directions
template<typename BoxIn, typename BoxOut, typename T>
inline void buffer_box(BoxIn const& box_in, T const& distance, BoxOut& box_out)
{
assert_dimension_equal<BoxIn, BoxOut>();
static const std::size_t N = dimension<BoxIn>::value;
box_loop<BoxIn, BoxOut, T, min_corner, 0, N>::apply(box_in, -distance, box_out);
box_loop<BoxIn, BoxOut, T, max_corner, 0, N>::apply(box_in, distance, box_out);
}
}} // namespace detail::buffer
#endif // DOXYGEN_NO_DETAIL
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_BUFFER_BOX_HPP

View File

@ -20,6 +20,7 @@
#include <boost/range.hpp>
#include <boost/geometry/core/assert.hpp>
#include <boost/geometry/core/config.hpp>
#include <boost/geometry/arithmetic/dot_product.hpp>
#include <boost/geometry/algorithms/assign.hpp>
@ -127,13 +128,13 @@ inline bool in_box(Point const& previous,
template <typename Tag>
struct use_side_of_intersection {};
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
template <>
struct use_side_of_intersection<cartesian_tag> { static bool const value = false; };
#else
#if defined(BOOST_GEOMETRY_USE_RESCALING)
// With rescaling, let Cartesian use side-of-intersection
template <>
struct use_side_of_intersection<cartesian_tag> { static bool const value = true; };
#else
template <>
struct use_side_of_intersection<cartesian_tag> { static bool const value = false; };
#endif
template <>

View File

@ -5,8 +5,8 @@
// Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland.
// This file was modified by Oracle on 2013-2017.
// Modifications copyright (c) 2013-2017, Oracle and/or its affiliates.
// This file was modified by Oracle on 2013-2019.
// Modifications copyright (c) 2013-2019, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
@ -28,6 +28,9 @@
#include <boost/geometry/algorithms/detail/point_on_border.hpp>
#include <boost/geometry/algorithms/detail/disjoint/linear_linear.hpp>
#include <boost/geometry/algorithms/detail/disjoint/segment_box.hpp>
#include <boost/geometry/iterators/segment_iterator.hpp>
namespace boost { namespace geometry
@ -38,30 +41,15 @@ namespace boost { namespace geometry
namespace detail { namespace disjoint
{
template <typename Geometry, typename Tag = typename tag<Geometry>::type>
struct check_each_ring_for_within_call_covered_by
template <typename Geometry1, typename Geometry2, typename Strategy>
inline bool point_on_border_covered_by(Geometry1 const& geometry1,
Geometry2 const& geometry2,
Strategy const& strategy)
{
/*!
\tparam Strategy point_in_geometry strategy
*/
template <typename Point, typename Strategy>
static inline bool apply(Point const& p, Geometry const& g, Strategy const& strategy)
{
return geometry::covered_by(p, g, strategy);
}
};
template <typename Geometry>
struct check_each_ring_for_within_call_covered_by<Geometry, box_tag>
{
template <typename Point, typename Strategy>
static inline bool apply(Point const& p, Geometry const& g, Strategy const& )
{
return geometry::covered_by(p, g);
}
};
typename geometry::point_type<Geometry1>::type pt;
return geometry::point_on_border(pt, geometry1)
&& geometry::covered_by(pt, geometry2, strategy);
}
/*!
\tparam Strategy point_in_geometry strategy
@ -83,13 +71,8 @@ struct check_each_ring_for_within
template <typename Range>
inline void apply(Range const& range)
{
typename point_type<Range>::type pt;
not_disjoint = not_disjoint
|| ( geometry::point_on_border(pt, range)
&& check_each_ring_for_within_call_covered_by
<
Geometry
>::apply(pt, m_geometry, m_strategy) );
|| point_on_border_covered_by(range, m_geometry, m_strategy);
}
};
@ -113,7 +96,7 @@ inline bool rings_containing(FirstGeometry const& geometry1,
template <typename Geometry1, typename Geometry2>
struct general_areal
struct areal_areal
{
/*!
\tparam Strategy relate (segments intersection) strategy
@ -147,6 +130,56 @@ struct general_areal
};
template <typename Areal, typename Box>
struct areal_box
{
/*!
\tparam Strategy relate (segments intersection) strategy
*/
template <typename Strategy>
static inline bool apply(Areal const& areal,
Box const& box,
Strategy const& strategy)
{
if ( ! for_each_segment(geometry::segments_begin(areal),
geometry::segments_end(areal),
box,
strategy.get_disjoint_segment_box_strategy()) )
{
return false;
}
// If there is no intersection of any segment and box,
// the box might be located inside areal geometry
if ( point_on_border_covered_by(box, areal,
strategy.template get_point_in_geometry_strategy<Box, Areal>()) )
{
return false;
}
return true;
}
private:
template <typename SegIter, typename Strategy>
static inline bool for_each_segment(SegIter first,
SegIter last,
Box const& box,
Strategy const& strategy)
{
for ( ; first != last ; ++first)
{
if (! disjoint_segment_box::apply(*first, box, strategy))
{
return false;
}
}
return true;
}
};
}} // namespace detail::disjoint
#endif // DOXYGEN_NO_DETAIL
@ -160,13 +193,13 @@ namespace dispatch
template <typename Areal1, typename Areal2>
struct disjoint<Areal1, Areal2, 2, areal_tag, areal_tag, false>
: detail::disjoint::general_areal<Areal1, Areal2>
: detail::disjoint::areal_areal<Areal1, Areal2>
{};
template <typename Areal, typename Box>
struct disjoint<Areal, Box, 2, areal_tag, box_tag, false>
: detail::disjoint::general_areal<Areal, Box>
: detail::disjoint::areal_box<Areal, Box>
{};

View File

@ -5,8 +5,8 @@
// Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland.
// This file was modified by Oracle on 2013-2018.
// Modifications copyright (c) 2013-2018, Oracle and/or its affiliates.
// This file was modified by Oracle on 2013-2019.
// Modifications copyright (c) 2013-2019, Oracle and/or its affiliates.
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
@ -152,23 +152,15 @@ struct disjoint_segment_box_sphere_or_spheroid
std::swap(lat1, lat2);
}
//Compute alp1 outside envelope and pass it to envelope_segment_impl
//in order for it to be used later in the algorithm
CT alp1;
azimuth_strategy.apply(lon1, lat1, lon2, lat2, alp1);
geometry::model::box<segment_point_type> box_seg;
// TODO: Shouldn't CSTag be taken from the caller, not from the segment?
strategy::envelope::detail::envelope_segment_impl
<
segment_cs_type
CS_Tag
>::template apply<geometry::radian>(lon1, lat1,
lon2, lat2,
box_seg,
azimuth_strategy,
alp1);
azimuth_strategy);
if (disjoint_box_box(box, box_seg, disjoint_box_box_strategy))
{
@ -177,13 +169,14 @@ struct disjoint_segment_box_sphere_or_spheroid
// Case 3: test intersection by comparing angles
CT a_b0, a_b1, a_b2, a_b3;
CT alp1, a_b0, a_b1, a_b2, a_b3;
CT b_lon_min = geometry::get_as_radian<geometry::min_corner, 0>(box);
CT b_lat_min = geometry::get_as_radian<geometry::min_corner, 1>(box);
CT b_lon_max = geometry::get_as_radian<geometry::max_corner, 0>(box);
CT b_lat_max = geometry::get_as_radian<geometry::max_corner, 1>(box);
azimuth_strategy.apply(lon1, lat1, lon2, lat2, alp1);
azimuth_strategy.apply(lon1, lat1, b_lon_min, b_lat_min, a_b0);
azimuth_strategy.apply(lon1, lat1, b_lon_max, b_lat_min, a_b1);
azimuth_strategy.apply(lon1, lat1, b_lon_min, b_lat_max, a_b2);

View File

@ -17,4 +17,10 @@
#define BOOST_GEOMETRY_CXX11_ARRAY_UNIFIED_INITIALIZATION
#endif
// Rescaling is turned on, unless NO_ROBUSTNESS is defined
// In future versions of Boost.Geometry, it will be turned off by default
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
#define BOOST_GEOMETRY_USE_RESCALING
#endif
#endif // BOOST_GEOMETRY_CORE_CONFIG_HPP

View File

@ -1,6 +1,6 @@
// Boost.Geometry
// Copyright (c) 2016-2017 Oracle and/or its affiliates.
// Copyright (c) 2016-2019 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
@ -70,10 +70,11 @@ public:
// equator
if (math::equals(sin_bet1, c0) && math::equals(sin_bet2, c0))
{
CT const sig_12 = math::abs(dlon) / one_minus_f;
CT const sig_12 = dlon / one_minus_f;
if (BOOST_GEOMETRY_CONDITION(EnableReducedLength))
{
CT m12 = sin(sig_12) * b;
int azi_sign = math::sign(azimuth) >= 0 ? 1 : -1; // for antipodal
CT m12 = azi_sign * sin(sig_12) * b;
reduced_length = m12;
}

View File

@ -19,7 +19,6 @@ template <typename CalculationType>
class interpolate_point_spherical
{
typedef model::point<CalculationType, 3, cs::cartesian> point3d_t;
CalculationType const c1 = 1;
public :
@ -38,7 +37,7 @@ public :
void compute_axis(Point const& p0,
CalculationType const& angle01)
{
CalculationType const c0 = 0;
CalculationType const c0 = 0, c1 = 1;
CalculationType const pi = math::pi<CalculationType>();
if (! math::equals(angle01, pi))
@ -73,6 +72,8 @@ public :
template <typename Point>
void compute_point(CalculationType const& a, Point& p)
{
CalculationType const c1 = 1;
// Axis-Angle rotation
// see: https://en.wikipedia.org/wiki/Axis-angle_representation
CalculationType const cos_a = cos(a);

View File

@ -88,15 +88,6 @@ public:
Azi azi12 = azimuth12;
math::normalize_azimuth<degree, Azi>(azi12);
Dist const dist_c0 = 0;
if (math::equals(distance, dist_c0) || distance < dist_c0)
{
result.lon2 = lon1;
result.lat2 = lat1;
return result;
}
CT const c0 = 0;
CT const c1 = 1;
CT const c2 = 2;

View File

@ -67,13 +67,6 @@ public:
CT const lon1 = lo1;
CT const lat1 = la1;
if ( math::equals(distance, Dist(0)) || distance < Dist(0) )
{
result.lon2 = lon1;
result.lat2 = lat1;
return result;
}
CT const c0 = 0;
CT const c1 = 1;
CT const c2 = 2;

View File

@ -74,13 +74,6 @@ public:
CT const lon1 = lo1;
CT const lat1 = la1;
if ( math::equals(distance, Dist(0)) || distance < Dist(0) )
{
result.lon2 = lon1;
result.lat2 = lat1;
return result;
}
CT const radius_a = CT(get_radius<0>(spheroid));
CT const radius_b = CT(get_radius<2>(spheroid));
CT const flattening = formula::flattening<CT>(spheroid);

View File

@ -25,6 +25,7 @@
#include <boost/type_traits/is_same.hpp>
#include <boost/geometry/core/assert.hpp>
#include <boost/geometry/core/config.hpp>
#include <boost/geometry/core/tag_cast.hpp>
#include <boost/geometry/algorithms/envelope.hpp>
@ -249,9 +250,7 @@ struct rescale_policy_type
: public detail::get_rescale_policy::rescale_policy_type
<
Point,
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
false
#else
#if defined(BOOST_GEOMETRY_USE_RESCALING)
boost::is_floating_point
<
typename geometry::coordinate_type<Point>::type
@ -262,6 +261,8 @@ struct rescale_policy_type
typename geometry::coordinate_system<Point>::type,
geometry::cs::cartesian
>::value
#else
false
#endif
>
{

View File

@ -3,8 +3,8 @@
// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2013-2017 Adam Wulkiewicz, Lodz, Poland.
// This file was modified by Oracle on 2014, 2016, 2017, 2018.
// Modifications copyright (c) 2014-2018, Oracle and/or its affiliates.
// This file was modified by Oracle on 2014, 2016, 2017, 2018, 2019.
// Modifications copyright (c) 2014-2019, 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
@ -35,6 +35,7 @@
#include <boost/geometry/strategies/cartesian/area.hpp>
#include <boost/geometry/strategies/cartesian/disjoint_box_box.hpp>
#include <boost/geometry/strategies/cartesian/disjoint_segment_box.hpp>
#include <boost/geometry/strategies/cartesian/distance_pythagoras.hpp>
#include <boost/geometry/strategies/cartesian/envelope.hpp>
#include <boost/geometry/strategies/cartesian/expand_box.hpp>
@ -171,6 +172,13 @@ struct cartesian_segments
return disjoint_box_box_strategy_type();
}
typedef disjoint::segment_box disjoint_segment_box_strategy_type;
static inline disjoint_segment_box_strategy_type get_disjoint_segment_box_strategy()
{
return disjoint_segment_box_strategy_type();
}
typedef covered_by::cartesian_point_box disjoint_point_box_strategy_type;
typedef expand::cartesian_box expand_box_strategy_type;

View File

@ -409,7 +409,7 @@ private :
return non_iterative_case(lon2, lat2, lon3, lat3, spheroid);
}
// Guess s14 (SPHERICAL)
// Guess s14 (SPHERICAL) aka along-track distance
typedef geometry::model::point
<
CT, 2,
@ -425,7 +425,12 @@ private :
geometry::strategy::distance::haversine<CT> str(earth_radius);
CT s13 = str.apply(p1, p3);
CT s14 = acos( cos(s13/earth_radius) / cos(s34/earth_radius) ) * earth_radius;
//CT s14 = acos( cos(s13/earth_radius) / cos(s34/earth_radius) ) * earth_radius;
CT cos_frac = cos(s13/earth_radius) / cos(s34/earth_radius);
CT s14 = cos_frac >= 1 ? CT(0)
: cos_frac <= -1 ? pi * earth_radius
: acos(cos_frac) * earth_radius;
#ifdef BOOST_GEOMETRY_DEBUG_GEOGRAPHIC_CROSS_TRACK
std::cout << "s34=" << s34 << std::endl;

View File

@ -37,6 +37,7 @@
#include <boost/geometry/srs/spheroid.hpp>
#include <boost/geometry/strategies/geographic/area.hpp>
#include <boost/geometry/strategies/geographic/disjoint_segment_box.hpp>
#include <boost/geometry/strategies/geographic/distance.hpp>
#include <boost/geometry/strategies/geographic/envelope.hpp>
#include <boost/geometry/strategies/geographic/parameters.hpp>
@ -181,6 +182,16 @@ struct geographic_segments
return disjoint_box_box_strategy_type();
}
typedef disjoint::segment_box_geographic
<
FormulaPolicy, Spheroid, CalculationType
> disjoint_segment_box_strategy_type;
inline disjoint_segment_box_strategy_type get_disjoint_segment_box_strategy() const
{
return disjoint_segment_box_strategy_type(m_spheroid);
}
typedef covered_by::spherical_point_box disjoint_point_box_strategy_type;
typedef expand::spherical_box expand_box_strategy_type;

View File

@ -100,6 +100,12 @@ struct generic_segment_box
CT lon2 = geometry::get_as_radian<0>(p1);
CT lat2 = geometry::get_as_radian<1>(p1);
if (lon1 > lon2)
{
std::swap(lon1, lon2);
std::swap(lat1, lat2);
}
CT vertex_lat;
CT lat_sum = lat1 + lat2;
if (lat_sum > CT(0))

View File

@ -337,26 +337,6 @@ private:
compute_box_corners<Units>(lon1, lat1, lon2, lat2, alp1, alp2, strategy);
}
template <typename Units, typename CalculationType, typename Strategy>
static inline void apply(CalculationType& lon1,
CalculationType& lat1,
CalculationType& lon2,
CalculationType& lat2,
Strategy const& strategy,
CalculationType alp1)
{
special_cases<Units>(lon1, lat1, lon2, lat2);
CalculationType lon1_rad = math::as_radian<Units>(lon1);
CalculationType lat1_rad = math::as_radian<Units>(lat1);
CalculationType lon2_rad = math::as_radian<Units>(lon2);
CalculationType lat2_rad = math::as_radian<Units>(lat2);
CalculationType alp2;
strategy.apply_reverse(lon1_rad, lat1_rad, lon2_rad, lat2_rad, alp2);
compute_box_corners<Units>(lon1, lat1, lon2, lat2, alp1, alp2, strategy);
}
public:
template
<
@ -383,31 +363,6 @@ public:
create_box<Units>(lon1, lat1, lon2, lat2, mbr);
}
template
<
typename Units,
typename CalculationType,
typename Box,
typename Strategy
>
static inline void apply(CalculationType lon1,
CalculationType lat1,
CalculationType lon2,
CalculationType lat2,
Box& mbr,
Strategy const& strategy,
CalculationType alp1)
{
typedef envelope_segment_convert_polar<Units, typename cs_tag<Box>::type> convert_polar;
convert_polar::pre(lat1, lat2);
apply<Units>(lon1, lat1, lon2, lat2, strategy, alp1);
convert_polar::post(lat1, lat2);
create_box<Units>(lon1, lat1, lon2, lat2, mbr);
}
};
} // namespace detail

View File

@ -2,7 +2,7 @@
// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
// Copyright (c) 2016-2018, Oracle and/or its affiliates.
// Copyright (c) 2016-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,
@ -42,6 +42,7 @@
#include <boost/geometry/strategies/side_info.hpp>
#include <boost/geometry/strategies/spherical/area.hpp>
#include <boost/geometry/strategies/spherical/disjoint_box_box.hpp>
#include <boost/geometry/strategies/spherical/disjoint_segment_box.hpp>
#include <boost/geometry/strategies/spherical/distance_haversine.hpp>
#include <boost/geometry/strategies/spherical/envelope.hpp>
#include <boost/geometry/strategies/spherical/expand_box.hpp>
@ -189,6 +190,13 @@ struct ecef_segments
return disjoint_box_box_strategy_type();
}
typedef disjoint::segment_box_spherical disjoint_segment_box_strategy_type;
static inline disjoint_segment_box_strategy_type get_disjoint_segment_box_strategy()
{
return disjoint_segment_box_strategy_type();
}
typedef covered_by::spherical_point_box disjoint_point_box_strategy_type;
typedef expand::spherical_box expand_box_strategy_type;

View File

@ -633,18 +633,19 @@ namespace boost { namespace geometry { namespace series_expansion {
inline void evaluate_coeffs_C3(Coeffs1 &coeffs1, Coeffs2 &coeffs2, CT const& eps)
{
CT mult = 1;
int offset = 1;
int offset = 0;
// l is the index of C3[l].
for (size_t l = 1; l < Coeffs1::static_size; ++l)
{
// Order of polynomial in eps.
int m = Coeffs1::static_size - l - 1;
int m = Coeffs1::static_size - l;
mult *= eps;
coeffs1[l] = mult * math::polyval(coeffs2.begin(), coeffs2.begin() + offset, eps);
coeffs1[l] = mult * math::horner_evaluate(eps, coeffs2.begin() + offset,
coeffs2.begin() + offset + m);
offset += m + 1;
offset += m;
}
// Post condition: offset == coeffs_C3_size
}

View File

@ -134,7 +134,7 @@ void test_one(std::string const& caseid, std::string const& wkt, double expected
settings.tolerance = 10000.0;
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
#if ! defined(BOOST_GEOMETRY_USE_RESCALING)
// in case robustness policies are changed, areas should be adapted
settings.tolerance = boost::starts_with(caseid, "no") ? 200000.0 : 100000.0;
#endif

View File

@ -187,7 +187,7 @@ void test_all()
// Having flat end
test_one<linestring, polygon>("for_collinear", for_collinear, join_round, end_flat, 68.561, 2.0);
test_one<linestring, polygon>("for_collinear", for_collinear, join_miter, end_flat, 72, 2.0);
#if defined(BOOST_GEOMETRY_BUFFER_INCLUDE_FAILING_TESTS)
#if defined(BOOST_GEOMETRY_TEST_ENABLE_FAILING)
test_one<linestring, polygon>("for_collinear2", for_collinear2, join_round, end_flat, 74.387, 2.0, 2.0);
test_one<linestring, polygon>("for_collinear2", for_collinear2, join_miter, end_flat, 78.0, 2.0, 2.0);
#endif
@ -245,10 +245,8 @@ void test_all()
test_one<linestring, polygon>("mysql_report_2015_03_02c_asym1", mysql_report_2015_03_02c, join_round(7), end_round(7), 39.714, d10, ut_settings(), d15);
test_one<linestring, polygon>("mysql_report_2015_03_02c_asym2", mysql_report_2015_03_02c, join_round(7), end_round(7), 46.116, d15, ut_settings(), d10);
#if defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION)
double const d100 = 10;
test_one<linestring, polygon>("mysql_report_2015_04_01", mysql_report_2015_04_01, join_round(32), end_round(32), 632.234, d100);
#endif
}
{
@ -288,7 +286,7 @@ void test_all()
27862.733459829971,
5.9518403867035365);
#if defined(BOOST_GEOMETRY_BUFFER_INCLUDE_FAILING_TESTS)
#if defined(BOOST_GEOMETRY_TEST_ENABLE_FAILING)
test_one<linestring, polygon>("mysql_report_2015_09_08a", mysql_report_2015_09_08a, join_round32, end_round32, 0.0, 1.0);
test_one<linestring, polygon>("mysql_report_2015_09_08b", mysql_report_2015_09_08b, join_round32, end_round32, 0.0, 1099511627778.0);
test_one<linestring, polygon>("mysql_report_2015_09_08c", mysql_report_2015_09_08c, join_round32, end_round32, 0.0, 0xbe);
@ -316,7 +314,7 @@ void test_all()
test_one<linestring, polygon>("mysql_25662426a_5", mysql_25662426a, join_round32, end_flat, 227.8325, 5.0);
test_one<linestring, polygon>("mysql_25662426a_10", mysql_25662426a, join_round32, end_flat, 534.1084, 10.0);
#if defined(BOOST_GEOMETRY_BUFFER_INCLUDE_FAILING_TESTS)
#if defined(BOOST_GEOMETRY_TEST_ENABLE_FAILING)
// Left
test_one<linestring, polygon>("mysql_25662426a_1", mysql_25662426a, join_round32, end_round32, 54.9018, 1.0, ut_settings(), 0.0);
test_one<linestring, polygon>("mysql_25662426a_2", mysql_25662426a, join_round32, end_round32, 103.6072, 2.0, ut_settings(), 0.0);

View File

@ -259,7 +259,7 @@ void test_aimes()
{ 6.52623768360172E-07, 6.53615401802199E-07, 1.30525545216642E-06, 1.30922269647726E-06},
{ 3.24414514807359E-07, 3.25418923807774E-07, 6.48829413307794E-07, 6.52846509296978E-07},
{ 1.65468009072356E-07, 1.66476610274913E-07, 3.30936202885823E-07, 3.34970451376648E-07},
{ 5.23240828442795E-09, 6.24356744083343E-09, 1.04648165688559E-08, 1.45094389836231E-08},
{ 5.23240828442795E-09, 6.24356744083343E-09, 1.04648165688559E-08, 1.45333485717657E-08},
{ 3.62318644420156E-07, 3.63320253882193E-07, 7.24637303051168E-07, 7.28643442471366E-07},
{ 5.94340193060816E-07, 5.95350627463631E-07, 1.18868054244103E-06, 1.19272210952204E-06},
{ 7.32884174681203E-07, 7.33866755808776E-07, 1.46576839199497E-06, 1.46969848913159E-06},
@ -341,7 +341,7 @@ void test_aimes()
{ 2.14196546721723E-07, 2.15193523445123E-07, 4.28392880280626E-07, 4.32381142445593E-07},
{ 2.53436667208007E-08, 2.63544563949836E-08, 5.06872623873278E-08, 5.47306626685895E-08},
{ 1.79067058070359E-07, 1.80076483502489E-07, 3.58134101929863E-07, 3.62171505230435E-07},
{ 1.14243619009358E-08, 1.24315846505851E-08, 2.28486385367432E-08, 2.68776432221784E-08},
{ 1.14243619009358E-08, 1.24315846505851E-08, 2.28486385367432E-08, 2.69068462005454E-08},
{ 1.62669806513804E-08, 1.72783103380425E-08, 3.25339186701967E-08, 3.65793084711186E-08},
{ 2.55726050113481E-07, 2.56733443393387E-07, 5.11451958118414E-07, 5.15481701768294E-07},
{ 6.74249776011493E-08, 6.84268144368616E-08, 1.34849770461187E-07, 1.38856961484635E-07},
@ -364,7 +364,7 @@ void test_aimes()
{ 2.52614157147946E-07, 2.5362039934862E-07, 5.05228484826148E-07, 5.09253013092348E-07},
{ 1.752849669856E-07, 1.76295728238074E-07, 3.50569891338637E-07, 3.54612936348531E-07},
{ 9.97295472870974E-08, 1.00740251696152E-07, 1.99459023519921E-07, 2.03501656415028E-07},
{ 1.27083694678731E-08, 1.37173685743619E-08, 2.54168952551481E-08, 2.94525364097353E-08},
{ 1.27083694678731E-08, 1.37173685743619E-08, 2.54168952551481E-08, 2.94820375698493E-08},
{ 2.88675792603499E-07, 2.89683143250841E-07, 5.77351315200758E-07, 5.81380774633544E-07},
{ 2.2199529325917E-07, 2.22990578890858E-07, 4.43990884946288E-07, 4.47971643779965E-07},
{ 3.101136769601E-08, 3.20127782060808E-08, 6.20226217051822E-08, 6.60284200648675E-08},
@ -418,7 +418,7 @@ void test_aimes()
{ 4.38233769273211E-08, 4.4833392109922E-08, 8.76467751709242E-08, 9.16867648470543E-08},
{ 1.28198685445113E-07, 1.29205858456771E-07, 2.56397569842193E-07, 2.60425942144593E-07},
{ 1.72098651773922E-07, 1.73105441092503E-07, 3.44197339074981E-07, 3.48224730828406E-07},
{ 1.79612058559542E-08, 1.79676149514307E-08, 3.5905237893985E-08, 3.59159741947224E-08}
{ 1.79612058559542E-08, 1.79676149514307E-08, 3.59441060869162E-08, 3.59159741947224E-08}
};
typedef bg::model::linestring<P> linestring;
@ -430,46 +430,15 @@ void test_aimes()
boost::ignore_unused(n, ne);
#if 0
// Create PostGIS query to verify results
{
std::cout << "with viewy as ( select " << std::endl;
for (int i = 0; i < n; i++)
{
std::cout << (i > 0 ? "," : "") << " ST_GeomFromText('" << testcases[i] << "',0) as p" << i << std::endl;
}
std::cout << ") select 'afm18' as code" << std::endl;
for (int i = 0; i < n; i++)
{
std::cout << ", ST_Area(ST_Buffer(p" << i << ", 0.000018, 'endcap=flat join=miter')) as afm18_" << i << std::endl;
}
std::cout << " from viewy union all select 'arr18' as code" << std::endl;
for (int i = 0; i < n; i++)
{
std::cout << ", ST_Area(ST_Buffer(p" << i << ", 0.000018, 'endcap=round join=round')) as arr18_" << i << std::endl;
}
std::cout << " from viewy union all select 'afm36' as code" << std::endl;
for (int i = 0; i < n; i++)
{
std::cout << ", ST_Area(ST_Buffer(p" << i << ", 0.000036, 'endcap=flat join=miter')) as afm36_" << i << std::endl;
}
std::cout << " from viewy union all select 'arr36' as code" << std::endl;
for (int i = 0; i < n; i++)
{
std::cout << ", ST_Area(ST_Buffer(p" << i << ", 0.000036, 'endcap=round join=round')) as arr36_" << i << std::endl;
}
std::cout << " from viewy" << std::endl;
}
#endif
bg::strategy::buffer::join_miter join_miter;
bg::strategy::buffer::join_round join_round(100);
bg::strategy::buffer::end_flat end_flat;
bg::strategy::buffer::end_round end_round(100);
// Aimes tested originally with 0.000018 degrees (around 2 m)
ut_settings settings(1.0e-10);
ut_settings settings;
settings.use_ln_area = true;
settings.tolerance = 0.001;
int expectation_index = 0;
for (int width = 18; width <= 36; width += 18, expectation_index += 2)

View File

@ -141,7 +141,7 @@ void test_all()
}
{
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
#if defined(BOOST_GEOMETRY_USE_RESCALING)
// Coordinates in one linestring vary so much that
// length = geometry::math::sqrt(dx * dx + dy * dy); returns a value of inf for length
// That geometry is skipped for the buffer
@ -173,7 +173,7 @@ void test_all()
mysql_23023665_1, join_round32, end_round32, 1, 1, 186.5504, 1.0);
test_one<multi_linestring_type, polygon>("touching1_1",
touching1, join_round32, end_round32, 2, 0, 78.70773, 1.0
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
#if defined(BOOST_GEOMETRY_USE_RESCALING)
, ut_settings::ignore_validity() // false positive, due to rescaling. As we remove it, it is gone
#endif
);
@ -199,7 +199,7 @@ void test_all()
test_one<multi_linestring_type, polygon>("mysql_23023665_1_20",
mysql_23023665_1, join_round32, end_flat, 1, 1, 350.1135, 2.0);
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
#if ! defined(BOOST_GEOMETRY_USE_RESCALING)
{
ut_settings settings(10.0);
test_one<multi_linestring_type, polygon>("ticket_13444_1",

View File

@ -47,7 +47,7 @@ void test_all()
test_one<multi_point_type, polygon>("simplex3", simplex, join, end_flat, 44.5692, 3.0);
test_one<multi_point_type, polygon>("three1", three, join, end_flat, 3.0 * pi, 1.0);
#if !defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
#if defined(BOOST_GEOMETRY_USE_RESCALING)
// For no-rescaling, fails in CCW mode
test_one<multi_point_type, polygon>("three2", three, join, end_flat, 36.7592, 2.0);
#endif
@ -122,7 +122,7 @@ void test_many_points_per_circle()
using bg::strategy::buffer::point_circle;
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
#if ! defined(BOOST_GEOMETRY_USE_RESCALING)
double const tolerance = 1000.0;
#else
double const tolerance = 1.0;

View File

@ -371,26 +371,28 @@ void test_all()
test_one<multi_polygon_type, polygon_type>("rt_g1", rt_g1, join_round, end_flat, 24.719, 1.0);
test_one<multi_polygon_type, polygon_type>("rt_g3", rt_g3, join_miter, end_flat, 16.5711, 1.0);
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
test_one<multi_polygon_type, polygon_type>("rt_d", rt_d, join_miter, end_flat, 19.8823, 0.3);
#if defined(BOOST_GEOMETRY_USE_RESCALING)
test_one<multi_polygon_type, polygon_type>("rt_e", rt_e, join_miter, end_flat, 15.1198, 0.3);
test_one<multi_polygon_type, polygon_type>("rt_f", rt_f, join_miter, end_flat, 4.60853, 0.3);
#endif
test_one<multi_polygon_type, polygon_type>("rt_g1", rt_g1, join_miter, end_flat, 30.3137, 1.0);
#if defined(BOOST_GEOMETRY_USE_RESCALING)
test_one<multi_polygon_type, polygon_type>("rt_g2", rt_g2, join_miter, end_flat, 18.5711, 1.0);
#endif
test_one<multi_polygon_type, polygon_type>("rt_h", rt_h, join_round, end_flat, 47.6012, 1.0);
test_one<multi_polygon_type, polygon_type>("rt_h", rt_h, join_miter, end_flat, 61.7058, 1.0);
test_one<multi_polygon_type, polygon_type>("rt_i", rt_i, join_round, end_flat, 10.7528, 1.0);
#if defined(BOOST_GEOMETRY_USE_RESCALING)
test_one<multi_polygon_type, polygon_type>("rt_i", rt_i, join_miter, end_flat, 13.6569, 1.0);
#endif
test_one<multi_polygon_type, polygon_type>("rt_j", rt_j, join_round, end_flat, 28.7309, 1.0);
test_one<multi_polygon_type, polygon_type>("rt_j", rt_j, join_miter, end_flat, 35.1421, 1.0);
test_one<multi_polygon_type, polygon_type>("rt_k", rt_k, join_round, end_flat, 42.0092, 1.0);
test_one<multi_polygon_type, polygon_type>("rt_k", rt_k, join_miter, end_flat, 48.0563, 1.0);
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
test_one<multi_polygon_type, polygon_type>("rt_l", rt_l, join_miter, end_flat, 19.3995, 1.0);
#endif
test_one<multi_polygon_type, polygon_type>("rt_m1", rt_m1, join_round, end_flat, 14.1074, 1.0);
test_one<multi_polygon_type, polygon_type>("rt_m1", rt_m1, join_miter, end_flat, 19.4853, 1.0);
@ -399,22 +401,16 @@ void test_all()
test_one<multi_polygon_type, polygon_type>("rt_n", rt_n, join_miter, end_flat, 18.4853, 1.0);
test_one<multi_polygon_type, polygon_type>("rt_o1", rt_o1, join_round, end_flat, 17.536, 1.0);
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
test_one<multi_polygon_type, polygon_type>("rt_o1", rt_o1, join_miter, end_flat, 20.9142, 1.0);
test_one<multi_polygon_type, polygon_type>("rt_o2", rt_o2, join_miter, end_flat, 25.7426, 1.0);
test_one<multi_polygon_type, polygon_type>("rt_o3", rt_o3, join_miter, end_flat, 28.8247, 1.0);
test_one<multi_polygon_type, polygon_type>("rt_o4", rt_o4, join_miter, end_flat, 34.6532, 1.0);
#endif
test_one<multi_polygon_type, polygon_type>("rt_p1", rt_p1, join_miter, end_flat, 24.8211, 1.0);
test_one<multi_polygon_type, polygon_type>("rt_p2", rt_p2, join_miter, end_flat, 21.4853, 1.0);
test_one<multi_polygon_type, polygon_type>("rt_p3", rt_p3, join_miter, end_flat, 22.3995, 1.0);
test_one<multi_polygon_type, polygon_type>("rt_p4", rt_p4, join_miter, end_flat, 33.0563, 1.0);
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
test_one<multi_polygon_type, polygon_type>("rt_p5", rt_p5, join_miter, end_flat, 17.0, 1.0);
#endif
test_one<multi_polygon_type, polygon_type>("rt_p6", rt_p6, join_miter, end_flat, 18.4853, 1.0);
test_one<multi_polygon_type, polygon_type>("rt_p7", rt_p7, join_miter, end_flat, 26.2279, 1.0);
@ -429,15 +425,15 @@ void test_all()
test_one<multi_polygon_type, polygon_type>("rt_p15", rt_p15, join_miter, end_flat, 23.6569, 1.0);
test_one<multi_polygon_type, polygon_type>("rt_p16", rt_p16, join_miter, end_flat, 23.4853, 1.0);
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
test_one<multi_polygon_type, polygon_type>("rt_p17", rt_p17, join_miter, end_flat, 25.3137, 1.0);
#endif
test_one<multi_polygon_type, polygon_type>("rt_p18", rt_p18, join_miter, end_flat, 23.3137, 1.0);
test_one<multi_polygon_type, polygon_type>("rt_p19", rt_p19, join_miter, end_flat, 25.5637, 1.0);
#if defined(BOOST_GEOMETRY_USE_RESCALING)
test_one<multi_polygon_type, polygon_type>("rt_p20", rt_p20, join_miter, end_flat, 25.4853, 1.0);
#endif
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
#if defined(BOOST_GEOMETRY_USE_RESCALING)
test_one<multi_polygon_type, polygon_type>("rt_p21", rt_p21, join_miter, end_flat, 17.1716, 1.0);
#endif
@ -447,17 +443,14 @@ void test_all()
test_one<multi_polygon_type, polygon_type>("rt_q2", rt_q2, join_miter, end_flat, 26.4853, 1.0);
test_one<multi_polygon_type, polygon_type>("rt_q2", rt_q2, join_miter, end_flat, 0.9697, -0.25);
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
#if defined(BOOST_GEOMETRY_USE_RESCALING)
test_one<multi_polygon_type, polygon_type>("rt_r", rt_r, join_miter, end_flat, 21.0761, 1.0);
#endif
test_one<multi_polygon_type, polygon_type>("rt_s1", rt_s1, join_miter, end_flat, 20.4853, 1.0);
test_one<multi_polygon_type, polygon_type>("rt_s2", rt_s2, join_miter, end_flat, 24.6495, 1.0);
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
test_one<multi_polygon_type, polygon_type>("rt_t1", rt_t, join_miter, end_flat, 15.6569, 1.0);
#endif
test_one<multi_polygon_type, polygon_type>("rt_t2", rt_t, join_miter, end_flat, 0.1679, -0.25);
test_one<multi_polygon_type, polygon_type>("rt_u1", rt_u1, join_round, end_flat, 33.2032, 1.0);
@ -485,10 +478,8 @@ void test_all()
test_one<multi_polygon_type, polygon_type>("rt_u11_50", rt_u11, join_miter, end_flat, 0.04289, -0.50);
test_one<multi_polygon_type, polygon_type>("rt_u11_25", rt_u11, join_miter, end_flat, 10.1449, -0.25);
#if defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION)
test_one<multi_polygon_type, polygon_type>("rt_u12", rt_u12, join_miter, end_flat, 142.1348, 1.0);
test_one<multi_polygon_type, polygon_type>("rt_u13", rt_u13, join_miter, end_flat, 115.4853, 1.0);
#endif
test_one<multi_polygon_type, polygon_type>("neighbouring_small",
neighbouring,

View File

@ -22,13 +22,15 @@ void test_point()
// NOTE: for now do not test with a radius less than 2 meter, because is not precise yet (in double)
test_one_geo<PointType, polygon>("simplex1", simplex, join_miter, end_flat, 70.7107, 5.0, ut_settings(0.1, false, 8));
test_one_geo<PointType, polygon>("simplex1", simplex, join_miter, end_flat, 76.5437, 5.0, ut_settings(0.1, false, 16));
test_one_geo<PointType, polygon>("simplex1", simplex, join_miter, end_flat, 78.0363, 5.0, ut_settings(0.1, false, 32));
// * Result is different for clang/VCC. Specified expectation is in between, and tolerance higher
test_one_geo<PointType, polygon>("simplex1", simplex, join_miter, end_flat, 77.9640, 5.0, ut_settings(0.2, false, 32));
// The more points used for the buffer, the more the area approaches 10*PI square meters
test_one_geo<PointType, polygon>("simplex1", simplex, join_miter, end_flat, 282.8430, 10.0, ut_settings(0.1, false, 8));
test_one_geo<PointType, polygon>("simplex1", simplex, join_miter, end_flat, 306.1471, 10.0, ut_settings(0.1, false, 16));
test_one_geo<PointType, polygon>("simplex1", simplex, join_miter, end_flat, 312.1450, 10.0, ut_settings(0.1, false, 32));
test_one_geo<PointType, polygon>("simplex1", simplex, join_miter, end_flat, 314.0960, 10.0, ut_settings(0.1, false, 180));
// * Same here
test_one_geo<PointType, polygon>("simplex1", simplex, join_miter, end_flat, 313.9051, 10.0, ut_settings(0.2, false, 180));
}
int test_main(int, char* [])

View File

@ -140,6 +140,12 @@ static std::string const ticket_10412
static std::string const ticket_11580
= "POLYGON((14.02 474.96,14.02 494.96,14.022 494.96,14.022 486.24,14.02 474.96))";
static std::string const issue_369
= "POLYGON((-0.0149622653 -0.0269554816,-0.0149539290 -0.0271028206,-0.0149470828 -0.0271355230,-0.0149622653 -0.0269554816))";
static std::string const issue_555
= "POLYGON((100.0637755102041 100.0770239202989,100.0360264929713 100.1,100 100.1,0 100.1,-0.0999999999999943 100.1,-0.09999999999999432 100,-0.1000000000000014 0,-0.1000000000000014 -0.1000000000000014,-1.836970198721056e-17 -0.1000000000000014,100 -0.1000000000000014,100.0360264929713 -0.1000000000000012,100.0637755102041 -0.07702392029888726,101.1041649480706 0.7844145387331185,103.4026139046043 2.203948968996805,105.8748306243106 3.293026604107826,108.4735936784235 4.030845140790255,111.1492644962378 4.403311621418428,113.8507355037622 4.403311621418428,116.5264063215765 4.030845140790252,119.1251693756894 3.293026604107823,121.5973860953957 2.203948968996801,123.8958350519294 0.7844145387331167,124.9362244897959 -0.07702392029888117,124.9639735070287 -0.09999999999999432,125 -0.09999999999999432,135 -0.1000000000000014,135.1 -0.0999999999999943,135.1 0,135.1 100,135.1 100.1,135 100.1,125 100.1,124.9639735070287 100.1,124.9362244897959 100.0770239202989,123.8958350519294 99.21558546126688,121.5973860953958 97.7960510310032,119.1251693756894 96.70697339589218,116.5264063215765 95.96915485920975,113.8507355037622 95.59668837858158,111.1492644962378 95.59668837858158,108.4735936784235 95.96915485920975,105.8748306243106 96.70697339589218,103.4026139046043 97.7960510310032,101.1041649480706 99.21558546126688,100.0637755102041 100.0770239202989),(124.9 71.15855631858324,124.9 28.84144368141676,124.9 27.45166011926875,124.5057975806765 24.70018817664119,123.7253617444602 22.03243382063001,122.574469398775 19.50232706258395,121.0763864178284 17.16101529763987,119.2613973111302 15.0558293341122,117.1661930067267 13.22932657712651,114.8331291254269 11.71843070902665,112.3093697403817 10.55368525835367,109.6459339313539 9.758636146879443,106.8966644080684 9.349355696820595,104.1171390524456 9.33411772066918,101.3635473834475 9.7132302618644,100.0275510204082 10.0961298147011,100.014047339233 10.09999999999999,100 10.09999999999999,29.6 10.1,28.20533247460344 10.1,25.44438883273841 10.49696376664363,22.76804145044581 11.28281026239098,20.2307730424806 12.44154191878281,17.88423507675108 13.94957030080114,15.77619629938279 15.77619629938281,13.94957030080113 17.88423507675109,12.44154191878281 20.23077304248061,11.28281026239098 22.76804145044582,10.49696376664362 25.44438883273843,10.1 28.20533247460346,10.1 29.6,10.1 70.40000000000001,10.1 71.79466752539656,10.49696376664363 74.5556111672616,11.28281026239098 77.23195854955421,12.44154191878281 79.76922695751941,13.94957030080114 82.11576492324893,15.77619629938281 84.22380370061721,17.88423507675109 86.05042969919887,20.23077304248062 87.5584580812172,22.76804145044583 88.71718973760903,25.44438883273843 89.50303623335638,28.20533247460346 89.90000000000001,29.6 89.90000000000001,100 89.90000000000001,100.014047339233 89.90000000000001,100.0275510204082 89.9038701852989,101.3635473834475 90.2867697381356,104.1171390524456 90.66588227933082,106.8966644080684 90.6506443031794,109.6459339313539 90.24136385312056,112.3093697403817 89.44631474164633,114.8331291254269 88.28156929097335,117.1661930067267 86.77067342287347,119.2613973111302 84.94417066588778,121.0763864178284 82.83898470236012,122.574469398775 80.49767293741604,123.7253617444602 77.96756617936998,124.5057975806765 75.29981182335879,124.9 72.54833988073125,124.9 71.15855631858324))";
// CCW Polygons not working in 1.56
static std::string const mysql_report_2014_10_24
= "POLYGON((0 0, 0 8, 8 8, 8 10, -10 10, -10 0, 0 0))";
@ -368,9 +374,7 @@ void test_all()
test_one<polygon_type, polygon_type>("snake4", snake, join_miter, end_flat, 64.44, 0.4);
test_one<polygon_type, polygon_type>("snake5", snake, join_miter, end_flat, 72, 0.5);
test_one<polygon_type, polygon_type>("snake6", snake, join_miter, end_flat, 75.44, 0.6);
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
test_one<polygon_type, polygon_type>("snake16", snake, join_miter, end_flat, 114.24, 1.6);
#endif
test_one<polygon_type, polygon_type>("funnelgate2", funnelgate, join_miter, end_flat, 120.982, 2.0);
test_one<polygon_type, polygon_type>("funnelgate3", funnelgate, join_miter, end_flat, 13.0*13.0, 3.0);
@ -467,11 +471,12 @@ void test_all()
}
{
ut_settings settings(0.0000001);
test_one<polygon_type, polygon_type>("county1", county1, join_round, end_flat, 0.00114092, 0.01, settings);
test_one<polygon_type, polygon_type>("county1", county1, join_miter, end_flat, 0.00132859, 0.01, settings);
test_one<polygon_type, polygon_type>("county1", county1, join_round, end_flat, 3.94411299566854723e-05, -0.003, settings);
test_one<polygon_type, polygon_type>("county1", county1, join_miter, end_flat, 3.94301960113807581e-05, -0.003, settings);
ut_settings settings;
settings.use_ln_area = true;
test_one<polygon_type, polygon_type>("county1", county1, join_round, end_flat, 0.00114, 0.01, settings);
test_one<polygon_type, polygon_type>("county1", county1, join_miter, end_flat, 0.00133, 0.01, settings);
test_one<polygon_type, polygon_type>("county1", county1, join_round, end_flat, 3.94411e-05, -0.003, settings);
test_one<polygon_type, polygon_type>("county1", county1, join_miter, end_flat, 3.94301e-05, -0.003, settings);
}
test_one<polygon_type, polygon_type>("parcel1_10", parcel1, join_round, end_flat, 7571.405, 10.0);
@ -508,21 +513,15 @@ void test_all()
test_one<polygon_type, polygon_type>("parcel1_20", parcel1, join_round, end_flat, 209.3579, -20.0);
test_one<polygon_type, polygon_type>("parcel1_20", parcel1, join_miter, end_flat, 188.4224, -20.0);
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
test_one<polygon_type, polygon_type>("nl_part1_2", nl_part1, join_round, end_flat, 1848737356.991, -0.2 * 1000.0);
test_one<polygon_type, polygon_type>("nl_part1_5", nl_part1, join_round, end_flat, 1775953811.679, -0.5 * 1000.0);
#else
test_one<polygon_type, polygon_type>("nl_part1_2", nl_part1, join_round, end_flat, 1848737292.653, -0.2 * 1000.0);
test_one<polygon_type, polygon_type>("nl_part1_5", nl_part1, join_round, end_flat, 1775953824.799, -0.5 * 1000.0);
#endif
test_one<polygon_type, polygon_type>("nl_part1_2", nl_part1,
join_round, end_flat, BG_IF_RESCALED(1848737356.991, 1848737292.653), -0.2 * 1000.0);
test_one<polygon_type, polygon_type>("nl_part1_5", nl_part1,
join_round, end_flat, BG_IF_RESCALED(1775953811.679, 1775953824.799), -0.5 * 1000.0);
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
test_one<polygon_type, polygon_type>("italy_part1_30", italy_part1, join_round, end_flat, 5015638814.956, 30.0 * 1000.0);
test_one<polygon_type, polygon_type>("italy_part1_50", italy_part1, join_round, end_flat, 11363180044.822, 50.0 * 1000.0);
#else
test_one<polygon_type, polygon_type>("italy_part1_30", italy_part1, join_round, end_flat, 5015638827.704, 30.0 * 1000.0);
test_one<polygon_type, polygon_type>("italy_part1_50", italy_part1, join_round, end_flat, 11363180033.564, 50.0 * 1000.0);
#endif
test_one<polygon_type, polygon_type>("italy_part1_30", italy_part1,
join_round, end_flat, BG_IF_RESCALED(5015638814.956, 5015638827.704), 30.0 * 1000.0);
test_one<polygon_type, polygon_type>("italy_part1_50", italy_part1,
join_round, end_flat, BG_IF_RESCALED(11363180044.822, 11363180033.564), 50.0 * 1000.0);
test_one<polygon_type, polygon_type>("italy_part1_60", italy_part1, join_round, end_flat, 15479097108.720, 60.0 * 1000.0);
{
@ -553,7 +552,7 @@ void test_all()
test_one<polygon_type, polygon_type>("ticket_10412", ticket_10412, join_miter, end_flat, 3109.6616, 1.5, settings);
test_one<polygon_type, polygon_type>("ticket_11580_100", ticket_11580, join_miter, end_flat, 52.0221000, 1.00, settings);
#ifdef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS
#if defined(BOOST_GEOMETRY_TEST_ENABLE_FAILING)
// Larger distance, resulting in only one circle
test_one<polygon_type, polygon_type>("ticket_11580_237", ticket_11580, join_miter, end_flat, 999.999, 2.37, settings);
#endif
@ -563,6 +562,37 @@ void test_all()
test_one<polygon_type, polygon_type>("ticket_10398_1_5", ticket_10398_1, join_miter, end_flat, 404.3936, -0.5);
test_one<polygon_type, polygon_type>("ticket_10398_1_25", ticket_10398_1, join_miter, end_flat, 246.7329, -2.5);
{
// Test issue 369 as reported (1.15e-3) and some variants
// Use high tolerance because output areas are very small
const double distance = 1.15e-3;
const auto join_distance = 0.1e-3;
const int points_per_circle = 2 * 3.1415 * distance / join_distance;
ut_settings specific;
specific.use_ln_area = true;
specific.tolerance = 0.01;
bg::strategy::buffer::join_round jr(points_per_circle);
bg::strategy::buffer::end_round er(points_per_circle);
test_one<polygon_type, polygon_type>("issue_369", issue_369, jr, er, 4.566e-06, distance, specific);
test_one<polygon_type, polygon_type>("issue_369_10", issue_369, jr, er, 8.346e-08, distance / 10.0, specific);
test_one<polygon_type, polygon_type>("issue_369_100", issue_369, jr, er, 4.942e-09, distance / 100.0, specific);
test_one<polygon_type, polygon_type>("issue_369_1000", issue_369, jr, er, 7.881e-10, distance / 1000.0, specific);
}
{
// Test issue 555 as reported (-0.000001) and some variants
bg::strategy::buffer::join_round jr(180);
bg::strategy::buffer::end_round er(180);
#if ! defined(BOOST_GEOMETRY_USE_RESCALING)
// With rescaling the interior ring is missing
test_one<polygon_type, polygon_type>("issue_555", issue_555, jr, er, 4520.7942, -0.000001);
#endif
test_one<polygon_type, polygon_type>("issue_555", issue_555, jr, er, 4520.7957, +0.000001);
test_one<polygon_type, polygon_type>("issue_555_1000", issue_555, jr, er, 4521.6280, +0.001);
test_one<polygon_type, polygon_type>("issue_555_1000", issue_555, jr, er, 4519.9627, -0.001);
}
{
bg::strategy::buffer::join_round join_round32(32);
bg::strategy::buffer::end_round end_round32(32);

View File

@ -100,12 +100,14 @@ struct ut_settings
double tolerance;
bool test_validity;
bool test_area;
bool use_ln_area;
int points_per_circle;
explicit ut_settings(double tol = 0.01, bool val = true, int points = 88)
: tolerance(tol)
, test_validity(val)
, test_area(true)
, use_ln_area(false)
, points_per_circle(points)
{}
@ -197,6 +199,9 @@ void test_buffer(std::string const& caseid,
<< (end_name.empty() ? "" : "_") << end_name
<< (distance_strategy.negative() ? "_deflate" : "")
<< (bg::point_order<GeometryOut>::value == bg::counterclockwise ? "_ccw" : "")
#if defined(BOOST_GEOMETRY_USE_RESCALING)
<< "_rescaled"
#endif
// << "_" << point_buffer_count
;
@ -313,8 +318,13 @@ void test_buffer(std::string const& caseid,
if (settings.test_area)
{
// Because areas vary hugely in buffer, the Boost.Test methods are not convenient.
// Use just the abs - but if areas are really small that is not convenient neither.
// Therefore there is a logarithmic option too.
typename bg::default_area_result<GeometryOut>::type area = bg::area(buffered, area_strategy);
double const difference = area - expected_area;
double const difference = settings.use_ln_area
? std::log(area) - std::log(expected_area)
: area - expected_area;
BOOST_CHECK_MESSAGE
(
bg::math::abs(difference) < settings.tolerance,
@ -327,11 +337,26 @@ void test_buffer(std::string const& caseid,
<< std::setprecision(3)
<< " , " << 100.0 * (difference / expected_area) << "%"
);
// if (settings.use_ln_area)
// {
// std::cout << complete.str()
// << std::setprecision(6)
// << " ln(detected)=" << std::log(area)
// << " ln(expected)=" << std::log(expected_area)
// << " diff=" << difference
// << " detected=" << area
// << std::endl;
// }
}
if (settings.test_validity && ! bg::is_valid(buffered))
#if ! defined(BOOST_GEOMETRY_TEST_ENABLE_FAILING)
if (settings.test_validity)
#endif
{
BOOST_CHECK_MESSAGE(bg::is_valid(buffered), complete.str() << " is not valid");
if (! bg::is_valid(buffered))
{
BOOST_CHECK_MESSAGE(bg::is_valid(buffered), complete.str() << " is not valid");
}
}
#if defined(TEST_WITH_SVG_PER_TURN)

View File

@ -1,6 +1,6 @@
// Boost.Geometry
// Copyright (c) 2016-2017 Oracle and/or its affiliates.
// Copyright (c) 2016-2019 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
@ -245,6 +245,14 @@ void disjoint_tests_sph_geo()
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(0 5, 20 6)",
"SEGMENT(0 4.9, 120 -1)",
false);
//https://github.com/boostorg/geometry/issues/579
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(10 10,20 20)",
"SEGMENT(12 2,12 1)",
true);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(10 10,20 20)",
"SEGMENT(12 1,12 2)",
true);
}
template <typename CT>

View File

@ -1,6 +1,6 @@
// Boost.Geometry
// Copyright (c) 2016 Oracle and/or its affiliates.
// Copyright (c) 2016, 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,
@ -253,6 +253,41 @@ void test_point_polygon()
false);
}
template <typename P>
void test_box_polygon()
{
typedef bg::model::box<P> box;
typedef bg::model::polygon<P> poly;
// https://github.com/boostorg/geometry/issues/466
test_geometry<box, poly>("BOX(2.2 48.88, 2.5 48.9021)",
"POLYGON((2.4 48.90205, 2.4 48.89, 2.3 48.89, 2.3 48.90205, 2.4 48.90205))",
false);
test_geometry<box, poly>("BOX(2.2 48.88, 2.5 48.9021)",
"POLYGON((2.4 48.9021, 2.4 48.89, 2.3 48.89, 2.3 48.9021, 2.4 48.9021))",
false);
test_geometry<box, poly>("BOX(2.2 48.88, 2.5 48.9021)",
"POLYGON((2.4 48.90215, 2.4 48.89, 2.3 48.89, 2.3 48.90215, 2.4 48.90215))",
false);
// extended
test_geometry<box, poly>("BOX(2.2 48.88, 2.5 48.9021)",
"POLYGON((2.4 48.9022, 2.4 48.89, 2.3 48.89, 2.3 48.9022, 2.4 48.9022))",
false);
// box within poly
test_geometry<box, poly>("BOX(2.2 48.88, 2.5 48.9021)",
"POLYGON((2.6 48.9021, 2.6 48.8, 2.1 48.8, 2.1 48.9021, 2.6 48.9021))",
false);
test_geometry<box, poly>("BOX(2.2 48.88, 2.5 48.9021)",
"POLYGON((2.6 48.9022, 2.6 48.8, 2.1 48.8, 2.1 48.9022, 2.6 48.9022))",
false);
// related to https://github.com/boostorg/geometry/issues/579
test_geometry<box, poly>("BOX(10 10,20 20)",
"POLYGON((11 0,10 1,11 2,12 3,13 1,11 0),"
"(12 1,11 1,12 2,12 1))",
true);
}
template <typename P>
void test_all()
@ -270,16 +305,19 @@ void test_all()
test_linestring_multi_linestring<P>();
test_multi_linestring_multi_linestring<P>();
test_linestring_linestring_radians<bg::model::point<double, 2,
bg::cs::spherical_equatorial<bg::radian> > >();
test_point_polygon<P>();
test_box_polygon<P>();
}
int test_main( int , char* [] )
{
test_all<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
typedef bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > point_deg;
typedef bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::radian> > point_rad;
test_all<point_deg>();
test_linestring_linestring_radians<point_rad>();
#if defined(HAVE_TTMATH)
test_cs<bg::model::point<ttmath_big, 2, bg::cs::spherical_equatorial<bg::degree> > >();

View File

@ -351,6 +351,13 @@ void test_distance_point_segment(Strategy_pp const& strategy_pp,
"SEGMENT(1 -1,1 0)",
pp_distance("POINT(2 0)", "POINT(1 0)", strategy_pp),
strategy_ps, true, true);
tester::apply("p-s-acos",
"POINT(0 90)",
"SEGMENT(90 0,0 1.000005)",
pp_distance("POINT(0 90)", "POINT(0.3017072304435489 1.000018955050697)",
strategy_pp),
strategy_ps, true, true);
}
template <typename Strategy_pp, typename Strategy_ps>
@ -546,6 +553,13 @@ void test_distance_linestring_multipoint(Strategy_pp const& strategy_pp,
"MULTIPOINT(1 -1,80 80,5 0,150 90)",
0,
strategy_ps, true, false, false);
tester::apply("l-mp-06",
"LINESTRING(90 0,0 1.00005)",
"MULTIPOINT((0 0),(0 0),(0 0),(0 0),(0 0),(0 0),(0 0 ),(0 0),\
(0 0),(0 0 ),(0 0),(0 0),(69.35235 155.0205),\
(75.72081 37.97683),(0 0),(0 0),(0 0))",
pp_distance("POINT(0 0)", "POINT(0 1.00005)", strategy_pp),
strategy_ps, true, false, false);
}
//===========================================================================

View File

@ -2484,6 +2484,17 @@ BOOST_AUTO_TEST_CASE( envelope_polygon )
from_wkt<G>("POLYGON((),(0.5 0.5,0.5 0.7,0.7 0.7,0.5 0.5),\
(0.7 0.5,0.9 0.5,0.9 0.7,0.7 0.5))"),
0.5, 0.5, 0.9, 0.70000106605644807);
// https://github.com/boostorg/geometry/issues/466
tester::apply("p5-issue466",
from_wkt<G>("POLYGON((2.4 48.9021,2.4 48.89,2.3 48.89,2.3 48.9021,2.4 48.9021))"),
2.3, 48.89, 2.4, 48.902110807274966);
tester::apply("p6-issue466",
from_wkt<G>("POLYGON((2.4 48.90215,2.4 48.89,2.3 48.89,2.3 48.90215,2.4 48.90215))"),
2.3, 48.89, 2.4, 48.902160807272381);
tester::apply("p7-issue466",
from_wkt<G>("POLYGON((2.4 48.9022,2.4 48.89,2.3 48.89,2.3 48.9022,2.4 48.9022))"),
2.3, 48.89, 2.4, 48.902210807269796);
}
// unit test for rings de-activated for now (current implementation

View File

@ -373,8 +373,8 @@ void test_overlay(std::string const& caseid,
<< "_" << string_from_type<typename bg::coordinate_type<Geometry>::type>::name()
<< (ccw ? "_ccw" : "")
<< (open ? "_open" : "")
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
<< "_no_rob"
#if defined(BOOST_GEOMETRY_USE_RESCALING)
<< "_rescaled"
#endif
<< ".svg";

View File

@ -943,6 +943,24 @@ static std::string ticket_9756[2] =
"POLYGON((440855.857887967 4046932.1248641, 440813.740724389 4046942.21109839, 440806.376538684 4046935.44583646, 440848.493702262 4046925.35960217))",
};
static std::string issue_548[2] =
{
"POLYGON((143526.96086588613 113763.64549686472, 76161.913300625194 96673.360975963747,76161.913300625194 71504.239234902911,145207.72299290277 81831.630077016118,143526.96086588613 113763.64549686472))",
"POLYGON((-47053.678255174891 -657486.29482312244,-610948.08772840793 300004.45446108561,-132202.71308630385 581951.65919770207,431691.69638692908 -375539.09008650586,-47053.678255174891 -657486.29482312244))"
};
static std::string issue_566_a[2] =
{
"POLYGON((16.8739 0.353458,8.80872e-14 5.50545e-15,0.266003 -12.6988,17.1399 -12.3454,16.8739 0.353458))",
"POLYGON((-4.53257e-19 2.16383e-17,9.99781 0.209424,10.1459 -6.86009,0.148086 -7.06952,-4.53257e-19 2.16383e-17))"
};
static std::string issue_566_b[2] =
{
"POLYGON((16.8739 0.353458,0 0,0.266003 -12.6988,17.1399 -12.3454,16.8739 0.353458))",
"POLYGON((0 0,0.148086 -7.06952,10.1459 -6.86009,9.99781 0.209424,0 0))"
};
static std::string ggl_list_20120229_volker[3] =
{
"POLYGON((1716 1554,2076 2250,2436 2352,2796 1248,3156 2484,3516 2688,3516 2688,3156 2484,2796 1248,2436 2352,2076 2250, 1716 1554))",
@ -956,6 +974,17 @@ static std::string ggl_list_20120717_volker[2] =
"POLYGON((1032 1458,1032 1212,2136 2328,3234 2220,3234 2412,2136 2646))"
};
static std::string ggl_list_20190307_matthieu_1[2] =
{
"POLYGON((-1.00000010731 -0.713619134602,-1.00000012822 -0.493922219801,-0.598172925227 0.100631982002,-1.00000012886 -0.0624283708015,-1.00000011994 0.0862738908136,-0.440262107798 0.31341400405,-0.360828341246 0.292948255722,-0.357275641893 0.210997365241,-0.970143533681 -0.695818118925,-1.00000010731 -0.713619134602))",
"POLYGON((-0.999999965066 -0.493921978401,-0.909999987372 -0.360755621066,-0.909999996424 -0.91000000872,0.91000000872 -0.909999996424,0.909999996424 0.91000000872,-0.909999996424 0.91000000872,-0.909999911756 -0.0259065349961,-0.999999867625 -0.0624282647935,-1 1,1 1,1 -1,-1 -1,-0.999999965066 -0.493921978401))"
};
static std::string ggl_list_20190307_matthieu_2[2] =
{
"POLYGON((-2 -2,-2 2,2 2,2 -2,-2 -2))",
"POLYGON((-0.430323140092 -0.999999912736,-1 -1,-1 1,1 1,1 -1,0.431066411049 -0.999999901684,0.43106695576 -1.00000010168,-0.43032321787 -1.00000011274,-0.430323140092 -0.999999912736),(0.135529235005 0.316180944443,-0.949848473072 -0.124261498451,-0.47733861208 -0.590634822845,0.135529235005 0.316180944443))"
};
static std::string buffer_rt_a[2] =
{

View File

@ -41,6 +41,11 @@
( #caseid, caseid[0], caseid[1], clips1, -1, area1, clips2, -1, area2, \
clips3, -1, area1 + area2)
#define TEST_DIFFERENCE_WITH(caseid, clips1, area1, clips2, area2, clips3) \
(test_one<polygon, polygon, polygon>) \
( #caseid, caseid[0], caseid[1], clips1, -1, area1, clips2, -1, area2, \
clips3, -1, area1 + area2, settings)
template <typename P>
void test_all()
{
@ -51,14 +56,12 @@ void test_all()
typedef typename bg::coordinate_type<P>::type ct;
ut_settings sym_settings;
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
#if ! defined(BOOST_GEOMETRY_USE_RESCALING)
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],
@ -82,11 +85,13 @@ void test_all()
1, 5, 8.0,
1, 5, 8.0);
#if defined(BOOST_GEOMETRY_USE_RESCALING)
test_one<polygon, polygon, polygon>("star_comb_15",
star_comb_15[0], star_comb_15[1],
30, 160, 227.658275102812,
30, 198, 480.485775259312,
30, -1, 227.658275102812,
30, -1, 480.485775259312,
sym_settings);
#endif
test_one<polygon, polygon, polygon>("new_hole",
new_hole[0], new_hole[1],
@ -117,6 +122,7 @@ void test_all()
1, 5, 9.0,
1, 5, 9.0);
#if defined(BOOST_GEOMETRY_USE_RESCALING)
test_one<polygon, polygon, polygon>("only_hole_intersections1",
only_hole_intersections[0], only_hole_intersections[1],
2, 10, 1.9090909,
@ -128,6 +134,7 @@ void test_all()
3, 20, 30.9090909,
4, 16, 10.9090909,
sym_settings);
#endif
test_one<polygon, polygon, polygon>("first_within_second",
first_within_second[1], first_within_second[0],
@ -199,13 +206,14 @@ void test_all()
8, 36, 2.43452380952381,
7, 33, 3.18452380952381);
#ifdef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS
#if ! defined(BOOST_GEOMETRY_USE_RESCALING)
// Fails, a-b is partly generated, b-a does not have any output
// It failed already in 1.59
test_one<polygon, polygon, polygon>("case_58_iet",
case_58[0], case_58[2],
3, 12, 0.6666666667,
1, -1, 11.1666666667);
1, -1, 11.1666666667,
2, -1, 0.6666666667 + 11.1666666667);
#endif
test_one<polygon, polygon, polygon>("case_80",
@ -213,7 +221,7 @@ void test_all()
1, 9, 44.5,
1, 10, 84.5);
#ifdef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS
#if ! defined(BOOST_GEOMETRY_USE_RESCALING)
// Fails, holes are not subtracted
test_one<polygon, polygon, polygon>("case_81",
case_81[0], case_81[1],
@ -263,7 +271,7 @@ void test_all()
1, 61, 10.2717,
1, 61, 10.2717);
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
#if defined(BOOST_GEOMETRY_USE_RESCALING)
if ( BOOST_GEOMETRY_CONDITION((boost::is_same<ct, double>::value)) )
{
test_one<polygon, polygon, polygon>("buffer_mp2",
@ -287,12 +295,8 @@ void test_all()
{
ut_settings settings;
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
settings.percentage = 0.1;
settings.test_validity = false;
#else
settings.percentage = 0.001;
#endif
settings.percentage = BG_IF_RESCALED(0.001, 0.1);
settings.test_validity = BG_IF_RESCALED(true, false);
// Isovist - the # output polygons differ per compiler/pointtype, (very) small
// rings might be discarded. We check area only
@ -308,7 +312,7 @@ void test_all()
settings);
}
#ifdef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS
#if defined(BOOST_GEOMETRY_TEST_ENABLE_FAILING)
test_one<polygon, polygon, polygon>("geos_1",
geos_1[0], geos_1[1],
21, -1, 0.31640625,
@ -330,18 +334,21 @@ void test_all()
settings.percentage = 0.01;
settings.test_validity = false;
// Output polygons for sym difference might be combined
test_one<polygon, polygon, polygon>("geos_2",
geos_2[0], geos_2[1],
1, -1, 138.6923828,
1, -1, 211.859375,
BG_IF_RESCALED(2, 1), -1, 138.6923828 + 211.859375,
settings);
}
// Output polygons for sym difference might be combined
test_one<polygon, polygon, polygon>("geos_3",
geos_3[0], geos_3[1],
1, -1, 16211128.5,
1, -1, 13180420.0,
1, -1, 16211128.5 + 13180420.0,
BG_IF_RESCALED(1, 2), -1, 16211128.5 + 13180420.0,
sym_settings);
test_one<polygon, polygon, polygon>("geos_4",
@ -371,7 +378,7 @@ void test_all()
1, -1, 35723.8506317139 + 58456.4964294434);
}
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
#if defined(BOOST_GEOMETRY_USE_RESCALING)
{
// symmetric difference is not valid due to robustness issue, it has
// two turns (touch_only) and a midpoint is located in other polygon
@ -392,7 +399,7 @@ void test_all()
1, 5, 384.2295081964694,
tolerance(0.01));
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
#if defined(BOOST_GEOMETRY_USE_RESCALING)
// 2011-07-02 / 2014-06-19
// Interesting FP-precision case.
// sql server gives: 6.62295817619452E-05
@ -409,6 +416,14 @@ void test_all()
);
#endif
{
// With rescaling, difference of output a-b and a sym b is invalid
ut_settings settings;
settings.test_validity = BG_IF_RESCALED(false, true);
TEST_DIFFERENCE_WITH(ggl_list_20190307_matthieu_1, 2, 0.18461532, 2, 0.617978, 4);
TEST_DIFFERENCE_WITH(ggl_list_20190307_matthieu_2, 2, 12.357152, 0, 0.0, 2);
}
// Ticket 8310, one should be completely subtracted from the other.
test_one<polygon, polygon, polygon>("ticket_8310a",
ticket_8310a[0], ticket_8310a[1],
@ -423,7 +438,7 @@ void test_all()
1, 10, 10.03103292,
0, 0, 0);
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
#if defined(BOOST_GEOMETRY_USE_RESCALING)
test_one<polygon, polygon, polygon>("ticket_9081_15",
ticket_9081_15[0], ticket_9081_15[1],
2, 10, 0.0334529710902111,
@ -435,11 +450,11 @@ void test_all()
2, 12, 0.0451236449624935,
0, 0, 0);
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
#if defined(BOOST_GEOMETRY_USE_RESCALING)
test_one<polygon, polygon, polygon>("ticket_9563",
ticket_9563[0], ticket_9563[1],
0, 0, 0,
6, 24, 20.096189);
0, -1, 0,
6, -1, 20.096189);
#endif
test_one<polygon, polygon, polygon>("ticket_10108_a",
@ -448,7 +463,7 @@ void test_all()
1, 4, 0.029019232,
sym_settings);
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
#if defined(BOOST_GEOMETRY_USE_RESCALING)
test_one<polygon, polygon, polygon>("ticket_10108_b",
ticket_10108_b[0], ticket_10108_b[1],
1, 5, 1081.68697,
@ -528,6 +543,14 @@ void test_all()
}
// Rescaling generates a very small false polygon
TEST_DIFFERENCE(issue_566_a, 1, 143.662, BG_IF_RESCALED(1, 0),
BG_IF_RESCALED(1.605078e-6, 0.0),
BG_IF_RESCALED(2, 1));
TEST_DIFFERENCE(issue_566_b, 1, 143.662, BG_IF_RESCALED(1, 0),
BG_IF_RESCALED(1.605078e-6, 0.0),
BG_IF_RESCALED(2, 1));
/***
Experimental (cut), does not work:
test_one<polygon, polygon, polygon>(
@ -544,8 +567,10 @@ void test_all()
TEST_DIFFERENCE(mysql_23023665_2, 1, 96.0, 1, 16.0, 2);
TEST_DIFFERENCE(mysql_23023665_3, 1, 225.0, 1, 66.0, 2);
TEST_DIFFERENCE(mysql_23023665_5, 2, 165.23735, 2, 105.73735, 4);
#if defined(BOOST_GEOMETRY_USE_RESCALING)
TEST_DIFFERENCE(mysql_23023665_6, 2, 105.68756, 3, 10.18756, 5);
TEST_DIFFERENCE(mysql_23023665_13, 3, 99.74526, 3, 37.74526, 6);
#endif
}

View File

@ -18,10 +18,6 @@
#include <sstream>
#include <string>
// If defined, tests are run without rescaling-to-integer or robustness policy
// Test which would fail then are disabled automatically
// #define BOOST_GEOMETRY_NO_ROBUSTNESS
#include <boost/geometry/algorithms/correct.hpp>
#include <boost/geometry/algorithms/is_valid.hpp>

View File

@ -109,9 +109,7 @@ void test_areal()
{
ut_settings settings;
#if !defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
settings.sym_difference = false;
#endif
settings.sym_difference = BG_IF_RESCALED(false, true);
test_one<Polygon, MultiPolygon, MultiPolygon>("case_108_multi",
case_108_multi[0], case_108_multi[1],
@ -150,35 +148,33 @@ void test_areal()
{
ut_settings settings;
settings.percentage = 0.001;
settings.test_validity = BG_IF_RESCALED(true, false);
TEST_DIFFERENCE_WITH(0, 1, ggl_list_20120221_volker, 2, 7962.66, 2, 2775258.93, 4);
}
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
{
// With rescaling, A is invalid (this is a robustness problem) and the other
// output is discarded because of zero (rescaled) area
// POSTGIS areas: 3.75893745345145, 2.5810000723917e-15
ut_settings settings;
settings.sym_difference = false; // Validity problem in sym difference
// POSTGIS areas: 3.75893745345145, 2.5810000723917e-15
TEST_DIFFERENCE_WITH(0, 1, bug_21155501, 1, 3.758937, 1, 1.7763568394002505e-15, 2);
}
#if defined(BOOST_GEOMETRY_USE_RESCALING)
settings.test_validity = false; // Invalid output in A
TEST_DIFFERENCE_WITH(0, 1, bug_21155501, 1, 3.758937, 0, 0.0, 2);
#else
{
// 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;
TEST_DIFFERENCE_WITH(0, 1, bug_21155501, 1, 3.758937, 1, 1.7763568394002505e-15, 2);
#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,
settings);
}
// With rescaling, A is invalid (this is a robustness problem) and the other
// output is discarded because of zero (rescaled) area
TEST_DIFFERENCE_IGNORE(bug_21155501, 1, 3.758937, 0, 0.0, 1);
#if defined(BOOST_GEOMETRY_USE_RESCALING)
{
// Without rescaling, this one misses one of the output polygons
// With rescaling, it is complete but invalid
ut_settings settings;
settings.percentage = 0.001;
settings.test_validity = false;
TEST_DIFFERENCE_WITH(0, 1, ticket_9081, 2, 0.0907392476356186, 4, 0.126018011439877, 4);
}
#endif
TEST_DIFFERENCE(ticket_12503, 46, 920.625, 4, 7.625, 50);
@ -320,7 +316,7 @@ void test_areal()
TEST_DIFFERENCE(case_recursive_boxes_59, 8, 6.5, 7, 7.0, 12);
TEST_DIFFERENCE(case_recursive_boxes_60, 6, 5.25, 7, 5.25, 11);
TEST_DIFFERENCE(case_recursive_boxes_61, 2, 1.5, 6, 2.0, 7);
#if defined(BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS)
#if defined(BOOST_GEOMETRY_TEST_ENABLE_FAILING)
// Misses one triangle
TEST_DIFFERENCE(case_recursive_boxes_62, 5, 5.0, 11, 5.75, 12);
#endif
@ -343,19 +339,15 @@ void test_areal()
TEST_DIFFERENCE(case_recursive_boxes_78, 11, 5.5, 8, 4.5, 14);
TEST_DIFFERENCE(case_recursive_boxes_79, 2, 1.25, 6, 4.5, 8);
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
TEST_DIFFERENCE(case_recursive_boxes_80, 1, 0.5, 2, 0.75, 2);
#else
// one polygon is divided into two, for same reason as union creates a small
// interior ring there
TEST_DIFFERENCE(case_recursive_boxes_80, 1, 0.5, 2, 0.75, 3);
#endif
TEST_DIFFERENCE(case_recursive_boxes_80, 1, 0.5, 2, 0.75, BG_IF_RESCALED(3, 2));
TEST_DIFFERENCE(case_recursive_boxes_81, 3, 5.0, 6, 6.75, 6);
TEST_DIFFERENCE(case_recursive_boxes_82, 5, 7.25, 7, 4.5, 8);
TEST_DIFFERENCE(case_recursive_boxes_83, 9, 5.25, 8, 5.25, 12);
TEST_DIFFERENCE(case_recursive_boxes_84, 4, 8.0, 7, 9.0, 4);
#ifdef BOOST_GEOMETRY_NO_ROBUSTNESS
#if ! defined(BOOST_GEOMETRY_USE_RESCALING)
TEST_DIFFERENCE(case_recursive_boxes_85, 4, 4.0, 7, 3.75, 9);
#endif
@ -370,7 +362,7 @@ void test_areal()
{
ut_settings sym_settings;
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
#if ! defined(BOOST_GEOMETRY_USE_RESCALING)
sym_settings.sym_difference = false;
#endif
test_one<Polygon, MultiPolygon, MultiPolygon>("mysql_21965285_b",
@ -381,11 +373,9 @@ void test_areal()
sym_settings);
}
#ifdef BOOST_GEOMETRY_NO_ROBUSTNESS
TEST_DIFFERENCE(mysql_regression_1_65_2017_08_31, 0, 0.0, 3, 152.0642, 3);
#else
TEST_DIFFERENCE(mysql_regression_1_65_2017_08_31, 1, 4.30697514e-7, 3, 152.0642, 4);
#endif
TEST_DIFFERENCE(mysql_regression_1_65_2017_08_31,
BG_IF_RESCALED(1, 0), BG_IF_RESCALED(4.30697514e-7, 0),
3, 152.0642, BG_IF_RESCALED(4, 3));
}
@ -405,12 +395,9 @@ void test_specific_areal()
{
{
// Spikes in a-b and b-a, failure in symmetric difference
ut_settings settings;
#if !defined(BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS)
settings.sym_difference = false;
settings.test_validity = false;
#endif
TEST_DIFFERENCE_WITH(0, 1, ticket_11674, 3, 9105781.5, 5, 119059.5, -1);
}

View File

@ -10,10 +10,6 @@
#include <iostream>
#include <string>
// If defined, tests are run without rescaling-to-integer or robustness policy
// This multi_difference currently contains no tests for double which then fail
// #define BOOST_GEOMETRY_NO_ROBUSTNESS
//#define HAVE_TTMATH
//#define BOOST_GEOMETRY_DEBUG_ASSEMBLE
//#define BOOST_GEOMETRY_CHECK_WITH_SQLSERVER

View File

@ -105,8 +105,8 @@ void difference_output(std::string const& caseid, G1 const& g1, G2 const& g2, Ou
<< string_from_type<coordinate_type>::name()
<< (ccw ? "_ccw" : "")
<< (open ? "_open" : "")
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
<< "_no_rob"
#if defined(BOOST_GEOMETRY_USE_RESCALING)
<< "_rescaled"
#endif
<< ".svg";
@ -191,7 +191,9 @@ std::string test_difference(std::string const& caseid, G1 const& g1, G2 const& g
? bg::num_points(result) : 0;
#if ! defined(BOOST_GEOMETRY_NO_BOOST_TEST)
#if ! defined(BOOST_GEOMETRY_TEST_ENABLE_FAILING)
if (settings.test_validity)
#endif
{
// std::cout << bg::dsv(result) << std::endl;
std::string message;
@ -340,7 +342,9 @@ std::string test_one(std::string const& caseid,
expected_count2, expected_rings_count2, expected_point_count2,
expected_area2, false, settings);
#if ! defined(BOOST_GEOMETRY_TEST_ENABLE_FAILING)
if (settings.sym_difference)
#endif
{
test_difference<OutputType>(caseid + "_s", g1, g2,
expected_count_s,

View File

@ -178,10 +178,7 @@ void test_areal()
{
ut_settings settings(if_typed_tt<ct>(0.01, 0.1));
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
settings.test_validity = false;
#endif
settings.test_validity = BG_IF_RESCALED(true, false);
// SQL Server gives: 88.1920416352664
// PostGIS gives: 88.19203677911
@ -203,11 +200,9 @@ void test_areal()
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)
test_one<Polygon, Polygon, Polygon>("geos_3",
geos_3[0], geos_3[1],
0, 0, 0.0);
#endif
test_one<Polygon, Polygon, Polygon>("geos_4",
geos_4[0], geos_4[1],
1, -1, 0.08368849);
@ -228,23 +223,15 @@ void test_areal()
// SQL Server reports: 0.400390625
// PostGIS reports 0.4
// BG did report 0.4 but is changed to 0.397
// BG did report 0.4 but with rescaling 0.397
// when selecting other IP closer at endpoint or if segment B is smaller than A
test_one<Polygon, Polygon, Polygon>("ggl_list_20110307_javier",
ggl_list_20110307_javier[0], ggl_list_20110307_javier[1],
1, 4,
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
0.40
#else
0.397162651, ut_settings(0.01)
#endif
);
1, 4, BG_IF_RESCALED(0.397162651, 0.40), ut_settings(0.01));
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
test_one<Polygon, Polygon, Polygon>("ggl_list_20110627_phillip",
ggl_list_20110627_phillip[0], ggl_list_20110627_phillip[1],
1, if_typed_tt<ct>(6, 5), 11151.6618);
#endif
test_one<Polygon, Polygon, Polygon>("ggl_list_20110716_enrico",
ggl_list_20110716_enrico[0], ggl_list_20110716_enrico[1],
@ -263,7 +250,10 @@ void test_areal()
ggl_list_20140321_7415963[0], ggl_list_20140321_7415963[1],
0, 0, 0, ut_settings(0.1));
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
TEST_INTERSECTION(ggl_list_20190307_matthieu_1, 2, -1, 0.035136);
TEST_INTERSECTION(ggl_list_20190307_matthieu_2, 1, -1, 3.64285);
#if defined(BOOST_GEOMETRY_USE_RESCALING)
test_one<Polygon, Polygon, Polygon>("buffer_rt_f", buffer_rt_f[0], buffer_rt_f[1],
1, 4, 0.00029437899183903937, ut_settings(0.01));
@ -293,7 +283,7 @@ void test_areal()
ticket_10108_a[0], ticket_10108_a[1],
0, 0, 0.0);
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
#if defined(BOOST_GEOMETRY_USE_RESCALING)
// msvc 5.6023011e-5
// mingw 5.6022954e-5
test_one<Polygon, Polygon, Polygon>("ticket_10108_b",
@ -324,6 +314,14 @@ void test_areal()
test_one<Polygon, Polygon, Polygon>("ticket_9563", ticket_9563[0], ticket_9563[1],
1, 8, 129.90381);
#if ! defined(BOOST_GEOMETRY_USE_RESCALING)
// With rescaling the output is empty
TEST_INTERSECTION(issue_548, 1, -1, 1958824415.2151);
#endif
TEST_INTERSECTION(issue_566_a, 1, -1, 70.7107);
TEST_INTERSECTION(issue_566_b, 1, -1, 70.7107);
test_one<Polygon, Polygon, Polygon>("buffer_mp1", buffer_mp1[0], buffer_mp1[1],
1, 31, 2.271707796);
test_one<Polygon, Polygon, Polygon>("buffer_mp2", buffer_mp2[0], buffer_mp2[1],
@ -923,7 +921,7 @@ int test_main(int, char* [])
test_boxes_nd<double>();
#ifdef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS
#if defined(BOOST_GEOMETRY_TEST_ENABLE_FAILING)
// ticket #10868 still fails for 32-bit integers
test_ticket_10868<int32_t>("MULTIPOLYGON(((33520458 6878575,33480192 14931538,31446819 18947953,30772384 19615678,30101303 19612322,30114725 16928001,33520458 6878575)))");

View File

@ -135,7 +135,7 @@ void test_areal()
case_107_multi[1], case_107_multi[2],
3, 13, 3.0);
#ifdef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS
#if defined(BOOST_GEOMETRY_TEST_ENABLE_FAILING)
{
ut_settings ignore_validity; ignore_validity.test_validity = false;
@ -326,23 +326,15 @@ void test_areal()
TEST_INTERSECTION(case_recursive_boxes_82, 5, -1, 8.5);
TEST_INTERSECTION(case_recursive_boxes_83, 5, -1, 10.25);
TEST_INTERSECTION(case_recursive_boxes_84, 1, -1, 0.5);
#ifdef BOOST_GEOMETRY_NO_ROBUSTNESS
TEST_INTERSECTION(case_recursive_boxes_85, 1, -1, 0.25);
#endif
TEST_INTERSECTION(case_recursive_boxes_86, 0, -1, 0.0);
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],
@ -360,16 +352,12 @@ void test_areal()
mail_2019_01_21_johan[2], mail_2019_01_21_johan[3],
2, -1, 0.0005889587);
// Very small slice is generated.
// qcc-arm reports 1.7791215549400884e-14
test_one<Polygon, MultiPolygon, MultiPolygon>("ticket_11018",
ticket_11018[0], ticket_11018[1],
1, 4,
#ifdef BOOST_GEOMETRY_NO_ROBUSTNESS
9.896437631745599e-09
#else
1.7791170511070893e-14, ut_settings(0.001)
#endif
1, 4, BG_IF_RESCALED(1.7791170511070893e-14, 9.896437631745599e-09),
ut_settings(0.001)
);
TEST_INTERSECTION(ticket_12503, 2, 13, 17.375);

View File

@ -105,7 +105,9 @@ check_result(
}
}
#if ! defined(BOOST_GEOMETRY_TEST_ENABLE_FAILING)
if (settings.test_validity)
#endif
{
std::string message;
bool const valid = check_validity<ResultType>::apply(intersection_output, message);
@ -115,7 +117,8 @@ check_result(
}
#if ! defined(BOOST_GEOMETRY_NO_BOOST_TEST)
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
#if defined(BOOST_GEOMETRY_USE_RESCALING)
// Without rescaling, point count might easily differ (which is no problem)
if (expected_point_count > 0)
{
BOOST_CHECK_MESSAGE(bg::math::abs(n - expected_point_count) < 3,
@ -256,8 +259,8 @@ typename bg::default_area_result<G1>::type test_intersection(std::string const&
<< string_from_type<CalculationType>::name()
<< (ccw ? "_ccw" : "")
<< (open ? "_open" : "")
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
<< "_no_rob"
#if defined(BOOST_GEOMETRY_USE_RESCALING)
<< "_rescaled"
#endif
<< ".svg";

View File

@ -125,7 +125,9 @@ void test_union(std::string const& caseid, G1 const& g1, G2 const& g2,
}
#endif
#if ! defined(BOOST_GEOMETRY_TEST_ENABLE_FAILING)
if (settings.test_validity)
#endif
{
std::string message;
bool const valid = check_validity<result_type>::apply(clip, message);
@ -197,7 +199,8 @@ void test_union(std::string const& caseid, G1 const& g1, G2 const& g2,
<< " type: " << (type_for_assert_message<G1, G2>())
);
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
#if defined(BOOST_GEOMETRY_USE_RESCALING)
// Without rescaling, point count might easily differ (which is no problem)
BOOST_CHECK_MESSAGE(expected_point_count < 0 || std::abs(int(n) - expected_point_count) < 3,
"union: " << caseid
<< " #points expected: " << expected_point_count
@ -223,8 +226,8 @@ void test_union(std::string const& caseid, G1 const& g1, G2 const& g2,
<< string_from_type<coordinate_type>::name()
<< (ccw ? "_ccw" : "")
<< (open ? "_open" : "")
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
<< "_no_rob"
#if defined(BOOST_GEOMETRY_USE_RESCALING)
<< "_rescaled"
#endif
<< ".svg";

View File

@ -324,17 +324,15 @@ void test_areal()
ggl_list_20110307_javier[0], ggl_list_20110307_javier[1],
1, 1, 13, 20016.4);
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
test_one<Polygon, Polygon, Polygon>("ggl_list_20110627_phillip",
ggl_list_20110627_phillip[0], ggl_list_20110627_phillip[1],
1, 0, 8, 14729.07145);
#endif
test_one<Polygon, Polygon, Polygon>("ggl_list_20110716_enrico",
ggl_list_20110716_enrico[0], ggl_list_20110716_enrico[1],
1, 1, 15, 129904.197692871);
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
#if defined(BOOST_GEOMETRY_USE_RESCALING)
test_one<Polygon, Polygon, Polygon>("ggl_list_20110820_christophe",
ggl_list_20110820_christophe[0], ggl_list_20110820_christophe[1],
-1, // Either 1 or 2, depending if the intersection/turn point (eps.region) is missed
@ -346,9 +344,7 @@ void test_areal()
{
ut_settings settings;
settings.percentage = 0.1;
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
settings.test_validity = false;
#endif
settings.test_validity = BG_IF_RESCALED(true, false);
test_one<Polygon, Polygon, Polygon>("isovist",
isovist1[0], isovist1[1],
@ -361,6 +357,9 @@ void test_areal()
// PostGIS gives: 313.360364623393
}
TEST_UNION(ggl_list_20190307_matthieu_1, 1, 1, -1, 0.83773);
TEST_UNION(ggl_list_20190307_matthieu_2, 1, 0, -1, 16.0);
// Ticket 5103 https://svn.boost.org/trac/boost/ticket/5103
// This ticket was actually reported for Boost.Polygon
// We check it for Boost.Geometry as well.
@ -396,18 +395,13 @@ void test_areal()
test_one<Polygon, Polygon, Polygon>("ticket_9756", ticket_9756[0], ticket_9756[1],
1, 0, 10, if_typed<ct, float>(1291.5469, 1289.08374));
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
// Can generate one polygon, or two splitted, both is OK
test_one<Polygon, Polygon, Polygon>("ticket_10108_a", ticket_10108_a[0], ticket_10108_a[1],
1, 0, 8, 0.0435229);
#else
test_one<Polygon, Polygon, Polygon>("ticket_10108_a", ticket_10108_a[0], ticket_10108_a[1],
2, 0, 8, 0.0435229);
#endif
BG_IF_RESCALED(2, 1), 0, 8, 0.0435229);
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
// Can generate one combined polygon, or two splitted, both is acceptable
test_one<Polygon, Polygon, Polygon>("ticket_10108_b", ticket_10108_b[0], ticket_10108_b[1],
1, 0, 10, 2424.3449);
#endif
BG_IF_RESCALED(1, 2), 0, 10, 2424.3449);
test_one<Polygon, Polygon, Polygon>("ticket_10866", ticket_10866[0], ticket_10866[1],
1, 0, 14, if_typed<ct, float>(332752493.0, 332760303.5));
@ -415,6 +409,14 @@ void test_areal()
test_one<Polygon, Polygon, Polygon>("ticket_11725", ticket_11725[0], ticket_11725[1],
1, 1, 10, 7.5);
#if ! defined(BOOST_GEOMETRY_USE_RESCALING)
// With rescaling an extra overlapping polygon is generated
TEST_UNION(issue_548, 1, 0, -1, 617382720000);
#endif
TEST_UNION(issue_566_a, 1, 0, -1, 214.3728);
TEST_UNION(issue_566_b, 1, 0, -1, 214.3728);
{
ut_settings ignore_validity;
ignore_validity.test_validity = false;
@ -433,32 +435,32 @@ void test_areal()
1, 0, 265, 19.280667);
// Robustness issues, followed out buffer-robustness-tests, test them also reverse
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
#if defined(BOOST_GEOMETRY_USE_RESCALING)
test_one<Polygon, Polygon, Polygon>("buffer_rt_f", buffer_rt_f[0], buffer_rt_f[1],
1, 0, -1, 4.60853);
test_one<Polygon, Polygon, Polygon>("buffer_rt_f_rev", buffer_rt_f[1], buffer_rt_f[0],
1, 0, -1, 4.60853);
#endif
test_one<Polygon, Polygon, Polygon>("buffer_rt_g", buffer_rt_g[0], buffer_rt_g[1],
1, 0, -1, 16.571);
test_one<Polygon, Polygon, Polygon>("buffer_rt_g_rev", buffer_rt_g[1], buffer_rt_g[0],
1, 0, -1, 16.571);
#if defined(BOOST_GEOMETRY_USE_RESCALING)
test_one<Polygon, Polygon, Polygon>("buffer_rt_i", buffer_rt_i[0], buffer_rt_i[1],
1, 0, -1, 13.6569);
#endif
test_one<Polygon, Polygon, Polygon>("buffer_rt_i_rev", buffer_rt_i[1], buffer_rt_i[0],
1, 0, -1, 13.6569);
#endif
test_one<Polygon, Polygon, Polygon>("buffer_rt_j", buffer_rt_j[0], buffer_rt_j[1],
1, 0, -1, 16.5711);
test_one<Polygon, Polygon, Polygon>("buffer_rt_j_rev", buffer_rt_j[1], buffer_rt_j[0],
1, 0, -1, 16.5711);
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
test_one<Polygon, Polygon, Polygon>("buffer_rt_l", buffer_rt_l[0], buffer_rt_l[1],
1, 0, -1, 19.3995);
test_one<Polygon, Polygon, Polygon>("buffer_rt_l_rev", buffer_rt_l[1], buffer_rt_l[0],
1, 0, -1, 19.3995);
#endif
test_one<Polygon, Polygon, Polygon>("buffer_rt_m1", buffer_rt_m1[0], buffer_rt_m1[1],
1, 0, 9, 19.4852);
@ -470,30 +472,26 @@ void test_areal()
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, -1, 18.5710);
test_one<Polygon, Polygon, Polygon>("buffer_rt_q_rev", buffer_rt_q[1], buffer_rt_q[0],
1, 0, -1, 18.5710);
#if defined(BOOST_GEOMETRY_USE_RESCALING)
test_one<Polygon, Polygon, Polygon>("buffer_rt_r", buffer_rt_r[0], buffer_rt_r[1],
1, 0, -1, 21.07612);
test_one<Polygon, Polygon, Polygon>("buffer_rt_r_rev", buffer_rt_r[1], buffer_rt_r[0],
1, 0, -1, 21.07612);
#endif
test_one<Polygon, Polygon, Polygon>("buffer_rt_t", buffer_rt_t[0], buffer_rt_t[1],
1, 0, -1, 15.6569);
test_one<Polygon, Polygon, Polygon>("buffer_rt_t_rev", buffer_rt_t[1], buffer_rt_t[0],
1, 0, -1, 15.6569);
#endif
test_one<Polygon, Polygon, Polygon>("buffer_mp1", buffer_mp1[0], buffer_mp1[1],
1, 0, if_typed_tt<ct>(93, 91), 22.815);
test_one<Polygon, Polygon, Polygon>("buffer_mp2", buffer_mp2[0], buffer_mp2[1],
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
1, 0, 217, 36.752837);
#else
1, 1, 217, 36.752837);
#endif
1, BG_IF_RESCALED(1, 0), 217, 36.752837);
test_one<Polygon, Polygon, Polygon>("mysql_21964079_1",
mysql_21964079_1[0], mysql_21964079_1[1],
@ -580,7 +578,7 @@ int test_main(int, char* [])
#if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE)
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
#if defined(BOOST_GEOMETRY_USE_RESCALING)
test_all<bg::model::d2::point_xy<float> >();
test_all<bg::model::d2::point_xy<long double> >();
#endif

View File

@ -363,13 +363,8 @@ void test_areal()
TEST_UNION(case_recursive_boxes_78, 2, 5, -1, 18.0);
TEST_UNION(case_recursive_boxes_79, 1, 2, -1, 14.75);
#if defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
// This is correct: no holes generated
TEST_UNION(case_recursive_boxes_80, 2, 0, -1, 1.5);
#else
// See comment for this testcase
TEST_UNION(case_recursive_boxes_80, 2, 1, -1, 1.5);
#endif
// No hole should be generated (but rescaling generates one hole)
TEST_UNION(case_recursive_boxes_80, 2, BG_IF_RESCALED(1, 0), -1, 1.5);
TEST_UNION(case_recursive_boxes_81, 5, 0, -1, 15.5);
TEST_UNION(case_recursive_boxes_82, 2, 2, -1, 20.25);
@ -392,19 +387,13 @@ void test_areal()
2, 0, 16, 0.002471626);
{
// Generates either 4 or 3 output polygons
// With rescaling the result is invalid.
ut_settings settings;
#if !defined(BOOST_GEOMETRY_NO_ROBUSTNESS) && !defined(BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS)
settings.test_validity = false;
#endif
settings.test_validity = BG_IF_RESCALED(false, true);
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,
BG_IF_RESCALED(4, 3), 0, 31, 0.2187385,
settings);
}
@ -419,7 +408,7 @@ void test_areal()
ticket_12118[0], ticket_12118[1],
1, 1, 27, 2221.38713);
#if defined(BOOST_GEOMETRY_ENABLE_FAILING_TESTS) || defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
#if defined(BOOST_GEOMETRY_TEST_ENABLE_FAILING) || ! defined(BOOST_GEOMETRY_USE_RESCALING)
// No output if rescaling is done
test_one<Polygon, MultiPolygon, MultiPolygon>("ticket_12125",
ticket_12125[0], ticket_12125[1],

View File

@ -13,6 +13,7 @@ test-suite boost-geometry-formulas
:
[ run inverse.cpp : : : : formulas_inverse ]
[ run direct.cpp : : : : formulas_direct ]
[ run direct_accuracy.cpp : : : : formulas_direct_accuracy ]
[ run direct_meridian.cpp : : : : formulas_direct_meridian ]
[ run intersection.cpp : : : : formulas_intersection ]
[ run vertex_longitude.cpp : : : : formulas_vertex_longitude ]

View File

@ -23,6 +23,30 @@
#include <boost/geometry/srs/srs.hpp>
#ifdef BOOST_GEOEMTRY_TEST_WITH_GEOGRAPHICLIB
#include <GeographicLib/Geodesic.hpp>
#include <GeographicLib/Constants.hpp>
#endif // BOOST_GEOEMTRY_TEST_WITH_GEOGRAPHICLIB
inline void symmetrize_wrt_origin(expected_result & r)
{
r.lon2 = -r.lon2;
r.lat2 = -r.lat2;
r.reduced_length = -r.reduced_length;
}
inline expected_results symmetric_wrt_origin(expected_results r)
{
r.distance = -r.distance;
symmetrize_wrt_origin(r.karney);
symmetrize_wrt_origin(r.series);
symmetrize_wrt_origin(r.spherical);
symmetrize_wrt_origin(r.thomas);
symmetrize_wrt_origin(r.thomas1st);
symmetrize_wrt_origin(r.vincenty);
return r;
}
template <typename Result>
void check_direct(Result const& result, expected_result const& expected, expected_result const& reference,
double reference_error, bool check_reference_only = false)
@ -98,7 +122,20 @@ void test_all(expected_results const& results)
typedef bg::formula::karney_direct<double, true, true, true, true, 2> ka_t;
result = ka_t::apply(lon1d, lat1d, distance, azi12d, spheroid);
check_direct(result, results.thomas, results.karney, 0.0000001);
check_direct(result, results.karney, results.karney, 0.0000001);
#ifdef BOOST_GEOEMTRY_TEST_WITH_GEOGRAPHICLIB
{
using namespace GeographicLib;
Geodesic geod(Constants::WGS84_a(), Constants::WGS84_f());
double foo = 0;
geod.Direct(lat1d, lon1d, azi12d, distance,
result.lat2, result.lon2, result.reverse_azimuth,
result.reduced_length, result.geodesic_scale, foo);
boost::ignore_unused(foo);
check_direct(result, results.karney, results.karney, 0.0000001);
}
#endif
}
void test_karney_antipodal(expected_results_antipodal const& results)
@ -123,6 +160,11 @@ int test_main(int, char*[])
for (size_t i = 0; i < expected_size; ++i)
{
test_all(expected[i]);
if (expected[i].p1.lon == 0 && expected[i].p1.lat == 0)
{
test_all(symmetric_wrt_origin(expected[i]));
}
}
for (size_t i = 0; i < expected_size_antipodal; ++i)

View File

@ -0,0 +1,97 @@
// Boost.Geometry
// Unit Test
// Copyright (c) 2019 Oracle and/or its affiliates.
// Contributed and/or modified by Vissarion Fysikopoulos, 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
// http://www.boost.org/LICENSE_1_0.txt)
#include <geometry_test_common.hpp>
#include <boost/geometry/formulas/karney_direct.hpp>
#include <boost/geometry/srs/srs.hpp>
#ifdef BOOST_GEOEMTRY_TEST_WITH_GEOGRAPHICLIB
#include <GeographicLib/Geodesic.hpp>
#include <GeographicLib/Constants.hpp>
#endif // BOOST_GEOEMTRY_TEST_WITH_GEOGRAPHICLIB
int test_main(int, char*[])
{
#ifdef BOOST_GEOEMTRY_TEST_WITH_GEOGRAPHICLIB
// accuracy test from https://github.com/boostorg/geometry/issues/560
using namespace GeographicLib;
const long double wgs84_a = 6378137.0L;
const long double wgs84_f = 1.0L / 298.257223563L;
const long double one_minus_f = 1.0L - wgs84_f;
const long double wgs84_b = wgs84_a * one_minus_f;
const boost::geometry::srs::spheroid<long double> BoostWGS84(wgs84_a, wgs84_b);
// boost karney_direct function class with azimuth output and SeriesOrder = 6
typedef boost::geometry::formula::karney_direct <double, true, true, false, false, 6u>
BoostKarneyDirect_6;
// boost karney_direct function class with azimuth output and SeriesOrder = 8
typedef boost::geometry::formula::karney_direct <double, true, true, false, false, 8u>
BoostKarneyDirect_8;
// boost test BOOST_CHECK_CLOSE macro takes a percentage accuracy parameter
const double EPSILON = std::numeric_limits<double>::epsilon();
const double CALCULATION_TOLERANCE = 100 * EPSILON;
const Geodesic GeographicLibWGS84(Geodesic::WGS84());
// Loop around latitudes: 0 to 89 degrees
for (int i=0; i < 90; ++i)
{
// The latitude in degrees.
double latitude(1.0 * i);
// Loop around longitudes: 1 to 179 degrees
for (int j=1; j < 180; ++j)
{
// The longitude in degrees.
double longitude(1.0 * j);
// The Geodesic: distance in metres, start azimuth and finish azimuth in degrees.
double distance_m, azimuth, azi2;
GeographicLibWGS84.Inverse(0.0, 0.0, latitude, longitude, distance_m, azimuth, azi2);
// The GeographicLib position and azimuth at the distance in metres
double lat2k, lon2k, azi2k;
GeographicLibWGS84.Direct(0.0, 0.0, azimuth, distance_m, lat2k, lon2k, azi2k);
BOOST_CHECK_CLOSE(latitude, lat2k, 140 * CALCULATION_TOLERANCE);
BOOST_CHECK_CLOSE(longitude, lon2k, 120 * CALCULATION_TOLERANCE);
// The boost karney_direct order 6 position at the azimuth and distance in metres.
boost::geometry::formula::result_direct<double> results_6
= BoostKarneyDirect_6::apply(0.0, 0.0, distance_m, azimuth, BoostWGS84);
BOOST_CHECK_CLOSE(azi2, results_6.reverse_azimuth, 140 * CALCULATION_TOLERANCE);
BOOST_CHECK_CLOSE(latitude, results_6.lat2, 220 * CALCULATION_TOLERANCE);
/******** Test below only passes with >= 10172000 * CALCULATION_TOLERANCE !! ********/
BOOST_CHECK_CLOSE(longitude, results_6.lon2, 10171000 * CALCULATION_TOLERANCE);
/*****************************************************************************/
// The boost karney_direct order 8 position at the azimuth and distance in metres.
boost::geometry::formula::result_direct<double> results_8
= BoostKarneyDirect_8::apply(0.0, 0.0, distance_m, azimuth, BoostWGS84);
BOOST_CHECK_CLOSE(azi2, results_8.reverse_azimuth, 140 * CALCULATION_TOLERANCE);
BOOST_CHECK_CLOSE(latitude, results_8.lat2, 220 * CALCULATION_TOLERANCE);
/******** Test below only passes with >= 10174000 * CALCULATION_TOLERANCE !! ********/
BOOST_CHECK_CLOSE(longitude, results_8.lon2, 10173000 * CALCULATION_TOLERANCE);
/*****************************************************************************/
}
}
#endif // BOOST_GEOEMTRY_TEST_WITH_GEOGRAPHICLIB
return 0;
}

View File

@ -101,6 +101,7 @@
// - do NOT use "using namespace boost::geometry" to make clear what is Boost.Geometry
// - use bg:: as short alias
#include <boost/geometry/core/coordinate_type.hpp>
#include <boost/geometry/core/config.hpp>
#include <boost/geometry/core/closure.hpp>
#include <boost/geometry/core/point_order.hpp>
#include <boost/geometry/core/tag.hpp>
@ -160,6 +161,10 @@ struct mathematical_policy
};
#if defined(BOOST_GEOMETRY_USE_RESCALING)
#define BG_IF_RESCALED(a, b) a
#else
#define BG_IF_RESCALED(a, b) b
#endif
#endif // GEOMETRY_TEST_GEOMETRY_TEST_COMMON_HPP