diff --git a/include/boost/geometry/algorithms/centroid.hpp b/include/boost/geometry/algorithms/centroid.hpp index 106818d67..191866b9a 100644 --- a/include/boost/geometry/algorithms/centroid.hpp +++ b/include/boost/geometry/algorithms/centroid.hpp @@ -32,7 +32,6 @@ #include #include -#include #include #include #include diff --git a/include/boost/geometry/algorithms/detail/distance/backward_compatibility.hpp b/include/boost/geometry/algorithms/detail/distance/backward_compatibility.hpp index 603963cbf..5dd69cbcd 100644 --- a/include/boost/geometry/algorithms/detail/distance/backward_compatibility.hpp +++ b/include/boost/geometry/algorithms/detail/distance/backward_compatibility.hpp @@ -110,7 +110,7 @@ struct distance static inline typename return_type::type>::type apply(Point const& point, Linestring const& linestring, - Strategy const& strategy) + Strategy const&) { typedef typename detail::distance::default_ps_strategy < @@ -143,7 +143,7 @@ struct distance static inline return_type apply(Point const& point, Ring const& ring, - Strategy const& strategy) + Strategy const&) { typedef typename detail::distance::default_ps_strategy < @@ -181,7 +181,7 @@ struct distance static inline return_type apply(Point const& point, Polygon const& polygon, - Strategy const& strategy) + Strategy const&) { typedef typename detail::distance::default_ps_strategy < diff --git a/include/boost/geometry/algorithms/detail/distance/box_to_box.hpp b/include/boost/geometry/algorithms/detail/distance/box_to_box.hpp index 98b3be0f7..7b032a19c 100644 --- a/include/boost/geometry/algorithms/detail/distance/box_to_box.hpp +++ b/include/boost/geometry/algorithms/detail/distance/box_to_box.hpp @@ -43,6 +43,7 @@ struct distance >::type apply(Box1 const& box1, Box2 const& box2, Strategy const& strategy) { + boost::ignore_unused_variable_warning(strategy); return strategy.apply(box1, box2); } }; diff --git a/include/boost/geometry/algorithms/detail/distance/point_to_geometry.hpp b/include/boost/geometry/algorithms/detail/distance/point_to_geometry.hpp index 4d6a598ad..7b89dcad1 100644 --- a/include/boost/geometry/algorithms/detail/distance/point_to_geometry.hpp +++ b/include/boost/geometry/algorithms/detail/distance/point_to_geometry.hpp @@ -390,10 +390,11 @@ struct distance Segment const& segment, Strategy const& strategy) { - typename point_type::type p[2]; geometry::detail::assign_point_from_index<0>(segment, p[0]); geometry::detail::assign_point_from_index<1>(segment, p[1]); + + boost::ignore_unused_variable_warning(strategy); return strategy.apply(point, p[0], p[1]); } }; @@ -413,6 +414,7 @@ struct distance >::type apply(Point const& point, Box const& box, Strategy const& strategy) { + boost::ignore_unused_variable_warning(strategy); return strategy.apply(point, box); } }; diff --git a/include/boost/geometry/algorithms/detail/distance/range_to_segment_or_box.hpp b/include/boost/geometry/algorithms/detail/distance/range_to_segment_or_box.hpp index db2bcf68f..e1d113ff3 100644 --- a/include/boost/geometry/algorithms/detail/distance/range_to_segment_or_box.hpp +++ b/include/boost/geometry/algorithms/detail/distance/range_to_segment_or_box.hpp @@ -106,6 +106,7 @@ private: SegmentPoints const& segment_points, ComparableStrategy const& strategy) { + boost::ignore_unused_variable_warning(strategy); return strategy.apply(point, segment_points[0], segment_points[1]); } }; @@ -126,6 +127,8 @@ private: BoxPoints const& box_points, ComparableStrategy const& strategy) { + boost::ignore_unused_variable_warning(strategy); + comparable_return_type cd_min = strategy.apply(point, box_points[0], box_points[3]); 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 3efa7673a..4a6f23839 100644 --- a/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp +++ b/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp @@ -81,6 +81,9 @@ private: { typedef cast_to_result cast; + boost::ignore_unused_variable_warning(pp_strategy); + boost::ignore_unused_variable_warning(ps_strategy); + // assert that the segment has non-negative slope BOOST_ASSERT( (math::equals(geometry::get<0>(p0), geometry::get<0>(p1)) @@ -217,6 +220,9 @@ private: { typedef cast_to_result cast; + boost::ignore_unused_variable_warning(pp_strategy); + boost::ignore_unused_variable_warning(ps_strategy); + // assert that the segment has negative slope BOOST_ASSERT ( geometry::get<0>(p0) < geometry::get<0>(p1) diff --git a/include/boost/geometry/algorithms/detail/overlay/follow_linear_linear.hpp b/include/boost/geometry/algorithms/detail/overlay/follow_linear_linear.hpp index 131154f82..6407706cb 100644 --- a/include/boost/geometry/algorithms/detail/overlay/follow_linear_linear.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/follow_linear_linear.hpp @@ -289,7 +289,7 @@ protected: public: template static inline OutputIterator - apply(Linestring const& linestring, Linear const& linear, + apply(Linestring const& linestring, Linear const&, TurnIterator first, TurnIterator beyond, OutputIterator oit) { diff --git a/include/boost/geometry/algorithms/detail/overlay/get_relative_order.hpp b/include/boost/geometry/algorithms/detail/overlay/get_relative_order.hpp index 50a14ea24..d71f4ad51 100644 --- a/include/boost/geometry/algorithms/detail/overlay/get_relative_order.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/get_relative_order.hpp @@ -10,8 +10,6 @@ #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_RELATIVE_ORDER_HPP -#include - #include diff --git a/include/boost/geometry/algorithms/detail/overlay/intersection_box_box.hpp b/include/boost/geometry/algorithms/detail/overlay/intersection_box_box.hpp new file mode 100644 index 000000000..dd041b0d7 --- /dev/null +++ b/include/boost/geometry/algorithms/detail/overlay/intersection_box_box.hpp @@ -0,0 +1,84 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2014 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_OVERLAY_INTERSECTION_BOX_BOX_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_INTERSECTION_BOX_BOX_HPP + + +#include +#include + + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace intersection +{ + +template +struct intersection_box_box +{ + template + < + typename Box1, typename Box2, + typename RobustPolicy, + typename BoxOut, + typename Strategy + > + static inline bool apply(Box1 const& box1, + Box2 const& box2, + RobustPolicy const& robust_policy, + BoxOut& box_out, + Strategy const& strategy) + { + typedef typename coordinate_type::type ct; + + ct min1 = get(box1); + ct min2 = get(box2); + ct max1 = get(box1); + ct max2 = get(box2); + + if (max1 < min2 || max2 < min1) + { + return false; + } + // Set dimensions of output coordinate + set(box_out, min1 < min2 ? min2 : min1); + set(box_out, max1 > max2 ? max2 : max1); + + return intersection_box_box + ::apply(box1, box2, robust_policy, box_out, strategy); + } +}; + +template +struct intersection_box_box +{ + template + < + typename Box1, typename Box2, + typename RobustPolicy, + typename BoxOut, + typename Strategy + > + static inline bool apply(Box1 const&, Box2 const&, + RobustPolicy const&, BoxOut&, Strategy const&) + { + return true; + } +}; + + +}} // namespace detail::intersection +#endif // DOXYGEN_NO_DETAIL + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_INTERSECTION_BOX_BOX_HPP diff --git a/include/boost/geometry/algorithms/detail/turns/filter_continue_turns.hpp b/include/boost/geometry/algorithms/detail/turns/filter_continue_turns.hpp index 4f38e3e73..17fbd65dd 100644 --- a/include/boost/geometry/algorithms/detail/turns/filter_continue_turns.hpp +++ b/include/boost/geometry/algorithms/detail/turns/filter_continue_turns.hpp @@ -24,7 +24,7 @@ namespace detail { namespace turns template struct filter_continue_turns { - static inline void apply(Turns& turns) {} + static inline void apply(Turns&) {} }; diff --git a/include/boost/geometry/algorithms/detail/turns/remove_duplicate_turns.hpp b/include/boost/geometry/algorithms/detail/turns/remove_duplicate_turns.hpp index 41f52c059..d48736c8f 100644 --- a/include/boost/geometry/algorithms/detail/turns/remove_duplicate_turns.hpp +++ b/include/boost/geometry/algorithms/detail/turns/remove_duplicate_turns.hpp @@ -23,7 +23,7 @@ namespace detail { namespace turns template struct remove_duplicate_turns { - static inline void apply(Turns& turns) {} + static inline void apply(Turns&) {} }; diff --git a/include/boost/geometry/algorithms/intersection.hpp b/include/boost/geometry/algorithms/intersection.hpp index 500cacc9f..ca3bb0682 100644 --- a/include/boost/geometry/algorithms/intersection.hpp +++ b/include/boost/geometry/algorithms/intersection.hpp @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -19,68 +20,6 @@ namespace boost { namespace geometry { -#ifndef DOXYGEN_NO_DETAIL -namespace detail { namespace intersection -{ - -template -struct intersection_box_box -{ - template - < - typename Box1, typename Box2, - typename RobustPolicy, - typename BoxOut, - typename Strategy - > - static inline bool apply(Box1 const& box1, - Box2 const& box2, - RobustPolicy const& robust_policy, - BoxOut& box_out, - Strategy const& strategy) - { - typedef typename coordinate_type::type ct; - - ct min1 = get(box1); - ct min2 = get(box2); - ct max1 = get(box1); - ct max2 = get(box2); - - if (max1 < min2 || max2 < min1) - { - return false; - } - // Set dimensions of output coordinate - set(box_out, min1 < min2 ? min2 : min1); - set(box_out, max1 > max2 ? max2 : max1); - - return intersection_box_box - ::apply(box1, box2, robust_policy, box_out, strategy); - } -}; - -template -struct intersection_box_box -{ - template - < - typename Box1, typename Box2, - typename RobustPolicy, - typename BoxOut, - typename Strategy - > - static inline bool apply(Box1 const&, Box2 const&, - RobustPolicy const&, BoxOut&, Strategy const&) - { - return true; - } -}; - - -}} // namespace detail::intersection -#endif // DOXYGEN_NO_DETAIL - - #ifndef DOXYGEN_NO_DISPATCH namespace dispatch diff --git a/include/boost/geometry/index/detail/algorithms/intersection_content.hpp b/include/boost/geometry/index/detail/algorithms/intersection_content.hpp index 955d6eb65..ed615c402 100644 --- a/include/boost/geometry/index/detail/algorithms/intersection_content.hpp +++ b/include/boost/geometry/index/detail/algorithms/intersection_content.hpp @@ -11,7 +11,8 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_INTERSECTION_CONTENT_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_INTERSECTION_CONTENT_HPP -#include +#include +#include #include namespace boost { namespace geometry { namespace index { namespace detail { @@ -25,7 +26,12 @@ inline typename default_content_result::type intersection_content(Box const if ( geometry::intersects(box1, box2) ) { Box box_intersection; - geometry::intersection(box1, box2, box_intersection); + + strategy_intersection_empty dummy; + geometry::detail::intersection::intersection_box_box + < + 0, geometry::dimension::value + >::apply(box1, box2, box_intersection, dummy); return detail::content(box_intersection); } return 0; diff --git a/include/boost/geometry/policies/robustness/rescale_policy.hpp b/include/boost/geometry/policies/robustness/rescale_policy.hpp index 570ba8bef..5b3b56697 100644 --- a/include/boost/geometry/policies/robustness/rescale_policy.hpp +++ b/include/boost/geometry/policies/robustness/rescale_policy.hpp @@ -16,6 +16,7 @@ #include +#include #include #include diff --git a/include/boost/geometry/strategies/intersection.hpp b/include/boost/geometry/strategies/intersection.hpp index d97baf66d..ef1b676fd 100644 --- a/include/boost/geometry/strategies/intersection.hpp +++ b/include/boost/geometry/strategies/intersection.hpp @@ -82,7 +82,8 @@ public: typedef RobustPolicy rescale_policy_type; }; - +// Version for box_box intersection or other detail calls not needing a strategy +struct strategy_intersection_empty {}; }} // namespace boost::geometry diff --git a/test/algorithms/Jamfile.v2 b/test/algorithms/Jamfile.v2 index de35ec60e..63b7fe3c4 100644 --- a/test/algorithms/Jamfile.v2 +++ b/test/algorithms/Jamfile.v2 @@ -47,6 +47,7 @@ test-suite boost-geometry-algorithms [ run intersects.cpp : : : msvc:/bigobj ] [ run length.cpp ] [ run make.cpp ] + [ run num_points.cpp ] [ run overlaps.cpp ] [ run perimeter.cpp ] [ run point_on_surface.cpp ] diff --git a/test/algorithms/from_wkt.hpp b/test/algorithms/from_wkt.hpp index 13d646356..5c78afdea 100644 --- a/test/algorithms/from_wkt.hpp +++ b/test/algorithms/from_wkt.hpp @@ -1,14 +1,27 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Tests + +// 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. +// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland. + +// 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_TEST_FROM_WKT_HPP #define BOOST_GEOMETRY_TEST_FROM_WKT_HPP #include +#include template -Geometry from_wkt(std::string const& wkt) +inline Geometry from_wkt(std::string const& wkt) { - Geometry res; - boost::geometry::read_wkt(wkt, res); - return res; + Geometry result; + boost::geometry::read_wkt(wkt, result); + return result; } #endif // BOOST_GEOMETRY_TEST_FROM_WKT_HPP diff --git a/test/algorithms/num_points.cpp b/test/algorithms/num_points.cpp new file mode 100644 index 000000000..3abeed449 --- /dev/null +++ b/test/algorithms/num_points.cpp @@ -0,0 +1,65 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// 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. +// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland. + +// 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_TEST_MODULE +#define BOOST_TEST_MODULE test_num_points +#endif + +#include +#include + +#include +#include +#include +#include + +#include +#include + +template +inline void test_num_points(std::string const& wkt, std::size_t expected) +{ + namespace bg = boost::geometry; + Geometry geometry; + boost::geometry::read_wkt(wkt, geometry); + std::size_t detected = bg::num_points(geometry); + BOOST_CHECK_EQUAL(expected, detected); + detected = bg::num_points(geometry, false); + BOOST_CHECK_EQUAL(expected, detected); + detected = bg::num_points(geometry, true); +} + +BOOST_AUTO_TEST_CASE( test_num_points_closed ) +{ + namespace bg = boost::geometry; + typedef bg::model::point point; + typedef bg::model::linestring linestring; + typedef bg::model::segment segment; + typedef bg::model::box box; + typedef bg::model::ring ring; + typedef bg::model::polygon polygon; + typedef bg::model::multi_point multi_point; + typedef bg::model::multi_linestring multi_linestring; + typedef bg::model::multi_polygon multi_polygon; + + test_num_points("POINT(0 0)", 1u); + test_num_points("LINESTRING(0 0,1 1)", 2u); + test_num_points("LINESTRING(0 0,1 1)", 2u); + test_num_points("POLYGON((0 0,10 10))", 4u); + test_num_points("POLYGON((0 0,1 1,0 1,0 0))", 4u); + test_num_points("POLYGON((0 0,10 10,0 10,0 0))", 4u); + test_num_points("POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,6 4,6 6,4 6,4 4))", 10u); + test_num_points("MULTIPOINT((0 0),(1 1))", 2u); + test_num_points("MULTILINESTRING((0 0,1 1),(2 2,3 3,4 4))", 5u); + test_num_points("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 10,1 10,1 9,0 10)))", 9u); +} + diff --git a/test/algorithms/test_set_ops_linear_linear.hpp b/test/algorithms/test_set_ops_linear_linear.hpp index 51d9d5794..c3ff6757d 100644 --- a/test/algorithms/test_set_ops_linear_linear.hpp +++ b/test/algorithms/test_set_ops_linear_linear.hpp @@ -92,7 +92,7 @@ struct multilinestring_equals template struct unique { - void operator()(MultiLinestring& mls) + void operator()(MultiLinestring&) { } }; diff --git a/test/to_svg.hpp b/test/to_svg.hpp index 54891b7bf..9f7c37749 100644 --- a/test/to_svg.hpp +++ b/test/to_svg.hpp @@ -29,7 +29,7 @@ #include template -inline void turns_to_svg(Turns const& turns, Mapper & mapper, bool enrich = false) +inline void turns_to_svg(Turns const& turns, Mapper & mapper, bool /*enrich*/ = false) { // turn points in orange, + enrichment/traversal info typedef typename bg::coordinate_type::type coordinate_type; @@ -196,7 +196,7 @@ struct to_svg_assign_policy }; template -inline void to_svg(G const& g, std::string const& filename, bool sort = true) +inline void to_svg(G const& g, std::string const& filename, bool /*sort*/ = true) { namespace bg = boost::geometry;