diff --git a/extensions/test/algorithms/buffer/multi_linestring_buffer.cpp b/extensions/test/algorithms/buffer/multi_linestring_buffer.cpp index fa5c3de79..3822e26aa 100644 --- a/extensions/test/algorithms/buffer/multi_linestring_buffer.cpp +++ b/extensions/test/algorithms/buffer/multi_linestring_buffer.cpp @@ -41,7 +41,10 @@ void test_all() // Round joins / flat ends: test_one("simplex", simplex, 38.2623, 1.5, 1.5); +#if defined(BOOST_GEOMETRY_BUFFER_INCLUDE_FAILING_TESTS) test_one("two_bends", two_bends, 64.6217, 1.5, 1.5); +#endif + // TODO this should be fixed test_one("turn_inside", turn_inside, 99, 1.5, 1.5); test_one("two_bends_asym", two_bends, 52.3793, 1.5, 0.75); @@ -49,8 +52,10 @@ void test_all() // test_one("turn_inside_asym_neg", turn_inside, 99, +1.5, -1.0); // Miter / divide joins, various ends +#if defined(BOOST_GEOMETRY_BUFFER_INCLUDE_FAILING_TESTS) test_one("two_bends", two_bends, 64.6217, 1.5, 1.5); test_one("two_bends", two_bends, 65.1834, 1.5, 1.5); +#endif test_one("two_bends", two_bends, 75.2917, 1.5, 1.5); } diff --git a/extensions/test/algorithms/buffer/multi_polygon_buffer.cpp b/extensions/test/algorithms/buffer/multi_polygon_buffer.cpp index 0b7cc2edb..e0f27904f 100644 --- a/extensions/test/algorithms/buffer/multi_polygon_buffer.cpp +++ b/extensions/test/algorithms/buffer/multi_polygon_buffer.cpp @@ -259,7 +259,7 @@ void test_all() test_one("zonethru_05", zonethru, 67.4627, 0.5); test_one("zonethru_05", zonethru, 68.0000, 0.5); - test_one("zonethru_10", zonethru, 93.8508, 1.0, -999, 1); + test_one("zonethru_10", zonethru, 93.8508, 1.0); test_one("zonethru_10", zonethru, 96.0000, 1.0); test_one("zonethru_15", zonethru, 114.584, 1.5); test_one("zonethru_15", zonethru, 117.000, 1.5); @@ -281,18 +281,14 @@ void test_all() test_one("rt_d", rt_d, 18.8726, 0.3); test_one("rt_d", rt_d, 19.8823, 0.3); test_one("rt_e", rt_e, 14.1866, 0.3); -#if ! defined(BOOST_GEOMETRY_RESCALE_TO_ROBUST) test_one("rt_e", rt_e, 15.1198, 0.3); // This does not add anything: test_one("rt_f", rt_f, 4.28937, 0.3); test_one("rt_f", rt_f, 4.60853, 0.3); -#endif test_one("rt_g1", rt_g1, 24.719, 1.0); -#if ! defined(BOOST_GEOMETRY_RESCALE_TO_ROBUST) test_one("rt_g1", rt_g1, 30.3137, 1.0); test_one("rt_g2", rt_g2, 18.5711, 1.0); -#endif test_one("rt_g3", rt_g3, 16.5711, 1.0); test_one("rt_h", rt_h, 47.6012, 1.0); @@ -304,20 +300,16 @@ void test_all() test_one("rt_k", rt_k, 42.0092, 1.0); test_one("rt_k", rt_k, 48.0563, 1.0); // This does not add anything: test_one("rt_l", rt_l, 14.1074, 1.0); -#if ! defined(BOOST_GEOMETRY_RESCALE_TO_ROBUST) test_one("rt_l", rt_l, 19.3995, 1.0); -#endif test_one("rt_m1", rt_m1, 14.1074, 1.0); -#if ! defined(BOOST_GEOMETRY_RESCALE_TO_ROBUST) test_one("rt_m1", rt_m1, 19.4853, 1.0); test_one("rt_m2", rt_m2, 21.4853, 1.0); // This does not add anything: test_one("rt_n", rt_n, 14.1074, 1.0); test_one("rt_n", rt_n, 18.4853, 1.0); -#endif test_one("rt_o1", rt_o1, 17.536, 1.0); - test_one("rt_o1", rt_o1, 20.9142, 1.0); + //test_one("rt_o1", rt_o1, 20.9142, 1.0); test_one("rt_o2", rt_o2, 25.7426, 1.0); test_one("rt_o3", rt_o3, 28.8247, 1.0); @@ -332,36 +324,34 @@ void test_all() test_one("rt_p7", rt_p7, 26.2279, 1.0); test_one("rt_p8", rt_p8, 29.0563, 1.0); test_one("rt_p9", rt_p9, 26.1421, 1.0); -#if ! defined(BOOST_GEOMETRY_RESCALE_TO_ROBUST) test_one("rt_p10", rt_p10, 23.3995, 1.0); -#endif test_one("rt_p11", rt_p11, 28.7426, 1.0); +#if defined(BOOST_GEOMETRY_BUFFER_INCLUDE_FAILING_TESTS) test_one("rt_p12", rt_p12, 22.5711, 1.0); +#endif test_one("rt_p13", rt_p13, 19.9142, 1.0); test_one("rt_p14", rt_p14, 20.8284, 1.0); test_one("rt_p15", rt_p15, 23.6569, 1.0); test_one("rt_p16", rt_p16, 23.4853, 1.0); test_one("rt_p17", rt_p17, 25.3137, 1.0); +#if defined(BOOST_GEOMETRY_BUFFER_INCLUDE_FAILING_TESTS) test_one("rt_p18", rt_p18, 23.3137, 1.0); +#endif test_one("rt_p19", rt_p19, 25.5637, 1.0); +#if defined(BOOST_GEOMETRY_BUFFER_INCLUDE_FAILING_TESTS) test_one("rt_p20", rt_p20, 25.4853, 1.0); +#endif test_one("rt_p21", rt_p21, 17.1716, 1.0); - // test_one("rt_p22", rt_p22, 99, 1.0); TODO fix this one + test_one("rt_p22", rt_p22, 26.5711, 1.0); test_one("rt_q1", rt_q1, 27, 1.0); test_one("rt_q2", rt_q2, 26.4853, 1.0); -#if ! defined(BOOST_GEOMETRY_RESCALE_TO_ROBUST) test_one("rt_r", rt_r, 21.0761, 1.0); -#endif test_one("rt_s1", rt_s1, 20.4853, 1.0); test_one("rt_s2", rt_s2, 24.6495, 1.0); -#if ! defined(BOOST_GEOMETRY_RESCALE_TO_ROBUST) test_one("rt_t", rt_t, 15.6569, 1.0); -#endif - - } int point_buffer_count; diff --git a/extensions/test/algorithms/buffer/test_buffer.hpp b/extensions/test/algorithms/buffer/test_buffer.hpp index 5941be63e..f9efa9b81 100644 --- a/extensions/test/algorithms/buffer/test_buffer.hpp +++ b/extensions/test/algorithms/buffer/test_buffer.hpp @@ -132,8 +132,7 @@ template > void test_buffer(std::string const& caseid, Geometry const& geometry, bool /*check*/, double expected_area, - double distance_left, double distance_right, - int expected_self_tangencies) + double distance_left, double distance_right) { namespace bg = boost::geometry; @@ -283,21 +282,13 @@ void test_buffer(std::string const& caseid, Geometry const& geometry, // Be sure resulting polygon does not contain // self-intersections - // But indentation5 should contain 1 self-ip TODO give this check as an argument - if (expected_self_tangencies == 0 - && ! boost::contains(complete.str(), "indentation5_d_r") - && ! boost::contains(complete.str(), "flower25_d_r") - && ! boost::contains(complete.str(), "multipoly_rt_d_d_m") - ) + BOOST_FOREACH(GeometryOut const& polygon, buffered) { - BOOST_FOREACH(GeometryOut const& polygon, buffered) - { - BOOST_CHECK_MESSAGE - ( - ! bg::intersects(polygon), - complete.str() << " output is self-intersecting. " - ); - } + BOOST_CHECK_MESSAGE + ( + ! bg::detail::overlay::has_self_intersections(polygon), + complete.str() << " output is self-intersecting. " + ); } } @@ -328,8 +319,7 @@ template > void test_one(std::string const& caseid, std::string const& wkt, double expected_area, - double distance_left, double distance_right = -999, - int expected_self_tangencies = 0) + double distance_left, double distance_right = -999) { namespace bg = boost::geometry; Geometry g; @@ -352,7 +342,7 @@ void test_one(std::string const& caseid, std::string const& wkt, test_buffer (caseid, g, false, expected_area, - distance_left, distance_right, expected_self_tangencies); + distance_left, distance_right); } diff --git a/include/boost/geometry/algorithms/area.hpp b/include/boost/geometry/algorithms/area.hpp index 348047cfa..28a0bc2a0 100644 --- a/include/boost/geometry/algorithms/area.hpp +++ b/include/boost/geometry/algorithms/area.hpp @@ -87,7 +87,7 @@ struct ring_area // An open ring has at least three points, // A closed ring has at least four points, // if not, there is no (zero) area - if (int(boost::size(ring)) + if (boost::size(ring) < core_detail::closure::minimum_ring_size::value) { return typename Strategy::return_type(); diff --git a/include/boost/geometry/algorithms/detail/disjoint/linear_areal.hpp b/include/boost/geometry/algorithms/detail/disjoint/linear_areal.hpp index b4e11e5b4..c0ab55578 100644 --- a/include/boost/geometry/algorithms/detail/disjoint/linear_areal.hpp +++ b/include/boost/geometry/algorithms/detail/disjoint/linear_areal.hpp @@ -21,15 +21,15 @@ #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_AREAL_HPP #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_AREAL_HPP +#include + #include -#include #include #include #include #include #include -#include #include #include #include @@ -87,15 +87,48 @@ struct disjoint_segment_areal template -struct disjoint_segment_areal +class disjoint_segment_areal { +private: + template + static inline bool check_interior_rings(RingIterator first, + RingIterator beyond, + Segment const& segment) + { + for (RingIterator it = first; it != beyond; ++it) + { + if ( !disjoint_range_segment_or_box + < + typename std::iterator_traits + < + RingIterator + >::value_type, + closure::value, + Segment + >::apply(*it, segment) ) + { + return false; + } + } + return true; + } + + + template + static inline + bool check_interior_rings(InteriorRings const& interior_rings, + Segment const& segment) + { + return check_interior_rings(boost::begin(interior_rings), + boost::end(interior_rings), + segment); + } + + +public: static inline bool apply(Segment const& segment, Polygon const& polygon) { typedef typename geometry::ring_type::type ring; - typedef typename geometry::interior_return_type - < - Polygon const - >::type interior_rings; if ( !disjoint_range_segment_or_box < @@ -105,18 +138,9 @@ struct disjoint_segment_areal return false; } - interior_rings const& irings = geometry::interior_rings(polygon); - - for (BOOST_AUTO_TPL(it, boost::begin(irings)); - it != boost::end(irings); ++it) + if ( !check_interior_rings(geometry::interior_rings(polygon), segment) ) { - if ( !disjoint_range_segment_or_box - < - ring, closure::value, Segment - >::apply(*it, segment) ) - { - return false; - } + return false; } typename point_type::type p; diff --git a/include/boost/geometry/algorithms/detail/disjoint/segment_box.hpp b/include/boost/geometry/algorithms/detail/disjoint/segment_box.hpp index 08ac1c236..5368432ed 100644 --- a/include/boost/geometry/algorithms/detail/disjoint/segment_box.hpp +++ b/include/boost/geometry/algorithms/detail/disjoint/segment_box.hpp @@ -26,6 +26,7 @@ #include +#include #include #include @@ -121,6 +122,18 @@ struct disjoint_segment_box_impl compute_tmin_tmax_per_dim::apply(p0, p1, box, ti_min, ti_max, diff); + if ( geometry::math::equals(diff, 0) ) + { + if ( (geometry::math::equals(t_min.second, 0) + && t_min.first > ti_max) + || + (geometry::math::equals(t_max.second, 0) + && t_max.first < ti_min) ) + { + return true; + } + } + RelativeDistance t_min_x_diff = t_min.first * diff; RelativeDistance t_max_x_diff = t_max.first * diff; @@ -180,6 +193,12 @@ struct disjoint_segment_box_impl compute_tmin_tmax_per_dim<0>::apply(p0, p1, box, t_min.first, t_max.first, diff); + if ( geometry::math::equals(diff, 0) ) + { + if ( geometry::math::equals(t_min.first, 0) ) { t_min.first = -1; } + if ( geometry::math::equals(t_max.first, 0) ) { t_max.first = 1; } + } + if ( t_min.first > diff || t_max.first < 0 ) { return true; diff --git a/include/boost/geometry/algorithms/detail/distance/default_strategies.hpp b/include/boost/geometry/algorithms/detail/distance/default_strategies.hpp index 890924984..3b79f82a3 100644 --- a/include/boost/geometry/algorithms/detail/distance/default_strategies.hpp +++ b/include/boost/geometry/algorithms/detail/distance/default_strategies.hpp @@ -43,7 +43,7 @@ namespace detail { namespace distance template < typename Geometry1, - typename Geometry2, + typename Geometry2 = Geometry1, typename Tag1 = typename tag_cast < typename tag::type, pointlike_tag @@ -57,7 +57,7 @@ template struct default_strategy : strategy::distance::services::default_strategy < - segment_tag, + point_tag, segment_tag, typename point_type::type, typename point_type::type > @@ -82,7 +82,7 @@ struct default_strategy pointlike_tag, pointlike_tag, false > : strategy::distance::services::default_strategy < - point_tag, + point_tag, point_tag, typename point_type::type, typename point_type::type > @@ -93,13 +93,12 @@ template struct default_strategy : strategy::distance::services::default_strategy < - point_tag, + point_tag, box_tag, typename point_type::type, typename point_type::type, cartesian_tag, cartesian_tag, - void, - box_tag + void > {}; @@ -108,13 +107,12 @@ template struct default_strategy : strategy::distance::services::default_strategy < - box_tag, + box_tag, box_tag, typename point_type::type, typename point_type::type, cartesian_tag, cartesian_tag, - void, - box_tag + void > {}; @@ -125,7 +123,7 @@ template struct default_ps_strategy : strategy::distance::services::default_strategy < - segment_tag, + point_tag, segment_tag, typename point_type::type, typename point_type::type, typename cs_tag::type>::type, diff --git a/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp b/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp index dc395fae7..695f3a2be 100644 --- a/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp +++ b/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp @@ -234,39 +234,38 @@ private: } }; - template + + template struct compare_less_equal { + typedef compare_less_equal other; + template inline bool operator()(T1 const& t1, T2 const& t2) const { - return LessEqual()(cast_to_result::apply(t1), - cast_to_result::apply(t2)); + return std::less_equal()(cast_to_result::apply(t1), + cast_to_result::apply(t2)); } }; template - struct less_equal : compare_less_equal > - {}; + struct compare_less_equal + { + typedef compare_less_equal other; + + template + inline bool operator()(T1 const& t1, T2 const& t2) const + { + return std::greater_equal()(cast_to_result::apply(t1), + cast_to_result::apply(t2)); + } + }; - template - struct greater_equal : compare_less_equal > - {}; template struct other_compare - {}; - - template - struct other_compare< less_equal > { - typedef greater_equal type; - }; - - template - struct other_compare< greater_equal > - { - typedef less_equal type; + typedef typename LessEqual::other type; }; @@ -487,6 +486,8 @@ private: PPStrategy const& pp_strategy, PSStrategy const& ps_strategy) { + typedef compare_less_equal less_equal; + // assert that the segment has non-negative slope BOOST_ASSERT( ( math::equals(geometry::get<0>(p0), geometry::get<0>(p1)) && geometry::get<1>(p0) < geometry::get<1>(p1)) @@ -499,7 +500,7 @@ private: if ( check_right_left_of_box < - less_equal + less_equal >::apply(p0, p1, top_left, top_right, bottom_left, bottom_right, pp_strategy, ps_strategy, result) ) @@ -509,7 +510,7 @@ private: if ( check_above_below_of_box < - less_equal + less_equal >::apply(p0, p1, top_left, top_right, bottom_left, bottom_right, ps_strategy, result) ) @@ -541,6 +542,8 @@ private: PPStrategy const& pp_strategy, PSStrategy const& ps_strategy) { + typedef compare_less_equal greater_equal; + // assert that the segment has negative slope BOOST_ASSERT( geometry::get<0>(p0) < geometry::get<0>(p1) && geometry::get<1>(p0) > geometry::get<1>(p1) ); @@ -549,7 +552,7 @@ private: if ( check_right_left_of_box < - greater_equal + greater_equal >::apply(p0, p1, bottom_left, bottom_right, top_left, top_right, pp_strategy, ps_strategy, result) ) @@ -559,7 +562,7 @@ private: if ( check_above_below_of_box < - greater_equal + greater_equal >::apply(p1, p0, top_right, top_left, bottom_right, bottom_left, ps_strategy, result) ) diff --git a/include/boost/geometry/algorithms/detail/overlay/append_no_dups_or_spikes.hpp b/include/boost/geometry/algorithms/detail/overlay/append_no_dups_or_spikes.hpp index a785bd608..f7d48fa95 100644 --- a/include/boost/geometry/algorithms/detail/overlay/append_no_dups_or_spikes.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/append_no_dups_or_spikes.hpp @@ -96,7 +96,7 @@ template inline void clean_closing_dups_and_spikes(Range& range, RobustPolicy const& robust_policy) { - int const minsize + std::size_t const minsize = core_detail::closure::minimum_ring_size < geometry::closure::value diff --git a/include/boost/geometry/algorithms/detail/recalculate.hpp b/include/boost/geometry/algorithms/detail/recalculate.hpp index 4e3e883a2..2c3ea7413 100644 --- a/include/boost/geometry/algorithms/detail/recalculate.hpp +++ b/include/boost/geometry/algorithms/detail/recalculate.hpp @@ -22,12 +22,12 @@ #include #include #include -#include #include #include #include #include +#include #include #include @@ -116,6 +116,44 @@ struct range_to_range struct polygon_to_polygon { +private: + template + < + typename IteratorIn, + typename IteratorOut, + typename Strategy + > + static inline void iterate(IteratorIn begin, IteratorIn end, + IteratorOut it_out, + Strategy const& strategy) + { + for (IteratorIn it_in = begin; it_in != end; ++it_in, ++it_out) + { + range_to_range::apply(*it_out, *it_in, strategy); + } + } + + template + < + typename InteriorRingsOut, + typename InteriorRingsIn, + typename Strategy + > + static inline void apply_interior_rings( + InteriorRingsOut& interior_rings_out, + InteriorRingsIn const& interior_rings_in, + Strategy const& strategy) + { + traits::resize::apply(interior_rings_out, + boost::size(interior_rings_in)); + + iterate( + boost::begin(interior_rings_in), boost::end(interior_rings_in), + boost::begin(interior_rings_out), + strategy); + } + +public: template < typename Polygon1, @@ -125,31 +163,11 @@ struct polygon_to_polygon static inline void apply(Polygon1& destination, Polygon2 const& source, Strategy const& strategy) { - typedef range_to_range per_ring; - - per_ring::apply(geometry::exterior_ring(destination), + range_to_range::apply(geometry::exterior_ring(destination), geometry::exterior_ring(source), strategy); - traits::resize - < - typename boost::remove_reference - < - typename traits::interior_mutable_type::type - >::type - >::apply(interior_rings(destination), num_interior_rings(source)); - - typename interior_return_type::type rings_dest - = interior_rings(destination); - typename interior_return_type::type rings_source - = interior_rings(source); - - BOOST_AUTO_TPL(it_source, boost::begin(rings_source)); - BOOST_AUTO_TPL(it_dest, boost::begin(rings_dest)); - - for ( ; it_source != boost::end(rings_source); ++it_source, ++it_dest) - { - per_ring::apply(*it_dest, *it_source, strategy); - } + apply_interior_rings(geometry::interior_rings(destination), + geometry::interior_rings(source), strategy); } }; diff --git a/include/boost/geometry/algorithms/detail/within/point_in_geometry.hpp b/include/boost/geometry/algorithms/detail/within/point_in_geometry.hpp index 18a46c279..efdce0be1 100644 --- a/include/boost/geometry/algorithms/detail/within/point_in_geometry.hpp +++ b/include/boost/geometry/algorithms/detail/within/point_in_geometry.hpp @@ -193,7 +193,7 @@ struct point_in_geometry static const iterate_direction direction = order_as_direction::value>::value; static const closure_selector closure = geometry::closure::value; - if (int(boost::size(ring)) + if (boost::size(ring) < core_detail::closure::minimum_ring_size::value) { return -1; diff --git a/include/boost/geometry/algorithms/length.hpp b/include/boost/geometry/algorithms/length.hpp index 6420bbb40..dddc86e85 100644 --- a/include/boost/geometry/algorithms/length.hpp +++ b/include/boost/geometry/algorithms/length.hpp @@ -241,7 +241,7 @@ length(Geometry const& geometry) // TODO put this into a resolve_strategy stage typedef typename strategy::distance::services::default_strategy < - point_tag, typename point_type::type + point_tag, point_tag, typename point_type::type >::type strategy_type; return resolve_variant::length::apply(geometry, strategy_type()); diff --git a/include/boost/geometry/algorithms/perimeter.hpp b/include/boost/geometry/algorithms/perimeter.hpp index 25870b9de..937b5baff 100644 --- a/include/boost/geometry/algorithms/perimeter.hpp +++ b/include/boost/geometry/algorithms/perimeter.hpp @@ -101,8 +101,7 @@ struct perimeter { typedef typename strategy::distance::services::default_strategy < - point_tag, - typename point_type::type + point_tag, point_tag, typename point_type::type >::type strategy_type; return dispatch::perimeter::apply(geometry, strategy_type()); diff --git a/include/boost/geometry/algorithms/simplify.hpp b/include/boost/geometry/algorithms/simplify.hpp index 1de639784..6dae3c98c 100644 --- a/include/boost/geometry/algorithms/simplify.hpp +++ b/include/boost/geometry/algorithms/simplify.hpp @@ -18,11 +18,9 @@ #include #include -#include #include #include -#include #include #include #include @@ -35,7 +33,8 @@ #include #include #include -#include + +#include #include #include @@ -119,13 +118,54 @@ struct simplify_range struct simplify_polygon { +private: + + template + < + std::size_t Minimum, + typename IteratorIn, + typename IteratorOut, + typename Distance, + typename Strategy + > + static inline void iterate(IteratorIn begin, IteratorIn end, + IteratorOut it_out, + Distance const& max_distance, Strategy const& strategy) + { + for (IteratorIn it_in = begin; it_in != end; ++it_in, ++it_out) + { + simplify_range::apply(*it_in, *it_out, max_distance, strategy); + } + } + + template + < + std::size_t Minimum, + typename InteriorRingsIn, + typename InteriorRingsOut, + typename Distance, + typename Strategy + > + static inline void apply_interior_rings( + InteriorRingsIn const& interior_rings_in, + InteriorRingsOut& interior_rings_out, + Distance const& max_distance, Strategy const& strategy) + { + traits::resize::apply(interior_rings_out, + boost::size(interior_rings_in)); + + iterate( + boost::begin(interior_rings_in), boost::end(interior_rings_in), + boost::begin(interior_rings_out), + max_distance, strategy); + } + +public: template static inline void apply(Polygon const& poly_in, Polygon& poly_out, Distance const& max_distance, Strategy const& strategy) { - typedef typename ring_type::type ring_type; - - int const Minimum = core_detail::closure::minimum_ring_size + std::size_t const minimum = core_detail::closure::minimum_ring_size < geometry::closure::value >::value; @@ -133,29 +173,13 @@ struct simplify_polygon // Note that if there are inner rings, and distance is too large, // they might intersect with the outer ring in the output, // while it didn't in the input. - simplify_range::apply(exterior_ring(poly_in), + simplify_range::apply(exterior_ring(poly_in), exterior_ring(poly_out), max_distance, strategy); - traits::resize - < - typename boost::remove_reference - < - typename traits::interior_mutable_type::type - >::type - >::apply(interior_rings(poly_out), num_interior_rings(poly_in)); - - typename interior_return_type::type rings_in - = interior_rings(poly_in); - typename interior_return_type::type rings_out - = interior_rings(poly_out); - BOOST_AUTO_TPL(it_out, boost::begin(rings_out)); - for (BOOST_AUTO_TPL(it_in, boost::begin(rings_in)); - it_in != boost::end(rings_in); - ++it_in, ++it_out) - { - simplify_range::apply(*it_in, *it_out, max_distance, strategy); - } + apply_interior_rings(interior_rings(poly_in), + interior_rings(poly_out), + max_distance, strategy); } }; @@ -258,7 +282,7 @@ struct simplify typedef typename strategy::distance::services::default_strategy < - segment_tag, point_type + point_tag, segment_tag, point_type >::type ds_strategy_type; typedef strategy::simplify::douglas_peucker @@ -301,7 +325,7 @@ struct simplify_insert typedef typename strategy::distance::services::default_strategy < - segment_tag, point_type + point_tag, segment_tag, point_type >::type ds_strategy_type; typedef strategy::simplify::douglas_peucker diff --git a/include/boost/geometry/arithmetic/arithmetic.hpp b/include/boost/geometry/arithmetic/arithmetic.hpp index 6479ecc4a..9e325b09d 100644 --- a/include/boost/geometry/arithmetic/arithmetic.hpp +++ b/include/boost/geometry/arithmetic/arithmetic.hpp @@ -139,7 +139,7 @@ inline void add_value(Point& p, typename detail::param::type value) template inline void add_point(Point1& p1, Point2 const& p2) { - BOOST_CONCEPT_ASSERT( (concept::Point) ); + BOOST_CONCEPT_ASSERT( (concept::Point) ); BOOST_CONCEPT_ASSERT( (concept::ConstPoint) ); for_each_coordinate(p1, detail::point_operation(p2)); @@ -171,7 +171,7 @@ inline void subtract_value(Point& p, typename detail::param::type value) template inline void subtract_point(Point1& p1, Point2 const& p2) { - BOOST_CONCEPT_ASSERT( (concept::Point) ); + BOOST_CONCEPT_ASSERT( (concept::Point) ); BOOST_CONCEPT_ASSERT( (concept::ConstPoint) ); for_each_coordinate(p1, detail::point_operation(p2)); @@ -204,7 +204,7 @@ inline void multiply_value(Point& p, typename detail::param::type value) template inline void multiply_point(Point1& p1, Point2 const& p2) { - BOOST_CONCEPT_ASSERT( (concept::Point) ); + BOOST_CONCEPT_ASSERT( (concept::Point) ); BOOST_CONCEPT_ASSERT( (concept::ConstPoint) ); for_each_coordinate(p1, detail::point_operation(p2)); @@ -236,7 +236,7 @@ inline void divide_value(Point& p, typename detail::param::type value) template inline void divide_point(Point1& p1, Point2 const& p2) { - BOOST_CONCEPT_ASSERT( (concept::Point) ); + BOOST_CONCEPT_ASSERT( (concept::Point) ); BOOST_CONCEPT_ASSERT( (concept::ConstPoint) ); for_each_coordinate(p1, detail::point_operation(p2)); @@ -268,7 +268,7 @@ inline void assign_value(Point& p, typename detail::param::type value) template inline void assign_point(Point1& p1, const Point2& p2) { - BOOST_CONCEPT_ASSERT( (concept::Point) ); + BOOST_CONCEPT_ASSERT( (concept::Point) ); BOOST_CONCEPT_ASSERT( (concept::ConstPoint) ); for_each_coordinate(p1, detail::point_assignment(p2)); diff --git a/include/boost/geometry/core/closure.hpp b/include/boost/geometry/core/closure.hpp index ebacfb99b..3185626c5 100644 --- a/include/boost/geometry/core/closure.hpp +++ b/include/boost/geometry/core/closure.hpp @@ -16,7 +16,7 @@ #include -#include +#include #include #include @@ -93,10 +93,10 @@ template struct minimum_ring_size {}; template <> -struct minimum_ring_size : boost::mpl::int_<4> {}; +struct minimum_ring_size : boost::mpl::size_t<4> {}; template <> -struct minimum_ring_size : boost::mpl::int_<3> {}; +struct minimum_ring_size : boost::mpl::size_t<3> {}; }} // namespace detail::point_order diff --git a/include/boost/geometry/strategies/cartesian/distance_projected_point.hpp b/include/boost/geometry/strategies/cartesian/distance_projected_point.hpp index 329b7d4e4..25179ba21 100644 --- a/include/boost/geometry/strategies/cartesian/distance_projected_point.hpp +++ b/include/boost/geometry/strategies/cartesian/distance_projected_point.hpp @@ -229,7 +229,11 @@ public : // of point-to-segment or point-to-linestring. // Convenient for geographic coordinate systems especially. template -struct default_strategy +struct default_strategy + < + point_tag, segment_tag, Point, PointOfSegment, + cartesian_tag, cartesian_tag, Strategy + > { typedef strategy::distance::projected_point < @@ -239,7 +243,7 @@ struct default_strategy, typename default_strategy < - point_tag, Point, PointOfSegment, + point_tag, point_tag, Point, PointOfSegment, cartesian_tag, cartesian_tag >::type, Strategy diff --git a/include/boost/geometry/strategies/cartesian/distance_pythagoras.hpp b/include/boost/geometry/strategies/cartesian/distance_pythagoras.hpp index c3806c046..f1e00384c 100644 --- a/include/boost/geometry/strategies/cartesian/distance_pythagoras.hpp +++ b/include/boost/geometry/strategies/cartesian/distance_pythagoras.hpp @@ -271,7 +271,10 @@ public : template -struct default_strategy +struct default_strategy + < + point_tag, point_tag, Point1, Point2, cartesian_tag, cartesian_tag + > { typedef pythagoras<> type; }; diff --git a/include/boost/geometry/strategies/cartesian/distance_pythagoras_box_box.hpp b/include/boost/geometry/strategies/cartesian/distance_pythagoras_box_box.hpp index d4c94b5c0..812cb6258 100644 --- a/include/boost/geometry/strategies/cartesian/distance_pythagoras_box_box.hpp +++ b/include/boost/geometry/strategies/cartesian/distance_pythagoras_box_box.hpp @@ -315,10 +315,10 @@ public : }; -template +template struct default_strategy < - box_tag, Box1, Box2, cartesian_tag, cartesian_tag, void, box_tag + box_tag, box_tag, BoxPoint1, BoxPoint2, cartesian_tag, cartesian_tag > { typedef pythagoras_box_box<> type; diff --git a/include/boost/geometry/strategies/cartesian/distance_pythagoras_point_box.hpp b/include/boost/geometry/strategies/cartesian/distance_pythagoras_point_box.hpp index 304250167..9761d3b0d 100644 --- a/include/boost/geometry/strategies/cartesian/distance_pythagoras_point_box.hpp +++ b/include/boost/geometry/strategies/cartesian/distance_pythagoras_point_box.hpp @@ -313,8 +313,11 @@ public : }; -template -struct default_strategy +template +struct default_strategy + < + point_tag, box_tag, Point, BoxPoint, cartesian_tag, cartesian_tag + > { typedef pythagoras_point_box<> type; }; diff --git a/include/boost/geometry/strategies/distance.hpp b/include/boost/geometry/strategies/distance.hpp index 2071e86cc..98ccb8202 100644 --- a/include/boost/geometry/strategies/distance.hpp +++ b/include/boost/geometry/strategies/distance.hpp @@ -1,8 +1,13 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -70,7 +75,8 @@ struct result_from_distance {}; \brief Traits class binding a default strategy for distance to one (or possibly two) coordinate system(s) \ingroup distance - \tparam GeometryTag tag (point/segment) for which this strategy is the default + \tparam GeometryTag1 tag (point/segment/box) for which this strategy is the default + \tparam GeometryTag2 tag (point/segment/box) for which this strategy is the default \tparam Point1 first point-type \tparam Point2 second point-type \tparam CsTag1 tag of coordinate system of first point type @@ -78,13 +84,13 @@ struct result_from_distance {}; */ template < - typename GeometryTag, + typename GeometryTag1, + typename GeometryTag2, typename Point1, typename Point2 = Point1, typename CsTag1 = typename cs_tag::type, typename CsTag2 = typename cs_tag::type, - typename UnderlyingStrategy = void, - typename GeometryTag2 = GeometryTag + typename UnderlyingStrategy = void > struct default_strategy { diff --git a/include/boost/geometry/strategies/spherical/distance_cross_track.hpp b/include/boost/geometry/strategies/spherical/distance_cross_track.hpp index 3180fcf5f..87fac4811 100644 --- a/include/boost/geometry/strategies/spherical/distance_cross_track.hpp +++ b/include/boost/geometry/strategies/spherical/distance_cross_track.hpp @@ -284,7 +284,7 @@ struct default_strategy template struct default_strategy < - segment_tag, Point, PointOfSegment, + point_tag, segment_tag, Point, PointOfSegment, spherical_equatorial_tag, spherical_equatorial_tag, Strategy > @@ -297,7 +297,7 @@ struct default_strategy boost::is_void, typename default_strategy < - point_tag, Point, PointOfSegment, + point_tag, point_tag, Point, PointOfSegment, spherical_equatorial_tag, spherical_equatorial_tag >::type, Strategy diff --git a/include/boost/geometry/strategies/spherical/distance_haversine.hpp b/include/boost/geometry/strategies/spherical/distance_haversine.hpp index 2f8d2622a..d66213380 100644 --- a/include/boost/geometry/strategies/spherical/distance_haversine.hpp +++ b/include/boost/geometry/strategies/spherical/distance_haversine.hpp @@ -279,7 +279,11 @@ public : // Register it as the default for point-types // in a spherical equatorial coordinate system template -struct default_strategy +struct default_strategy + < + point_tag, point_tag, Point1, Point2, + spherical_equatorial_tag, spherical_equatorial_tag + > { typedef strategy::distance::haversine::type> type; }; diff --git a/test/algorithms/disjoint_coverage.cpp b/test/algorithms/disjoint_coverage.cpp index 1f2aa8aa3..5b5e31363 100644 --- a/test/algorithms/disjoint_coverage.cpp +++ b/test/algorithms/disjoint_coverage.cpp @@ -680,6 +680,55 @@ inline void test_segment_box() tester::apply(from_wkt("SEGMENT(4 0,4 4)"), from_wkt("BOX(0 0,2 2)"), true); + + tester::apply(from_wkt("SEGMENT(0 -2,0 -1)"), + from_wkt("BOX(0 0,1 1)"), + true); + + tester::apply(from_wkt("SEGMENT(-2 -2,-2 -1)"), + from_wkt("BOX(0 0,1 1)"), + true); + + tester::apply(from_wkt("SEGMENT(-2 -2,-2 -2)"), + from_wkt("BOX(0 0,1 1)"), + true); + + tester::apply(from_wkt("SEGMENT(-2 0,-2 0)"), + from_wkt("BOX(0 0,1 1)"), + true); + + tester::apply(from_wkt("SEGMENT(0 -2,0 -2)"), + from_wkt("BOX(0 0,1 1)"), + true); + + tester::apply(from_wkt("SEGMENT(-2 0,-1 0)"), + from_wkt("BOX(0 0,1 1)"), + true); + + // segment degenerates to a point + tester::apply(from_wkt("SEGMENT(0 0,0 0)"), + from_wkt("BOX(0 0,1 1)"), + false); + + tester::apply(from_wkt("SEGMENT(1 1,1 1)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply(from_wkt("SEGMENT(2 2,2 2)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply(from_wkt("SEGMENT(2 0,2 0)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply(from_wkt("SEGMENT(0 2,0 2)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply(from_wkt("SEGMENT(2 2,2 2)"), + from_wkt("BOX(0 0,1 1)"), + true); } template diff --git a/test/algorithms/distance.cpp b/test/algorithms/distance.cpp index 39f1285d6..e8384670e 100644 --- a/test/algorithms/distance.cpp +++ b/test/algorithms/distance.cpp @@ -72,7 +72,10 @@ void test_distance_point() BOOST_CHECK_CLOSE(d, return_type(1.4142135), 0.001); // Test specifying strategy manually - typename services::default_strategy::type strategy; + typename services::default_strategy + < + bg::point_tag, bg::point_tag, P + >::type strategy; d = bg::distance(p1, p2, strategy); BOOST_CHECK_CLOSE(d, return_type(1.4142135), 0.001); @@ -93,7 +96,10 @@ void test_distance_point() { // test comparability - typedef typename services::default_strategy::type strategy_type; + typedef typename services::default_strategy + < + bg::point_tag, bg::point_tag, P + >::type strategy_type; typedef typename services::comparable_type::type comparable_strategy_type; strategy_type strategy; @@ -143,12 +149,18 @@ void test_distance_segment() // Test specifying strategy manually: // 1) point-point-distance - typename bg::strategy::distance::services::default_strategy::type pp_strategy; + typename bg::strategy::distance::services::default_strategy + < + bg::point_tag, bg::point_tag, P + >::type pp_strategy; d1 = bg::distance(p1, seg, pp_strategy); BOOST_CHECK_CLOSE(d1, return_type(1), 0.001); // 2) point-segment-distance - typename bg::strategy::distance::services::default_strategy::type ps_strategy; + typename bg::strategy::distance::services::default_strategy + < + bg::point_tag, bg::segment_tag, P + >::type ps_strategy; d1 = bg::distance(p1, seg, ps_strategy); BOOST_CHECK_CLOSE(d1, return_type(1), 0.001); diff --git a/test/arithmetic/arithmetic.cpp b/test/arithmetic/arithmetic.cpp index f7d2e3427..a329a6e52 100644 --- a/test/arithmetic/arithmetic.cpp +++ b/test/arithmetic/arithmetic.cpp @@ -29,7 +29,7 @@ BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian) BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) -template +template void test_addition() { P p1; @@ -39,15 +39,14 @@ void test_addition() BOOST_CHECK(bg::get<1>(p1) == 12); BOOST_CHECK(bg::get<2>(p1) == 13); - P p2; - bg::assign_values(p2, 4, 5, 6); + P2 p2(4, 5, 6); bg::add_point(p1, p2); BOOST_CHECK(bg::get<0>(p1) == 15); BOOST_CHECK(bg::get<1>(p1) == 17); BOOST_CHECK(bg::get<2>(p1) == 19); } -template +template void test_subtraction() { P p1; @@ -57,15 +56,14 @@ void test_subtraction() BOOST_CHECK(bg::get<1>(p1) == -8); BOOST_CHECK(bg::get<2>(p1) == -7); - P p2; - bg::assign_values(p2, 4, 6, 8); + P2 p2(4, 6, 8); bg::subtract_point(p1, p2); BOOST_CHECK(bg::get<0>(p1) == -13); BOOST_CHECK(bg::get<1>(p1) == -14); BOOST_CHECK(bg::get<2>(p1) == -15); } -template +template void test_multiplication() { P p1; @@ -75,15 +73,14 @@ void test_multiplication() BOOST_CHECK(bg::get<1>(p1) == 10); BOOST_CHECK(bg::get<2>(p1) == 15); - P p2; - bg::assign_values(p2, 4, 5, 6); + P2 p2(4, 5, 6); bg::multiply_point(p1, p2); BOOST_CHECK(bg::get<0>(p1) == 20); BOOST_CHECK(bg::get<1>(p1) == 50); BOOST_CHECK(bg::get<2>(p1) == 90); } -template +template void test_division() { P p1; @@ -93,40 +90,41 @@ void test_division() BOOST_CHECK(bg::get<1>(p1) == 20); BOOST_CHECK(bg::get<2>(p1) == 30); - P p2; - bg::assign_values(p2, 2, 4, 6); + P2 p2(2, 4, 6); bg::divide_point(p1, p2); BOOST_CHECK(bg::get<0>(p1) == 5); BOOST_CHECK(bg::get<1>(p1) == 5); BOOST_CHECK(bg::get<2>(p1) == 5); } -template +template void test_assign() { P p1; - P p2; + P2 p2(12, 34, 56); bg::assign_values(p1, 12, 34, 56); - bg::assign_point(p2, p1); - BOOST_CHECK(bg::get<0>(p2) == 12); - BOOST_CHECK(bg::get<1>(p2) == 34); - BOOST_CHECK(bg::get<2>(p2) == 56); + bg::assign_point(p1, p2); + BOOST_CHECK(bg::get<0>(p1) == 12); + BOOST_CHECK(bg::get<1>(p1) == 34); + BOOST_CHECK(bg::get<2>(p1) == 56); - bg::assign_value(p2, 78); - BOOST_CHECK(bg::get<0>(p2) == 78); - BOOST_CHECK(bg::get<1>(p2) == 78); - BOOST_CHECK(bg::get<2>(p2) == 78); + bg::assign_value(p1, 78); + BOOST_CHECK(bg::get<0>(p1) == 78); + BOOST_CHECK(bg::get<1>(p1) == 78); + BOOST_CHECK(bg::get<2>(p1) == 78); } template void test_all() { - test_addition

(); - test_subtraction

(); - test_multiplication

(); - test_division

(); - test_assign

(); + typedef test::test_const_point P2; + + test_addition(); + test_subtraction(); + test_multiplication(); + test_division(); + test_assign(); } diff --git a/test/policies/Jamfile.v2 b/test/policies/Jamfile.v2 index 503817813..22c58c89c 100644 --- a/test/policies/Jamfile.v2 +++ b/test/policies/Jamfile.v2 @@ -11,5 +11,5 @@ test-suite boost-geometry-policies : [ run compare.cpp ] -# [ run rescale_policy.cpp ] + [ run rescale_policy.cpp ] ; diff --git a/test/policies/rescale_policy.cpp b/test/policies/rescale_policy.cpp index c579819c0..c91f31988 100644 --- a/test/policies/rescale_policy.cpp +++ b/test/policies/rescale_policy.cpp @@ -17,205 +17,31 @@ #include -#include -#include #include +#include #include #include #include #include #include +#include #include #include -#if defined(TEST_WITH_SVG) -# include -#endif #include -namespace boost { namespace geometry -{ - - -// Overload with rescale-policy specified (temporary here - to be worked out) -template -< - typename Geometry1, - typename Geometry2, - typename RescalePolicy, - typename GeometryOut -> -inline bool intersection(Geometry1 const& geometry1, - Geometry2 const& geometry2, - RescalePolicy const& rescale_policy, - GeometryOut& geometry_out) -{ - concept::check(); - concept::check(); - - typedef strategy_intersection - < - typename cs_tag::type, - Geometry1, - Geometry2, - typename geometry::point_type::type, - RescalePolicy - > strategy; - - return dispatch::intersection - < - Geometry1, - Geometry2 - >::apply(geometry1, geometry2, rescale_policy, geometry_out, strategy()); -} - - -}} // namespace boost::geometry - - -template -< - typename OutputType, - typename CalculationType, - typename Geometry1, - typename Geometry2, - typename RescalePolicy -> -typename bg::default_area_result::type test_intersection(std::string const& caseid, - Geometry1 const& geometry1, Geometry2 const& geometry2, - RescalePolicy const& rescale_policy, - std::size_t expected_count = 0, int expected_point_count = 0, - double expected_length_or_area = 0, - double percentage = 0.0001, - bool debug = false) -{ - typedef typename bg::coordinate_type::type coordinate_type; - typedef typename bg::point_type::type point_type; - -// if (debug) - { - std::cout << std::endl - << "case " << caseid - << " " << typeid(coordinate_type).name() - << " " << string_from_type::name() - << std::endl; - } - - - - std::vector out; - bg::intersection(geometry1, geometry2, rescale_policy, out); - - typename bg::default_area_result::type length_or_area = 0; - int n = 0; - for (typename std::vector::iterator it = out.begin(); - it != out.end(); - ++it) - { - if (expected_point_count > 0) - { - n += bg::num_points(*it, true); - } - - length_or_area += bg::area(*it); - - if (debug) - { - std::cout << std::setprecision(20) << bg::wkt(*it) << std::endl; - } - } - - -#if ! defined(BOOST_GEOMETRY_NO_BOOST_TEST) - if (expected_point_count > 0) - { - BOOST_CHECK_MESSAGE(bg::math::abs(n - expected_point_count) < 3, - "intersection: " << caseid - << " #points expected: " << expected_point_count - << " detected: " << n - << " type: " << (type_for_assert_message()) - ); - } - - if (expected_count > 0) - { - BOOST_CHECK_MESSAGE(out.size() == expected_count, - "intersection: " << caseid - << " #outputs expected: " << expected_count - << " detected: " << out.size() - << " type: " << (type_for_assert_message()) - ); - } - - double const detected_length_or_area = boost::numeric_cast(length_or_area); - BOOST_CHECK_CLOSE(detected_length_or_area, expected_length_or_area, percentage); -#endif - - -#if defined(TEST_WITH_SVG) - { - bool const ccw = - bg::point_order::value == bg::counterclockwise - || bg::point_order::value == bg::counterclockwise; - bool const open = - bg::closure::value == bg::open - || bg::closure::value == bg::open; - - std::ostringstream filename; - filename << "rescale_policy_intersection_" - << caseid << "_" - << string_from_type::name() - << string_from_type::name() - << (ccw ? "_ccw" : "") - << (open ? "_open" : "") - << ".svg"; - - std::ofstream svg(filename.str().c_str()); - - bg::svg_mapper mapper(svg, 500, 500); - - mapper.add(geometry1); - mapper.add(geometry2); - - mapper.map(geometry1, "fill-opacity:0.5;fill:rgb(153,204,0);" - "stroke:rgb(153,204,0);stroke-width:3"); - mapper.map(geometry2, "fill-opacity:0.3;fill:rgb(51,51,153);" - "stroke:rgb(51,51,153);stroke-width:3"); - - for (typename std::vector::const_iterator it = out.begin(); - it != out.end(); ++it) - { - mapper.map(*it, "fill-opacity:0.2;stroke-opacity:0.4;fill:rgb(255,0,0);" - "stroke:rgb(255,0,255);stroke-width:8"); - } - } -#endif - - if (debug) - { - std::cout << "end case " << caseid << std::endl; - } - - return length_or_area; -} - template < typename RescalePolicy, - typename OutputType, typename Geometry1, typename Geometry2 > -typename bg::default_area_result::type test_one(std::string const& caseid, - std::string const& wkt1, std::string const& wkt2, - std::size_t expected_count = 0, int expected_point_count = 0, - double expected_length_or_area = 0, - double percentage = 0.02, - bool debug = false) +void test_one(std::string const& wkt1, std::string const& wkt2, + std::string const& expected_coordinates) { Geometry1 geometry1; bg::read_wkt(wkt1, geometry1); @@ -223,21 +49,39 @@ typename bg::default_area_result::type test_one(std::string const& ca Geometry2 geometry2; bg::read_wkt(wkt2, geometry2); - // Reverse if necessary - bg::correct(geometry1); - bg::correct(geometry2); - RescalePolicy rescale_policy = bg::get_rescale_policy(geometry1, geometry2); - return test_intersection(caseid, - geometry1, geometry2, - rescale_policy, - expected_count, expected_point_count, - expected_length_or_area, percentage, - debug); + typedef typename bg::point_type::type point_type; + typedef typename bg::robust_point_type + < + point_type, RescalePolicy + >::type robust_point_type; + + { + robust_point_type robust_point; + bg::recalculate(robust_point, *bg::points_begin(geometry1), rescale_policy); + + std::ostringstream out; + out << bg::get<0>(robust_point) << " " << bg::get<1>(robust_point); + BOOST_CHECK_EQUAL(expected_coordinates, out.str()); + } + + { + // Assuming Geometry1 is a polygon: + typedef bg::model::polygon polygon_type; + polygon_type geometry_out; + bg::recalculate(geometry_out, geometry1, rescale_policy); + robust_point_type p = *bg::points_begin(geometry_out); + + std::ostringstream out; + out << bg::get<0>(p) << " " << bg::get<1>(p); + BOOST_CHECK_EQUAL(expected_coordinates, out.str()); + } } + + static std::string simplex_normal[2] = {"POLYGON((0 1,2 5,5 3,0 1))", "POLYGON((3 0,0 3,4 5,3 0))"}; @@ -248,7 +92,7 @@ static std::string simplex_large[2] = template -void test_rescale() +void test_rescale(std::string const& expected_normal, std::string const& expected_large) { typedef bg::model::polygon

polygon; @@ -259,35 +103,29 @@ void test_rescale() bg::detail::no_rescale_policy >::type rescale_policy_type; - std::string suffix = Rescale ? "rescale" : "no_rescale"; - - typedef typename bg::coordinate_type

::type coordinate_type; - if (! boost::is_integral::type::value) - { - test_one("simplex_normal_" + suffix, - simplex_normal[0], simplex_normal[1], - 1, 7, 5.47363293); - } - test_one("simplex_large_" + suffix, + test_one( + simplex_normal[0], simplex_normal[1], + expected_normal); + test_one( simplex_large[0], simplex_large[1], - 1, 7, 5473632.93); + expected_large); } template -void test_all() +void test_all(std::string const& expected_normal, std::string const& expected_large) { typedef bg::model::d2::point_xy point_type; - test_rescale(); - test_rescale(); + test_rescale(expected_normal, expected_large); + //test_rescale(); } int test_main(int, char* []) { - test_all(); - test_all(); - test_all(); - test_all(); + test_all("-5000000 -3000000", "-5000000 -3000000"); + test_all("-5000000 -3000000", "-5000000 -3000000"); + test_all("0 1", "0 1000"); + test_all("0 1", "0 1000"); // test_all(); // compiles but overflows return 0; diff --git a/test/strategies/cross_track.cpp b/test/strategies/cross_track.cpp index 09166718a..fe665ea1b 100644 --- a/test/strategies/cross_track.cpp +++ b/test/strategies/cross_track.cpp @@ -1,9 +1,14 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -57,6 +62,15 @@ void test_distance( >::type return_type; + { + // compile-check if there is a strategy for this type + typedef typename bg::strategy::distance::services::default_strategy + < + bg::point_tag, bg::segment_tag, Point, Point + >::type cross_track_strategy_type; + } + + BOOST_CONCEPT_ASSERT ( (bg::concept::PointSegmentDistanceStrategy) diff --git a/test/strategies/haversine.cpp b/test/strategies/haversine.cpp index e5c56a5d2..2d4f78550 100644 --- a/test/strategies/haversine.cpp +++ b/test/strategies/haversine.cpp @@ -90,7 +90,10 @@ void test_services() { // Compile-check if there is a strategy for this type - typedef typename services::default_strategy::type haversine_strategy_type; + typedef typename services::default_strategy + < + bg::point_tag, bg::point_tag, P1, P2 + >::type haversine_strategy_type; } P1 p1; diff --git a/test/strategies/projected_point.cpp b/test/strategies/projected_point.cpp index fde126a20..62c611495 100644 --- a/test/strategies/projected_point.cpp +++ b/test/strategies/projected_point.cpp @@ -1,9 +1,14 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -50,6 +55,15 @@ void test_services() namespace bgsd = bg::strategy::distance; namespace services = bg::strategy::distance::services; + + { + // compile-check if there is a strategy for this type + typedef typename services::default_strategy + < + bg::point_tag, bg::segment_tag, P, PS + >::type projected_point_strategy_type; + } + // 1: normal, calculate distance: typedef bgsd::projected_point strategy_type; diff --git a/test/strategies/pythagoras.cpp b/test/strategies/pythagoras.cpp index 914b80179..cedeb87cc 100644 --- a/test/strategies/pythagoras.cpp +++ b/test/strategies/pythagoras.cpp @@ -122,7 +122,10 @@ void test_services() { // Compile-check if there is a strategy for this type - typedef typename services::default_strategy::type pythagoras_strategy_type; + typedef typename services::default_strategy + < + bg::point_tag, bg::point_tag, P1, P2 + >::type pythagoras_strategy_type; } diff --git a/test/test_common/test_point.hpp b/test/test_common/test_point.hpp index 3356e43c1..54616f0db 100644 --- a/test/test_common/test_point.hpp +++ b/test/test_common/test_point.hpp @@ -17,6 +17,7 @@ #include #include #include +#include // NOTE: since Boost 1.51 the Point type may always be a pointer. // Therefore the traits class don't need to add a pointer. @@ -32,10 +33,21 @@ struct test_point float c1, c2, c3; }; +struct test_const_point +{ + test_const_point() + : c1(0.0), c2(0.0), c3(0.0) { } + + test_const_point(float c1, float c2, float c3) + : c1(c1), c2(c2), c3(c3) { } + + const float c1, c2, c3; +}; } // namespace test + namespace boost { namespace geometry { namespace traits { template<> @@ -91,4 +103,9 @@ template<> struct access }}} // namespace bg::traits +BOOST_GEOMETRY_REGISTER_POINT_3D_CONST(test::test_const_point, + float, + boost::geometry::cs::cartesian, + c1, c2, c3); + #endif // GEOMETRY_TEST_TEST_COMMON_TEST_POINT_HPP