From adb8dfa0234f12d10c03e0991b8e75917bcc1a45 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Fri, 6 Mar 2015 10:56:42 +0200 Subject: [PATCH 001/146] [algorithms][partition] modify partition to work for forward ranges --- .../geometry/algorithms/detail/partition.hpp | 486 ++++++++++-------- 1 file changed, 277 insertions(+), 209 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/partition.hpp b/include/boost/geometry/algorithms/detail/partition.hpp index 25a34ba2e..8408c38fc 100644 --- a/include/boost/geometry/algorithms/detail/partition.hpp +++ b/include/boost/geometry/algorithms/detail/partition.hpp @@ -1,6 +1,11 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2011-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2011-2015 Barend Gehrels, Amsterdam, the Netherlands. + +// This file was modified by Oracle on 2015. +// Modifications copyright (c) 2015 Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, 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 @@ -9,10 +14,13 @@ #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_PARTITION_HPP #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_PARTITION_HPP +#include #include -#include -#include +#include +#include #include +#include + namespace boost { namespace geometry { @@ -20,8 +28,6 @@ namespace boost { namespace geometry namespace detail { namespace partition { -typedef std::vector index_vector_type; - template inline void divide_box(Box const& box, Box& lower_box, Box& upper_box) { @@ -38,31 +44,33 @@ inline void divide_box(Box const& box, Box& lower_box, Box& upper_box) geometry::set(upper_box, mid); } -// Divide collection into three subsets: lower, upper and oversized +// Divide forward_range into three subsets: lower, upper and oversized // (not-fitting) // (lower == left or bottom, upper == right or top) -template +template +< + typename OverlapsPolicy, + typename ForwardRange, + typename Box, + typename IteratorVector +> inline void divide_into_subsets(Box const& lower_box, Box const& upper_box, - InputCollection const& collection, - index_vector_type const& input, - index_vector_type& lower, - index_vector_type& upper, - index_vector_type& exceeding) + ForwardRange const& /*forward_range*/, + IteratorVector const& input, + IteratorVector& lower, + IteratorVector& upper, + IteratorVector& exceeding) { - typedef boost::range_iterator + typedef typename boost::range_iterator < - index_vector_type const - >::type index_iterator_type; + IteratorVector const + >::type it_type; - for(index_iterator_type it = boost::begin(input); - it != boost::end(input); - ++it) + for(it_type it = boost::begin(input); it != boost::end(input); ++it) { - bool const lower_overlapping = OverlapsPolicy::apply(lower_box, - collection[*it]); - bool const upper_overlapping = OverlapsPolicy::apply(upper_box, - collection[*it]); + bool const lower_overlapping = OverlapsPolicy::apply(lower_box, **it); + bool const upper_overlapping = OverlapsPolicy::apply(upper_box, **it); if (lower_overlapping && upper_overlapping) { @@ -84,23 +92,34 @@ inline void divide_into_subsets(Box const& lower_box, } } -template +template +< + typename ExpandPolicy, + typename Box, + typename ForwardRange, + typename IteratorVector +> inline void expand_with_elements(Box& total, - InputCollection const& collection, - index_vector_type const& input) + ForwardRange const& /*forward_range*/, + IteratorVector const& input) { - typedef boost::range_iterator::type it_type; + typedef typename boost::range_iterator::type it_type; for(it_type it = boost::begin(input); it != boost::end(input); ++it) { - ExpandPolicy::apply(total, collection[*it]); + ExpandPolicy::apply(total, **it); } } -// Match collection with itself -template -inline void handle_one(InputCollection const& collection, - index_vector_type const& input, +// Match forward_range with itself +template +< + typename ForwardRange, + typename Policy, + typename IteratorVector +> +inline void handle_one(ForwardRange const& /*forward_range*/, + IteratorVector const& input, Policy& policy) { if (boost::size(input) == 0) @@ -108,75 +127,87 @@ inline void handle_one(InputCollection const& collection, return; } - typedef boost::range_iterator::type - index_iterator_type; + typedef typename boost::range_iterator::type it_type; // Quadratic behaviour at lowest level (lowest quad, or all exceeding) - for(index_iterator_type it1 = boost::begin(input); - it1 != boost::end(input); - ++it1) + for (it_type it1 = boost::begin(input); it1 != boost::end(input); ++it1) { - index_iterator_type it2 = it1; - for(++it2; it2 != boost::end(input); ++it2) + it_type it2 = it1; + for (++it2; it2 != boost::end(input); ++it2) { - policy.apply(collection[*it1], collection[*it2]); + policy.apply(**it1, **it2); } } } -// Match collection 1 with collection 2 +// Match forward range 1 with forward range 2 template < - typename InputCollection1, - typename InputCollection2, - typename Policy + typename ForwardRange1, + typename ForwardRange2, + typename Policy, + typename IteratorVector1, + typename IteratorVector2 > inline void handle_two( - InputCollection1 const& collection1, index_vector_type const& input1, - InputCollection2 const& collection2, index_vector_type const& input2, + ForwardRange1 const& /*forward_range1*/, IteratorVector1 const& input1, + ForwardRange2 const& /*forward_range2*/, IteratorVector2 const& input2, Policy& policy) { + typedef typename boost::range_iterator + < + IteratorVector1 const + >::type iterator_type1; + + typedef typename boost::range_iterator + < + IteratorVector2 const + >::type iterator_type2; + if (boost::size(input1) == 0 || boost::size(input2) == 0) { return; } - typedef boost::range_iterator - < - index_vector_type const - >::type index_iterator_type; - - for(index_iterator_type it1 = boost::begin(input1); + for(iterator_type1 it1 = boost::begin(input1); it1 != boost::end(input1); ++it1) { - for(index_iterator_type it2 = boost::begin(input2); + for(iterator_type2 it2 = boost::begin(input2); it2 != boost::end(input2); ++it2) { - policy.apply(collection1[*it1], collection2[*it2]); + policy.apply(**it1, **it2); } } } -inline bool recurse_ok(index_vector_type const& input, +template +inline bool recurse_ok(IteratorVector const& input, std::size_t min_elements, std::size_t level) { return boost::size(input) >= min_elements && level < 100; } -inline bool recurse_ok(index_vector_type const& input1, - index_vector_type const& input2, +template +inline bool recurse_ok(IteratorVector1 const& input1, + IteratorVector2 const& input2, std::size_t min_elements, std::size_t level) { return boost::size(input1) >= min_elements && recurse_ok(input2, min_elements, level); } -inline bool recurse_ok(index_vector_type const& input1, - index_vector_type const& input2, - index_vector_type const& input3, +template +< + typename IteratorVector1, + typename IteratorVector2, + typename IteratorVector3 +> +inline bool recurse_ok(IteratorVector1 const& input1, + IteratorVector2 const& input2, + IteratorVector3 const& input3, std::size_t min_elements, std::size_t level) { return boost::size(input1) >= min_elements @@ -193,7 +224,7 @@ template typename ExpandPolicy2, typename VisitBoxPolicy > -class partition_two_collections; +class partition_two_ranges; template @@ -204,79 +235,91 @@ template typename ExpandPolicy, typename VisitBoxPolicy > -class partition_one_collection +class partition_one_range { - typedef std::vector index_vector_type; - - template - static inline Box get_new_box(InputCollection const& collection, - index_vector_type const& input) + template + static inline Box get_new_box(ForwardRange const& forward_range, + IteratorVector const& input) { Box box; geometry::assign_inverse(box); - expand_with_elements(box, collection, input); + expand_with_elements(box, forward_range, input); return box; } - template + template + < + typename ForwardRange, + typename Policy, + typename IteratorVector + > static inline void next_level(Box const& box, - InputCollection const& collection, - index_vector_type const& input, + ForwardRange const& forward_range, + IteratorVector const& input, std::size_t level, std::size_t min_elements, Policy& policy, VisitBoxPolicy& box_policy) { if (recurse_ok(input, min_elements, level)) { - partition_one_collection + partition_one_range < 1 - Dimension, Box, OverlapsPolicy, ExpandPolicy, VisitBoxPolicy - >::apply(box, collection, input, + >::apply(box, forward_range, input, level + 1, min_elements, policy, box_policy); } else { - handle_one(collection, input, policy); + handle_one(forward_range, input, policy); } } - // Function to switch to two collections if there are geometries exceeding - // the separation line - template + // Function to switch to two forward ranges if there are + // geometries exceeding the separation line + template + < + typename ForwardRange, + typename Policy, + typename IteratorVector + > static inline void next_level2(Box const& box, - InputCollection const& collection, - index_vector_type const& input1, - index_vector_type const& input2, + ForwardRange const& forward_range, + IteratorVector const& input1, + IteratorVector const& input2, std::size_t level, std::size_t min_elements, Policy& policy, VisitBoxPolicy& box_policy) { - if (recurse_ok(input1, input2, min_elements, level)) { - partition_two_collections + partition_two_ranges < 1 - Dimension, Box, OverlapsPolicy, OverlapsPolicy, ExpandPolicy, ExpandPolicy, VisitBoxPolicy - >::apply(box, collection, input1, collection, input2, + >::apply(box, forward_range, input1, forward_range, input2, level + 1, min_elements, policy, box_policy); } else { - handle_two(collection, input1, collection, input2, policy); + handle_two(forward_range, input1, forward_range, input2, policy); } } public : - template + template + < + typename ForwardRange, + typename Policy, + typename IteratorVector + > static inline void apply(Box const& box, - InputCollection const& collection, - index_vector_type const& input, + ForwardRange const& forward_range, + IteratorVector const& input, std::size_t level, std::size_t min_elements, Policy& policy, VisitBoxPolicy& box_policy) @@ -286,32 +329,32 @@ public : Box lower_box, upper_box; divide_box(box, lower_box, upper_box); - index_vector_type lower, upper, exceeding; - divide_into_subsets(lower_box, upper_box, collection, + IteratorVector lower, upper, exceeding; + divide_into_subsets(lower_box, upper_box, forward_range, input, lower, upper, exceeding); if (boost::size(exceeding) > 0) { // Get the box of exceeding-only - Box exceeding_box = get_new_box(collection, exceeding); + Box exceeding_box = get_new_box(forward_range, exceeding); // Recursively do exceeding elements only, in next dimension they // will probably be less exceeding within the new box - next_level(exceeding_box, collection, exceeding, level, + next_level(exceeding_box, forward_range, exceeding, level, min_elements, policy, box_policy); - // Switch to two collections, combine exceeding with lower resp upper - // but not lower/lower, upper/upper - next_level2(exceeding_box, collection, exceeding, lower, level, + // Switch to two forward ranges, combine exceeding with + // lower resp upper, but not lower/lower, upper/upper + next_level2(exceeding_box, forward_range, exceeding, lower, level, min_elements, policy, box_policy); - next_level2(exceeding_box, collection, exceeding, upper, level, + next_level2(exceeding_box, forward_range, exceeding, upper, level, min_elements, policy, box_policy); } // Recursively call operation both parts - next_level(lower_box, collection, lower, level, min_elements, + next_level(lower_box, forward_range, lower, level, min_elements, policy, box_policy); - next_level(upper_box, collection, upper, level, min_elements, + next_level(upper_box, forward_range, upper, level, min_elements, policy, box_policy); } }; @@ -326,25 +369,25 @@ template typename ExpandPolicy2, typename VisitBoxPolicy > -class partition_two_collections +class partition_two_ranges { - typedef std::vector index_vector_type; - template < - typename InputCollection1, - typename InputCollection2, - typename Policy + typename ForwardRange1, + typename ForwardRange2, + typename Policy, + typename IteratorVector1, + typename IteratorVector2 > static inline void next_level(Box const& box, - InputCollection1 const& collection1, - index_vector_type const& input1, - InputCollection2 const& collection2, - index_vector_type const& input2, + ForwardRange1 const& forward_range1, + IteratorVector1 const& input1, + ForwardRange2 const& forward_range2, + IteratorVector2 const& input2, std::size_t level, std::size_t min_elements, Policy& policy, VisitBoxPolicy& box_policy) { - partition_two_collections + partition_two_ranges < 1 - Dimension, Box, @@ -353,7 +396,7 @@ class partition_two_collections ExpandPolicy1, ExpandPolicy2, VisitBoxPolicy - >::apply(box, collection1, input1, collection2, input2, + >::apply(box, forward_range1, input1, forward_range2, input2, level + 1, min_elements, policy, box_policy); } @@ -361,42 +404,49 @@ class partition_two_collections template < typename ExpandPolicy, - typename InputCollection + typename ForwardRange, + typename IteratorVector > - static inline Box get_new_box(InputCollection const& collection, - index_vector_type const& input) + static inline Box get_new_box(ForwardRange const& forward_range, + IteratorVector const& input) { Box box; geometry::assign_inverse(box); - expand_with_elements(box, collection, input); + expand_with_elements(box, forward_range, input); return box; } template < - typename InputCollection1, - typename InputCollection2 + typename ForwardRange1, + typename ForwardRange2, + typename IteratorVector1, + typename IteratorVector2 > - static inline Box get_new_box(InputCollection1 const& collection1, - index_vector_type const& input1, - InputCollection2 const& collection2, - index_vector_type const& input2) + static inline Box get_new_box(ForwardRange1 const& forward_range1, + IteratorVector1 const& input1, + ForwardRange2 const& forward_range2, + IteratorVector2 const& input2) { - Box box = get_new_box(collection1, input1); - expand_with_elements(box, collection2, input2); + Box box = get_new_box(forward_range1, input1); + expand_with_elements(box, forward_range2, input2); return box; } public : template < - typename InputCollection1, - typename InputCollection2, - typename Policy + typename ForwardRange1, + typename ForwardRange2, + typename Policy, + typename IteratorVector1, + typename IteratorVector2 > static inline void apply(Box const& box, - InputCollection1 const& collection1, index_vector_type const& input1, - InputCollection2 const& collection2, index_vector_type const& input2, + ForwardRange1 const& forward_range1, + IteratorVector1 const& input1, + ForwardRange2 const& forward_range2, + IteratorVector2 const& input2, std::size_t level, std::size_t min_elements, Policy& policy, VisitBoxPolicy& box_policy) @@ -406,12 +456,12 @@ public : Box lower_box, upper_box; divide_box(box, lower_box, upper_box); - index_vector_type lower1, upper1, exceeding1; - index_vector_type lower2, upper2, exceeding2; - divide_into_subsets(lower_box, upper_box, collection1, - input1, lower1, upper1, exceeding1); - divide_into_subsets(lower_box, upper_box, collection2, - input2, lower2, upper2, exceeding2); + IteratorVector1 lower1, upper1, exceeding1; + IteratorVector2 lower2, upper2, exceeding2; + divide_into_subsets(lower_box, upper_box, + forward_range1, input1, lower1, upper1, exceeding1); + divide_into_subsets(lower_box, upper_box, + forward_range2, input2, lower2, upper2, exceeding2); if (boost::size(exceeding1) > 0) { @@ -419,35 +469,39 @@ public : if (recurse_ok(exceeding1, exceeding2, min_elements, level)) { - Box exceeding_box = get_new_box(collection1, exceeding1, - collection2, exceeding2); - next_level(exceeding_box, collection1, exceeding1, - collection2, exceeding2, level, + Box exceeding_box = get_new_box(forward_range1, exceeding1, + forward_range2, exceeding2); + next_level(exceeding_box, forward_range1, exceeding1, + forward_range2, exceeding2, level, min_elements, policy, box_policy); } else { - handle_two(collection1, exceeding1, collection2, exceeding2, - policy); + handle_two(forward_range1, exceeding1, forward_range2, + exceeding2, policy); } // All exceeding from 1 with lower and upper of 2: - // (Check sizes of all three collections to avoid recurse into + // (Check sizes of all three forward ranges to avoid recurse into // the same combinations again and again) if (recurse_ok(lower2, upper2, exceeding1, min_elements, level)) { Box exceeding_box - = get_new_box(collection1, exceeding1); - next_level(exceeding_box, collection1, exceeding1, - collection2, lower2, level, min_elements, policy, box_policy); - next_level(exceeding_box, collection1, exceeding1, - collection2, upper2, level, min_elements, policy, box_policy); + = get_new_box(forward_range1, exceeding1); + next_level(exceeding_box, forward_range1, exceeding1, + forward_range2, lower2, level, min_elements, + policy, box_policy); + next_level(exceeding_box, forward_range1, exceeding1, + forward_range2, upper2, level, min_elements, + policy, box_policy); } else { - handle_two(collection1, exceeding1, collection2, lower2, policy); - handle_two(collection1, exceeding1, collection2, upper2, policy); + handle_two(forward_range1, exceeding1, forward_range2, lower2, + policy); + handle_two(forward_range1, exceeding1, forward_range2, upper2, + policy); } } @@ -457,36 +511,42 @@ public : if (recurse_ok(lower1, upper1, exceeding2, min_elements, level)) { Box exceeding_box - = get_new_box(collection2, exceeding2); - next_level(exceeding_box, collection1, lower1, - collection2, exceeding2, level, min_elements, policy, box_policy); - next_level(exceeding_box, collection1, upper1, - collection2, exceeding2, level, min_elements, policy, box_policy); + = get_new_box(forward_range2, exceeding2); + next_level(exceeding_box, forward_range1, lower1, + forward_range2, exceeding2, level, min_elements, + policy, box_policy); + next_level(exceeding_box, forward_range1, upper1, + forward_range2, exceeding2, level, min_elements, + policy, box_policy); } else { - handle_two(collection1, lower1, collection2, exceeding2, policy); - handle_two(collection1, upper1, collection2, exceeding2, policy); + handle_two(forward_range1, lower1, forward_range2, exceeding2, + policy); + handle_two(forward_range1, upper1, forward_range2, exceeding2, + policy); } } if (recurse_ok(lower1, lower2, min_elements, level)) { - next_level(lower_box, collection1, lower1, collection2, lower2, level, + next_level(lower_box, forward_range1, lower1, + forward_range2, lower2, level, min_elements, policy, box_policy); } else { - handle_two(collection1, lower1, collection2, lower2, policy); + handle_two(forward_range1, lower1, forward_range2, lower2, policy); } if (recurse_ok(upper1, upper2, min_elements, level)) { - next_level(upper_box, collection1, upper1, collection2, upper2, level, + next_level(upper_box, forward_range1, upper1, + forward_range2, upper2, level, min_elements, policy, box_policy); } else { - handle_two(collection1, upper1, collection2, upper2, policy); + handle_two(forward_range1, upper1, forward_range2, upper2, policy); } } }; @@ -523,63 +583,67 @@ template > class partition { - typedef std::vector index_vector_type; - - template - static inline void expand_to_collection(InputCollection const& collection, - Box& total, index_vector_type& index_vector) + template + < + typename ExpandPolicy, + typename IncludePolicy, + typename ForwardRange, + typename IteratorVector + > + static inline void expand_to_range(ForwardRange const& forward_range, + Box& total, IteratorVector& iterator_vector) { - std::size_t index = 0; - for(typename boost::range_iterator::type it - = boost::begin(collection); - it != boost::end(collection); - ++it, ++index) + for(typename boost::range_iterator::type it + = boost::begin(forward_range); + it != boost::end(forward_range); + ++it) { if (IncludePolicy::apply(*it)) { ExpandPolicy::apply(total, *it); - index_vector.push_back(index); + iterator_vector.push_back(it); } } } public : - template - static inline void apply(InputCollection const& collection, + template + static inline void apply(ForwardRange const& forward_range, VisitPolicy& visitor, std::size_t min_elements = 16, VisitBoxPolicy box_visitor = detail::partition::visit_no_policy() ) { - if (std::size_t(boost::size(collection)) > min_elements) + typedef typename boost::range_iterator + < + ForwardRange const + >::type iterator_type; + + if (std::size_t(boost::size(forward_range)) > min_elements) { - index_vector_type index_vector; + std::vector iterator_vector; Box total; assign_inverse(total); - expand_to_collection(collection, - total, index_vector); + expand_to_range(forward_range, + total, iterator_vector); - detail::partition::partition_one_collection + detail::partition::partition_one_range < 0, Box, OverlapsPolicy1, ExpandPolicy1, VisitBoxPolicy - >::apply(total, collection, index_vector, 0, min_elements, + >::apply(total, forward_range, iterator_vector, 0, min_elements, visitor, box_visitor); } else { - typedef typename boost::range_iterator - < - InputCollection const - >::type iterator_type; - for(iterator_type it1 = boost::begin(collection); - it1 != boost::end(collection); + for(iterator_type it1 = boost::begin(forward_range); + it1 != boost::end(forward_range); ++it1) { iterator_type it2 = it1; - for(++it2; it2 != boost::end(collection); ++it2) + for(++it2; it2 != boost::end(forward_range); ++it2) { visitor.apply(*it1, *it2); } @@ -589,53 +653,57 @@ public : template < - typename InputCollection1, - typename InputCollection2, + typename ForwardRange1, + typename ForwardRange2, typename VisitPolicy > - static inline void apply(InputCollection1 const& collection1, - InputCollection2 const& collection2, + static inline void apply(ForwardRange1 const& forward_range1, + ForwardRange2 const& forward_range2, VisitPolicy& visitor, std::size_t min_elements = 16, - VisitBoxPolicy box_visitor = detail::partition::visit_no_policy() + VisitBoxPolicy box_visitor + = detail::partition::visit_no_policy() ) { - if (std::size_t(boost::size(collection1)) > min_elements - && std::size_t(boost::size(collection2)) > min_elements) + typedef typename boost::range_iterator + < + ForwardRange1 const + >::type iterator_type1; + + typedef typename boost::range_iterator + < + ForwardRange2 const + >::type iterator_type2; + + if (std::size_t(boost::size(forward_range1)) > min_elements + && std::size_t(boost::size(forward_range2)) > min_elements) { - index_vector_type index_vector1, index_vector2; + std::vector iterator_vector1; + std::vector iterator_vector2; Box total; assign_inverse(total); - expand_to_collection(collection1, - total, index_vector1); - expand_to_collection(collection2, - total, index_vector2); + expand_to_range(forward_range1, + total, iterator_vector1); + expand_to_range(forward_range2, + total, iterator_vector2); - detail::partition::partition_two_collections + detail::partition::partition_two_ranges < 0, Box, OverlapsPolicy1, OverlapsPolicy2, ExpandPolicy1, ExpandPolicy2, VisitBoxPolicy >::apply(total, - collection1, index_vector1, - collection2, index_vector2, + forward_range1, iterator_vector1, + forward_range2, iterator_vector2, 0, min_elements, visitor, box_visitor); } else { - typedef typename boost::range_iterator - < - InputCollection1 const - >::type iterator_type1; - typedef typename boost::range_iterator - < - InputCollection2 const - >::type iterator_type2; - for(iterator_type1 it1 = boost::begin(collection1); - it1 != boost::end(collection1); + for(iterator_type1 it1 = boost::begin(forward_range1); + it1 != boost::end(forward_range1); ++it1) { - for(iterator_type2 it2 = boost::begin(collection2); - it2 != boost::end(collection2); + for(iterator_type2 it2 = boost::begin(forward_range2); + it2 != boost::end(forward_range2); ++it2) { visitor.apply(*it1, *it2); From ee1e0e0899e92084aabd20faa413c850d9e9cd52 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Sat, 7 Mar 2015 17:34:17 +0200 Subject: [PATCH 002/146] [algorithms][detail][partition] remove the forward range(s) argument(s) --- .../geometry/algorithms/detail/partition.hpp | 214 ++++++------------ 1 file changed, 66 insertions(+), 148 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/partition.hpp b/include/boost/geometry/algorithms/detail/partition.hpp index 8408c38fc..8b19add47 100644 --- a/include/boost/geometry/algorithms/detail/partition.hpp +++ b/include/boost/geometry/algorithms/detail/partition.hpp @@ -47,16 +47,9 @@ inline void divide_box(Box const& box, Box& lower_box, Box& upper_box) // Divide forward_range into three subsets: lower, upper and oversized // (not-fitting) // (lower == left or bottom, upper == right or top) -template -< - typename OverlapsPolicy, - typename ForwardRange, - typename Box, - typename IteratorVector -> +template inline void divide_into_subsets(Box const& lower_box, Box const& upper_box, - ForwardRange const& /*forward_range*/, IteratorVector const& input, IteratorVector& lower, IteratorVector& upper, @@ -96,12 +89,9 @@ template < typename ExpandPolicy, typename Box, - typename ForwardRange, typename IteratorVector > -inline void expand_with_elements(Box& total, - ForwardRange const& /*forward_range*/, - IteratorVector const& input) +inline void expand_with_elements(Box& total, IteratorVector const& input) { typedef typename boost::range_iterator::type it_type; for(it_type it = boost::begin(input); it != boost::end(input); ++it) @@ -112,15 +102,8 @@ inline void expand_with_elements(Box& total, // Match forward_range with itself -template -< - typename ForwardRange, - typename Policy, - typename IteratorVector -> -inline void handle_one(ForwardRange const& /*forward_range*/, - IteratorVector const& input, - Policy& policy) +template +inline void handle_one(IteratorVector const& input, Policy& policy) { if (boost::size(input) == 0) { @@ -143,15 +126,12 @@ inline void handle_one(ForwardRange const& /*forward_range*/, // Match forward range 1 with forward range 2 template < - typename ForwardRange1, - typename ForwardRange2, typename Policy, typename IteratorVector1, typename IteratorVector2 > -inline void handle_two( - ForwardRange1 const& /*forward_range1*/, IteratorVector1 const& input1, - ForwardRange2 const& /*forward_range2*/, IteratorVector2 const& input2, +inline void handle_two(IteratorVector1 const& input1, + IteratorVector2 const& input2, Policy& policy) { typedef typename boost::range_iterator @@ -237,24 +217,17 @@ template > class partition_one_range { - template - static inline Box get_new_box(ForwardRange const& forward_range, - IteratorVector const& input) + template + static inline Box get_new_box(IteratorVector const& input) { Box box; geometry::assign_inverse(box); - expand_with_elements(box, forward_range, input); + expand_with_elements(box, input); return box; } - template - < - typename ForwardRange, - typename Policy, - typename IteratorVector - > + template static inline void next_level(Box const& box, - ForwardRange const& forward_range, IteratorVector const& input, std::size_t level, std::size_t min_elements, Policy& policy, VisitBoxPolicy& box_policy) @@ -268,25 +241,18 @@ class partition_one_range OverlapsPolicy, ExpandPolicy, VisitBoxPolicy - >::apply(box, forward_range, input, - level + 1, min_elements, policy, box_policy); + >::apply(box, input, level + 1, min_elements, policy, box_policy); } else { - handle_one(forward_range, input, policy); + handle_one(input, policy); } } // Function to switch to two forward ranges if there are // geometries exceeding the separation line - template - < - typename ForwardRange, - typename Policy, - typename IteratorVector - > + template static inline void next_level2(Box const& box, - ForwardRange const& forward_range, IteratorVector const& input1, IteratorVector const& input2, std::size_t level, std::size_t min_elements, @@ -301,24 +267,18 @@ class partition_one_range OverlapsPolicy, OverlapsPolicy, ExpandPolicy, ExpandPolicy, VisitBoxPolicy - >::apply(box, forward_range, input1, forward_range, input2, - level + 1, min_elements, policy, box_policy); + >::apply(box, input1, input2, level + 1, min_elements, + policy, box_policy); } else { - handle_two(forward_range, input1, forward_range, input2, policy); + handle_two(input1, input2, policy); } } public : - template - < - typename ForwardRange, - typename Policy, - typename IteratorVector - > + template static inline void apply(Box const& box, - ForwardRange const& forward_range, IteratorVector const& input, std::size_t level, std::size_t min_elements, @@ -330,32 +290,30 @@ public : divide_box(box, lower_box, upper_box); IteratorVector lower, upper, exceeding; - divide_into_subsets(lower_box, upper_box, forward_range, + divide_into_subsets(lower_box, upper_box, input, lower, upper, exceeding); if (boost::size(exceeding) > 0) { // Get the box of exceeding-only - Box exceeding_box = get_new_box(forward_range, exceeding); + Box exceeding_box = get_new_box(exceeding); // Recursively do exceeding elements only, in next dimension they // will probably be less exceeding within the new box - next_level(exceeding_box, forward_range, exceeding, level, - min_elements, policy, box_policy); + next_level(exceeding_box, exceeding, level, min_elements, + policy, box_policy); // Switch to two forward ranges, combine exceeding with // lower resp upper, but not lower/lower, upper/upper - next_level2(exceeding_box, forward_range, exceeding, lower, level, - min_elements, policy, box_policy); - next_level2(exceeding_box, forward_range, exceeding, upper, level, - min_elements, policy, box_policy); + next_level2(exceeding_box, exceeding, lower, level, min_elements, + policy, box_policy); + next_level2(exceeding_box, exceeding, upper, level, min_elements, + policy, box_policy); } // Recursively call operation both parts - next_level(lower_box, forward_range, lower, level, min_elements, - policy, box_policy); - next_level(upper_box, forward_range, upper, level, min_elements, - policy, box_policy); + next_level(lower_box, lower, level, min_elements, policy, box_policy); + next_level(upper_box, upper, level, min_elements, policy, box_policy); } }; @@ -373,16 +331,12 @@ class partition_two_ranges { template < - typename ForwardRange1, - typename ForwardRange2, typename Policy, typename IteratorVector1, typename IteratorVector2 > static inline void next_level(Box const& box, - ForwardRange1 const& forward_range1, IteratorVector1 const& input1, - ForwardRange2 const& forward_range2, IteratorVector2 const& input2, std::size_t level, std::size_t min_elements, Policy& policy, VisitBoxPolicy& box_policy) @@ -396,56 +350,37 @@ class partition_two_ranges ExpandPolicy1, ExpandPolicy2, VisitBoxPolicy - >::apply(box, forward_range1, input1, forward_range2, input2, - level + 1, min_elements, - policy, box_policy); + >::apply(box, input1, input2, level + 1, min_elements, + policy, box_policy); } - template - < - typename ExpandPolicy, - typename ForwardRange, - typename IteratorVector - > - static inline Box get_new_box(ForwardRange const& forward_range, - IteratorVector const& input) + template + static inline Box get_new_box(IteratorVector const& input) { Box box; geometry::assign_inverse(box); - expand_with_elements(box, forward_range, input); + expand_with_elements(box, input); return box; } - template - < - typename ForwardRange1, - typename ForwardRange2, - typename IteratorVector1, - typename IteratorVector2 - > - static inline Box get_new_box(ForwardRange1 const& forward_range1, - IteratorVector1 const& input1, - ForwardRange2 const& forward_range2, + template + static inline Box get_new_box(IteratorVector1 const& input1, IteratorVector2 const& input2) { - Box box = get_new_box(forward_range1, input1); - expand_with_elements(box, forward_range2, input2); + Box box = get_new_box(input1); + expand_with_elements(box, input2); return box; } public : template < - typename ForwardRange1, - typename ForwardRange2, typename Policy, typename IteratorVector1, typename IteratorVector2 > static inline void apply(Box const& box, - ForwardRange1 const& forward_range1, IteratorVector1 const& input1, - ForwardRange2 const& forward_range2, IteratorVector2 const& input2, std::size_t level, std::size_t min_elements, @@ -459,9 +394,9 @@ public : IteratorVector1 lower1, upper1, exceeding1; IteratorVector2 lower2, upper2, exceeding2; divide_into_subsets(lower_box, upper_box, - forward_range1, input1, lower1, upper1, exceeding1); + input1, lower1, upper1, exceeding1); divide_into_subsets(lower_box, upper_box, - forward_range2, input2, lower2, upper2, exceeding2); + input2, lower2, upper2, exceeding2); if (boost::size(exceeding1) > 0) { @@ -469,16 +404,13 @@ public : if (recurse_ok(exceeding1, exceeding2, min_elements, level)) { - Box exceeding_box = get_new_box(forward_range1, exceeding1, - forward_range2, exceeding2); - next_level(exceeding_box, forward_range1, exceeding1, - forward_range2, exceeding2, level, - min_elements, policy, box_policy); + Box exceeding_box = get_new_box(exceeding1, exceeding2); + next_level(exceeding_box, exceeding1, exceeding2, level, + min_elements, policy, box_policy); } else { - handle_two(forward_range1, exceeding1, forward_range2, - exceeding2, policy); + handle_two(exceeding1, exceeding2, policy); } // All exceeding from 1 with lower and upper of 2: @@ -487,21 +419,16 @@ public : // the same combinations again and again) if (recurse_ok(lower2, upper2, exceeding1, min_elements, level)) { - Box exceeding_box - = get_new_box(forward_range1, exceeding1); - next_level(exceeding_box, forward_range1, exceeding1, - forward_range2, lower2, level, min_elements, - policy, box_policy); - next_level(exceeding_box, forward_range1, exceeding1, - forward_range2, upper2, level, min_elements, - policy, box_policy); + Box exceeding_box = get_new_box(exceeding1); + next_level(exceeding_box, exceeding1, lower2, level, + min_elements, policy, box_policy); + next_level(exceeding_box, exceeding1, upper2, level, + min_elements, policy, box_policy); } else { - handle_two(forward_range1, exceeding1, forward_range2, lower2, - policy); - handle_two(forward_range1, exceeding1, forward_range2, upper2, - policy); + handle_two(exceeding1, lower2, policy); + handle_two(exceeding1, upper2, policy); } } @@ -510,43 +437,36 @@ public : // All exceeding from 2 with lower and upper of 1: if (recurse_ok(lower1, upper1, exceeding2, min_elements, level)) { - Box exceeding_box - = get_new_box(forward_range2, exceeding2); - next_level(exceeding_box, forward_range1, lower1, - forward_range2, exceeding2, level, min_elements, - policy, box_policy); - next_level(exceeding_box, forward_range1, upper1, - forward_range2, exceeding2, level, min_elements, - policy, box_policy); + Box exceeding_box = get_new_box(exceeding2); + next_level(exceeding_box, lower1, exceeding2, level, + min_elements, policy, box_policy); + next_level(exceeding_box, upper1, exceeding2, level, + min_elements, policy, box_policy); } else { - handle_two(forward_range1, lower1, forward_range2, exceeding2, - policy); - handle_two(forward_range1, upper1, forward_range2, exceeding2, - policy); + handle_two(lower1, exceeding2, policy); + handle_two(upper1, exceeding2, policy); } } if (recurse_ok(lower1, lower2, min_elements, level)) { - next_level(lower_box, forward_range1, lower1, - forward_range2, lower2, level, - min_elements, policy, box_policy); + next_level(lower_box, lower1, lower2, level, + min_elements, policy, box_policy); } else { - handle_two(forward_range1, lower1, forward_range2, lower2, policy); + handle_two(lower1, lower2, policy); } if (recurse_ok(upper1, upper2, min_elements, level)) { - next_level(upper_box, forward_range1, upper1, - forward_range2, upper2, level, - min_elements, policy, box_policy); + next_level(upper_box, upper1, upper2, level, + min_elements, policy, box_policy); } else { - handle_two(forward_range1, upper1, forward_range2, upper2, policy); + handle_two(upper1, upper2, policy); } } }; @@ -633,8 +553,8 @@ public : OverlapsPolicy1, ExpandPolicy1, VisitBoxPolicy - >::apply(total, forward_range, iterator_vector, 0, min_elements, - visitor, box_visitor); + >::apply(total, iterator_vector, 0, min_elements, + visitor, box_visitor); } else { @@ -691,10 +611,8 @@ public : < 0, Box, OverlapsPolicy1, OverlapsPolicy2, ExpandPolicy1, ExpandPolicy2, VisitBoxPolicy - >::apply(total, - forward_range1, iterator_vector1, - forward_range2, iterator_vector2, - 0, min_elements, visitor, box_visitor); + >::apply(total, iterator_vector1, iterator_vector2, + 0, min_elements, visitor, box_visitor); } else { From ec5efe3799899d7931e4ec8d5f52394c1ba245b9 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Tue, 10 Mar 2015 16:04:31 +0200 Subject: [PATCH 003/146] [test][algorithms][set operations][pointlike] polish tests of set operations for pointlike/pointlike geometries (make the case ID the first argument of the tester); modify the common set operations test code so that it can be applied to set operations of pointlike/linear geometries as well; --- .../difference/difference_pl_pl.cpp | 128 ++++++++------- .../intersection/intersection_pl_pl.cpp | 124 ++++++++------- ...s_pl_pl.hpp => test_set_ops_pointlike.hpp} | 149 +++++++++++++----- .../set_operations/union/union_pl_pl.cpp | 139 ++++++++-------- 4 files changed, 330 insertions(+), 210 deletions(-) rename test/algorithms/set_operations/{test_set_ops_pl_pl.hpp => test_set_ops_pointlike.hpp} (58%) diff --git a/test/algorithms/set_operations/difference/difference_pl_pl.cpp b/test/algorithms/set_operations/difference/difference_pl_pl.cpp index 14a80f485..1712d94c5 100644 --- a/test/algorithms/set_operations/difference/difference_pl_pl.cpp +++ b/test/algorithms/set_operations/difference/difference_pl_pl.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html @@ -20,7 +20,7 @@ #include -#include "../test_set_ops_pl_pl.hpp" +#include "../test_set_ops_pointlike.hpp" #include @@ -51,17 +51,19 @@ BOOST_AUTO_TEST_CASE( test_difference_point_point ) > tester; tester::apply - (from_wkt

("POINT(0 0)"), + ("ppdf01", + from_wkt

("POINT(0 0)"), from_wkt

("POINT(1 1)"), from_wkt("MULTIPOINT(0 0)"), - from_wkt("MULTIPOINT(1 1)"), - "ppdf01"); + from_wkt("MULTIPOINT(1 1)") + ); tester::apply - (from_wkt

("POINT(0 0)"), + ("ppdf02", from_wkt

("POINT(0 0)"), - from_wkt("MULTIPOINT()"), - "ppdf02"); + from_wkt

("POINT(0 0)"), + from_wkt("MULTIPOINT()") + ); } @@ -82,58 +84,66 @@ BOOST_AUTO_TEST_CASE( test_difference_multipoint_point ) > tester; tester::apply - (from_wkt("MULTIPOINT(0 0)"), + ("mppdf01", + from_wkt("MULTIPOINT(0 0)"), from_wkt

("POINT(1 1)"), from_wkt("MULTIPOINT(0 0)"), - from_wkt("MULTIPOINT(1 1)"), - "mppdf01"); + from_wkt("MULTIPOINT(1 1)") + ); tester::apply - (from_wkt("MULTIPOINT(0 0)"), + ("mppdf02", + from_wkt("MULTIPOINT(0 0)"), from_wkt

("POINT(0 0)"), - from_wkt("MULTIPOINT()"), - "mppdf02"); + from_wkt("MULTIPOINT()") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,0 0)"), + ("mppdf03", + from_wkt("MULTIPOINT(0 0,0 0)"), from_wkt

("POINT(1 1)"), from_wkt("MULTIPOINT(0 0,0 0)"), - from_wkt("MULTIPOINT(1 1)"), - "mppdf03"); + from_wkt("MULTIPOINT(1 1)") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,0 0)"), + ("mppdf04", + from_wkt("MULTIPOINT(0 0,0 0)"), from_wkt

("POINT(0 0)"), - from_wkt("MULTIPOINT()"), - "mppdf04"); + from_wkt("MULTIPOINT()") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,0 0,1 0)"), + ("mppdf05", + from_wkt("MULTIPOINT(0 0,0 0,1 0)"), from_wkt

("POINT(1 1)"), from_wkt("MULTIPOINT(0 0,0 0,1 0)"), - from_wkt("MULTIPOINT(1 1)"), - "mppdf05"); + from_wkt("MULTIPOINT(1 1)") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,0 0,1 0)"), + ("mppdf06", + from_wkt("MULTIPOINT(0 0,0 0,1 0)"), from_wkt

("POINT(1 0)"), from_wkt("MULTIPOINT(0 0,0 0)"), - from_wkt("MULTIPOINT()"), - "mppdf06"); + from_wkt("MULTIPOINT()") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,0 0,1 0)"), + ("mppdf07", + from_wkt("MULTIPOINT(0 0,0 0,1 0)"), from_wkt

("POINT(0 0)"), from_wkt("MULTIPOINT(1 0)"), - from_wkt("MULTIPOINT()"), - "mppdf07"); + from_wkt("MULTIPOINT()") + ); tester::apply - (from_wkt("MULTIPOINT()"), + ("mppdf08", + from_wkt("MULTIPOINT()"), from_wkt

("POINT(0 0)"), from_wkt("MULTIPOINT()"), - from_wkt("MULTIPOINT(0 0)"), - "mppdf08"); + from_wkt("MULTIPOINT(0 0)") + ); } @@ -154,25 +164,28 @@ BOOST_AUTO_TEST_CASE( test_difference_point_multipoint ) > tester; tester::apply - (from_wkt

("POINT(0 0)"), + ("pmpdf01", + from_wkt

("POINT(0 0)"), from_wkt("MULTIPOINT(1 0,1 1,1 1)"), from_wkt("MULTIPOINT(0 0)"), - from_wkt("MULTIPOINT(1 0,1 1,1 1)"), - "pmpdf01"); + from_wkt("MULTIPOINT(1 0,1 1,1 1)") + ); tester::apply - (from_wkt

("POINT(0 0)"), + ("pmpdf02", + from_wkt

("POINT(0 0)"), from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)"), from_wkt("MULTIPOINT()"), - from_wkt("MULTIPOINT(1 0,1 1)"), - "pmpdf02"); + from_wkt("MULTIPOINT(1 0,1 1)") + ); tester::apply - (from_wkt

("POINT(0 0)"), + ("pmpdf03", + from_wkt

("POINT(0 0)"), from_wkt("MULTIPOINT()"), from_wkt("MULTIPOINT(0 0)"), - from_wkt("MULTIPOINT()"), - "pmpdf03"); + from_wkt("MULTIPOINT()") + ); } @@ -192,35 +205,40 @@ BOOST_AUTO_TEST_CASE( test_difference_multipoint_multipoint ) > tester; tester::apply - (from_wkt("MULTIPOINT(2 2,3 3,0 0,0 0,2 2,1 1,1 1,1 0,1 0)"), + ("mpmpdf01", + from_wkt("MULTIPOINT(2 2,3 3,0 0,0 0,2 2,1 1,1 1,1 0,1 0)"), from_wkt("MULTIPOINT(1 0,1 1,1 1,4 4)"), from_wkt("MULTIPOINT(2 2,3 3,0 0,0 0,2 2)"), - from_wkt("MULTIPOINT(4 4)"), - "mpmpdf01"); + from_wkt("MULTIPOINT(4 4)") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), + ("mpmpdf02", + from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)"), - from_wkt("MULTIPOINT()"), - "mpmpdf02"); + from_wkt("MULTIPOINT()") + ); tester::apply - (from_wkt("MULTIPOINT()"), - from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)"), + ("mpmpdf03", from_wkt("MULTIPOINT()"), from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)"), - "mpmpdf03"); + from_wkt("MULTIPOINT()"), + from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), - from_wkt("MULTIPOINT()"), + ("mpmpdf04", from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), from_wkt("MULTIPOINT()"), - "mpmpdf04"); + from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), + from_wkt("MULTIPOINT()") + ); tester::apply - (from_wkt("MULTIPOINT()"), + ("mpmpdf05", from_wkt("MULTIPOINT()"), from_wkt("MULTIPOINT()"), - "mpmpdf05"); + from_wkt("MULTIPOINT()") + ); } diff --git a/test/algorithms/set_operations/intersection/intersection_pl_pl.cpp b/test/algorithms/set_operations/intersection/intersection_pl_pl.cpp index 27b592e7a..ced2245d7 100644 --- a/test/algorithms/set_operations/intersection/intersection_pl_pl.cpp +++ b/test/algorithms/set_operations/intersection/intersection_pl_pl.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html @@ -20,7 +20,7 @@ #include -#include "../test_set_ops_pl_pl.hpp" +#include "../test_set_ops_pointlike.hpp" #include @@ -51,16 +51,18 @@ BOOST_AUTO_TEST_CASE( test_intersection_point_point ) > tester; tester::apply - (from_wkt

("POINT(0 0)"), + ("ppi01", + from_wkt

("POINT(0 0)"), from_wkt

("POINT(1 1)"), - from_wkt("MULTIPOINT()"), - "ppi01"); + from_wkt("MULTIPOINT()") + ); tester::apply - (from_wkt

("POINT(0 0)"), + ("ppi02", from_wkt

("POINT(0 0)"), - from_wkt("MULTIPOINT(0 0)"), - "ppi02"); + from_wkt

("POINT(0 0)"), + from_wkt("MULTIPOINT(0 0)") + ); } @@ -81,52 +83,60 @@ BOOST_AUTO_TEST_CASE( test_intersection_multipoint_point ) > tester; tester::apply - (from_wkt("MULTIPOINT(0 0)"), - from_wkt

("POINT(1 1)"), - from_wkt("MULTIPOINT()"), - "mppi01"); - - tester::apply - (from_wkt("MULTIPOINT(0 0)"), - from_wkt

("POINT(0 0)"), + ("mppi01", from_wkt("MULTIPOINT(0 0)"), - "mppi02"); - - tester::apply - (from_wkt("MULTIPOINT(0 0,0 0)"), from_wkt

("POINT(1 1)"), - from_wkt("MULTIPOINT()"), - "mppi03"); + from_wkt("MULTIPOINT()") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,0 0)"), - from_wkt

("POINT(0 0)"), + ("mppi02", from_wkt("MULTIPOINT(0 0)"), - "mppi04"); + from_wkt

("POINT(0 0)"), + from_wkt("MULTIPOINT(0 0)") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,0 0,1 0)"), + ("mppi03", + from_wkt("MULTIPOINT(0 0,0 0)"), from_wkt

("POINT(1 1)"), - from_wkt("MULTIPOINT()"), - "mppi05"); + from_wkt("MULTIPOINT()") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,0 0,1 0)"), + ("mppi04", + from_wkt("MULTIPOINT(0 0,0 0)"), + from_wkt

("POINT(0 0)"), + from_wkt("MULTIPOINT(0 0)") + ); + + tester::apply + ("mppi05", + from_wkt("MULTIPOINT(0 0,0 0,1 0)"), + from_wkt

("POINT(1 1)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mppi06", + from_wkt("MULTIPOINT(0 0,0 0,1 0)"), from_wkt

("POINT(1 0)"), - from_wkt("MULTIPOINT(1 0)"), - "mppi06"); + from_wkt("MULTIPOINT(1 0)") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,0 0,1 0)"), + ("mppi07", + from_wkt("MULTIPOINT(0 0,0 0,1 0)"), from_wkt

("POINT(0 0)"), - from_wkt("MULTIPOINT(0 0)"), - "mppi07"); + from_wkt("MULTIPOINT(0 0)") + ); tester::apply - (from_wkt("MULTIPOINT()"), - from_wkt

("POINT(0 0)"), + ("mppi08", from_wkt("MULTIPOINT()"), - "mppi08"); + from_wkt

("POINT(0 0)"), + from_wkt("MULTIPOINT()") + ); } @@ -146,40 +156,46 @@ BOOST_AUTO_TEST_CASE( test_intersection_multipoint_multipoint ) > tester; tester::apply - (from_wkt("MULTIPOINT(2 2,3 3,0 0,0 0,2 2,1 1,1 1,1 0,1 0)"), + ("mpmpi01", + from_wkt("MULTIPOINT(2 2,3 3,0 0,0 0,2 2,1 1,1 1,1 0,1 0)"), from_wkt("MULTIPOINT(1 0,1 1,1 1,1 1)"), - from_wkt("MULTIPOINT(1 0,1 1,1 1,1 1)"), - "mpmpi01"); + from_wkt("MULTIPOINT(1 0,1 1,1 1,1 1)") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), - from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)"), + ("mpmp02", from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)"), - "mpmpi02"); + from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), + from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)") + ); tester::apply - (from_wkt("MULTIPOINT()"), + ("mpmpi03", + from_wkt("MULTIPOINT()"), from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)"), - from_wkt("MULTIPOINT()"), - "mpmpi03"); + from_wkt("MULTIPOINT()") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), + ("mpmpi04", + from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), from_wkt("MULTIPOINT()"), - from_wkt("MULTIPOINT()"), - "mpmpi04"); + from_wkt("MULTIPOINT()") + ); tester::apply - (from_wkt("MULTIPOINT()"), + ("mpmpi05", from_wkt("MULTIPOINT()"), from_wkt("MULTIPOINT()"), - "mpmpi05"); + from_wkt("MULTIPOINT()") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,1 0,2 0,3 0,0 0,1 0,2 0)"), + ("mpmpi06", + from_wkt("MULTIPOINT(0 0,1 0,2 0,3 0,0 0,1 0,2 0)"), from_wkt("MULTIPOINT(0 1,0 2,1 0,0 0,2 0)"), - from_wkt("MULTIPOINT(1 0,0 0,2 0)"), - "mpmpi06"); + from_wkt("MULTIPOINT(1 0,0 0,2 0)") + ); } diff --git a/test/algorithms/set_operations/test_set_ops_pl_pl.hpp b/test/algorithms/set_operations/test_set_ops_pointlike.hpp similarity index 58% rename from test/algorithms/set_operations/test_set_ops_pl_pl.hpp rename to test/algorithms/set_operations/test_set_ops_pointlike.hpp index fd825d003..cb14ebe45 100644 --- a/test/algorithms/set_operations/test_set_ops_pl_pl.hpp +++ b/test/algorithms/set_operations/test_set_ops_pointlike.hpp @@ -1,14 +1,14 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle -#ifndef BOOST_GEOMETRY_TEST_SET_OPS_PL_PL_HPP -#define BOOST_GEOMETRY_TEST_SET_OPS_PL_PL_HPP +#ifndef BOOST_GEOMETRY_TEST_SET_OPS_POINTLIKE_HPP +#define BOOST_GEOMETRY_TEST_SET_OPS_POINTLIKE_HPP #include @@ -170,6 +170,54 @@ struct set_op }; +template +< + typename Geometry, + typename Tag = typename bg::tag::type +> struct geometry_info +{}; + +template +struct geometry_info +{ + static std::size_t const topological_dimension = 0; + + static inline char const* name() { return "P"; } +}; + +template +struct geometry_info +{ + static std::size_t const topological_dimension = 0; + + static inline char const* name() { return "MP"; } +}; + +template +struct geometry_info +{ + static std::size_t const topological_dimension = 1; + + static inline char const* name() { return "L"; } +}; + +template +struct geometry_info +{ + static std::size_t const topological_dimension = 1; + + static inline char const* name() { return "ML"; } +}; + +template +struct geometry_info +{ + static std::size_t const topological_dimension = 1; + + static inline char const* name() { return "S"; } +}; + + //================================================================== //================================================================== @@ -188,54 +236,78 @@ template class test_set_op_of_pointlike_geometries { private: - template - static inline void base_test(G1 const& geometry1, - G2 const& geometry2, - MP const& mp_expected, - std::string const& case_id) + template + struct base_test { - MultiPoint mp_output; + template + static inline void apply(std::string const& case_id, + G1 const& geometry1, + G2 const& geometry2, + MP const& mp_expected) + { + MultiPoint mp_output; - set_op::apply(geometry1, geometry2, mp_output); + set_op::apply(geometry1, geometry2, mp_output); - std::string op_name = set_op::name(); + std::string op_name = set_op::name(); - BOOST_CHECK_MESSAGE( equals::apply(mp_expected, mp_output), - op_name << " P/P: " << bg::wkt(geometry1) - << " " << bg::wkt(geometry2) - << " -> Expected: " << bg::wkt(mp_expected) - << " computed: " << bg::wkt(mp_output) ); + BOOST_CHECK_MESSAGE(equals::apply(mp_expected, mp_output), + "case ID: " << case_id << ", " + << op_name << " " + << geometry_info::name() << "/" + << geometry_info::name() << ": " + << bg::wkt(geometry1) + << " " << bg::wkt(geometry2) + << " -> Expected: " << bg::wkt(mp_expected) + << " computed: " << bg::wkt(mp_output) ); - set_operation_output(op_name, case_id, - geometry1, geometry2, mp_output); + set_operation_output(op_name, case_id, + geometry1, geometry2, mp_output); #ifdef BOOST_GEOMETRY_TEST_DEBUG - std::cout << "Geometry #1: " << bg::wkt(geometry1) << std::endl; - std::cout << "Geometry #2: " << bg::wkt(geometry2) << std::endl; - std::cout << "expected " << op_name << " : " - << bg::wkt(mp_expected) << std::endl; - std::cout << op_name << " : " << bg::wkt(mp_output) << std::endl; - std::cout << std::endl; - std::cout << "************************************" << std::endl; - std::cout << std::endl; - std::cout << std::endl; + std::cout << "Geometry #1: " << bg::wkt(geometry1) << std::endl; + std::cout << "Geometry #2: " << bg::wkt(geometry2) << std::endl; + std::cout << "expected " << op_name << " : " + << bg::wkt(mp_expected) << std::endl; + std::cout << op_name << " : " << bg::wkt(mp_output) << std::endl; + std::cout << std::endl; + std::cout << "************************************" << std::endl; + std::cout << std::endl; + std::cout << std::endl; #endif - } + } + }; + template + struct base_test + { + template + static inline void apply(std::string const&, G1 const&, G2 const&, + MP const&) + { + } + }; public: - static inline void apply(Geometry1 const& geometry1, + static inline void apply(std::string const& case_id, + Geometry1 const& geometry1, Geometry2 const& geometry2, MultiPoint const& mp_expected12, - MultiPoint const& mp_expected21, - std::string const& case_id) + MultiPoint const& mp_expected21) { #ifdef BOOST_GEOMETRY_TEST_DEBUG std::cout << "test case: " << case_id << std::endl; #endif - base_test(geometry1, geometry2, mp_expected12, case_id); - base_test(geometry2, geometry1, mp_expected21, case_id); + base_test::apply(case_id, geometry1, geometry2, mp_expected12); + // try the same set operation with the arguments' order + // reversed only if the two geometries are of the same + // topological dimension + base_test + < + (geometry_info::topological_dimension + == geometry_info::topological_dimension) + >::apply(case_id, geometry2, geometry1, mp_expected21); #ifdef BOOST_GEOMETRY_TEST_DEBUG std::cout << std::endl; @@ -243,15 +315,14 @@ public: #endif } - - static inline void apply(Geometry1 const& geometry1, + static inline void apply(std::string const& case_id, + Geometry1 const& geometry1, Geometry2 const& geometry2, - MultiPoint const& mp_expected, - std::string const& case_id) + MultiPoint const& mp_expected) { - apply(geometry1, geometry2, mp_expected, mp_expected, case_id); + apply(case_id, geometry1, geometry2, mp_expected, mp_expected); } }; -#endif // BOOST_GEOMETRY_TEST_SET_OPS_PL_PL_HPP +#endif // BOOST_GEOMETRY_TEST_SET_OPS_POINTLIKE_HPP diff --git a/test/algorithms/set_operations/union/union_pl_pl.cpp b/test/algorithms/set_operations/union/union_pl_pl.cpp index 05be9f1f6..f1eb2d976 100644 --- a/test/algorithms/set_operations/union/union_pl_pl.cpp +++ b/test/algorithms/set_operations/union/union_pl_pl.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html @@ -20,7 +20,7 @@ #include -#include "../test_set_ops_pl_pl.hpp" +#include "../test_set_ops_pointlike.hpp" #include @@ -51,16 +51,18 @@ BOOST_AUTO_TEST_CASE( test_union_point_point ) > tester; tester::apply - (from_wkt

("POINT(0 0)"), + ("ppu01", + from_wkt

("POINT(0 0)"), from_wkt

("POINT(1 1)"), - from_wkt("MULTIPOINT(0 0,1 1)"), - "ppu01"); + from_wkt("MULTIPOINT(0 0,1 1)") + ); tester::apply - (from_wkt

("POINT(0 0)"), + ("ppu02", from_wkt

("POINT(0 0)"), - from_wkt("MULTIPOINT(0 0)"), - "ppu02"); + from_wkt

("POINT(0 0)"), + from_wkt("MULTIPOINT(0 0)") + ); } @@ -81,52 +83,60 @@ BOOST_AUTO_TEST_CASE( test_union_multipoint_point ) > tester; tester::apply - (from_wkt("MULTIPOINT(0 0)"), - from_wkt

("POINT(1 1)"), - from_wkt("MULTIPOINT(0 0,1 1)"), - "mppu01"); - - tester::apply - (from_wkt("MULTIPOINT(0 0)"), - from_wkt

("POINT(0 0)"), + ("mppu01", from_wkt("MULTIPOINT(0 0)"), - "mppu02"); - - tester::apply - (from_wkt("MULTIPOINT(0 0,0 0)"), from_wkt

("POINT(1 1)"), - from_wkt("MULTIPOINT(0 0,0 0,1 1)"), - "mppu03"); + from_wkt("MULTIPOINT(0 0,1 1)") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,0 0)"), - from_wkt

("POINT(0 0)"), + ("mppu02", from_wkt("MULTIPOINT(0 0)"), - "mppu04"); + from_wkt

("POINT(0 0)"), + from_wkt("MULTIPOINT(0 0)") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,0 0,1 0)"), + ("mppu03", + from_wkt("MULTIPOINT(0 0,0 0)"), from_wkt

("POINT(1 1)"), - from_wkt("MULTIPOINT(0 0,0 0,1 0,1 1)"), - "mppu05"); + from_wkt("MULTIPOINT(0 0,0 0,1 1)") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,0 0,1 0)"), - from_wkt

("POINT(1 0)"), + ("mppu04", + from_wkt("MULTIPOINT(0 0,0 0)"), + from_wkt

("POINT(0 0)"), + from_wkt("MULTIPOINT(0 0)") + ); + + tester::apply + ("mppu05", from_wkt("MULTIPOINT(0 0,0 0,1 0)"), - "mppu06"); + from_wkt

("POINT(1 1)"), + from_wkt("MULTIPOINT(0 0,0 0,1 0,1 1)") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,0 0,1 0)"), - from_wkt

("POINT(0 0)"), - from_wkt("MULTIPOINT(0 0,1 0)"), - "mppu07"); + ("mppu06", + from_wkt("MULTIPOINT(0 0,0 0,1 0)"), + from_wkt

("POINT(1 0)"), + from_wkt("MULTIPOINT(0 0,0 0,1 0)") + ); tester::apply - (from_wkt("MULTIPOINT()"), + ("mppu07", + from_wkt("MULTIPOINT(0 0,0 0,1 0)"), from_wkt

("POINT(0 0)"), - from_wkt("MULTIPOINT(0 0)"), - "mppu08"); + from_wkt("MULTIPOINT(0 0,1 0)") + ); + + tester::apply + ("mppu08", + from_wkt("MULTIPOINT()"), + from_wkt

("POINT(0 0)"), + from_wkt("MULTIPOINT(0 0)") + ); } @@ -146,42 +156,47 @@ BOOST_AUTO_TEST_CASE( test_union_multipoint_multipoint ) > tester; tester::apply - (from_wkt("MULTIPOINT(2 2,3 3,0 0,0 0,2 2,1 1,1 1,1 0,1 0)"), + ("mpmpu01", + from_wkt("MULTIPOINT(2 2,3 3,0 0,0 0,2 2,1 1,1 1,1 0,1 0)"), from_wkt("MULTIPOINT(1 0,1 1,1 1,1 1)"), from_wkt("MULTIPOINT(2 2,3 3,0 0,0 0,2 2,1 1,1 1,1 0,1 0)"), - from_wkt("MULTIPOINT(1 0,1 1,1 1,1 1,2 2,3 3,0 0,0 0,2 2)"), - "mpmpu01"); + from_wkt("MULTIPOINT(1 0,1 1,1 1,1 1,2 2,3 3,0 0,0 0,2 2)") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), - from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)"), + ("mpmpu02", from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)"), - "mpmpu02"); - - tester::apply - (from_wkt("MULTIPOINT()"), - from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)"), - from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)"), - "mpmpu03"); - - tester::apply - (from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), - from_wkt("MULTIPOINT()"), from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), - "mpmpu04"); + from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)") + ); tester::apply - (from_wkt("MULTIPOINT()"), + ("mpmpu03", from_wkt("MULTIPOINT()"), - from_wkt("MULTIPOINT()"), - "mpmpu05"); + from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)"), + from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,1 0,2 0,3 0,0 0,1 0,2 0)"), + ("mpmpu04", + from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), + from_wkt("MULTIPOINT()"), + from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)") + ); + + tester::apply + ("mpmpu05", + from_wkt("MULTIPOINT()"), + from_wkt("MULTIPOINT()"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpmpu06", + from_wkt("MULTIPOINT(0 0,1 0,2 0,3 0,0 0,1 0,2 0)"), from_wkt("MULTIPOINT(0 1,0 2,1 0,0 0,2 0)"), from_wkt("MULTIPOINT(0 0,1 0,2 0,3 0,0 0,1 0,2 0,0 1,0 2)"), - from_wkt("MULTIPOINT(0 1,0 2,1 0,0 0,2 0,3 0)"), - "mpmpu06"); + from_wkt("MULTIPOINT(0 1,0 2,1 0,0 0,2 0,3 0)") + ); } - From 6828fd5bdaafcb20a8078189e5f24af8e7be39fe Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Wed, 11 Mar 2015 03:54:42 +0100 Subject: [PATCH 004/146] [policies] Fix unused parameter warnings in direction policy. --- include/boost/geometry/policies/relate/direction.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/geometry/policies/relate/direction.hpp b/include/boost/geometry/policies/relate/direction.hpp index 4b0a2f818..2c903bd79 100644 --- a/include/boost/geometry/policies/relate/direction.hpp +++ b/include/boost/geometry/policies/relate/direction.hpp @@ -242,7 +242,7 @@ struct segments_direction static inline return_type segments_collinear( Segment1 const& , Segment2 const& , bool opposite, int a1_wrt_b, int a2_wrt_b, int b1_wrt_a, int b2_wrt_a, - Ratio const& ra_from_wrt_b, Ratio const& ra_to_wrt_b, + Ratio const& /*ra_from_wrt_b*/, Ratio const& /*ra_to_wrt_b*/, Ratio const& /*rb_from_wrt_a*/, Ratio const& /*rb_to_wrt_a*/) { return_type r('c', opposite); From e5c40ca188c1866184024e3dc5914db18bd40a47 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Wed, 11 Mar 2015 03:56:04 +0100 Subject: [PATCH 005/146] [buffer] Fix unused variable MSVC warning in analyse_turn_wrt_point_piece. --- .../algorithms/detail/buffer/turn_in_piece_visitor.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/boost/geometry/algorithms/detail/buffer/turn_in_piece_visitor.hpp b/include/boost/geometry/algorithms/detail/buffer/turn_in_piece_visitor.hpp index a7731549d..8803efdec 100644 --- a/include/boost/geometry/algorithms/detail/buffer/turn_in_piece_visitor.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/turn_in_piece_visitor.hpp @@ -9,6 +9,9 @@ #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_TURN_IN_PIECE_VISITOR #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_TURN_IN_PIECE_VISITOR + +#include + #include #include @@ -172,7 +175,8 @@ public : typename strategy_type::state_type state; strategy_type strategy; - + boost::ignore_unused(strategy); + for (std::size_t s = 0; s < piece.sections.size(); s++) { section_type const& section = piece.sections[s]; From c8d6269b09c1b15eb0b32bfddc2c32fa1137cf39 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Wed, 11 Mar 2015 10:43:17 +0200 Subject: [PATCH 006/146] [test][algorithms][distance] polish and update code; re-factor some parts; allow testing against test cases where distance computed is not a finite floating-point value; --- .../distance/test_distance_common.hpp | 350 +++++++++--------- 1 file changed, 178 insertions(+), 172 deletions(-) diff --git a/test/algorithms/distance/test_distance_common.hpp b/test/algorithms/distance/test_distance_common.hpp index 62e87e368..11ef52c40 100644 --- a/test/algorithms/distance/test_distance_common.hpp +++ b/test/algorithms/distance/test_distance_common.hpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -25,15 +26,12 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include -#include - #include -#include #include #include @@ -128,18 +126,34 @@ struct pretty_print_geometry template struct check_equal { - static inline void apply(T const& value1, T const& value2) + static inline void apply(T const& detected, T const& expected, + bool is_finite) { - BOOST_CHECK( value1 == value2 ); + if (is_finite) + { + BOOST_CHECK(detected == expected); + } + else + { + BOOST_CHECK(! boost::math::isfinite(detected)); + } } }; template <> struct check_equal { - static inline void apply(double value1, double value2) + static inline void apply(double detected, double expected, + bool is_finite) { - BOOST_CHECK_CLOSE( value1, value2, 0.0001 ); + if (is_finite) + { + BOOST_CHECK_CLOSE(detected, expected, 0.0001); + } + else + { + BOOST_CHECK(! boost::math::isfinite(detected)); + } } }; @@ -158,8 +172,125 @@ struct test_distance_of_geometries template -struct test_distance_of_geometries +class test_distance_of_geometries { +private: + template + < + typename G1, + typename G2, + typename DistanceType, + typename ComparableDistanceType, + typename Strategy + > + static inline + void base_test(std::string const& header, + G1 const& g1, G2 const& g2, + DistanceType const& expected_distance, + ComparableDistanceType const& expected_comparable_distance, + Strategy const& strategy, + bool is_finite) + { + typedef typename bg::default_distance_result + < + G1, G2 + >::type default_distance_result; + + typedef typename bg::strategy::distance::services::return_type + < + Strategy, G1, G2 + >::type distance_result_from_strategy; + + static const bool same_regular = boost::is_same + < + default_distance_result, + distance_result_from_strategy + >::type::value; + + BOOST_CHECK( same_regular ); + + + typedef typename bg::default_comparable_distance_result + < + G1, G2 + >::type default_comparable_distance_result; + + typedef typename bg::strategy::distance::services::return_type + < + typename bg::strategy::distance::services::comparable_type + < + Strategy + >::type, + G1, + G2 + >::type comparable_distance_result_from_strategy; + + static const bool same_comparable = boost::is_same + < + default_comparable_distance_result, + comparable_distance_result_from_strategy + >::type::value; + + BOOST_CHECK( same_comparable ); + + + // check distance with default strategy + default_distance_result dist_def = bg::distance(g1, g2); + + check_equal + < + default_distance_result + >::apply(dist_def, expected_distance, is_finite); + + + // check distance with passed strategy + distance_result_from_strategy dist = bg::distance(g1, g2, strategy); + + check_equal + < + default_distance_result + >::apply(dist, expected_distance, is_finite); + + + // check comparable distance with default strategy + default_comparable_distance_result cdist_def = + bg::comparable_distance(g1, g2); + + check_equal + < + default_comparable_distance_result + >::apply(cdist_def, expected_comparable_distance, is_finite); + + + // check comparable distance with passed strategy + comparable_distance_result_from_strategy cdist = + bg::comparable_distance(g1, g2, strategy); + + check_equal + < + default_comparable_distance_result + >::apply(cdist, expected_comparable_distance, is_finite); + +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << string_from_type::type>::name() + << string_from_type::type>::name() + << " -> " + << string_from_type::name() + << string_from_type::name() + << std::endl; + + std::cout << "distance" << header + << " (def. strategy) = " << dist_def << " ; " + << "distance" << header + <<" (passed strategy) = " << dist << " ; " + << "comp. distance" << header <<" (def. strategy) = " + << cdist_def << " ; " + << "comp. distance" << header <<" (passed strategy) = " + << cdist << std::endl; +#endif + } + +public: template < typename DistanceType, @@ -172,14 +303,14 @@ struct test_distance_of_geometries DistanceType const& expected_distance, ComparableDistanceType const& expected_comparable_distance, Strategy const& strategy, - bool test_reversed = true) + bool is_finite = true) { Geometry1 geometry1 = from_wkt(wkt1); Geometry2 geometry2 = from_wkt(wkt2); apply(geometry1, geometry2, expected_distance, expected_comparable_distance, - strategy, test_reversed); + strategy, is_finite); } @@ -195,7 +326,7 @@ struct test_distance_of_geometries DistanceType const& expected_distance, ComparableDistanceType const& expected_comparable_distance, Strategy const& strategy, - bool test_reversed = true) + bool is_finite = true) { #ifdef BOOST_GEOMETRY_TEST_DEBUG typedef pretty_print_geometry PPG1; @@ -205,155 +336,18 @@ struct test_distance_of_geometries PPG2::apply(geometry2, std::cout); std::cout << std::endl; #endif - typedef typename bg::default_distance_result - < - Geometry1, Geometry2 - >::type default_distance_result; - typedef typename bg::strategy::distance::services::return_type - < - Strategy, Geometry1, Geometry2 - >::type distance_result_from_strategy; + base_test("", geometry1, geometry2, + expected_distance, expected_comparable_distance, + strategy, is_finite); - static const bool same_regular = boost::is_same - < - default_distance_result, - distance_result_from_strategy - >::type::value; - - BOOST_CHECK( same_regular ); - - - typedef typename bg::default_comparable_distance_result - < - Geometry1, Geometry2 - >::type default_comparable_distance_result; - - typedef typename bg::strategy::distance::services::return_type - < - typename bg::strategy::distance::services::comparable_type - < - Strategy - >::type, - Geometry1, - Geometry2 - >::type comparable_distance_result_from_strategy; - - static const bool same_comparable = boost::is_same - < - default_comparable_distance_result, - comparable_distance_result_from_strategy - >::type::value; - - BOOST_CHECK( same_comparable ); - - - // check distance with default strategy - default_distance_result dist_def = bg::distance(geometry1, geometry2); - - check_equal - < - default_distance_result - >::apply(dist_def, expected_distance); - - - // check distance with passed strategy - distance_result_from_strategy dist = - bg::distance(geometry1, geometry2, strategy); - - check_equal - < - default_distance_result - >::apply(dist, expected_distance); - - - // check comparable distance with default strategy - default_comparable_distance_result cdist_def = - bg::comparable_distance(geometry1, geometry2); - - check_equal - < - default_comparable_distance_result - >::apply(cdist_def, expected_comparable_distance); - - - // check comparable distance with passed strategy - comparable_distance_result_from_strategy cdist = - bg::comparable_distance(geometry1, geometry2, strategy); - - check_equal - < - default_comparable_distance_result - >::apply(cdist, expected_comparable_distance); + base_test("[reversed args]", geometry2, geometry1, + expected_distance, expected_comparable_distance, + strategy, is_finite); #ifdef BOOST_GEOMETRY_TEST_DEBUG - std::cout << string_from_type::type>::name() - << string_from_type::type>::name() - << " -> " - << string_from_type::name() - << string_from_type::name() - << std::endl; - std::cout << "distance (default strategy) = " << dist_def << " ; " - << "distance (passed strategy) = " << dist << " ; " - << "comp. distance (default strategy) = " - << cdist_def << " ; " - << "comp. distance (passed strategy) = " - << cdist << std::endl; - - if ( !test_reversed ) - { - std::cout << std::endl; - } + std::cout << std::endl; #endif - - if ( test_reversed ) - { - // check distance with default strategy - dist_def = bg::distance(geometry2, geometry1); - - check_equal - < - default_distance_result - >::apply(dist_def, expected_distance); - - - // check distance with given strategy - dist = bg::distance(geometry2, geometry1, strategy); - - check_equal - < - default_distance_result - >::apply(dist, expected_distance); - - - // check comparable distance with default strategy - cdist_def = bg::comparable_distance(geometry2, geometry1); - - check_equal - < - default_comparable_distance_result - >::apply(cdist_def, expected_comparable_distance); - - // check comparable distance with given strategy - cdist = bg::comparable_distance(geometry2, geometry1, strategy); - - check_equal - < - default_comparable_distance_result - >::apply(cdist, expected_comparable_distance); - -#ifdef BOOST_GEOMETRY_TEST_DEBUG - std::cout << "distance[reversed args] (def. startegy) = " - << dist_def << " ; " - << "distance[reversed args] (passed startegy) = " - << dist << " ; " - << "comp. distance[reversed args] (def. strategy) = " - << cdist_def << " ; " - << "comp. distance[reversed args] (passed strategy) = " - << cdist << std::endl; - std::cout << std::endl; -#endif - } } }; @@ -383,7 +377,8 @@ struct test_distance_of_geometries std::string const& wkt_polygon, DistanceType const& expected_distance, ComparableDistanceType const& expected_comparable_distance, - Strategy const& strategy) + Strategy const& strategy, + bool is_finite = true) { Segment segment = from_wkt(wkt_segment); Polygon polygon = from_wkt(wkt_polygon); @@ -391,7 +386,8 @@ struct test_distance_of_geometries polygon, expected_distance, expected_comparable_distance, - strategy); + strategy, + is_finite); } @@ -406,10 +402,12 @@ struct test_distance_of_geometries Polygon const& polygon, DistanceType const& expected_distance, ComparableDistanceType const& expected_comparable_distance, - Strategy const& strategy) + Strategy const& strategy, + bool is_finite = true) { base::apply(segment, polygon, expected_distance, - expected_comparable_distance, strategy); + expected_comparable_distance, strategy, is_finite); + if ( bg::num_interior_rings(polygon) == 0 ) { #ifdef BOOST_GEOMETRY_TEST_DEBUG std::cout << "... testing also exterior ring ..." << std::endl; @@ -421,7 +419,8 @@ struct test_distance_of_geometries bg::exterior_ring(polygon), expected_distance, expected_comparable_distance, - strategy); + strategy, + is_finite); } } }; @@ -446,7 +445,8 @@ struct test_distance_of_geometries std::string const& wkt_segment, DistanceType const& expected_distance, ComparableDistanceType const& expected_comparable_distance, - Strategy const& strategy) + Strategy const& strategy, + bool is_finite = true) { test_distance_of_geometries < @@ -455,7 +455,8 @@ struct test_distance_of_geometries wkt_box, expected_distance, expected_comparable_distance, - strategy); + strategy, + is_finite); } }; @@ -481,7 +482,8 @@ struct test_distance_of_geometries std::string const& wkt_box, DistanceType const& expected_distance, ComparableDistanceType const& expected_comparable_distance, - Strategy const& strategy) + Strategy const& strategy, + bool is_finite = true) { Segment segment = from_wkt(wkt_segment); Box box = from_wkt(wkt_box); @@ -489,7 +491,8 @@ struct test_distance_of_geometries box, expected_distance, expected_comparable_distance, - strategy); + strategy, + is_finite); } @@ -504,7 +507,8 @@ struct test_distance_of_geometries Box const& box, DistanceType const& expected_distance, ComparableDistanceType const& expected_comparable_distance, - Strategy const& strategy) + Strategy const& strategy, + bool is_finite = true) { typedef typename bg::strategy::distance::services::return_type < @@ -523,7 +527,7 @@ struct test_distance_of_geometries base::apply(segment, box, expected_distance, - expected_comparable_distance, strategy); + expected_comparable_distance, strategy, is_finite); comparable_strategy cstrategy = bg::strategy::distance::services::get_comparable @@ -547,12 +551,14 @@ struct test_distance_of_geometries check_equal < distance_result_type - >::apply(distance_generic, expected_distance); + >::apply(distance_generic, expected_distance, is_finite); check_equal < comparable_distance_result_type - >::apply(comparable_distance_generic, expected_comparable_distance); + >::apply(comparable_distance_generic, + expected_comparable_distance, + is_finite); #ifdef BOOST_GEOMETRY_TEST_DEBUG std::cout << "... testing with naive seg-box distance algorithm..." From bb25a857eefa22e5586df91b99b79aff4c8ec14f Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Wed, 11 Mar 2015 10:49:18 +0200 Subject: [PATCH 007/146] [test][algorithms][distance] update copyright year --- test/algorithms/distance/distance_pointlike_areal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/algorithms/distance/distance_pointlike_areal.cpp b/test/algorithms/distance/distance_pointlike_areal.cpp index 9eb943f1c..fd5c6c852 100644 --- a/test/algorithms/distance/distance_pointlike_areal.cpp +++ b/test/algorithms/distance/distance_pointlike_areal.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle From c519fb80e319e01447bbdcb831fcb5081f7e1bc5 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Wed, 11 Mar 2015 10:49:55 +0200 Subject: [PATCH 008/146] [test][algorithms][distance] remove last argument in tester calls (not needed) --- .../distance/distance_areal_areal.cpp | 10 ++-- .../distance/distance_linear_areal.cpp | 54 +++++++++---------- .../distance/distance_linear_linear.cpp | 6 +-- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/test/algorithms/distance/distance_areal_areal.cpp b/test/algorithms/distance/distance_areal_areal.cpp index 53d01dda0..37c324e81 100644 --- a/test/algorithms/distance/distance_areal_areal.cpp +++ b/test/algorithms/distance/distance_areal_areal.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle @@ -79,12 +79,12 @@ void test_distance_polygon_multipolygon(Strategy const& strategy) tester::apply("polygon((12 0,14 0,19 0,19.9 -1,12 0))", "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ ((20 -1,21 2,30 -10,20 -1)))", - 0.1, 0.01, strategy, true); + 0.1, 0.01, strategy); tester::apply("polygon((19 0,19.9 -1,12 0,20.5 0.5,19 0))", "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ ((20 -1,21 2,30 -10,20 -1)))", - 0, 0, strategy, true); + 0, 0, strategy); } //=========================================================================== @@ -155,12 +155,12 @@ void test_distance_multipolygon_ring(Strategy const& strategy) tester::apply("multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ ((20 -1,21 2,30 -10,20 -1)))", "polygon((12 0,14 0,19 0,19.9 -1,12 0))", - 0.1, 0.01, strategy, true); + 0.1, 0.01, strategy); tester::apply("multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ ((20 -1,21 2,30 -10,20 -1)))", "polygon((19 0,19.9 -1,12 0,20.5 0.5,19 0))", - 0, 0, strategy, true); + 0, 0, strategy); } //=========================================================================== diff --git a/test/algorithms/distance/distance_linear_areal.cpp b/test/algorithms/distance/distance_linear_areal.cpp index 0c97c2beb..ae396ba47 100644 --- a/test/algorithms/distance/distance_linear_areal.cpp +++ b/test/algorithms/distance/distance_linear_areal.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle @@ -84,27 +84,27 @@ void test_distance_linestring_polygon(Strategy const& strategy) tester::apply("linestring(-1 20,1 20,1 30)", "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 10, 100, strategy, true); + 10, 100, strategy); tester::apply("linestring(-5 1,-2 1)", "polygon((0 0,10 0,10 10,0 10,0 0))", - 2, 4, strategy, true); + 2, 4, strategy); tester::apply("linestring(-1 20,1 20,1 5)", "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 0, 0, strategy, true); + 0, 0, strategy); tester::apply("linestring(-1 20,1 20,1 -20)", "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 0, 0, strategy, true); + 0, 0, strategy); tester::apply("linestring(-2 1)", "polygon((0 0,10 0,10 10,0 10,0 0))", - 2, 4, strategy, true); + 2, 4, strategy); tester::apply("linestring(-5 1,-2 1)", "polygon((0 0))", - sqrt(5.0), 5, strategy, true); + sqrt(5.0), 5, strategy); } //=========================================================================== @@ -123,7 +123,7 @@ void test_distance_linestring_open_polygon(Strategy const& strategy) tester::apply("linestring(-5 1,-2 1)", "polygon((0 0,10 0,10 10,0 10))", - 2, 4, strategy, true); + 2, 4, strategy); } //=========================================================================== @@ -142,23 +142,23 @@ void test_distance_multilinestring_polygon(Strategy const& strategy) tester::apply("multilinestring((-100 -100,-90 -90),(-1 20,1 20,1 30))", "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 10, 100, strategy, true); + 10, 100, strategy); tester::apply("multilinestring((-1 20,1 20,1 30),(-1 20,1 20,1 5))", "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 0, 0, strategy, true); + 0, 0, strategy); tester::apply("multilinestring((-1 20,1 20,1 30),(-1 20,1 20,1 -20))", "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 0, 0, strategy, true); + 0, 0, strategy); tester::apply("multilinestring((-100 -100,-90 -90),(1 20))", "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 10, 100, strategy, true); + 10, 100, strategy); tester::apply("multilinestring((-100 -100,-90 -90),(-1 20,1 20,1 30))", "polygon((-110 -110))", - sqrt(200.0), 200, strategy, true); + sqrt(200.0), 200, strategy); } //=========================================================================== @@ -213,22 +213,22 @@ void test_distance_linestring_multipolygon(Strategy const& strategy) tester::apply("linestring(-1 20,1 20)", "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ ((0 22,-1 30, 2 40,0 22)))", - 2, 4, strategy, true); + 2, 4, strategy); tester::apply("linestring(12 0,14 0)", "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ ((20 -1,21 2,30 -10,20 -1)))", - 2, 4, strategy, true); + 2, 4, strategy); tester::apply("linestring(12 0,20.5 0.5)", "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ ((20 -1,21 2,30 -10,20 -1)))", - 0, 0, strategy, true); + 0, 0, strategy); tester::apply("linestring(12 0,50 0)", "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ ((20 -1,21 2,30 -10,20 -1)))", - 0, 0, strategy, true); + 0, 0, strategy); } //=========================================================================== @@ -247,11 +247,11 @@ void test_distance_linestring_open_multipolygon(Strategy const& strategy) tester::apply("linestring(-5 1,-2 1)", "multipolygon(((0 0,10 0,10 10,0 10)))", - 2, 4, strategy, true); + 2, 4, strategy); tester::apply("linestring(-5 1,-3 1)", "multipolygon(((20 20,21 20,21 21,20 21)),((0 0,10 0,10 10,0 10)))", - 3, 9, strategy, true); + 3, 9, strategy); } //=========================================================================== @@ -271,12 +271,12 @@ void test_distance_multilinestring_multipolygon(Strategy const& strategy) tester::apply("multilinestring((12 0,14 0),(19 0,19.9 -1))", "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ ((20 -1,21 2,30 -10)))", - 0.1, 0.01, strategy, true); + 0.1, 0.01, strategy); tester::apply("multilinestring((19 0,19.9 -1),(12 0,20.5 0.5))", "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ ((20 -1,21 2,30 -10,20 -1)))", - 0, 0, strategy, true); + 0, 0, strategy); } //=========================================================================== @@ -320,15 +320,15 @@ void test_distance_linestring_ring(Strategy const& strategy) tester::apply("linestring(-1 20,1 20,1 30)", "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 10, 100, strategy, true); + 10, 100, strategy); tester::apply("linestring(-1 20,1 20,1 5)", "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 0, 0, strategy, true); + 0, 0, strategy); tester::apply("linestring(-1 20,1 20,1 -20)", "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 0, 0, strategy, true); + 0, 0, strategy); } //=========================================================================== @@ -347,15 +347,15 @@ void test_distance_multilinestring_ring(Strategy const& strategy) tester::apply("multilinestring((-100 -100,-90 -90),(-1 20,1 20,1 30))", "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 10, 100, strategy, true); + 10, 100, strategy); tester::apply("multilinestring((-1 20,1 20,1 30),(-1 20,1 20,1 5))", "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 0, 0, strategy, true); + 0, 0, strategy); tester::apply("multilinestring((-1 20,1 20,1 30),(-1 20,1 20,1 -20))", "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 0, 0, strategy, true); + 0, 0, strategy); } //=========================================================================== diff --git a/test/algorithms/distance/distance_linear_linear.cpp b/test/algorithms/distance/distance_linear_linear.cpp index 5c5654511..efd1ceab9 100644 --- a/test/algorithms/distance/distance_linear_linear.cpp +++ b/test/algorithms/distance/distance_linear_linear.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle @@ -194,11 +194,11 @@ void test_distance_linestring_multilinestring(Strategy const& strategy) tester::apply("linestring(1 1,2 2,3 3)", "multilinestring((2 1,1 2,4 0),(1 -10,2 1.9,2.1 -10,4 0))", - 0, 0, strategy, true); + 0, 0, strategy); tester::apply("linestring(1 1,2 2,3 3)", "multilinestring((1 -10,2 0,2.1 -10,4 0),(1 -10,2 1.9,2.1 -10,4 0))", - sqrt(0.005), 0.005, strategy, true); + sqrt(0.005), 0.005, strategy); tester::apply("linestring(1 1,2 2)", "multilinestring((2.5 0,4 0,5 0),(3 3,3 3))", From a33fb12f2e6e30d9604ba1c364111c3a77fc032f Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Wed, 11 Mar 2015 10:50:41 +0200 Subject: [PATCH 009/146] [test][algorithms][distance] add test case where distance overflows --- test/algorithms/distance/distance_pointlike_pointlike.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/algorithms/distance/distance_pointlike_pointlike.cpp b/test/algorithms/distance/distance_pointlike_pointlike.cpp index 4f267504d..265faeb9f 100644 --- a/test/algorithms/distance/distance_pointlike_pointlike.cpp +++ b/test/algorithms/distance/distance_pointlike_pointlike.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle @@ -44,6 +44,11 @@ void test_distance_point_point(Strategy const& strategy) tester::apply("point(1 1)", "point(1 1)", 0, 0, strategy); + + // distance overflows + tester::apply("point(0 0)", + "point(4.297374e+307 8.433875e+307)", + 0, 0, strategy, false); } //=========================================================================== From 556637448f215007a693b3504fe18a2404fd0685 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Wed, 11 Mar 2015 10:51:03 +0200 Subject: [PATCH 010/146] [test][algorithms][distance] add test case where distance computed is a NaN --- .../distance/distance_pointlike_linear.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/algorithms/distance/distance_pointlike_linear.cpp b/test/algorithms/distance/distance_pointlike_linear.cpp index df9ea0e79..ad22bf120 100644 --- a/test/algorithms/distance/distance_pointlike_linear.cpp +++ b/test/algorithms/distance/distance_pointlike_linear.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle @@ -49,6 +49,11 @@ void test_distance_point_segment(Strategy const& strategy) tester::apply("point(2 0)", "segment(2 0,3 0)", 0, 0, strategy); tester::apply("point(3 0)", "segment(2 0,3 0)", 0, 0, strategy); tester::apply("point(2.5 0)", "segment(2 0,3 0)", 0, 0, strategy); + + // distance is a NaN + tester::apply("POINT(4.297374e+307 8.433875e+307)", + "SEGMENT(26 87,13 95)", + 0, 0, strategy, false); } //=========================================================================== @@ -70,6 +75,11 @@ void test_distance_point_linestring(Strategy const& strategy) // linestring with a single point tester::apply("point(0 0)", "linestring(2 0)", 2, 4, strategy); + + // distance is a NaN + tester::apply("POINT(4.297374e+307 8.433875e+307)", + "LINESTRING(26 87,13 95)", + 0, 0, strategy, false); } //=========================================================================== From 099388c5ae0c291ee7e667adbf835bc1c3e1150b Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Wed, 11 Mar 2015 19:44:39 +0200 Subject: [PATCH 011/146] [test][algorithms][equals] remove obsolete includes referring to the "multi" directory --- test/algorithms/relational_operations/equals.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/test/algorithms/relational_operations/equals.cpp b/test/algorithms/relational_operations/equals.cpp index 7bd0772f5..3fc067646 100644 --- a/test/algorithms/relational_operations/equals.cpp +++ b/test/algorithms/relational_operations/equals.cpp @@ -18,15 +18,6 @@ #include #include -#include - -#include -#include -#include -#include -#include -#include -#include namespace bgm = bg::model; From 09a335d5ead3bc0a97a80c2afbce1bc0f0c08811 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Wed, 11 Mar 2015 19:54:57 +0200 Subject: [PATCH 012/146] [test][geometry] guard the inclusion of Boost.Test related files with the BOOST_TEST_MODULE macro; this way geometry_test_common.hpp can be included in tests that proceed with unit testing using other Boost.Test utilities (like some of the distance and set-ops tests, validity and simplicity) --- test/geometry_test_common.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/geometry_test_common.hpp b/test/geometry_test_common.hpp index ca9959ad7..f4fbd65b7 100644 --- a/test/geometry_test_common.hpp +++ b/test/geometry_test_common.hpp @@ -72,9 +72,11 @@ #endif # include +#ifndef BOOST_TEST_MODULE # include //# include # include +#endif #ifdef __clang__ # pragma clang diagnostic pop From 65f57b1947d1b206282f9f4aca25bad501e9ed58 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 11 Mar 2015 19:07:16 +0100 Subject: [PATCH 013/146] [test] move as_range to algorithms/detail --- test/algorithms/detail/Jamfile.v2 | 1 + test/{util => algorithms/detail}/as_range.cpp | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) rename test/{util => algorithms/detail}/as_range.cpp (92%) diff --git a/test/algorithms/detail/Jamfile.v2 b/test/algorithms/detail/Jamfile.v2 index 015e2be6a..b6bd15949 100644 --- a/test/algorithms/detail/Jamfile.v2 +++ b/test/algorithms/detail/Jamfile.v2 @@ -10,6 +10,7 @@ test-suite boost-geometry-algorithms-detail : + [ run as_range.cpp ] [ run partition.cpp ] ; diff --git a/test/util/as_range.cpp b/test/algorithms/detail/as_range.cpp similarity index 92% rename from test/util/as_range.cpp rename to test/algorithms/detail/as_range.cpp index f8696eeca..dd6aabf28 100644 --- a/test/util/as_range.cpp +++ b/test/algorithms/detail/as_range.cpp @@ -17,7 +17,7 @@ #include -#include +#include #include #include @@ -47,10 +47,10 @@ void test_geometry(std::string const& wkt, double expected_x, double expected_y) bg::read_wkt(wkt, geometry); - double s = sum<0>(bg::as_range(geometry)); + double s = sum<0>(bg::detail::as_range(geometry)); BOOST_CHECK_CLOSE(s, expected_x, 0.001); - s = sum<1>(bg::as_range(geometry)); + s = sum<1>(bg::detail::as_range(geometry)); BOOST_CHECK_CLOSE(s, expected_y, 0.001); } From d8263e54f2697a7533365d80a39ac27e47d8c090 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Wed, 11 Mar 2015 19:51:48 +0100 Subject: [PATCH 014/146] [test][get_turns] Add tests failing for MinGW guarded with #ifdef. --- .../overlay/get_turns_linear_linear.cpp | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/test/algorithms/overlay/get_turns_linear_linear.cpp b/test/algorithms/overlay/get_turns_linear_linear.cpp index 9278c02fd..5686ebd3b 100644 --- a/test/algorithms/overlay/get_turns_linear_linear.cpp +++ b/test/algorithms/overlay/get_turns_linear_linear.cpp @@ -290,6 +290,53 @@ void test_all() expected("")("")); } +#if defined(BOOST_MSVC) || defined(BOOST_GEOMETRY_TEST_ENABLE_FAILING) + // Results different for MinGW (probably also QCC and GCC5.0) and MSVC/GCC + // depending which instruction is used to subtract values fsub or fsubr + // see also: https://github.com/boostorg/geometry/pull/259 + if ( BOOST_GEOMETRY_CONDITION((boost::is_same::value)) ) + { + test_geometry("LINESTRING(0 0, 10 0, 20 1)", + "LINESTRING(12 10, 13 0.3, 14 0.4, 15 0.5)", + expected("mii++")("ccc==")("mux==")); + test_geometry("LINESTRING(0 0, 10 0, 20 1)", + "LINESTRING(15 0.5, 14 0.4, 13 0.3, 12 10)", + expected("miu+=")("mui=+")); + test_geometry("LINESTRING(20 1, 10 0, 0 0)", + "LINESTRING(12 10, 13 0.3, 14 0.4, 15 0.5)", + expected("mui=+")("mix+=")); + test_geometry("LINESTRING(20 1, 10 0, 0 0)", + "LINESTRING(15 0.5, 14 0.4, 13 0.3, 12 10)", + expected("muu==")("ccc==")("mii++")); + + test_geometry("LINESTRING(0 0, 10 0, 20 1)", + "LINESTRING(13 0.3, 14 0.4, 15 0.5)", + expected("mii++")("ccc==")("mux==")); + test_geometry("LINESTRING(0 0, 10 0, 20 1)", + "LINESTRING(15 0.5, 14 0.4, 13 0.3)", + expected("mix+=")("mui=+")); + test_geometry("LINESTRING(20 1, 10 0, 0 0)", + "LINESTRING(13 0.3, 14 0.4, 15 0.5)", + expected("mui=+")("mix+=")); + test_geometry("LINESTRING(20 1, 10 0, 0 0)", + "LINESTRING(15 0.5, 14 0.4, 13 0.3)", + expected("mux==")("ccc==")("mii++")); + + test_geometry("LINESTRING(0 0, 10 0, 20 1)", + "LINESTRING(12 10, 13 0.3, 14 0.4)", + expected("mii++")("mux==")); + test_geometry("LINESTRING(0 0, 10 0, 20 1)", + "LINESTRING(14 0.4, 13 0.3, 12 10)", + expected("miu+=")("mui=+")); + test_geometry("LINESTRING(20 1, 10 0, 0 0)", + "LINESTRING(12 10, 13 0.3, 14 0.4)", + expected("mui=+")("mix+=")); + test_geometry("LINESTRING(20 1, 10 0, 0 0)", + "LINESTRING(14 0.4, 13 0.3, 12 10)", + expected("muu==")("mii++")); + } +#endif + // TODO: //test_geometry("LINESTRING(0 0,2 0,1 0)", "LINESTRING(0 1,0 0,2 0)", "1FF00F102"); //test_geometry("LINESTRING(2 0,0 0,1 0)", "LINESTRING(0 1,0 0,2 0)", "1FF00F102"); From 8e36f8f8733841a2ac1fdf7cf48603011b6315c2 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 12 Mar 2015 00:20:51 +0200 Subject: [PATCH 015/146] [algorithms] remove deprecated includes referring to the include/boost/geometry/multi/ directory --- include/boost/geometry/algorithms/centroid.hpp | 9 ++++----- .../geometry/algorithms/detail/buffer/buffered_ring.hpp | 6 +++--- .../geometry/algorithms/detail/intersection/multi.hpp | 6 ++---- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/include/boost/geometry/algorithms/centroid.hpp b/include/boost/geometry/algorithms/centroid.hpp index 67ed68ac0..c4d995d78 100644 --- a/include/boost/geometry/algorithms/centroid.hpp +++ b/include/boost/geometry/algorithms/centroid.hpp @@ -1,9 +1,9 @@ // 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) 2014 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +// Copyright (c) 2014-2015 Adam Wulkiewicz, Lodz, Poland. // This file was modified by Oracle on 2014, 2015. // Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. @@ -56,7 +56,6 @@ #include #include -#include #include diff --git a/include/boost/geometry/algorithms/detail/buffer/buffered_ring.hpp b/include/boost/geometry/algorithms/detail/buffer/buffered_ring.hpp index 9ea8bc1e8..0889663a2 100644 --- a/include/boost/geometry/algorithms/detail/buffer/buffered_ring.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/buffered_ring.hpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2012-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2012-2015 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 @@ -19,6 +19,8 @@ #include +#include + #include #include #include @@ -26,8 +28,6 @@ #include #include -#include - namespace boost { namespace geometry { diff --git a/include/boost/geometry/algorithms/detail/intersection/multi.hpp b/include/boost/geometry/algorithms/detail/intersection/multi.hpp index b1f13862f..88b49b016 100644 --- a/include/boost/geometry/algorithms/detail/intersection/multi.hpp +++ b/include/boost/geometry/algorithms/detail/intersection/multi.hpp @@ -1,9 +1,9 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. // This file was modified by Oracle on 2014. -// Modifications copyright (c) 2014, Oracle and/or its affiliates. +// Modifications copyright (c) 2014-2015, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -36,8 +36,6 @@ #include #include -// TODO: remove this after moving num_point from multi directory -#include namespace boost { namespace geometry { From cdb25bc74184ccd9716fc61aebcd1984ba8b999e Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 12 Mar 2015 00:22:27 +0200 Subject: [PATCH 016/146] [io][svg_mapper] remove deprecated includes referring to the include/boost/geometry/multi/ directory --- include/boost/geometry/io/svg/svg_mapper.hpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/include/boost/geometry/io/svg/svg_mapper.hpp b/include/boost/geometry/io/svg/svg_mapper.hpp index b53fef2ce..9982d0f7e 100644 --- a/include/boost/geometry/io/svg/svg_mapper.hpp +++ b/include/boost/geometry/io/svg/svg_mapper.hpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2009-2015 Barend Gehrels, Amsterdam, the Netherlands. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -37,9 +37,6 @@ #include #include -#include -#include - #include // Helper geometries (all points are transformed to integer-points) From 35a85e671be926485356aed864474bf0ae104d86 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 12 Mar 2015 00:23:07 +0200 Subject: [PATCH 017/146] [geometry] remove deprecated include referring to the include/boost/geometry/multi/ directory --- include/boost/geometry/geometry.hpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/include/boost/geometry/geometry.hpp b/include/boost/geometry/geometry.hpp index 8d34a0e4e..7d3a99519 100644 --- a/include/boost/geometry/geometry.hpp +++ b/include/boost/geometry/geometry.hpp @@ -90,10 +90,6 @@ #include #include -// Include multi a.o. because it can give weird effects -// if you don't (e.g. area=0 of a multipolygon) -#include - // check includes all concepts #include From 29c460b5468b1bf2ea23cc6a12303857eb571288 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 12 Mar 2015 02:10:14 +0200 Subject: [PATCH 018/146] [test][algorithms] remove deprecated includes referring to the include/boost/geometry/multi/ directory; polish and simplify some includes; --- test/algorithms/append.cpp | 21 +++++------- test/algorithms/buffer/country_buffer.cpp | 4 +-- .../buffer/multi_linestring_buffer.cpp | 4 +-- test/algorithms/buffer/multi_point_buffer.cpp | 2 -- .../buffer/multi_polygon_buffer.cpp | 4 +-- test/algorithms/detail/partition.cpp | 5 ++- test/algorithms/distance/distance.cpp | 12 ++----- .../distance/test_distance_se_common.hpp | 11 +++---- test/algorithms/multi_area.cpp | 7 ++-- test/algorithms/multi_centroid.cpp | 16 +++------- test/algorithms/multi_clear.cpp | 8 +---- test/algorithms/multi_convert.cpp | 12 +------ test/algorithms/multi_convex_hull.cpp | 30 +++++++---------- test/algorithms/multi_correct.cpp | 7 ++-- test/algorithms/multi_envelope.cpp | 14 ++------ test/algorithms/multi_for_each.cpp | 10 +++--- test/algorithms/multi_length.cpp | 9 +----- test/algorithms/multi_num_geometries.cpp | 7 +--- test/algorithms/multi_num_interior_rings.cpp | 7 +--- test/algorithms/multi_num_points.cpp | 10 +++--- test/algorithms/multi_perimeter.cpp | 6 ++-- test/algorithms/multi_reverse.cpp | 8 +---- test/algorithms/multi_simplify.cpp | 13 +++----- test/algorithms/multi_transform.cpp | 13 ++------ test/algorithms/multi_unique.cpp | 10 +----- test/algorithms/num_points.cpp | 11 +++---- test/algorithms/overlay/dissolver.cpp | 7 ++-- .../overlay/multi_overlay_common.hpp | 12 +++---- test/algorithms/overlay/multi_traverse.cpp | 32 +++++++------------ test/algorithms/overlay/traverse.cpp | 5 ++- test/algorithms/point_on_surface.cpp | 18 ++++------- .../disjoint/disjoint_coverage.cpp | 18 ++--------- .../disjoint/multi_disjoint.cpp | 13 +------- .../disjoint/test_disjoint.hpp | 9 +++--- .../multi_covered_by.cpp | 9 ++---- .../relational_operations/multi_equals.cpp | 9 ++---- .../multi_intersects.cpp | 3 +- .../relational_operations/multi_touches.cpp | 23 +++---------- .../relational_operations/test_covered_by.hpp | 9 ++---- .../relational_operations/test_intersects.hpp | 23 +++++-------- test/algorithms/remove_spikes.cpp | 17 +++------- .../set_operations/difference/difference.cpp | 10 +++--- .../difference/difference_linear_linear.cpp | 2 +- .../difference/multi_difference.cpp | 16 +++++----- .../difference/multi_difference_spike.cpp | 3 +- .../difference/test_difference.hpp | 8 ++--- .../intersection_linear_linear.cpp | 2 +- .../intersection/multi_intersection.cpp | 16 +++++----- .../intersection/test_intersection.hpp | 2 +- .../test_intersection_linear_linear.hpp | 1 - .../sym_difference_linear_linear.cpp | 2 +- .../test_set_ops_linear_linear.hpp | 1 - .../set_operations/union/multi_union.cpp | 14 ++++---- .../union/union_linear_linear.cpp | 4 +-- test/algorithms/test_convex_hull.hpp | 5 ++- test/algorithms/test_length.hpp | 2 +- 56 files changed, 177 insertions(+), 379 deletions(-) diff --git a/test/algorithms/append.cpp b/test/algorithms/append.cpp index 2a3d01a86..0eda9669c 100644 --- a/test/algorithms/append.cpp +++ b/test/algorithms/append.cpp @@ -1,12 +1,12 @@ // 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) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. -// This file was modified by Oracle on 2014. -// Modifications copyright (c) 2014, Oracle and/or its affiliates. +// This file was modified by Oracle on 2014, 2015. +// Modifications copyright (c) 2014-2015, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle @@ -24,25 +24,20 @@ #include #include +#include +#include #include #include #include #include #include +#include #include #include #include #include -// includes for multi-geometries -#include -#include -#include -#include -#include -#include -#include BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::vector) BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::deque) diff --git a/test/algorithms/buffer/country_buffer.cpp b/test/algorithms/buffer/country_buffer.cpp index 66e985728..6cde8171b 100644 --- a/test/algorithms/buffer/country_buffer.cpp +++ b/test/algorithms/buffer/country_buffer.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2014-2015 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 @@ -9,8 +9,6 @@ #include -#include - template std::string read_from_file(std::string const& filename) diff --git a/test/algorithms/buffer/multi_linestring_buffer.cpp b/test/algorithms/buffer/multi_linestring_buffer.cpp index 24aca1a67..0f125f064 100644 --- a/test/algorithms/buffer/multi_linestring_buffer.cpp +++ b/test/algorithms/buffer/multi_linestring_buffer.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2012-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2012-2015 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 @@ -9,8 +9,6 @@ #include -#include - static std::string const simplex = "MULTILINESTRING((0 0,4 5),(5 4,10 0))"; static std::string const two_bends = "MULTILINESTRING((0 0,4 5,7 4,10 6),(1 5,5 9,8 6))"; static std::string const turn_inside = "MULTILINESTRING((0 0,4 5,7 4,10 6),(1 5,5 9,8 6),(0 4,-2 6))"; diff --git a/test/algorithms/buffer/multi_point_buffer.cpp b/test/algorithms/buffer/multi_point_buffer.cpp index 5c4cbd6a7..d5fcf0583 100644 --- a/test/algorithms/buffer/multi_point_buffer.cpp +++ b/test/algorithms/buffer/multi_point_buffer.cpp @@ -9,8 +9,6 @@ #include -#include - static std::string const simplex = "MULTIPOINT((5 5),(7 7))"; static std::string const three = "MULTIPOINT((5 8),(9 8),(7 11))"; diff --git a/test/algorithms/buffer/multi_polygon_buffer.cpp b/test/algorithms/buffer/multi_polygon_buffer.cpp index 4b526a8e6..eef6d5155 100644 --- a/test/algorithms/buffer/multi_polygon_buffer.cpp +++ b/test/algorithms/buffer/multi_polygon_buffer.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2012-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2012-2015 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 @@ -9,8 +9,6 @@ #include -#include - static std::string const simplex = "MULTIPOLYGON(((0 1,2 5,5 3,0 1)),((1 1,5 2,5 0,1 1)))"; diff --git a/test/algorithms/detail/partition.cpp b/test/algorithms/detail/partition.cpp index e55c87307..bf50b880f 100644 --- a/test/algorithms/detail/partition.cpp +++ b/test/algorithms/detail/partition.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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) @@ -11,14 +11,13 @@ #include -#include +#include #include #include #include #include -#include #if defined(TEST_WITH_SVG) # include diff --git a/test/algorithms/distance/distance.cpp b/test/algorithms/distance/distance.cpp index 84e066808..2f9c74c39 100644 --- a/test/algorithms/distance/distance.cpp +++ b/test/algorithms/distance/distance.cpp @@ -1,9 +1,9 @@ // 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) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -30,12 +30,6 @@ #include #include -// includes for multi-geometries -#include -#include -#include -#include - #include BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian) diff --git a/test/algorithms/distance/test_distance_se_common.hpp b/test/algorithms/distance/test_distance_se_common.hpp index 5e846346d..5d514c826 100644 --- a/test/algorithms/distance/test_distance_se_common.hpp +++ b/test/algorithms/distance/test_distance_se_common.hpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle @@ -25,15 +25,12 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include -#include - #include -#include #include #include diff --git a/test/algorithms/multi_area.cpp b/test/algorithms/multi_area.cpp index 3dbc658e1..fdb9ea6d7 100644 --- a/test/algorithms/multi_area.cpp +++ b/test/algorithms/multi_area.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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) @@ -8,14 +8,11 @@ #include -#include - #include #include -#include +#include #include -#include diff --git a/test/algorithms/multi_centroid.cpp b/test/algorithms/multi_centroid.cpp index 03cb8ecde..c98b3f164 100644 --- a/test/algorithms/multi_centroid.cpp +++ b/test/algorithms/multi_centroid.cpp @@ -1,9 +1,9 @@ // 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-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -17,18 +17,12 @@ #include -#include -#include -#include +#include +#include #include #include -#include -#include -#include -#include - // #define REPORT_RESULTS diff --git a/test/algorithms/multi_clear.cpp b/test/algorithms/multi_clear.cpp index 39d777930..44f4716e0 100644 --- a/test/algorithms/multi_clear.cpp +++ b/test/algorithms/multi_clear.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2011-2015 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) @@ -9,17 +9,11 @@ #include #include -#include -#include #include -#include #include #include -#include -#include -#include #include diff --git a/test/algorithms/multi_convert.cpp b/test/algorithms/multi_convert.cpp index 0bfdf6ea6..ad24d3d7a 100644 --- a/test/algorithms/multi_convert.cpp +++ b/test/algorithms/multi_convert.cpp @@ -1,22 +1,12 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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) #include -#include -#include - -#include -#include -#include - -#include -#include - template void test_mixed_point_types() diff --git a/test/algorithms/multi_convex_hull.cpp b/test/algorithms/multi_convex_hull.cpp index ef493e8f5..eaf0ddc8d 100644 --- a/test/algorithms/multi_convex_hull.cpp +++ b/test/algorithms/multi_convex_hull.cpp @@ -1,12 +1,12 @@ // 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-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. -// This file was modified by Oracle on 2014. -// Modifications copyright (c) 2014 Oracle and/or its affiliates. +// This file was modified by Oracle on 2014, 2015. +// Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -26,22 +26,16 @@ #include #include -#include +#include +#include -#include -#include +#include -#include +#include -#include -#include - -#include -#include - -#include -#include -#include +#include +#include +#include diff --git a/test/algorithms/multi_correct.cpp b/test/algorithms/multi_correct.cpp index 7359d3f76..be61640cd 100644 --- a/test/algorithms/multi_correct.cpp +++ b/test/algorithms/multi_correct.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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) @@ -11,10 +11,7 @@ #include -#include - #include -#include #include #include @@ -22,7 +19,7 @@ #include #include #include -#include +#include template diff --git a/test/algorithms/multi_envelope.cpp b/test/algorithms/multi_envelope.cpp index bafa5dc25..5ebbc6eee 100644 --- a/test/algorithms/multi_envelope.cpp +++ b/test/algorithms/multi_envelope.cpp @@ -1,9 +1,9 @@ // 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-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -15,14 +15,6 @@ #include - -#include -#include -#include -#include - -#include - #include #include #include diff --git a/test/algorithms/multi_for_each.cpp b/test/algorithms/multi_for_each.cpp index 70165a44f..e9c02b685 100644 --- a/test/algorithms/multi_for_each.cpp +++ b/test/algorithms/multi_for_each.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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) @@ -8,10 +8,8 @@ #include #include -#include #include -#include #include #include @@ -20,9 +18,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include diff --git a/test/algorithms/multi_length.cpp b/test/algorithms/multi_length.cpp index 5d94be158..3738665f1 100644 --- a/test/algorithms/multi_length.cpp +++ b/test/algorithms/multi_length.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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) @@ -8,15 +8,8 @@ #include -#include - #include #include -#include - -#include -#include - template diff --git a/test/algorithms/multi_num_geometries.cpp b/test/algorithms/multi_num_geometries.cpp index bf7a3cee4..292e06ea9 100644 --- a/test/algorithms/multi_num_geometries.cpp +++ b/test/algorithms/multi_num_geometries.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2011-2015 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) @@ -8,16 +8,11 @@ #include #include -#include #include -#include #include #include -#include -#include -#include template void test_geometry(std::string const& wkt, int expected) diff --git a/test/algorithms/multi_num_interior_rings.cpp b/test/algorithms/multi_num_interior_rings.cpp index 73fcdc114..2f9991fe9 100644 --- a/test/algorithms/multi_num_interior_rings.cpp +++ b/test/algorithms/multi_num_interior_rings.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2011-2015 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) @@ -8,16 +8,11 @@ #include #include -#include #include -#include #include #include -#include -#include -#include template void test_geometry(std::string const& wkt, int expected) diff --git a/test/algorithms/multi_num_points.cpp b/test/algorithms/multi_num_points.cpp index d43b71d47..68b814e32 100644 --- a/test/algorithms/multi_num_points.cpp +++ b/test/algorithms/multi_num_points.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2011-2015 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) @@ -8,16 +8,14 @@ #include #include -#include #include -#include #include #include -#include -#include -#include +#include +#include +#include #include diff --git a/test/algorithms/multi_perimeter.cpp b/test/algorithms/multi_perimeter.cpp index 8268fed62..3ddd8395c 100644 --- a/test/algorithms/multi_perimeter.cpp +++ b/test/algorithms/multi_perimeter.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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) @@ -8,14 +8,12 @@ #include #include -#include #include -#include #include #include -#include +#include #include diff --git a/test/algorithms/multi_reverse.cpp b/test/algorithms/multi_reverse.cpp index 78334928d..f3a7f574d 100644 --- a/test/algorithms/multi_reverse.cpp +++ b/test/algorithms/multi_reverse.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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) @@ -8,18 +8,12 @@ #include #include -#include #include -#include #include #include -#include -#include -#include - #include diff --git a/test/algorithms/multi_simplify.cpp b/test/algorithms/multi_simplify.cpp index 8b9d92265..f142f91d8 100644 --- a/test/algorithms/multi_simplify.cpp +++ b/test/algorithms/multi_simplify.cpp @@ -1,17 +1,12 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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) #include -#include - -#include -#include - #include #include #include @@ -20,9 +15,9 @@ #include -#include -#include -#include +#include +#include +#include #include diff --git a/test/algorithms/multi_transform.cpp b/test/algorithms/multi_transform.cpp index 9c0002583..66cb8ba6e 100644 --- a/test/algorithms/multi_transform.cpp +++ b/test/algorithms/multi_transform.cpp @@ -1,9 +1,9 @@ // 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-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -22,14 +22,7 @@ #include #include -#include - -#include -#include -#include - #include -#include // This test is a little different from transform.cpp test. diff --git a/test/algorithms/multi_unique.cpp b/test/algorithms/multi_unique.cpp index 397e46265..9061d7ef3 100644 --- a/test/algorithms/multi_unique.cpp +++ b/test/algorithms/multi_unique.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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) @@ -8,18 +8,10 @@ #include #include -#include - -#include -#include #include #include -#include -#include -#include - #include diff --git a/test/algorithms/num_points.cpp b/test/algorithms/num_points.cpp index 1c266d8af..6d24f43f0 100644 --- a/test/algorithms/num_points.cpp +++ b/test/algorithms/num_points.cpp @@ -1,10 +1,10 @@ // 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. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +// Copyright (c) 2013-2015 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 @@ -15,12 +15,9 @@ #include #include -#include #include -#include #include -#include template struct box_dD diff --git a/test/algorithms/overlay/dissolver.cpp b/test/algorithms/overlay/dissolver.cpp index 28bd3e560..c928fa7b3 100644 --- a/test/algorithms/overlay/dissolver.cpp +++ b/test/algorithms/overlay/dissolver.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2010-2015 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 @@ -17,9 +17,8 @@ #include #include -#include -#include -#include +#include +#include #include diff --git a/test/algorithms/overlay/multi_overlay_common.hpp b/test/algorithms/overlay/multi_overlay_common.hpp index 6a49c300d..4b98944da 100644 --- a/test/algorithms/overlay/multi_overlay_common.hpp +++ b/test/algorithms/overlay/multi_overlay_common.hpp @@ -1,8 +1,8 @@ // 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) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. // 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) @@ -12,11 +12,11 @@ #define GEOMETRY_TEST_MULTI_OVERLAY_COMMON_HPP -#include -#include +#include +#include -#include -//#include +#include +//#include diff --git a/test/algorithms/overlay/multi_traverse.cpp b/test/algorithms/overlay/multi_traverse.cpp index 7cab06c96..d600ce9cb 100644 --- a/test/algorithms/overlay/multi_traverse.cpp +++ b/test/algorithms/overlay/multi_traverse.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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 @@ -15,27 +15,19 @@ #define BOOST_GEOMETRY_TEST_MULTI #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include +#include #include "multi_overlay_cases.hpp" diff --git a/test/algorithms/overlay/traverse.cpp b/test/algorithms/overlay/traverse.cpp index 0ae6bfd0a..4589fdc2e 100644 --- a/test/algorithms/overlay/traverse.cpp +++ b/test/algorithms/overlay/traverse.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2010-2015 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 @@ -57,8 +57,7 @@ #include -#include -#include +#include #if defined(TEST_WITH_SVG) diff --git a/test/algorithms/point_on_surface.cpp b/test/algorithms/point_on_surface.cpp index 00b6f1236..0a89d960d 100644 --- a/test/algorithms/point_on_surface.cpp +++ b/test/algorithms/point_on_surface.cpp @@ -1,13 +1,13 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2007-2013 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2013 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2013 Mateusz Loskot, London, UK. -// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2014. -// Modifications copyright (c) 2014 Oracle and/or its affiliates. +// This file was modified by Oracle on 2014, 2015. +// Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -43,11 +43,7 @@ #include #if defined(BOOST_GEOMETRY_UNIT_TEST_MULTI) -# include -# include -# include -# include -# include +# include #endif diff --git a/test/algorithms/relational_operations/disjoint/disjoint_coverage.cpp b/test/algorithms/relational_operations/disjoint/disjoint_coverage.cpp index 4708fd6db..f2d6d3ee0 100644 --- a/test/algorithms/relational_operations/disjoint/disjoint_coverage.cpp +++ b/test/algorithms/relational_operations/disjoint/disjoint_coverage.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html @@ -19,25 +19,13 @@ #include #include -#include #include -#include -#include -#include -#include +#include #include -#include -#include -#include -#include -#include - -#include -#include -#include +#include #include diff --git a/test/algorithms/relational_operations/disjoint/multi_disjoint.cpp b/test/algorithms/relational_operations/disjoint/multi_disjoint.cpp index 330a66e52..8bc8a6b55 100644 --- a/test/algorithms/relational_operations/disjoint/multi_disjoint.cpp +++ b/test/algorithms/relational_operations/disjoint/multi_disjoint.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2012-2015 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 @@ -12,17 +12,6 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - #include #include diff --git a/test/algorithms/relational_operations/disjoint/test_disjoint.hpp b/test/algorithms/relational_operations/disjoint/test_disjoint.hpp index 55a22e9bd..9e4902421 100644 --- a/test/algorithms/relational_operations/disjoint/test_disjoint.hpp +++ b/test/algorithms/relational_operations/disjoint/test_disjoint.hpp @@ -1,9 +1,9 @@ // 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-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -22,8 +22,7 @@ #include #include -#include -#include +#include template diff --git a/test/algorithms/relational_operations/multi_covered_by.cpp b/test/algorithms/relational_operations/multi_covered_by.cpp index 7489435b4..720e72716 100644 --- a/test/algorithms/relational_operations/multi_covered_by.cpp +++ b/test/algorithms/relational_operations/multi_covered_by.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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) @@ -11,16 +11,13 @@ #include #include -#include -#include -#include +#include #include -#include +#include #include -#include #include "test_covered_by.hpp" diff --git a/test/algorithms/relational_operations/multi_equals.cpp b/test/algorithms/relational_operations/multi_equals.cpp index d1239d38f..6984f29e5 100644 --- a/test/algorithms/relational_operations/multi_equals.cpp +++ b/test/algorithms/relational_operations/multi_equals.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2010-2015 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) @@ -8,15 +8,10 @@ #include "test_equals.hpp" -#include -#include +#include #include #include -#include - -#include - template diff --git a/test/algorithms/relational_operations/multi_intersects.cpp b/test/algorithms/relational_operations/multi_intersects.cpp index 1880064f8..6ed8b358f 100644 --- a/test/algorithms/relational_operations/multi_intersects.cpp +++ b/test/algorithms/relational_operations/multi_intersects.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2012-2015 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 @@ -19,7 +19,6 @@ #include #include -#include template void test_all() diff --git a/test/algorithms/relational_operations/multi_touches.cpp b/test/algorithms/relational_operations/multi_touches.cpp index 86456b04a..65de6b52c 100644 --- a/test/algorithms/relational_operations/multi_touches.cpp +++ b/test/algorithms/relational_operations/multi_touches.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2010-2015 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) @@ -8,24 +8,9 @@ #include "test_touches.hpp" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - +#include +#include +#include template diff --git a/test/algorithms/relational_operations/test_covered_by.hpp b/test/algorithms/relational_operations/test_covered_by.hpp index b9d8f5853..5403e8edb 100644 --- a/test/algorithms/relational_operations/test_covered_by.hpp +++ b/test/algorithms/relational_operations/test_covered_by.hpp @@ -1,8 +1,8 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2013-2015 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 @@ -22,13 +22,10 @@ #include #include #include +#include #include -#include -#include -#include - template void check_geometry(Geometry1 const& geometry1, Geometry2 const& geometry2, diff --git a/test/algorithms/relational_operations/test_intersects.hpp b/test/algorithms/relational_operations/test_intersects.hpp index 7a8af7161..9c4c7914b 100644 --- a/test/algorithms/relational_operations/test_intersects.hpp +++ b/test/algorithms/relational_operations/test_intersects.hpp @@ -1,8 +1,8 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2013-2015 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 @@ -14,27 +14,20 @@ #include + +#include +#include #include +#include #include #include #include #include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - template void test_geometry(std::string const& wkt1, std::string const& wkt2, bool expected) diff --git a/test/algorithms/remove_spikes.cpp b/test/algorithms/remove_spikes.cpp index 8f7fd75bb..f4e252103 100644 --- a/test/algorithms/remove_spikes.cpp +++ b/test/algorithms/remove_spikes.cpp @@ -1,10 +1,10 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2007-2013 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2013 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2013 Mateusz Loskot, London, UK. -// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +// Copyright (c) 2013-2015 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 @@ -36,14 +36,7 @@ #include #if defined(BOOST_GEOMETRY_UNIT_TEST_MULTI) - -# include - -# include -# include -# include -# include -# include +# include #endif diff --git a/test/algorithms/set_operations/difference/difference.cpp b/test/algorithms/set_operations/difference/difference.cpp index c1da88ad8..2f1f8355b 100644 --- a/test/algorithms/set_operations/difference/difference.cpp +++ b/test/algorithms/set_operations/difference/difference.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2010-2015 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 @@ -16,12 +16,11 @@ // #define BOOST_GEOMETRY_NO_ROBUSTNESS #include +#include #include +#include -#include -#include -#include -#include +#include #include @@ -29,7 +28,6 @@ #include #include #include -#include #ifdef HAVE_TTMATH diff --git a/test/algorithms/set_operations/difference/difference_linear_linear.cpp b/test/algorithms/set_operations/difference/difference_linear_linear.cpp index b1ae1a21b..cd4be8c00 100644 --- a/test/algorithms/set_operations/difference/difference_linear_linear.cpp +++ b/test/algorithms/set_operations/difference/difference_linear_linear.cpp @@ -23,7 +23,7 @@ #include "test_difference_linear_linear.hpp" #include -#include +#include #include typedef bg::model::point point_type; diff --git a/test/algorithms/set_operations/difference/multi_difference.cpp b/test/algorithms/set_operations/difference/multi_difference.cpp index f9e0c3d4d..3d088aae6 100644 --- a/test/algorithms/set_operations/difference/multi_difference.cpp +++ b/test/algorithms/set_operations/difference/multi_difference.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2010-2015 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 @@ -27,16 +27,16 @@ #include #include -#include -#include -#include // only for testing #77 +#include +#include +#include // only for testing #77 #include -#include -#include -#include +#include +#include +#include -#include +#include template void test_areal() diff --git a/test/algorithms/set_operations/difference/multi_difference_spike.cpp b/test/algorithms/set_operations/difference/multi_difference_spike.cpp index 56a909262..f1141ca6c 100644 --- a/test/algorithms/set_operations/difference/multi_difference_spike.cpp +++ b/test/algorithms/set_operations/difference/multi_difference_spike.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2013 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2013-2015 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 @@ -11,7 +11,6 @@ #include #include #include -#include #include "test_difference.hpp" diff --git a/test/algorithms/set_operations/difference/test_difference.hpp b/test/algorithms/set_operations/difference/test_difference.hpp index e3cda5d95..65b97dea0 100644 --- a/test/algorithms/set_operations/difference/test_difference.hpp +++ b/test/algorithms/set_operations/difference/test_difference.hpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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) @@ -30,9 +30,9 @@ #include -#include -#include -#include +#include +#include +#include #include diff --git a/test/algorithms/set_operations/intersection/intersection_linear_linear.cpp b/test/algorithms/set_operations/intersection/intersection_linear_linear.cpp index 0102edc5c..5224f10f4 100644 --- a/test/algorithms/set_operations/intersection/intersection_linear_linear.cpp +++ b/test/algorithms/set_operations/intersection/intersection_linear_linear.cpp @@ -23,7 +23,7 @@ #include "test_intersection_linear_linear.hpp" #include -#include +#include #include typedef bg::model::point point_type; diff --git a/test/algorithms/set_operations/intersection/multi_intersection.cpp b/test/algorithms/set_operations/intersection/multi_intersection.cpp index 46106022d..2399935cb 100644 --- a/test/algorithms/set_operations/intersection/multi_intersection.cpp +++ b/test/algorithms/set_operations/intersection/multi_intersection.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2010-2015 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 @@ -20,16 +20,16 @@ #include #include -#include -#include -#include // only for testing #77 +#include +#include +#include // only for testing #77 #include -#include -#include -#include +#include +#include +#include -#include +#include template void test_areal() diff --git a/test/algorithms/set_operations/intersection/test_intersection.hpp b/test/algorithms/set_operations/intersection/test_intersection.hpp index 4a7cc645c..140250e13 100644 --- a/test/algorithms/set_operations/intersection/test_intersection.hpp +++ b/test/algorithms/set_operations/intersection/test_intersection.hpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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) diff --git a/test/algorithms/set_operations/intersection/test_intersection_linear_linear.hpp b/test/algorithms/set_operations/intersection/test_intersection_linear_linear.hpp index 8e9254040..07105aa8b 100644 --- a/test/algorithms/set_operations/intersection/test_intersection_linear_linear.hpp +++ b/test/algorithms/set_operations/intersection/test_intersection_linear_linear.hpp @@ -12,7 +12,6 @@ #include -#include #include #include "../test_set_ops_linear_linear.hpp" #include diff --git a/test/algorithms/set_operations/sym_difference/sym_difference_linear_linear.cpp b/test/algorithms/set_operations/sym_difference/sym_difference_linear_linear.cpp index bcd0398ad..5741b1303 100644 --- a/test/algorithms/set_operations/sym_difference/sym_difference_linear_linear.cpp +++ b/test/algorithms/set_operations/sym_difference/sym_difference_linear_linear.cpp @@ -23,7 +23,7 @@ #include "test_sym_difference_linear_linear.hpp" #include -#include +#include #include typedef bg::model::point point_type; diff --git a/test/algorithms/set_operations/test_set_ops_linear_linear.hpp b/test/algorithms/set_operations/test_set_ops_linear_linear.hpp index 884b5028a..b69e78b67 100644 --- a/test/algorithms/set_operations/test_set_ops_linear_linear.hpp +++ b/test/algorithms/set_operations/test_set_ops_linear_linear.hpp @@ -21,7 +21,6 @@ #include #include #include -#include #include "test_get_turns_ll_invariance.hpp" diff --git a/test/algorithms/set_operations/union/multi_union.cpp b/test/algorithms/set_operations/union/multi_union.cpp index 74c9d060d..ac542220d 100644 --- a/test/algorithms/set_operations/union/multi_union.cpp +++ b/test/algorithms/set_operations/union/multi_union.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2010-2015 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 @@ -18,15 +18,15 @@ #include #include -#include -#include -#include +#include +#include +#include #include -#include -#include +#include +#include -#include +#include template diff --git a/test/algorithms/set_operations/union/union_linear_linear.cpp b/test/algorithms/set_operations/union/union_linear_linear.cpp index 925c8363b..4ef79e6cc 100644 --- a/test/algorithms/set_operations/union/union_linear_linear.cpp +++ b/test/algorithms/set_operations/union/union_linear_linear.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html @@ -23,7 +23,7 @@ #include "test_union_linear_linear.hpp" #include -#include +#include #include typedef bg::model::point point_type; diff --git a/test/algorithms/test_convex_hull.hpp b/test/algorithms/test_convex_hull.hpp index 1570dec2a..5e48d1e60 100644 --- a/test/algorithms/test_convex_hull.hpp +++ b/test/algorithms/test_convex_hull.hpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. // This file was modified by Oracle on 2014, 2015. // Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. @@ -26,8 +26,7 @@ #include -#include -#include +#include #include diff --git a/test/algorithms/test_length.hpp b/test/algorithms/test_length.hpp index 9543a3035..107bdae21 100644 --- a/test/algorithms/test_length.hpp +++ b/test/algorithms/test_length.hpp @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include From 6f0b6a19e21a9d970662b9aca3543d34cfc8c925 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 12 Mar 2015 02:11:28 +0200 Subject: [PATCH 019/146] [test][geometries] remove deprecated includes referring to the include/boost/geometry/multi/ directory --- test/geometries/adapted.cpp | 7 +++---- test/geometries/geometries.cpp | 3 +-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/test/geometries/adapted.cpp b/test/geometries/adapted.cpp index fd3bb6419..4dd8c8923 100644 --- a/test/geometries/adapted.cpp +++ b/test/geometries/adapted.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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 @@ -14,7 +14,6 @@ #include #include -#include #include #include @@ -35,8 +34,8 @@ #elif defined(BOOST_GEOMETRY_TEST_MULTI_POINT) - #include - #include + #include + #include BOOST_GEOMETRY_REGISTER_MULTI_POINT_TEMPLATED(std::vector) BOOST_GEOMETRY_REGISTER_MULTI_POINT_TEMPLATED(std::deque) diff --git a/test/geometries/geometries.cpp b/test/geometries/geometries.cpp index 8510df1da..23dd11f52 100644 --- a/test/geometries/geometries.cpp +++ b/test/geometries/geometries.cpp @@ -1,7 +1,7 @@ // Boost.Geometry // Unit Test -// Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2014-2015 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 @@ -18,7 +18,6 @@ #include #include -#include #include typedef std::pair pt_pair_t; From 4e8abc3f8033f46e9f8953b62e9d2f5b09079457 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 12 Mar 2015 02:15:11 +0200 Subject: [PATCH 020/146] [test][robustness] remove deprecated includes referring to the include/boost/geometry/multi/ directory --- test/robustness/convex_hull/random_multi_points.cpp | 3 +-- test/robustness/overlay/areal_areal/test_overlay_p_q.hpp | 3 +-- test/robustness/overlay/areal_areal/ticket_9081.cpp | 4 ++-- test/robustness/overlay/buffer/many_ring_buffer.cpp | 4 ++-- test/robustness/overlay/buffer/multi_point_growth.cpp | 2 +- test/robustness/overlay/buffer/recursive_polygons_buffer.cpp | 3 +-- .../overlay/linear_areal/recursive_polygons_linear_areal.cpp | 3 +-- 7 files changed, 9 insertions(+), 13 deletions(-) diff --git a/test/robustness/convex_hull/random_multi_points.cpp b/test/robustness/convex_hull/random_multi_points.cpp index c7b146681..93662ca9d 100644 --- a/test/robustness/convex_hull/random_multi_points.cpp +++ b/test/robustness/convex_hull/random_multi_points.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Robustness Test - convex_hull -// Copyright (c) 2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2012-2015 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 @@ -23,7 +23,6 @@ #include #include #include -#include #include struct settings_type diff --git a/test/robustness/overlay/areal_areal/test_overlay_p_q.hpp b/test/robustness/overlay/areal_areal/test_overlay_p_q.hpp index fa5544a77..6fbd38b3e 100644 --- a/test/robustness/overlay/areal_areal/test_overlay_p_q.hpp +++ b/test/robustness/overlay/areal_areal/test_overlay_p_q.hpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test // -// Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2009-2015 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) @@ -27,7 +27,6 @@ #include #include #include -#include #include #include diff --git a/test/robustness/overlay/areal_areal/ticket_9081.cpp b/test/robustness/overlay/areal_areal/ticket_9081.cpp index 9c2f81597..91f336c6f 100644 --- a/test/robustness/overlay/areal_areal/ticket_9081.cpp +++ b/test/robustness/overlay/areal_areal/ticket_9081.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Robustness Test -// Copyright (c) 2013 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2013-2015 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 @@ -20,7 +20,7 @@ #include #include #include - #include + #include #include #include diff --git a/test/robustness/overlay/buffer/many_ring_buffer.cpp b/test/robustness/overlay/buffer/many_ring_buffer.cpp index 82226a087..1fd54c23f 100644 --- a/test/robustness/overlay/buffer/many_ring_buffer.cpp +++ b/test/robustness/overlay/buffer/many_ring_buffer.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2012-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2012-2015 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 @@ -14,7 +14,7 @@ #include #include -#include +#include #include #include diff --git a/test/robustness/overlay/buffer/multi_point_growth.cpp b/test/robustness/overlay/buffer/multi_point_growth.cpp index d74a6c5f6..4aed939cf 100644 --- a/test/robustness/overlay/buffer/multi_point_growth.cpp +++ b/test/robustness/overlay/buffer/multi_point_growth.cpp @@ -8,7 +8,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include +#include #include #include diff --git a/test/robustness/overlay/buffer/recursive_polygons_buffer.cpp b/test/robustness/overlay/buffer/recursive_polygons_buffer.cpp index 737f22c2e..2000de657 100644 --- a/test/robustness/overlay/buffer/recursive_polygons_buffer.cpp +++ b/test/robustness/overlay/buffer/recursive_polygons_buffer.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Robustness Test -// Copyright (c) 2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2012-2015 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 @@ -26,7 +26,6 @@ #include #include #include -#include #include diff --git a/test/robustness/overlay/linear_areal/recursive_polygons_linear_areal.cpp b/test/robustness/overlay/linear_areal/recursive_polygons_linear_areal.cpp index 8e057471d..c29a0df12 100644 --- a/test/robustness/overlay/linear_areal/recursive_polygons_linear_areal.cpp +++ b/test/robustness/overlay/linear_areal/recursive_polygons_linear_areal.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Robustness Test -// Copyright (c) 2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2012-2015 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 @@ -26,7 +26,6 @@ #include #include #include -#include #include #include From 63e87041da5c75721d1c8e142a9c4c6b580bccef Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 12 Mar 2015 02:19:42 +0200 Subject: [PATCH 021/146] [test][io] remove deprecated includes referring to the include/boost/geometry/multi/ directory; also cleanup includes a bit; --- test/io/dsv/multi_dsv.cpp | 11 +++++------ test/io/wkt/multi_wkt.cpp | 23 ++++++----------------- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/test/io/dsv/multi_dsv.cpp b/test/io/dsv/multi_dsv.cpp index 0af8f10e9..0b4bd8f28 100644 --- a/test/io/dsv/multi_dsv.cpp +++ b/test/io/dsv/multi_dsv.cpp @@ -1,9 +1,9 @@ // 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-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -15,9 +15,8 @@ #include #include -#include -#include -#include +#include +#include template void test_dsv(std::string const& wkt, std::string const& expected, bool json = false) diff --git a/test/io/wkt/multi_wkt.cpp b/test/io/wkt/multi_wkt.cpp index 35265feee..809f69fad 100644 --- a/test/io/wkt/multi_wkt.cpp +++ b/test/io/wkt/multi_wkt.cpp @@ -1,12 +1,12 @@ // 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-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. -// This file was modified by Oracle on 2014. -// Modifications copyright (c) 2014 Oracle and/or its affiliates. +// This file was modified by Oracle on 2014, 2015. +// Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -29,18 +29,7 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include +#include template void test_all(); From 63ff5bde6a23659ed7e9d38d886943e9add78c0f Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 12 Mar 2015 02:20:47 +0200 Subject: [PATCH 022/146] [test][iterators] remove deprecated includes referring to the include/boost/geometry/multi/ directory --- test/iterators/point_iterator.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/test/iterators/point_iterator.cpp b/test/iterators/point_iterator.cpp index b07d64ea2..59d2266cb 100644 --- a/test/iterators/point_iterator.cpp +++ b/test/iterators/point_iterator.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle @@ -29,16 +29,13 @@ #include #include -#include #include #include -#include -#include +#include #include #include -#include #include From 3f2c06c9dd9682e8582b9415f1e9763b691517d4 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 12 Mar 2015 02:21:54 +0200 Subject: [PATCH 023/146] [test] remove deprecated include referring to the include/boost/geometry/multi/ directory --- test/from_wkt.hpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/from_wkt.hpp b/test/from_wkt.hpp index a12dc051d..2d5f7bac6 100644 --- a/test/from_wkt.hpp +++ b/test/from_wkt.hpp @@ -1,10 +1,10 @@ // 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. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +// Copyright (c) 2013-2015 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 @@ -16,7 +16,6 @@ #include #include -#include template inline Geometry from_wkt(std::string const& wkt) From 821c9ef17225fbe3e2467d313b68d981fa4a4eb8 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 12 Mar 2015 10:01:24 +0200 Subject: [PATCH 024/146] [doc][Doxyfile] remove deprecated multi/ directories from input path --- doc/doxy/Doxyfile | 7 ------- 1 file changed, 7 deletions(-) diff --git a/doc/doxy/Doxyfile b/doc/doxy/Doxyfile index 633625f46..92098767d 100644 --- a/doc/doxy/Doxyfile +++ b/doc/doxy/Doxyfile @@ -200,13 +200,6 @@ INPUT = . .. ../../../../boost/geometry/core \ ../../../../boost/geometry/iterators \ ../../../../boost/geometry/io/wkt \ ../../../../boost/geometry/io/svg \ - ../../../../boost/geometry/multi/algorithms \ - ../../../../boost/geometry/multi/algorithms/detail \ - ../../../../boost/geometry/multi/core \ - ../../../../boost/geometry/multi/geometries \ - ../../../../boost/geometry/multi/geometries/register \ - ../../../../boost/geometry/multi/geometries/concepts \ - ../../../../boost/geometry/multi/strategies/cartesian \ ../../../../boost/geometry/policies \ ../../../../boost/geometry/policies/relate \ ../../../../boost/geometry/strategies \ From 5b09619b4ca772fa83e25b1dcc66520a186008dd Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 12 Mar 2015 10:03:04 +0200 Subject: [PATCH 025/146] [doc][doxygen_input] remove deprecated includes referring to the include/boost/geometry/multi/ directory --- doc/doxy/doxygen_input/pages/doxygen_pages.hpp | 3 --- doc/doxy/doxygen_input/sourcecode/doxygen_4.cpp | 2 -- 2 files changed, 5 deletions(-) diff --git a/doc/doxy/doxygen_input/pages/doxygen_pages.hpp b/doc/doxy/doxygen_input/pages/doxygen_pages.hpp index 7ec99f557..7369d3eb6 100644 --- a/doc/doxy/doxygen_input/pages/doxygen_pages.hpp +++ b/doc/doxy/doxygen_input/pages/doxygen_pages.hpp @@ -118,9 +118,6 @@ For users using only Cartesian points, with floating point coordinates (double), etc. Using this headerfile the library seems to be a non-template library, so it is convenient for users that are not so into the template world. -For users using multi-geometries: -- \#include - \section advanced_includes Advanced includes This section is for users who have their own geometries and want to use algorithms from the Boost.Geometry. diff --git a/doc/doxy/doxygen_input/sourcecode/doxygen_4.cpp b/doc/doxy/doxygen_input/sourcecode/doxygen_4.cpp index b6fdecb73..e7960271c 100644 --- a/doc/doxy/doxygen_input/sourcecode/doxygen_4.cpp +++ b/doc/doxy/doxygen_input/sourcecode/doxygen_4.cpp @@ -15,8 +15,6 @@ OBSOLETE #include #include -#include - #include #include From 4e3a07df4fa037e032fd2047f428e76c5da503bd Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 12 Mar 2015 10:04:44 +0200 Subject: [PATCH 026/146] [doc][doxygen_xml2qbk] remove multi/multi.hpp from convenience headers --- doc/src/docutils/tools/doxygen_xml2qbk/for_debugger.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/docutils/tools/doxygen_xml2qbk/for_debugger.ini b/doc/src/docutils/tools/doxygen_xml2qbk/for_debugger.ini index 7849e8f66..6dbaa7006 100644 --- a/doc/src/docutils/tools/doxygen_xml2qbk/for_debugger.ini +++ b/doc/src/docutils/tools/doxygen_xml2qbk/for_debugger.ini @@ -8,6 +8,6 @@ xml=../../../../doxy/doxygen_output/xml/structboost_1_1geometry_1_1closeable__vi start_include=boost/geometry/ convenience_header_path=../../../../../../../boost/geometry/ -convenience_headers=geometry.hpp,geometries/geometries.hpp,multi/multi.hpp +convenience_headers=geometry.hpp,geometries/geometries.hpp skip_namespace=boost::geometry:: From 38c2869fd30606a7d45541e10837c89ed0e6cf97 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 12 Mar 2015 10:19:14 +0200 Subject: [PATCH 027/146] [test][algorithms][within] remove deprecated includes referring to the include/boost/geometry/multi/ directory --- .../relational_operations/within/multi_within.cpp | 9 ++------- .../relational_operations/within/test_within.hpp | 13 +++++-------- .../relational_operations/within/within.cpp | 15 +++++++-------- .../within/within_areal_areal.cpp | 7 +++---- .../within/within_linear_areal.cpp | 13 ++++++------- .../within/within_linear_linear.cpp | 11 +++++------ .../within/within_pointlike_xxx.cpp | 15 +++++++-------- 7 files changed, 35 insertions(+), 48 deletions(-) diff --git a/test/algorithms/relational_operations/within/multi_within.cpp b/test/algorithms/relational_operations/within/multi_within.cpp index cf5573aa6..b41529cc0 100644 --- a/test/algorithms/relational_operations/within/multi_within.cpp +++ b/test/algorithms/relational_operations/within/multi_within.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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) @@ -8,19 +8,14 @@ #include #include -#include #include #include #include #include - -#include -#include - #include -#include +#include #include "test_within.hpp" diff --git a/test/algorithms/relational_operations/within/test_within.hpp b/test/algorithms/relational_operations/within/test_within.hpp index c82bdaf7e..b92b029dd 100644 --- a/test/algorithms/relational_operations/within/test_within.hpp +++ b/test/algorithms/relational_operations/within/test_within.hpp @@ -1,11 +1,11 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2014. -// Modifications copyright (c) 2014 Oracle and/or its affiliates. +// This file was modified by Oracle on 2014, 2015. +// Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -26,6 +26,7 @@ #include #include #include +#include #include @@ -38,10 +39,6 @@ #include -#include -#include -#include - template void check_geometry(Geometry1 const& geometry1, Geometry2 const& geometry2, diff --git a/test/algorithms/relational_operations/within/within.cpp b/test/algorithms/relational_operations/within/within.cpp index 2300a4ec5..c8999e4db 100644 --- a/test/algorithms/relational_operations/within/within.cpp +++ b/test/algorithms/relational_operations/within/within.cpp @@ -1,10 +1,10 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2014. -// Modifications copyright (c) 2014 Oracle and/or its affiliates. +// This file was modified by Oracle on 2014, 2015. +// Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -17,10 +17,9 @@ #include #include -#include -#include -#include -#include +#include +#include +#include template void test_all() diff --git a/test/algorithms/relational_operations/within/within_areal_areal.cpp b/test/algorithms/relational_operations/within/within_areal_areal.cpp index a2901ba4b..559543945 100644 --- a/test/algorithms/relational_operations/within/within_areal_areal.cpp +++ b/test/algorithms/relational_operations/within/within_areal_areal.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. // This file was modified by Oracle on 2014, 2015. // Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. @@ -18,8 +18,7 @@ #include #include -#include -#include +#include template void test_a_a() diff --git a/test/algorithms/relational_operations/within/within_linear_areal.cpp b/test/algorithms/relational_operations/within/within_linear_areal.cpp index 889ff3692..14e541d36 100644 --- a/test/algorithms/relational_operations/within/within_linear_areal.cpp +++ b/test/algorithms/relational_operations/within/within_linear_areal.cpp @@ -1,10 +1,10 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2014. -// Modifications copyright (c) 2014 Oracle and/or its affiliates. +// This file was modified by Oracle on 2014, 2015. +// Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -17,9 +17,8 @@ #include #include -#include -#include -#include +#include +#include template void test_l_a() diff --git a/test/algorithms/relational_operations/within/within_linear_linear.cpp b/test/algorithms/relational_operations/within/within_linear_linear.cpp index 6467e0110..f2e2876bf 100644 --- a/test/algorithms/relational_operations/within/within_linear_linear.cpp +++ b/test/algorithms/relational_operations/within/within_linear_linear.cpp @@ -1,10 +1,10 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2014. -// Modifications copyright (c) 2014 Oracle and/or its affiliates. +// This file was modified by Oracle on 2014, 2015. +// Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -17,8 +17,7 @@ #include #include -#include -#include +#include template void test_l_l() diff --git a/test/algorithms/relational_operations/within/within_pointlike_xxx.cpp b/test/algorithms/relational_operations/within/within_pointlike_xxx.cpp index 5ea4f09f2..ff9e67f12 100644 --- a/test/algorithms/relational_operations/within/within_pointlike_xxx.cpp +++ b/test/algorithms/relational_operations/within/within_pointlike_xxx.cpp @@ -1,10 +1,10 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2014. -// Modifications copyright (c) 2014 Oracle and/or its affiliates. +// This file was modified by Oracle on 2014, 2015. +// Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -17,10 +17,9 @@ #include #include -#include -#include -#include -#include +#include +#include +#include template void test_p_p() From bfcd9594d051d94154ffede1a90f1a80a83791a3 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 12 Mar 2015 10:32:50 +0200 Subject: [PATCH 028/146] [geometry][multi] make boost/geometry/multi/multi.hpp include boost/geometry/geometry.hpp; file kept for now for backward compatibility; --- include/boost/geometry/multi/multi.hpp | 73 +++----------------------- 1 file changed, 8 insertions(+), 65 deletions(-) diff --git a/include/boost/geometry/multi/multi.hpp b/include/boost/geometry/multi/multi.hpp index 4b3063e52..85d763ee6 100644 --- a/include/boost/geometry/multi/multi.hpp +++ b/include/boost/geometry/multi/multi.hpp @@ -1,11 +1,11 @@ // 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-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. -// This file was modified by Oracle on 2013. -// Modifications copyright (c) 2013, Oracle and/or its affiliates. +// This file was modified by Oracle on 2013, 2015. +// Modifications copyright (c) 2013-2015, Oracle and/or its affiliates. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -17,65 +17,8 @@ #ifndef BOOST_GEOMETRY_MULTI_HPP #define BOOST_GEOMETRY_MULTI_HPP - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include - +// keep this file for now, for backward compatibility +// functionality-wise, make it equivalent to boost/geometry/geometry.hpp +#include #endif // BOOST_GEOMETRY_MULTI_HPP From 742d4090d8932352723c91ed1f0e52dcdf415c6c Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 12 Mar 2015 10:35:33 +0200 Subject: [PATCH 029/146] [doc][tools][support status] remove deprecated includes referring to the include/boost/geometry/multi/ directory; fix call for num_points: dispatch::num_points<> takes a second boolean argument with no default value, which was not accounted for by support status; --- .../tools/support_status/support_status.cpp | 31 +++++-------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/doc/src/docutils/tools/support_status/support_status.cpp b/doc/src/docutils/tools/support_status/support_status.cpp index 9372a1967..6bf00b5d0 100644 --- a/doc/src/docutils/tools/support_status/support_status.cpp +++ b/doc/src/docutils/tools/support_status/support_status.cpp @@ -1,8 +1,8 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Tool reporting Implementation Support Status in QBK or plain text format -// Copyright (c) 2011-2012 Bruno Lalande, Paris, France. -// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2011-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2011-2015 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 @@ -48,26 +48,6 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include "text_outputter.hpp" @@ -103,6 +83,11 @@ typedef boost::mpl::vector< struct algorithm: boost::geometry::dispatch::algorithm \ {}; +#define DECLARE_UNARY_ALGORITHM_WITH_BOOLEAN(algorithm) \ + template \ + struct algorithm: boost::geometry::dispatch::algorithm \ + {}; + #define DECLARE_BINARY_ALGORITHM(algorithm) \ template \ struct algorithm: boost::geometry::dispatch::algorithm \ @@ -129,7 +114,7 @@ DECLARE_UNARY_ALGORITHM(is_valid) DECLARE_UNARY_ALGORITHM(length) DECLARE_UNARY_ALGORITHM(num_geometries) DECLARE_UNARY_ALGORITHM(num_interior_rings) -DECLARE_UNARY_ALGORITHM(num_points) +DECLARE_UNARY_ALGORITHM_WITH_BOOLEAN(num_points) DECLARE_UNARY_ALGORITHM(num_segments) DECLARE_BINARY_ALGORITHM(overlaps) DECLARE_UNARY_ALGORITHM(perimeter) From 4d544287a3d521b236029a57e9a843c6a4ceef5e Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 12 Mar 2015 10:47:28 +0200 Subject: [PATCH 030/146] [test][algorithms][set operations] update deprecated includes referring to the include/boost/geometry/multi/ directory --- .../algorithms/set_operations/difference/difference_pl_pl.cpp | 4 ++-- .../set_operations/intersection/intersection_pl_pl.cpp | 4 ++-- test/algorithms/set_operations/union/union_pl_pl.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/algorithms/set_operations/difference/difference_pl_pl.cpp b/test/algorithms/set_operations/difference/difference_pl_pl.cpp index 14a80f485..1e3326451 100644 --- a/test/algorithms/set_operations/difference/difference_pl_pl.cpp +++ b/test/algorithms/set_operations/difference/difference_pl_pl.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html @@ -22,7 +22,7 @@ #include "../test_set_ops_pl_pl.hpp" -#include +#include typedef bg::model::point point_type; typedef bg::model::multi_point multi_point_type; diff --git a/test/algorithms/set_operations/intersection/intersection_pl_pl.cpp b/test/algorithms/set_operations/intersection/intersection_pl_pl.cpp index 27b592e7a..212f914af 100644 --- a/test/algorithms/set_operations/intersection/intersection_pl_pl.cpp +++ b/test/algorithms/set_operations/intersection/intersection_pl_pl.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html @@ -22,7 +22,7 @@ #include "../test_set_ops_pl_pl.hpp" -#include +#include typedef bg::model::point point_type; typedef bg::model::multi_point multi_point_type; diff --git a/test/algorithms/set_operations/union/union_pl_pl.cpp b/test/algorithms/set_operations/union/union_pl_pl.cpp index 05be9f1f6..59798be23 100644 --- a/test/algorithms/set_operations/union/union_pl_pl.cpp +++ b/test/algorithms/set_operations/union/union_pl_pl.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html @@ -22,7 +22,7 @@ #include "../test_set_ops_pl_pl.hpp" -#include +#include typedef bg::model::point point_type; typedef bg::model::multi_point multi_point_type; From ec6f9148cd86580fce96d2af0d6feada01946027 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 12 Mar 2015 23:03:27 +0100 Subject: [PATCH 031/146] [strategies][cart_intersect] Compare ratios denominators consistently. Compare both ratios' potential denominators, corresponding to both segments. Furthermore, take into account the machine epsilon. --- include/boost/geometry/strategies/cartesian/cart_intersect.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/boost/geometry/strategies/cartesian/cart_intersect.hpp b/include/boost/geometry/strategies/cartesian/cart_intersect.hpp index bb0749d61..e90af64f1 100644 --- a/include/boost/geometry/strategies/cartesian/cart_intersect.hpp +++ b/include/boost/geometry/strategies/cartesian/cart_intersect.hpp @@ -200,7 +200,8 @@ struct relate_cartesian_segments get<1>(robust_b1) - get<1>(robust_a1), robust_db0, robust_db); - if (robust_da0 == 0) + robust_coordinate_type const zero = 0; + if (math::equals(robust_da0, zero) || math::equals(robust_db0, zero)) { // If this is the case, no rescaling is done for FP precision. // We set it to collinear, but it indicates a robustness issue. From 4940d8d669c7b18b83076aed44aedf78ae385bd9 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Fri, 13 Mar 2015 12:22:57 +0200 Subject: [PATCH 032/146] [extensions][ttmath] add support for fmod free function --- .../extensions/contrib/ttmath_stub.hpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/include/boost/geometry/extensions/contrib/ttmath_stub.hpp b/include/boost/geometry/extensions/contrib/ttmath_stub.hpp index e2ade189b..733d73dd2 100644 --- a/include/boost/geometry/extensions/contrib/ttmath_stub.hpp +++ b/include/boost/geometry/extensions/contrib/ttmath_stub.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-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2015. +// Modifications copyright (c) 2015, 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. @@ -83,7 +88,6 @@ namespace ttmath return ACos(v); } - template inline Big atan2(Big const& y, Big const& x) { @@ -103,6 +107,12 @@ namespace ttmath return two * ATan((sqrt(x * x + y * y) - x) / y); } + // needed in order to work with boost::geometry::math::fmod + template + inline Big fmod(Big const& x, Big const& y) + { + return Mod(x, y); + } } // Specific structure implementing constructor From 5de5e93780788d04101115ba21169e5c6368cd9a Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Fri, 13 Mar 2015 12:31:07 +0200 Subject: [PATCH 033/146] [util][math][fmod] add support for calls to fmod: for fundamental floating-point numbers it calls std::fmod; for fundamental integral numbers it calls operator%; for user defined number types the free function fmod is called (lookup is activated in the global namespace, the std namespace and the type's namespace); --- include/boost/geometry/util/math.hpp | 78 ++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/include/boost/geometry/util/math.hpp b/include/boost/geometry/util/math.hpp index fb9b976ac..69b747020 100644 --- a/include/boost/geometry/util/math.hpp +++ b/include/boost/geometry/util/math.hpp @@ -30,6 +30,7 @@ #include #include #include +#include #include @@ -191,6 +192,66 @@ struct square_root }; + +template +< + typename T, + bool IsFundemantal = boost::is_fundamental::value /* false */ +> +struct modulo +{ + typedef T return_type; + + static inline T apply(T const& value1, T const& value2) + { + // for non-fundamental number types assume that sqrt is + // defined either: + // 1) at T's scope, or + // 2) at global scope, or + // 3) in namespace std + using ::fmod; + using std::fmod; + + return fmod(value1, value2); + } +}; + +template +struct modulo_for_fundamental +{ + typedef Fundamental return_type; + + static inline Fundamental apply(Fundamental const& value1, + Fundamental const& value2) + { + return value1 % value2; + } +}; + +// specialization for floating-point numbers +template +struct modulo_for_fundamental +{ + typedef Fundamental return_type; + + static inline Fundamental apply(Fundamental const& value1, + Fundamental const& value2) + { + return std::fmod(value1, value2); + } +}; + +// specialization for fundamental number type +template +struct modulo + : modulo_for_fundamental + < + Fundamental, boost::is_integral::value + > +{}; + + + /*! \brief Short construct to enable partial specialization for PI, currently not possible in Math. */ @@ -358,6 +419,23 @@ sqrt(T const& value) >::apply(value); } +/*! +\brief Short utility to return the result of fmod of two values +\ingroup utility +\param value1 First value +\param value2 Second value +\return The result of the fmod operation on the (ordered) pair (value1, value2) +*/ +template +inline typename detail::modulo::return_type +fmod(T const& value1, T const& value2) +{ + return detail::modulo + < + T, boost::is_fundamental::value + >::apply(value1, value2); +} + /*! \brief Short utility to workaround gcc/clang problem that abs is converting to integer and that older versions of MSVC does not support abs of long long... From 7b4798231ef918d4b0d53db7e07c9ae0d05df02a Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Sat, 14 Mar 2015 01:51:04 +0200 Subject: [PATCH 034/146] [extensions][ttmath] add missing arithmetic operators for ttmath_big: unary and binary +, binary *, binary /; these operators are needed so that the result of arithmetic operations on objects of type ttmath_big is also of type ttmath_big (instead of ttmath:Big<1,4> which is the base class for ttmath_big); --- .../extensions/contrib/ttmath_stub.hpp | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/include/boost/geometry/extensions/contrib/ttmath_stub.hpp b/include/boost/geometry/extensions/contrib/ttmath_stub.hpp index e2ade189b..009942979 100644 --- a/include/boost/geometry/extensions/contrib/ttmath_stub.hpp +++ b/include/boost/geometry/extensions/contrib/ttmath_stub.hpp @@ -116,6 +116,18 @@ struct ttmath_big : ttmath::Big<1,4> : ttmath::Big<1,4>(v) {} + // needed since the binary operator+ needs to be defined + inline ttmath_big const& operator+() const + { + return *this; + } + + // needed in order for the result of the addition to be a ttmath_big object + inline ttmath_big operator+(ttmath_big const& other) const + { + return ttmath::Big<1,4>::operator+(other); + } + // needed in order to work with boost::geometry::math::abs inline ttmath_big operator-() const { @@ -128,6 +140,19 @@ struct ttmath_big : ttmath::Big<1,4> return ttmath::Big<1,4>::operator-(other); } + // needed in order for the result of the multiplication to be a + // ttmath_big object + inline ttmath_big operator*(ttmath_big const& other) const + { + return ttmath::Big<1,4>::operator*(other); + } + + // needed in order for the result of the division to be a ttmath_big object + inline ttmath_big operator/(ttmath_big const& other) const + { + return ttmath::Big<1,4>::operator/(other); + } + /* inline operator double() const { From b5887efd5e839e0e458bce207a34272cc3193a5c Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sat, 14 Mar 2015 03:52:02 +0100 Subject: [PATCH 035/146] [math] Add/improve math utils. Add the support for policy calculating epsilon factor in equals(). Add greatest() algorithm - max() equivalent taking more than 2 parameters. Add specialization of abs() for floating-point numbers. --- include/boost/geometry/util/math.hpp | 144 +++++++++++++++++++++------ 1 file changed, 112 insertions(+), 32 deletions(-) diff --git a/include/boost/geometry/util/math.hpp b/include/boost/geometry/util/math.hpp index fb9b976ac..301d8dc43 100644 --- a/include/boost/geometry/util/math.hpp +++ b/include/boost/geometry/util/math.hpp @@ -23,6 +23,8 @@ #include #include +#include + #include #ifdef BOOST_GEOMETRY_SQRT_CHECK_FINITENESS #include @@ -43,11 +45,90 @@ namespace math namespace detail { +template +inline T const& greatest(T const& v1, T const& v2) +{ + return (std::max)(v1, v2); +} -template +template +inline T const& greatest(T const& v1, T const& v2, T const& v3) +{ + return (std::max)(greatest(v1, v2), v3); +} + +template +inline T const& greatest(T const& v1, T const& v2, T const& v3, T const& v4) +{ + return (std::max)(greatest(v1, v2, v3), v4); +} + +template +inline T const& greatest(T const& v1, T const& v2, T const& v3, T const& v4, T const& v5) +{ + return (std::max)(greatest(v1, v2, v3, v4), v5); +} + + +template ::value> +struct abs +{ + static inline T apply(T const& value) + { + T const zero = T(); + return value < zero ? -value : value; + } +}; + +template +struct abs +{ + static inline T apply(T const& value) + { + return fabs(value); + } +}; + + +struct equals_default_policy +{ + template + static inline T const& apply(T const& a, T const& b) + { + // See http://www.parashift.com/c++-faq-lite/newbie.html#faq-29.17 + return greatest(abs::apply(a), abs::apply(b), T(1)); + } +}; + +template +struct equals_factor_policy +{ + equals_factor_policy() + : factor(1) {} + explicit equals_factor_policy(T const& v) + : factor(greatest(abs::apply(v), T(1))) + {} + equals_factor_policy(T const& v0, T const& v1, T const& v2, T const& v3) + : factor(greatest(abs::apply(v0), abs::apply(v1), + abs::apply(v2), abs::apply(v3), + T(1))) + {} + + T const& apply(T const&, T const&) const + { + return factor; + } + + T factor; +}; + +template ::value> struct equals { - static inline bool apply(Type const& a, Type const& b) + template + static inline bool apply(Type const& a, Type const& b, Policy const&) { return a == b; } @@ -56,25 +137,31 @@ struct equals template struct equals { - static inline Type get_max(Type const& a, Type const& b, Type const& c) + template + static inline bool apply(Type const& a, Type const& b, Policy const& policy) { - return (std::max)((std::max)(a, b), c); - } + boost::ignore_unused(policy); - static inline bool apply(Type const& a, Type const& b) - { if (a == b) { return true; } - // See http://www.parashift.com/c++-faq-lite/newbie.html#faq-29.17, - // FUTURE: replace by some boost tool or boost::test::close_at_tolerance - return std::abs(a - b) <= std::numeric_limits::epsilon() * get_max(std::abs(a), std::abs(b), 1.0); + return std::abs(a - b) <= std::numeric_limits::epsilon() * policy.apply(a, b); } }; -template +template +inline bool equals_by_policy(T1 const& a, T2 const& b, Policy const& policy) +{ + return detail::equals + < + typename select_most_precise::type + >::apply(a, b, policy); +} + +template ::value> struct smaller { static inline bool apply(Type const& a, Type const& b) @@ -88,7 +175,7 @@ struct smaller { static inline bool apply(Type const& a, Type const& b) { - if (equals::apply(a, b)) + if (equals::apply(a, b, equals_default_policy())) { return false; } @@ -97,8 +184,11 @@ struct smaller }; -template -struct equals_with_epsilon : public equals {}; +template ::value> +struct equals_with_epsilon + : public equals +{}; template < @@ -270,44 +360,36 @@ inline T relaxed_epsilon(T const& factor) template inline bool equals(T1 const& a, T2 const& b) { - typedef typename select_most_precise::type select_type; return detail::equals < - select_type, - boost::is_floating_point::type::value - >::apply(a, b); + typename select_most_precise::type + >::apply(a, b, detail::equals_default_policy()); } template inline bool equals_with_epsilon(T1 const& a, T2 const& b) { - typedef typename select_most_precise::type select_type; return detail::equals_with_epsilon < - select_type, - boost::is_floating_point::type::value - >::apply(a, b); + typename select_most_precise::type + >::apply(a, b, detail::equals_default_policy()); } template inline bool smaller(T1 const& a, T2 const& b) { - typedef typename select_most_precise::type select_type; return detail::smaller < - select_type, - boost::is_floating_point::type::value + typename select_most_precise::type >::apply(a, b); } template inline bool larger(T1 const& a, T2 const& b) { - typedef typename select_most_precise::type select_type; return detail::smaller < - select_type, - boost::is_floating_point::type::value + typename select_most_precise::type >::apply(b, a); } @@ -366,8 +448,7 @@ sqrt(T const& value) template inline T abs(T const& value) { - T const zero = T(); - return value < zero ? -value : value; + return detail::abs::apply(value); } /*! @@ -386,12 +467,11 @@ static inline int sign(T const& value) \ingroup utility \note If the source T is NOT an integral type and Result is an integral type the value is rounded towards the closest integral value. Otherwise it's - just casted. + casted. */ template inline Result round(T const& v) { - // NOTE: boost::round() could be used instead but it throws in some situations return detail::round::apply(v); } From dbeb823fcbd8ef5c30f8c2a7f25f3ac2300a0f27 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sat, 14 Mar 2015 03:55:44 +0100 Subject: [PATCH 036/146] [strategies][cart_intersect] Use equals() with policy. Compare the floating-point results of cramer's rule (denominators) using the epsilon scaled by the greatest of the differences of coordinates of the segments' endpoints (the input of the determinant formula). --- .../boost/geometry/strategies/cartesian/cart_intersect.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/boost/geometry/strategies/cartesian/cart_intersect.hpp b/include/boost/geometry/strategies/cartesian/cart_intersect.hpp index e90af64f1..6e5976c05 100644 --- a/include/boost/geometry/strategies/cartesian/cart_intersect.hpp +++ b/include/boost/geometry/strategies/cartesian/cart_intersect.hpp @@ -200,8 +200,11 @@ struct relate_cartesian_segments get<1>(robust_b1) - get<1>(robust_a1), robust_db0, robust_db); + math::detail::equals_factor_policy + policy(robust_dx_a, robust_dy_a, robust_dx_b, robust_dy_b); robust_coordinate_type const zero = 0; - if (math::equals(robust_da0, zero) || math::equals(robust_db0, zero)) + if (math::detail::equals_by_policy(robust_da0, zero, policy) + || math::detail::equals_by_policy(robust_db0, zero, policy)) { // If this is the case, no rescaling is done for FP precision. // We set it to collinear, but it indicates a robustness issue. From f59f6ffaceb6cb36f0b07ae24f01d8790527985c Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sat, 14 Mar 2015 04:03:02 +0100 Subject: [PATCH 037/146] [strategies][side_by_triangle] Use equals() with policy. Compare the floating-point results of determinant (denominators) using the epsilon scaled by the greatest of the differences of coordinates of the points passed into the determinant formula. --- .../strategies/cartesian/side_by_triangle.hpp | 63 +++++++++++++++---- 1 file changed, 50 insertions(+), 13 deletions(-) diff --git a/include/boost/geometry/strategies/cartesian/side_by_triangle.hpp b/include/boost/geometry/strategies/cartesian/side_by_triangle.hpp index d6324d454..77443d46a 100644 --- a/include/boost/geometry/strategies/cartesian/side_by_triangle.hpp +++ b/include/boost/geometry/strategies/cartesian/side_by_triangle.hpp @@ -46,6 +46,24 @@ namespace strategy { namespace side template class side_by_triangle { + template + struct eps_policy + { + eps_policy() {} + template + eps_policy(Type const& a, Type const& b, Type const& c, Type const& d) + : policy(a, b, c, d) + {} + Policy policy; + }; + + struct eps_empty + { + eps_empty() {} + template + eps_empty(Type const&, Type const&, Type const&, Type const&) {} + }; + public : // Template member function, because it is not always trivial @@ -61,10 +79,11 @@ public : typename PromotedType, typename P1, typename P2, - typename P + typename P, + typename EpsPolicy > static inline - PromotedType side_value(P1 const& p1, P2 const& p2, P const& p) + PromotedType side_value(P1 const& p1, P2 const& p2, P const& p, EpsPolicy & eps_policy) { CoordinateType const x = get<0>(p); CoordinateType const y = get<1>(p); @@ -79,6 +98,8 @@ public : PromotedType const dpx = x - sx1; PromotedType const dpy = y - sy1; + eps_policy = EpsPolicy(dx, dy, dpx, dpy); + return geometry::detail::determinant ( dx, dy, @@ -87,6 +108,21 @@ public : } + template + < + typename CoordinateType, + typename PromotedType, + typename P1, + typename P2, + typename P + > + static inline + PromotedType side_value(P1 const& p1, P2 const& p2, P const& p) + { + eps_empty dummy; + return side_value(p1, p2, p, dummy); + } + template < @@ -96,18 +132,18 @@ public : > struct compute_side_value { - template - static inline PromotedType apply(P1 const& p1, P2 const& p2, P const& p) + template + static inline PromotedType apply(P1 const& p1, P2 const& p2, P const& p, EpsPolicy & epsp) { - return side_value(p1, p2, p); + return side_value(p1, p2, p, epsp); } }; template struct compute_side_value { - template - static inline PromotedType apply(P1 const& p1, P2 const& p2, P const& p) + template + static inline PromotedType apply(P1 const& p1, P2 const& p2, P const& p, EpsPolicy & epsp) { // For robustness purposes, first check if any two points are // the same; in this case simply return that the points are @@ -135,24 +171,24 @@ public : if (less(p, p2)) { // p is the lexicographically smallest - return side_value(p, p1, p2); + return side_value(p, p1, p2, epsp); } else { // p2 is the lexicographically smallest - return side_value(p2, p, p1); + return side_value(p2, p, p1, epsp); } } if (less(p1, p2)) { // p1 is the lexicographically smallest - return side_value(p1, p2, p); + return side_value(p1, p2, p, epsp); } else { // p2 is the lexicographically smallest - return side_value(p2, p, p1); + return side_value(p2, p, p1, epsp); } } }; @@ -191,13 +227,14 @@ public : && boost::is_integral::value && boost::is_integral::value; + eps_policy< math::detail::equals_factor_policy > epsp; promoted_type s = compute_side_value < coordinate_type, promoted_type, are_all_integral_coordinates - >::apply(p1, p2, p); + >::apply(p1, p2, p, epsp); promoted_type const zero = promoted_type(); - return math::equals(s, zero) ? 0 + return math::detail::equals_by_policy(s, zero, epsp.policy) ? 0 : s > zero ? 1 : -1; } From 4be351e433ad618223e2aaf49444e338746e9b3e Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sat, 14 Mar 2015 04:06:12 +0100 Subject: [PATCH 038/146] [test][get_turns] Update the tests, enable previously failing ones. Instead of expecting invalid results, disable 2 still failing tests. --- .../overlay/get_turns_linear_linear.cpp | 39 +++++++++++++------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/test/algorithms/overlay/get_turns_linear_linear.cpp b/test/algorithms/overlay/get_turns_linear_linear.cpp index 5686ebd3b..cc7003f8e 100644 --- a/test/algorithms/overlay/get_turns_linear_linear.cpp +++ b/test/algorithms/overlay/get_turns_linear_linear.cpp @@ -21,7 +21,7 @@ #include //TEST -#include +//#include template void test_all() @@ -224,7 +224,7 @@ void test_all() test_geometry("LINESTRING(3 -0.6,1 -0.8,0 -0.9)", "LINESTRING(4 2.232432,1 -0.8,9 0)", - expected("tuu++")); + expected("tui=+")("miu+=")); test_geometry("LINESTRING(3 -0.6, 0 -0.9, -1 -1)", "LINESTRING(4 2.232432, 0 -0.9, 9 0)", @@ -267,18 +267,23 @@ void test_all() if ( BOOST_GEOMETRY_CONDITION((boost::is_same::value)) ) { // BUG - the operations are correct but IP coordinates are wrong + // ok now also the 3rd turn is wrong +#ifdef BOOST_GEOMETRY_TEST_ENABLE_FAILING test_geometry("LINESTRING(8 5,5 1,-2 3,1 10)", "LINESTRING(1.9375 1.875, 1.7441860465116283 1.9302325581395348, -0.7692307692307692 2.6483516483516487, -2 3, -1.0071942446043165 5.316546762589928)", - expected("mii++")("ccc==")("tuu++")); + expected("mii++")("ccc==")("ccc==")("mux==")); + // Now tii++ is generated instead of ccc== + test_geometry("LINESTRING(8 5,5 1,-2 3,1 10)", "LINESTRING(1.9375 1.875, 1.7441860465116283 1.9302325581395348, -0.7692307692307692 2.6483516483516487, -2 3, -0.5 6.5)", - expected("mii++")("ccc==")("tii++")("mux==")); + expected("mii++")("ccc==")("ccc==")("mux==")); + // Now tii++ is generated instead of ccc== + +#endif - // FAILING - wrong number of turns test_geometry("LINESTRING(-0.5 7,8 1,0 -0.2)", "LINESTRING(2 8,4 0.4,8 1,0 5)", - //expected("iuu++")("mui=+")("tiu+=")); - expected("")("")); + expected("iuu++")("mui=+")("tiu+=")); // assertion failure in 1.57 // FAILING - no assertion failure but the result is not very good @@ -290,15 +295,26 @@ void test_all() expected("")("")); } -#if defined(BOOST_MSVC) || defined(BOOST_GEOMETRY_TEST_ENABLE_FAILING) - // Results different for MinGW (probably also QCC and GCC5.0) and MSVC/GCC - // depending which instruction is used to subtract values fsub or fsubr - // see also: https://github.com/boostorg/geometry/pull/259 + // In 1.57 the results of those combinations was different for MinGW + // (probably also QCC and GCC5.0) and MSVC/GCC. The results was depending + // on the instructions generated by the compiler when calculating the + // determinants. + // See also: https://svn.boost.org/trac/boost/ticket/8379 + // https://github.com/boostorg/geometry/pull/259 if ( BOOST_GEOMETRY_CONDITION((boost::is_same::value)) ) { test_geometry("LINESTRING(0 0, 10 0, 20 1)", "LINESTRING(12 10, 13 0.3, 14 0.4, 15 0.5)", expected("mii++")("ccc==")("mux==")); + test_geometry("LINESTRING(0 0, 10 0, 110 1)", + "LINESTRING(12 10, 13 0.03, 14 0.04, 15 0.05)", + expected("mii++")("ccc==")("mux==")); + test_geometry("LINESTRING(0 0, 10 0, 110 1)", + "LINESTRING(102 10, 103 0.93, 104 0.94, 105 0.95)", + expected("mii++")("ccc==")("mux==")); + test_geometry("LINESTRING(100 0, 110 0, 120 1)", + "LINESTRING(112 10, 113 0.3, 114 0.4, 115 0.5)", + expected("mii++")("ccc==")("mux==")); test_geometry("LINESTRING(0 0, 10 0, 20 1)", "LINESTRING(15 0.5, 14 0.4, 13 0.3, 12 10)", expected("miu+=")("mui=+")); @@ -335,7 +351,6 @@ void test_all() "LINESTRING(14 0.4, 13 0.3, 12 10)", expected("muu==")("mii++")); } -#endif // TODO: //test_geometry("LINESTRING(0 0,2 0,1 0)", "LINESTRING(0 1,0 0,2 0)", "1FF00F102"); From c72e6812bedd50e0297c134f49c210a10f12a307 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sat, 14 Mar 2015 04:07:59 +0100 Subject: [PATCH 039/146] [test][difference] Enable the tests failing before the recent changes in cart_intersect. --- .../set_operations/difference/difference_linear_linear.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/test/algorithms/set_operations/difference/difference_linear_linear.cpp b/test/algorithms/set_operations/difference/difference_linear_linear.cpp index b1ae1a21b..9f79baa08 100644 --- a/test/algorithms/set_operations/difference/difference_linear_linear.cpp +++ b/test/algorithms/set_operations/difference/difference_linear_linear.cpp @@ -548,7 +548,6 @@ BOOST_AUTO_TEST_CASE( test_difference_linestring_linestring ) "lldf31s" ); -#ifdef GEOMETRY_TEST_INCLUDE_FAILING_TESTS tester::apply (from_wkt("LINESTRING(8 1, 4 .4,2 8)"), from_wkt("LINESTRING(0 -.2, 8 1)"), @@ -586,9 +585,7 @@ BOOST_AUTO_TEST_CASE( test_difference_linestring_linestring ) "lldf31y+", 1e-10 ); -#endif -#ifdef GEOMETRY_TEST_INCLUDE_FAILING_TESTS tester::apply (from_wkt("LINESTRING(10.0002 2,9 -1032.34324, .3 8, 0 5, 8 1, 4 .4, 2 8)"), from_wkt("LINESTRING(0 -.2, 8 1, -.5 7, 6 +.2)"), @@ -611,7 +608,6 @@ BOOST_AUTO_TEST_CASE( test_difference_linestring_linestring ) from_wkt("MULTILINESTRING((0 0,4 .5),(8 1,-.5 7))"), "lldf32" ); -#endif } @@ -1157,7 +1153,6 @@ BOOST_AUTO_TEST_CASE( test_difference_multilinestring_multilinestring ) "mlmldf19" ); -#ifdef GEOMETRY_TEST_INCLUDE_FAILING_TESTS tester::apply (from_wkt("MULTILINESTRING((1 5, -4.3 -.1), (0 6, 8.6 6, 189.7654 5, 1 3, 6 3, 3 5, 6 2.232432, 0 4), (-6 5, 1 2.232432), (3 -1032.34324, 9 0, 189.7654 1, -1.4 3, 3 189.7654, +.3 10.0002, 1 5, 6 3, 5 1, 9 1, 10.0002 -1032.34324, -0.7654 0, 5 3, 3 4), (2.232432 2.232432, 8.6 +.4, 0.0 2.232432, 4 0, -8.8 10.0002), (1 0, 6 6, 7 2, -0 8.4), (-0.7654 3, +.6 8, 4 -1032.34324, 1 6, 0 4), (0 7, 2 1, 8 -7, 7 -.7, -1032.34324 9), (5 0, 10.0002 4, 8 7, 3 3, -8.1 5))"), from_wkt("MULTILINESTRING((5 10.0002, 2 7, -0.7654 0, 5 3), (0 -0.7654, 4 10.0002, 4 +.1, -.8 3, -.1 8, 10.0002 2, +.9 -1032.34324))"), @@ -1189,7 +1184,6 @@ BOOST_AUTO_TEST_CASE( test_difference_multilinestring_multilinestring ) "mlmldf25-r", 1e-10 ); -#endif } From 059142283df21db757a23cf738b32a620ff2a070 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sat, 14 Mar 2015 05:10:58 +0100 Subject: [PATCH 040/146] [test] Rename occurances of CS because this name is used as a macro on Solaris. --- test/geometries/segment.cpp | 10 +++--- test/strategies/distance_default_result.cpp | 36 ++++++++++----------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/test/geometries/segment.cpp b/test/geometries/segment.cpp index 25165b6b7..c6cef3e10 100644 --- a/test/geometries/segment.cpp +++ b/test/geometries/segment.cpp @@ -58,13 +58,13 @@ void test_all() //std::cout << sizeof(typename coordinate_type::type) << std::endl; - typedef bg::model::referring_segment

CS; - //BOOST_CONCEPT_ASSERT( (concept::ConstSegment) ); + typedef bg::model::referring_segment

refseg_t; + //BOOST_CONCEPT_ASSERT( (concept::ConstSegment) ); - CS cs(p1, p2); + refseg_t seg(p1, p2); - typedef typename bg::coordinate_type::type CT; - typedef typename bg::point_type::type CSP; + typedef typename bg::coordinate_type::type CT; + typedef typename bg::point_type::type CSP; boost::ignore_unused(); } diff --git a/test/strategies/distance_default_result.cpp b/test/strategies/distance_default_result.cpp index 40315d207..e862d3313 100644 --- a/test/strategies/distance_default_result.cpp +++ b/test/strategies/distance_default_result.cpp @@ -180,7 +180,7 @@ struct test_distance_result_box //========================================================================= -template +template inline void test_segment_all() { #if defined(HAVE_TTMATH) @@ -189,32 +189,32 @@ inline void test_segment_all() #endif typedef typename boost::mpl::if_ < - typename boost::is_same::type, + typename boost::is_same::type, double, float >::type float_return_type; - test_distance_result_segment(); - test_distance_result_segment(); - test_distance_result_segment(); - test_distance_result_segment(); + test_distance_result_segment(); + test_distance_result_segment(); + test_distance_result_segment(); + test_distance_result_segment(); - test_distance_result_segment(); - test_distance_result_segment(); + test_distance_result_segment(); + test_distance_result_segment(); - test_distance_result_segment(); - test_distance_result_segment(); - test_distance_result_segment(); - test_distance_result_segment(); - test_distance_result_segment(); + test_distance_result_segment(); + test_distance_result_segment(); + test_distance_result_segment(); + test_distance_result_segment(); + test_distance_result_segment(); #if defined(HAVE_TTMATH) - test_distance_result_segment(); - test_distance_result_segment(); + test_distance_result_segment(); + test_distance_result_segment(); - test_distance_result_segment(); - test_distance_result_segment(); - test_distance_result_segment(); + test_distance_result_segment(); + test_distance_result_segment(); + test_distance_result_segment(); #endif } From 6dff81523831998f73b98b8bf8787c2dbfd616eb Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Mon, 16 Mar 2015 10:26:34 +0200 Subject: [PATCH 041/146] [extensions][ttmath] implement binary arithmetic operators for ttmath_big as free functions --- .../extensions/contrib/ttmath_stub.hpp | 61 ++++++++++--------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/include/boost/geometry/extensions/contrib/ttmath_stub.hpp b/include/boost/geometry/extensions/contrib/ttmath_stub.hpp index 009942979..fb5bf048e 100644 --- a/include/boost/geometry/extensions/contrib/ttmath_stub.hpp +++ b/include/boost/geometry/extensions/contrib/ttmath_stub.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-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2014, 2015. +// Modifications copyright (c) 2014-2015, 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. @@ -116,43 +121,18 @@ struct ttmath_big : ttmath::Big<1,4> : ttmath::Big<1,4>(v) {} - // needed since the binary operator+ needs to be defined + // unary operator+() is implemented for completeness inline ttmath_big const& operator+() const { return *this; } - // needed in order for the result of the addition to be a ttmath_big object - inline ttmath_big operator+(ttmath_big const& other) const - { - return ttmath::Big<1,4>::operator+(other); - } - // needed in order to work with boost::geometry::math::abs inline ttmath_big operator-() const { return ttmath::Big<1,4>::operator-(); } - // needed because unary operator-() is defined (above) - inline ttmath_big operator-(ttmath_big const& other) const - { - return ttmath::Big<1,4>::operator-(other); - } - - // needed in order for the result of the multiplication to be a - // ttmath_big object - inline ttmath_big operator*(ttmath_big const& other) const - { - return ttmath::Big<1,4>::operator*(other); - } - - // needed in order for the result of the division to be a ttmath_big object - inline ttmath_big operator/(ttmath_big const& other) const - { - return ttmath::Big<1,4>::operator/(other); - } - /* inline operator double() const { @@ -166,6 +146,29 @@ struct ttmath_big : ttmath::Big<1,4> */ }; + +// arithmetic operators for ttmath_big objects, defined as free functions +inline ttmath_big operator+(ttmath_big const& x, ttmath_big const& y) +{ + return static_cast const&>(x).operator+(y); +} + +inline ttmath_big operator-(ttmath_big const& x, ttmath_big const& y) +{ + return static_cast const&>(x).operator-(y); +} + +inline ttmath_big operator*(ttmath_big const& x, ttmath_big const& y) +{ + return static_cast const&>(x).operator*(y); +} + +inline ttmath_big operator/(ttmath_big const& x, ttmath_big const& y) +{ + return static_cast const&>(x).operator/(y); +} + + namespace boost{ namespace geometry { namespace math { From 4230755b0722b111ae88ec66ea6b94582050aae5 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Mon, 16 Mar 2015 10:31:45 +0200 Subject: [PATCH 042/146] [extensions][ttmath] fix years in copyright header --- include/boost/geometry/extensions/contrib/ttmath_stub.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/geometry/extensions/contrib/ttmath_stub.hpp b/include/boost/geometry/extensions/contrib/ttmath_stub.hpp index 733d73dd2..5840a9eea 100644 --- a/include/boost/geometry/extensions/contrib/ttmath_stub.hpp +++ b/include/boost/geometry/extensions/contrib/ttmath_stub.hpp @@ -4,8 +4,8 @@ // Copyright (c) 2008-2015 Bruno Lalande, Paris, France. // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. -// This file was modified by Oracle on 2015. -// Modifications copyright (c) 2015, Oracle and/or its affiliates. +// This file was modified by Oracle on 2014, 2015. +// Modifications copyright (c) 2014-2015, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle From bf96857a46d4b71d64f8ae076c64a2814f70f51d Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Mon, 16 Mar 2015 12:09:36 +0200 Subject: [PATCH 043/146] [util][math][mod] rename math::fmod() to math::mod() (more generic and descriptive name); fix/update inline doc and comments; add default value to IsIntegral template parameter of modulo_for_fundamental struct; --- include/boost/geometry/util/math.hpp | 30 +++++++++++++--------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/include/boost/geometry/util/math.hpp b/include/boost/geometry/util/math.hpp index 69b747020..e3b2c388f 100644 --- a/include/boost/geometry/util/math.hpp +++ b/include/boost/geometry/util/math.hpp @@ -204,19 +204,19 @@ struct modulo static inline T apply(T const& value1, T const& value2) { - // for non-fundamental number types assume that sqrt is - // defined either: + // for non-fundamental number types assume that a free + // function mod() is defined either: // 1) at T's scope, or - // 2) at global scope, or - // 3) in namespace std - using ::fmod; - using std::fmod; - - return fmod(value1, value2); + // 2) at global scope + return mod(value1, value2); } }; -template +template +< + typename Fundamental, + bool IsIntegral = boost::is_integral::value +> struct modulo_for_fundamental { typedef Fundamental return_type; @@ -244,10 +244,7 @@ struct modulo_for_fundamental // specialization for fundamental number type template struct modulo - : modulo_for_fundamental - < - Fundamental, boost::is_integral::value - > + : modulo_for_fundamental {}; @@ -420,15 +417,16 @@ sqrt(T const& value) } /*! -\brief Short utility to return the result of fmod of two values +\brief Short utility to return the modulo of two values \ingroup utility \param value1 First value \param value2 Second value -\return The result of the fmod operation on the (ordered) pair (value1, value2) +\return The result of the modulo operation on the (ordered) pair +(value1, value2) */ template inline typename detail::modulo::return_type -fmod(T const& value1, T const& value2) +mod(T const& value1, T const& value2) { return detail::modulo < From 6098d419ba46b54c97974748ef533b55a34a40f4 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Mon, 16 Mar 2015 17:22:13 +0100 Subject: [PATCH 044/146] [util][math] Fix equals policies return types. To avoid returning reference to temporary object. Add equals_factor_policy "empty" specialization for integral types. --- include/boost/geometry/util/math.hpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/include/boost/geometry/util/math.hpp b/include/boost/geometry/util/math.hpp index 301d8dc43..4042f4e4c 100644 --- a/include/boost/geometry/util/math.hpp +++ b/include/boost/geometry/util/math.hpp @@ -94,14 +94,15 @@ struct abs struct equals_default_policy { template - static inline T const& apply(T const& a, T const& b) + static inline T apply(T const& a, T const& b) { // See http://www.parashift.com/c++-faq-lite/newbie.html#faq-29.17 return greatest(abs::apply(a), abs::apply(b), T(1)); } }; -template +template ::value> struct equals_factor_policy { equals_factor_policy() @@ -123,6 +124,19 @@ struct equals_factor_policy T factor; }; +template +struct equals_factor_policy +{ + equals_factor_policy() {} + explicit equals_factor_policy(T const&) {} + equals_factor_policy(T const& , T const& , T const& , T const& ) {} + + static inline T apply(T const&, T const&) + { + return T(1); + } +}; + template ::value> struct equals @@ -147,7 +161,7 @@ struct equals return true; } - return std::abs(a - b) <= std::numeric_limits::epsilon() * policy.apply(a, b); + return abs::apply(a - b) <= std::numeric_limits::epsilon() * policy.apply(a, b); } }; From 062a7abce9efa44013c099052ee6728cdf431938 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Mon, 16 Mar 2015 17:26:20 +0100 Subject: [PATCH 045/146] [strategies][cart_intersect] Modify type of factor stored in the equals policy. --- include/boost/geometry/strategies/cartesian/cart_intersect.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/geometry/strategies/cartesian/cart_intersect.hpp b/include/boost/geometry/strategies/cartesian/cart_intersect.hpp index 6e5976c05..a7bd38522 100644 --- a/include/boost/geometry/strategies/cartesian/cart_intersect.hpp +++ b/include/boost/geometry/strategies/cartesian/cart_intersect.hpp @@ -200,7 +200,7 @@ struct relate_cartesian_segments get<1>(robust_b1) - get<1>(robust_a1), robust_db0, robust_db); - math::detail::equals_factor_policy + math::detail::equals_factor_policy policy(robust_dx_a, robust_dy_a, robust_dx_b, robust_dy_b); robust_coordinate_type const zero = 0; if (math::detail::equals_by_policy(robust_da0, zero, policy) From a239fb629a19cb7aa66fcdff7fc1aba2c4d64cd2 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Mon, 16 Mar 2015 17:28:12 +0100 Subject: [PATCH 046/146] [test][get_turns] Add additional output for debugging purposes, enabled with macro definition. --- test/algorithms/overlay/test_get_turns.hpp | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/algorithms/overlay/test_get_turns.hpp b/test/algorithms/overlay/test_get_turns.hpp index 6aa781910..314c5c8c4 100644 --- a/test/algorithms/overlay/test_get_turns.hpp +++ b/test/algorithms/overlay/test_get_turns.hpp @@ -156,6 +156,10 @@ void check_geometry_range( bool ok = boost::size(expected) == turns.size(); +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::vector turns_dbg = turns; +#endif + BOOST_CHECK_MESSAGE(ok, "get_turns: " << wkt1 << " and " << wkt2 << " -> Expected turns #: " << boost::size(expected) << " detected turns #: " << turns.size()); @@ -170,11 +174,43 @@ void check_geometry_range( turns.erase(it); else { + ok = false; BOOST_CHECK_MESSAGE(false, "get_turns: " << wkt1 << " and " << wkt2 << " -> Expected turn: " << *sit << " not found"); } } + +#ifdef BOOST_GEOMETRY_TEST_DEBUG + if ( !ok ) + { + std::cout << "Coordinates: " + << typeid(typename bg::coordinate_type::type).name() + << ", " + << typeid(typename bg::coordinate_type::type).name() + << std::endl; + std::cout << "Detected: "; + if ( turns_dbg.empty() ) + { + std::cout << "{empty}"; + } + else + { + for ( typename std::vector::const_iterator it = turns_dbg.begin() ; + it != turns_dbg.end() ; ++it ) + { + if ( it != turns_dbg.begin() ) + std::cout << ", "; + std::cout << bg::method_char(it->method); + std::cout << bg::operation_char(it->operations[0].operation); + std::cout << bg::operation_char(it->operations[1].operation); + std::cout << equal_turn<1>::is_colinear_char(it->operations[0].is_collinear); + std::cout << equal_turn<1>::is_colinear_char(it->operations[1].is_collinear); + } + } + std::cout << std::endl; + } +#endif } template From 6eb80018c645e544d0e84b2d008a32dbdce91f9a Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Tue, 17 Mar 2015 02:49:54 +0100 Subject: [PATCH 047/146] [index][pack_create] Fix for iterators not returning true references. Don't dereference iterators passed by the user in the expression where a dereferenced value is passed into the translator/indexable-getter. Without this fix if an iterator returns non-true reference (e.g. like segment_iterator) and this reference is adapted to the Geometry concept (like pointing_segment returned by segment_iterator) and the default indexable<> getter is used (which returns a true reference), then a true reference returned by it is a dangling reference corresponding to a destroyed temporary object. --- .../geometry/index/detail/rtree/pack_create.hpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/include/boost/geometry/index/detail/rtree/pack_create.hpp b/include/boost/geometry/index/detail/rtree/pack_create.hpp index 1c24fdb91..abe921f05 100644 --- a/include/boost/geometry/index/detail/rtree/pack_create.hpp +++ b/include/boost/geometry/index/detail/rtree/pack_create.hpp @@ -2,7 +2,7 @@ // // R-tree initial packing // -// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2015 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 @@ -161,7 +161,10 @@ public: geometry::assign_inverse(hint_box); for ( ; first != last ; ++first ) { - typename Translator::result_type indexable = translator(*first); + // NOTE: support for iterators not returning true references adapted + // to Geometry concept and default translator returning true reference + typename std::iterator_traits::reference in_ref = *first; // MAY THROW (ref copy) + typename Translator::result_type indexable = translator(in_ref); // NOTE: added for consistency with insert() // CONSIDER: alternative - ignore invalid indexable or throw an exception @@ -215,8 +218,14 @@ private: geometry::assign_inverse(elements_box); for ( ; first != last ; ++first ) { - rtree::elements(l).push_back(*(first->second)); // MAY THROW (A?,C) - geometry::expand(elements_box, translator(*(first->second))); + // NOTE: support for iterators not returning true references adapted + // to Geometry concept and default translator returning true reference + // and an optimization (reuse) + typedef typename std::iterator_traits::value_type::second_type iter_type; + typename std::iterator_traits::reference in_ref = *(first->second); // MAY THROW (ref copy) + + rtree::elements(l).push_back(in_ref); // MAY THROW (A?,C) + geometry::expand(elements_box, translator(in_ref)); } auto_remover.release(); From f7cc47bb30e0768c279a5f7ce87a9239549a18dc Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Wed, 18 Mar 2015 14:16:02 +0100 Subject: [PATCH 048/146] [test][get_turns] Add test file for Areal/Areal. --- test/algorithms/overlay/Jamfile.v2 | 1 + .../overlay/get_turns_areal_areal.cpp | 62 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 test/algorithms/overlay/get_turns_areal_areal.cpp diff --git a/test/algorithms/overlay/Jamfile.v2 b/test/algorithms/overlay/Jamfile.v2 index 2d736874b..c1758d155 100644 --- a/test/algorithms/overlay/Jamfile.v2 +++ b/test/algorithms/overlay/Jamfile.v2 @@ -19,6 +19,7 @@ test-suite boost-geometry-algorithms-overlay [ run ccw_traverse.cpp : : : msvc:/bigobj ] [ run get_turn_info.cpp ] [ run get_turns.cpp ] + [ run get_turns_areal_areal.cpp ] [ run get_turns_linear_linear.cpp ] [ run get_turns_linear_areal.cpp ] [ run multi_traverse.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE BOOST_GEOMETRY_RESCALE_TO_ROBUST ] diff --git a/test/algorithms/overlay/get_turns_areal_areal.cpp b/test/algorithms/overlay/get_turns_areal_areal.cpp new file mode 100644 index 000000000..f84c8d0bf --- /dev/null +++ b/test/algorithms/overlay/get_turns_areal_areal.cpp @@ -0,0 +1,62 @@ +// Boost.Geometry +// 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. + +// This file was modified by Oracle on 2015. +// Modifications copyright (c) 2015 Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include "test_get_turns.hpp" +#include + +//TEST +//#include + +template +void test_all() +{ + typedef bg::model::point pt; + //typedef bg::model::ring ring; + typedef bg::model::polygon poly; + //typedef bg::model::multi_polygon mpoly; + + // mailing list report 17.03.2015 + // operations ok but wrong IPs for int + // (the coordinates are generates at endpoints only) + { + // cw(duplicated point) + test_geometry("POLYGON((-8042 -1485,-8042 250,-8042 250,15943 254,15943 -1485,-8042 -1485))", + "POLYGON((-7901 -1485,-7901 529,-7901 529, 15802 544, 15802 -1485, -7901 -1485))", + expected_pusher<0>()("iiu")("iui")("mcc")("cui")); + //to_svg("POLYGON((-8042 -1485,-8042 250,15943 254,15943 -1485,-8042 -1485))", + // "POLYGON((-7901 -1485,-7901 529,15802 544, 15802 -1485, -7901 -1485))", + // "poly_poly_1.svg"); + test_geometry("POLYGON((-7901 -1485,-7901 529,-7901 529, 15802 544, 15802 -1485, -7901 -1485))", + "POLYGON((-8042 -1485,-8042 250,-8042 250,15943 254,15943 -1485,-8042 -1485))", + expected_pusher<0>()("iui")("iiu")("mcc")("ciu")); + } +} + +int test_main(int, char* []) +{ + test_all(); + test_all(); + test_all(); + +#if ! defined(_MSC_VER) + test_all(); +#endif + +#if defined(HAVE_TTMATH) + test_all(); +#endif + return 0; +} From 6fd35a3fb86ef18018de7209789df2f0b4bac90b Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Wed, 18 Mar 2015 17:25:57 +0100 Subject: [PATCH 049/146] [test][util] Generate custom error message in select_most_precise test. --- test/util/select_most_precise.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/util/select_most_precise.cpp b/test/util/select_most_precise.cpp index 11b066fa3..ec93b5f25 100644 --- a/test/util/select_most_precise.cpp +++ b/test/util/select_most_precise.cpp @@ -24,8 +24,15 @@ template void test() { typedef typename bg::select_most_precise::type type; + bool is_same = boost::is_same::type::value; - BOOST_CHECK((boost::is_same::type::value)); + BOOST_CHECK_MESSAGE(is_same, + "The most precise of types " + "T1: {" << typeid(T1).name() << " | s: " << sizeof(T1) << "}" << + " and " + "T2: {" << typeid(T2).name() << " | s: " << sizeof(T2) << "}" << + " does not match " + "ExpectedType: {" << typeid(ExpectedType).name() << " | s: " << sizeof(ExpectedType) << "}"); } int test_main(int, char* []) From 91fb7241e597997cca7724d35ccf0f6f86c73d21 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 19 Mar 2015 01:25:34 +0100 Subject: [PATCH 050/146] [index] Support move_iterator in packing algorithm. --- .../geometry/index/detail/rtree/pack_create.hpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/include/boost/geometry/index/detail/rtree/pack_create.hpp b/include/boost/geometry/index/detail/rtree/pack_create.hpp index abe921f05..86317e8cd 100644 --- a/include/boost/geometry/index/detail/rtree/pack_create.hpp +++ b/include/boost/geometry/index/detail/rtree/pack_create.hpp @@ -163,7 +163,9 @@ public: { // NOTE: support for iterators not returning true references adapted // to Geometry concept and default translator returning true reference - typename std::iterator_traits::reference in_ref = *first; // MAY THROW (ref copy) + // An alternative would be to dereference the iterator and translate + // in one expression each time the indexable was needed. + typename std::iterator_traits::reference in_ref = *first; typename Translator::result_type indexable = translator(in_ref); // NOTE: added for consistency with insert() @@ -218,14 +220,11 @@ private: geometry::assign_inverse(elements_box); for ( ; first != last ; ++first ) { - // NOTE: support for iterators not returning true references adapted - // to Geometry concept and default translator returning true reference - // and an optimization (reuse) - typedef typename std::iterator_traits::value_type::second_type iter_type; - typename std::iterator_traits::reference in_ref = *(first->second); // MAY THROW (ref copy) - - rtree::elements(l).push_back(in_ref); // MAY THROW (A?,C) - geometry::expand(elements_box, translator(in_ref)); + // NOTE: push_back() must be called at the end in order to support move_iterator. + // The iterator is dereferenced 2x (no temporary reference) to support + // non-true reference types and move_iterator without boost::forward<>. + geometry::expand(elements_box, translator(*(first->second))); + rtree::elements(l).push_back(*(first->second)); // MAY THROW (A?,C) } auto_remover.release(); From 5cd851d48a45a756868b9b7d24e7a3e842da83ba Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 19 Mar 2015 01:27:51 +0100 Subject: [PATCH 051/146] [test][index] Add test for rtree packing using move_itreator. --- index/test/rtree/Jamfile.v2 | 1 + index/test/rtree/rtree_move_pack.cpp | 134 +++++++++++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 index/test/rtree/rtree_move_pack.cpp diff --git a/index/test/rtree/Jamfile.v2 b/index/test/rtree/Jamfile.v2 index 463ccb3fa..23578b4e9 100644 --- a/index/test/rtree/Jamfile.v2 +++ b/index/test/rtree/Jamfile.v2 @@ -12,6 +12,7 @@ build-project generated ; test-suite boost-geometry-index-rtree : + [ run rtree_move_pack.cpp ] [ run rtree_values.cpp ] [ compile-fail rtree_values_invalid.cpp ] ; diff --git a/index/test/rtree/rtree_move_pack.cpp b/index/test/rtree/rtree_move_pack.cpp new file mode 100644 index 000000000..b7210772d --- /dev/null +++ b/index/test/rtree/rtree_move_pack.cpp @@ -0,0 +1,134 @@ +// Boost.Geometry Index +// Unit Test + +// Copyright (c) 2015 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) + +#include + +#include +#include +#include +#include + +#include + +class point_cm +{ + BOOST_COPYABLE_AND_MOVABLE(point_cm) + +public: + point_cm(double xx = 0, double yy = 0) + : x(xx) + , y(yy) + , moved(false) + {} + point_cm(point_cm const& other) + : x(other.x) + , y(other.y) + , moved(false) + { + BOOST_CHECK_MESSAGE(false, "copy not allowed"); + } + point_cm & operator=(BOOST_COPY_ASSIGN_REF(point_cm) other) + { + BOOST_CHECK_MESSAGE(false, "copy not allowed"); + x = other.x; + y = other.y; + moved = false; + return *this; + } + point_cm(BOOST_RV_REF(point_cm) other) + : x(other.x) + , y(other.y) + , moved(false) + { + BOOST_CHECK_MESSAGE(!other.moved, "only one move allowed"); + other.moved = true; + } + point_cm & operator=(BOOST_RV_REF(point_cm) other) + { + BOOST_CHECK_MESSAGE(!other.moved, "only one move allowed"); + x = other.x; + y = other.y; + moved = false; + other.moved = true; + return *this; + } + + double x, y; + bool moved; +}; + +template +struct indexable +{ + typedef Point const& result_type; + result_type operator()(Point const& p) const + { + BOOST_CHECK_MESSAGE(!p.moved, "can't access indexable of moved Value"); + return p; + } +}; + +BOOST_GEOMETRY_REGISTER_POINT_2D(point_cm, double, bg::cs::cartesian, x, y) + +template +void append(Vector & vec, double x, double y) +{ + point_cm pt(x, y); + BOOST_CHECK(!pt.moved); + vec.push_back(boost::move(pt)); + BOOST_CHECK(pt.moved); +} + +struct test_moved +{ + test_moved(bool ex) + : expected(ex) + {} + template + void operator()(Point const& p) const + { + BOOST_CHECK_EQUAL(p.moved, expected); + } + bool expected; +}; + +template +void test_rtree(Params const& params = Params()) +{ + // sanity check + boost::container::vector vec; + append(vec, 0, 0); append(vec, 0, 1); append(vec, 0, 2); + append(vec, 1, 0); append(vec, 1, 1); append(vec, 1, 2); + append(vec, 2, 0); append(vec, 2, 1); append(vec, 2, 2); + + std::for_each(vec.begin(), vec.end(), test_moved(false)); + + bgi::rtree > rt( + boost::make_move_iterator(vec.begin()), + boost::make_move_iterator(vec.end()), + params); + + std::for_each(vec.begin(), vec.end(), test_moved(true)); + + BOOST_CHECK_EQUAL(rt.size(), vec.size()); +} + + +int test_main(int, char* []) +{ + test_rtree< point_cm, bgi::linear<4> >(); + test_rtree< point_cm, bgi::quadratic<4> >(); + test_rtree< point_cm, bgi::rstar<4> >(); + + test_rtree(bgi::dynamic_linear(4)); + test_rtree(bgi::dynamic_quadratic(4)); + test_rtree(bgi::dynamic_rstar(4)); + + return 0; +} From d22b3a00bf27b464be8d0d0ee79fd76071fbba37 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 19 Mar 2015 03:54:10 +0100 Subject: [PATCH 052/146] [test][index] Add more tests for types convertible to rtree::value_type. Hopefully it'll give info needed to fix wrong results of rtree::count() for types convertible to value_type on Android. --- index/test/rtree/rtree_values.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/index/test/rtree/rtree_values.cpp b/index/test/rtree/rtree_values.cpp index 2059a8141..e9eb13810 100644 --- a/index/test/rtree/rtree_values.cpp +++ b/index/test/rtree/rtree_values.cpp @@ -22,6 +22,30 @@ struct point BOOST_GEOMETRY_REGISTER_POINT_2D(point, double, bg::cs::cartesian, x, y) +template +void check_convertible_to_value(Rtree const& rt, Convertible const& conv) +{ + static const bool + is_conv_to_indexable + = boost::is_convertible::value; + static const bool + is_conv_to_value + = boost::is_convertible::value; + static const bool + is_same_as_indexable + = boost::is_same::value; + static const bool + is_same_as_value + = boost::is_same::value; + + BOOST_CHECK_EQUAL(is_same_as_indexable, false); + BOOST_CHECK_EQUAL(is_same_as_value, false); + BOOST_CHECK_EQUAL(is_conv_to_indexable, false); + BOOST_CHECK_EQUAL(is_conv_to_value, true); + + typename Rtree::value_type const& val = conv; + BOOST_CHECK(rt.value_eq()(val, conv)); +} template void test_pair() @@ -45,6 +69,11 @@ void test_pair() rt.insert(std::make_pair(box, (unsigned short)0)); BOOST_CHECK_EQUAL(rt.size(), 3u); + check_convertible_to_value(rt, std::make_pair(box, 0)); + check_convertible_to_value(rt, std::make_pair(box, (unsigned short)0)); + BOOST_CHECK(bg::covered_by(rt.indexable_get()(std::make_pair(box, 0)), rt.bounds())); + BOOST_CHECK(bg::covered_by(rt.indexable_get()(std::make_pair(box, (unsigned short)0)), rt.bounds())); + BOOST_CHECK_EQUAL(rt.count(val), 3u); BOOST_CHECK_EQUAL(rt.count(std::make_pair(box, 0)), 3u); BOOST_CHECK_EQUAL(rt.count(std::make_pair(box, (unsigned short)0)), 3u); From 0f4ce76449f15ad0db2e0a85645191a4db6eb7f1 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 19 Mar 2015 23:35:20 +0100 Subject: [PATCH 053/146] [index] Replace std::auto_ptr with boost::scoped_ptr in query_iterator. --- .../index/detail/rtree/query_iterators.hpp | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/include/boost/geometry/index/detail/rtree/query_iterators.hpp b/include/boost/geometry/index/detail/rtree/query_iterators.hpp index 1bcb97988..74000d03e 100644 --- a/include/boost/geometry/index/detail/rtree/query_iterators.hpp +++ b/include/boost/geometry/index/detail/rtree/query_iterators.hpp @@ -11,6 +11,8 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_QUERY_ITERATORS_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_QUERY_ITERATORS_HPP +#include + //#define BOOST_GEOMETRY_INDEX_DETAIL_QUERY_ITERATORS_USE_MOVE namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { namespace iterators { @@ -253,7 +255,7 @@ template class query_iterator { typedef query_iterator_base iterator_base; - typedef std::auto_ptr iterator_ptr; + typedef boost::scoped_ptr iterator_ptr; public: typedef std::input_iterator_tag iterator_category; @@ -280,21 +282,24 @@ public: #ifndef BOOST_GEOMETRY_INDEX_DETAIL_QUERY_ITERATORS_USE_MOVE query_iterator & operator=(query_iterator const& o) { - m_ptr.reset(o.m_ptr.get() ? o.m_ptr->clone() : 0); + if ( this != boost::addressof(o) ) + { + m_ptr.reset(o.m_ptr.get() ? o.m_ptr->clone() : 0); + } return *this; } #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES query_iterator(query_iterator && o) - : m_ptr(o.m_ptr.get()) + : m_ptr(0) { - o.m_ptr.release(); + m_ptr.swap(o.m_ptr); } query_iterator & operator=(query_iterator && o) { if ( this != boost::addressof(o) ) { - m_ptr.reset(o.m_ptr.get()); - o.m_ptr.release(); + m_ptr.swap(o.m_ptr); + o.m_ptr.reset(); } return *this; } @@ -305,20 +310,23 @@ private: public: query_iterator & operator=(BOOST_COPY_ASSIGN_REF(query_iterator) o) { - m_ptr.reset(o.m_ptr.get() ? o.m_ptr->clone() : 0); + if ( this != boost::addressof(o) ) + { + m_ptr.reset(o.m_ptr.get() ? o.m_ptr->clone() : 0); + } return *this; } query_iterator(BOOST_RV_REF(query_iterator) o) - : m_ptr(o.m_ptr.get()) + : m_ptr(0) { - o.m_ptr.release(); + m_ptr.swap(o.m_ptr); } query_iterator & operator=(BOOST_RV_REF(query_iterator) o) { if ( this != boost::addressof(o) ) { - m_ptr.reset(o.m_ptr.get()); - o.m_ptr.release(); + m_ptr.swap(o.m_ptr); + o.m_ptr.reset(); } return *this; } From 4514e325f9bd25b60a2d511a49c7c2fa30dcd85c Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 19 Mar 2015 23:36:32 +0100 Subject: [PATCH 054/146] [index] Move predicates and operators into detail::predicates namespace. In order to use the operators only for predicates. --- .../index/detail/distance_predicates.hpp | 18 +-- .../geometry/index/detail/predicates.hpp | 114 +++++++++--------- include/boost/geometry/index/predicates.hpp | 90 ++++++++++---- 3 files changed, 133 insertions(+), 89 deletions(-) diff --git a/include/boost/geometry/index/detail/distance_predicates.hpp b/include/boost/geometry/index/detail/distance_predicates.hpp index 3e057290a..9a9371df9 100644 --- a/include/boost/geometry/index/detail/distance_predicates.hpp +++ b/include/boost/geometry/index/detail/distance_predicates.hpp @@ -3,7 +3,7 @@ // Spatial index distance predicates, calculators and checkers // used in nearest query - specialized for envelopes // -// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2015 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 @@ -104,13 +104,13 @@ struct calculate_distance // this handles nearest() with default Point parameter, to_nearest() and bounds template -struct calculate_distance< nearest, Indexable, Tag > +struct calculate_distance< predicates::nearest, Indexable, Tag > { typedef detail::relation relation; typedef typename relation::value_type point_type; typedef typename geometry::default_comparable_distance_result::type result_type; - static inline bool apply(nearest const& p, Indexable const& i, result_type & result) + static inline bool apply(predicates::nearest const& p, Indexable const& i, result_type & result) { result = geometry::comparable_distance(relation::value(p.point_or_relation), i); return true; @@ -118,12 +118,12 @@ struct calculate_distance< nearest, Indexable, Tag > }; template -struct calculate_distance< nearest< to_centroid >, Indexable, value_tag> +struct calculate_distance< predicates::nearest< to_centroid >, Indexable, value_tag> { typedef Point point_type; typedef typename geometry::default_comparable_distance_result::type result_type; - static inline bool apply(nearest< to_centroid > const& p, Indexable const& i, result_type & result) + static inline bool apply(predicates::nearest< to_centroid > const& p, Indexable const& i, result_type & result) { result = index::detail::comparable_distance_centroid(p.point_or_relation.value, i); return true; @@ -131,12 +131,12 @@ struct calculate_distance< nearest< to_centroid >, Indexable, value_tag> }; template -struct calculate_distance< nearest< to_furthest >, Indexable, value_tag> +struct calculate_distance< predicates::nearest< to_furthest >, Indexable, value_tag> { typedef Point point_type; typedef typename geometry::default_comparable_distance_result::type result_type; - static inline bool apply(nearest< to_furthest > const& p, Indexable const& i, result_type & result) + static inline bool apply(predicates::nearest< to_furthest > const& p, Indexable const& i, result_type & result) { result = index::detail::comparable_distance_far(p.point_or_relation.value, i); return true; @@ -144,13 +144,13 @@ struct calculate_distance< nearest< to_furthest >, Indexable, value_tag> }; template -struct calculate_distance< path, Indexable, Tag> +struct calculate_distance< predicates::path, Indexable, Tag> { typedef typename index::detail::default_path_intersection_distance_type< Indexable, SegmentOrLinestring >::type result_type; - static inline bool apply(path const& p, Indexable const& i, result_type & result) + static inline bool apply(predicates::path const& p, Indexable const& i, result_type & result) { return index::detail::path_intersection(i, p.geometry, result); } diff --git a/include/boost/geometry/index/detail/predicates.hpp b/include/boost/geometry/index/detail/predicates.hpp index b92256649..60f80207d 100644 --- a/include/boost/geometry/index/detail/predicates.hpp +++ b/include/boost/geometry/index/detail/predicates.hpp @@ -2,7 +2,7 @@ // // Spatial query predicates definition and checks. // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2015 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 @@ -16,6 +16,8 @@ namespace boost { namespace geometry { namespace index { namespace detail { +namespace predicates { + // ------------------------------------------------------------------ // // predicates // ------------------------------------------------------------------ // @@ -92,6 +94,8 @@ struct path unsigned count; }; +} // namespace predicates + // ------------------------------------------------------------------ // // predicate_check // ------------------------------------------------------------------ // @@ -108,20 +112,20 @@ struct predicate_check // ------------------------------------------------------------------ // template -struct predicate_check, value_tag> +struct predicate_check, value_tag> { template - static inline bool apply(satisfies const& p, Value const& v, Indexable const&) + static inline bool apply(predicates::satisfies const& p, Value const& v, Indexable const&) { return p.fun(v); } }; template -struct predicate_check, value_tag> +struct predicate_check, value_tag> { template - static inline bool apply(satisfies const& p, Value const& v, Indexable const&) + static inline bool apply(predicates::satisfies const& p, Value const& v, Indexable const&) { return !p.fun(v); } @@ -136,7 +140,7 @@ struct spatial_predicate_call }; template <> -struct spatial_predicate_call +struct spatial_predicate_call { template static inline bool apply(G1 const& g1, G2 const& g2) @@ -146,7 +150,7 @@ struct spatial_predicate_call }; template <> -struct spatial_predicate_call +struct spatial_predicate_call { template static inline bool apply(G1 const& g1, G2 const& g2) @@ -156,7 +160,7 @@ struct spatial_predicate_call }; template <> -struct spatial_predicate_call +struct spatial_predicate_call { template static inline bool apply(G1 const& g1, G2 const& g2) @@ -166,7 +170,7 @@ struct spatial_predicate_call }; template <> -struct spatial_predicate_call +struct spatial_predicate_call { template static inline bool apply(G1 const& g1, G2 const& g2) @@ -176,7 +180,7 @@ struct spatial_predicate_call }; template <> -struct spatial_predicate_call +struct spatial_predicate_call { template static inline bool apply(G1 const& g1, G2 const& g2) @@ -186,7 +190,7 @@ struct spatial_predicate_call }; template <> -struct spatial_predicate_call +struct spatial_predicate_call { template static inline bool apply(G1 const& g1, G2 const& g2) @@ -196,7 +200,7 @@ struct spatial_predicate_call }; template <> -struct spatial_predicate_call +struct spatial_predicate_call { template static inline bool apply(G1 const& g1, G2 const& g2) @@ -206,7 +210,7 @@ struct spatial_predicate_call }; template <> -struct spatial_predicate_call +struct spatial_predicate_call { template static inline bool apply(G1 const& g1, G2 const& g2) @@ -219,9 +223,9 @@ struct spatial_predicate_call // spatial predicate template -struct predicate_check, value_tag> +struct predicate_check, value_tag> { - typedef spatial_predicate Pred; + typedef predicates::spatial_predicate Pred; template static inline bool apply(Pred const& p, Value const&, Indexable const& i) @@ -232,9 +236,9 @@ struct predicate_check, value_tag> // negated spatial predicate template -struct predicate_check, value_tag> +struct predicate_check, value_tag> { - typedef spatial_predicate Pred; + typedef predicates::spatial_predicate Pred; template static inline bool apply(Pred const& p, Value const&, Indexable const& i) @@ -246,20 +250,20 @@ struct predicate_check, value_tag> // ------------------------------------------------------------------ // template -struct predicate_check, value_tag> +struct predicate_check, value_tag> { template - static inline bool apply(nearest const&, Value const&, Box const&) + static inline bool apply(predicates::nearest const&, Value const&, Box const&) { return true; } }; template -struct predicate_check, value_tag> +struct predicate_check, value_tag> { template - static inline bool apply(path const&, Value const&, Box const&) + static inline bool apply(predicates::path const&, Value const&, Box const&) { return true; } @@ -270,10 +274,10 @@ struct predicate_check, value_tag> // ------------------------------------------------------------------ // template -struct predicate_check, bounds_tag> +struct predicate_check, bounds_tag> { template - static bool apply(satisfies const&, Value const&, Box const&) + static bool apply(predicates::satisfies const&, Value const&, Box const&) { return true; } @@ -295,53 +299,53 @@ struct predicate_check, bounds_tag> // spatial predicate - default template -struct predicate_check, bounds_tag> +struct predicate_check, bounds_tag> { - typedef spatial_predicate Pred; + typedef predicates::spatial_predicate Pred; template static inline bool apply(Pred const& p, Value const&, Indexable const& i) { - return spatial_predicate_call::apply(i, p.geometry); + return spatial_predicate_call::apply(i, p.geometry); } }; // spatial predicate - contains template -struct predicate_check, bounds_tag> +struct predicate_check, bounds_tag> { - typedef spatial_predicate Pred; + typedef predicates::spatial_predicate Pred; template static inline bool apply(Pred const& p, Value const&, Indexable const& i) { - return spatial_predicate_call::apply(i, p.geometry); + return spatial_predicate_call::apply(i, p.geometry); } }; // spatial predicate - covers template -struct predicate_check, bounds_tag> +struct predicate_check, bounds_tag> { - typedef spatial_predicate Pred; + typedef predicates::spatial_predicate Pred; template static inline bool apply(Pred const& p, Value const&, Indexable const& i) { - return spatial_predicate_call::apply(i, p.geometry); + return spatial_predicate_call::apply(i, p.geometry); } }; // spatial predicate - disjoint template -struct predicate_check, bounds_tag> +struct predicate_check, bounds_tag> { - typedef spatial_predicate Pred; + typedef predicates::spatial_predicate Pred; template static inline bool apply(Pred const& p, Value const&, Indexable const& i) { - return !spatial_predicate_call::apply(i, p.geometry); + return !spatial_predicate_call::apply(i, p.geometry); } }; @@ -359,9 +363,9 @@ struct predicate_check, bounds_ // negated spatial predicate - default template -struct predicate_check, bounds_tag> +struct predicate_check, bounds_tag> { - typedef spatial_predicate Pred; + typedef predicates::spatial_predicate Pred; template static inline bool apply(Pred const& p, Value const&, Indexable const& i) @@ -372,9 +376,9 @@ struct predicate_check, bounds_tag> // negated spatial predicate - contains template -struct predicate_check, bounds_tag> +struct predicate_check, bounds_tag> { - typedef spatial_predicate Pred; + typedef predicates::spatial_predicate Pred; template static inline bool apply(Pred const& , Value const&, Indexable const& ) @@ -385,9 +389,9 @@ struct predicate_check, bounds_t // negated spatial predicate - covers template -struct predicate_check, bounds_tag> +struct predicate_check, bounds_tag> { - typedef spatial_predicate Pred; + typedef predicates::spatial_predicate Pred; template static inline bool apply(Pred const& , Value const&, Indexable const& ) @@ -398,22 +402,22 @@ struct predicate_check, bounds_tag // negated spatial predicate - intersects template -struct predicate_check, bounds_tag> +struct predicate_check, bounds_tag> { - typedef spatial_predicate Pred; + typedef predicates::spatial_predicate Pred; template static inline bool apply(Pred const& p, Value const&, Indexable const& i) { - return !spatial_predicate_call::apply(i, p.geometry); + return !spatial_predicate_call::apply(i, p.geometry); } }; // negated spatial predicate - overlaps template -struct predicate_check, bounds_tag> +struct predicate_check, bounds_tag> { - typedef spatial_predicate Pred; + typedef predicates::spatial_predicate Pred; template static inline bool apply(Pred const& , Value const&, Indexable const& ) @@ -424,34 +428,34 @@ struct predicate_check, bounds_t // negated spatial predicate - touches template -struct predicate_check, bounds_tag> +struct predicate_check, bounds_tag> { - typedef spatial_predicate Pred; + typedef predicates::spatial_predicate Pred; template static inline bool apply(Pred const& p, Value const&, Indexable const& i) { - return !spatial_predicate_call::apply(i, p.geometry); + return !spatial_predicate_call::apply(i, p.geometry); } }; // ------------------------------------------------------------------ // template -struct predicate_check, bounds_tag> +struct predicate_check, bounds_tag> { template - static inline bool apply(nearest const&, Value const&, Box const&) + static inline bool apply(predicates::nearest const&, Value const&, Box const&) { return true; } }; template -struct predicate_check, bounds_tag> +struct predicate_check, bounds_tag> { template - static inline bool apply(path const&, Value const&, Box const&) + static inline bool apply(predicates::path const&, Value const&, Box const&) { return true; } @@ -697,13 +701,13 @@ struct predicates_is_distance }; template -struct predicates_is_distance< nearest > +struct predicates_is_distance< predicates::nearest > { static const unsigned value = 1; }; template -struct predicates_is_distance< path > +struct predicates_is_distance< predicates::path > { static const unsigned value = 1; }; diff --git a/include/boost/geometry/index/predicates.hpp b/include/boost/geometry/index/predicates.hpp index 10033abff..3bb1bf4d8 100644 --- a/include/boost/geometry/index/predicates.hpp +++ b/include/boost/geometry/index/predicates.hpp @@ -2,7 +2,7 @@ // // Spatial query predicates // -// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2015 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 @@ -43,10 +43,15 @@ bgi::query(spatial_index, bgi::contains(box), std::back_inserter(result)); \param g The Geometry object. */ template inline -detail::spatial_predicate +detail::predicates::spatial_predicate contains(Geometry const& g) { - return detail::spatial_predicate(g); + return detail::predicates::spatial_predicate + < + Geometry, + detail::predicates::contains_tag, + false + >(g); } /*! @@ -68,10 +73,15 @@ bgi::query(spatial_index, bgi::covered_by(box), std::back_inserter(result)); \param g The Geometry object. */ template inline -detail::spatial_predicate +detail::predicates::spatial_predicate covered_by(Geometry const& g) { - return detail::spatial_predicate(g); + return detail::predicates::spatial_predicate + < + Geometry, + detail::predicates::covered_by_tag, + false + >(g); } /*! @@ -93,10 +103,15 @@ bgi::query(spatial_index, bgi::covers(box), std::back_inserter(result)); \param g The Geometry object. */ template inline -detail::spatial_predicate +detail::predicates::spatial_predicate covers(Geometry const& g) { - return detail::spatial_predicate(g); + return detail::predicates::spatial_predicate + < + Geometry, + detail::predicates::covers_tag, + false + >(g); } /*! @@ -118,10 +133,15 @@ bgi::query(spatial_index, bgi::disjoint(box), std::back_inserter(result)); \param g The Geometry object. */ template inline -detail::spatial_predicate +detail::predicates::spatial_predicate disjoint(Geometry const& g) { - return detail::spatial_predicate(g); + return detail::predicates::spatial_predicate + < + Geometry, + detail::predicates::disjoint_tag, + false + >(g); } /*! @@ -145,10 +165,15 @@ bgi::query(spatial_index, bgi::intersects(polygon), std::back_inserter(result)); \param g The Geometry object. */ template inline -detail::spatial_predicate +detail::predicates::spatial_predicate intersects(Geometry const& g) { - return detail::spatial_predicate(g); + return detail::predicates::spatial_predicate + < + Geometry, + detail::predicates::intersects_tag, + false + >(g); } /*! @@ -170,10 +195,15 @@ bgi::query(spatial_index, bgi::overlaps(box), std::back_inserter(result)); \param g The Geometry object. */ template inline -detail::spatial_predicate +detail::predicates::spatial_predicate overlaps(Geometry const& g) { - return detail::spatial_predicate(g); + return detail::predicates::spatial_predicate + < + Geometry, + detail::predicates::overlaps_tag, + false + >(g); } #ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL @@ -192,10 +222,15 @@ returns true. \param g The Geometry object. */ template inline -detail::spatial_predicate +detail::predicates::spatial_predicate touches(Geometry const& g) { - return detail::spatial_predicate(g); + return detail::predicates::spatial_predicate + < + Geometry, + detail::predicates::touches_tag, + false + >(g); } #endif // BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL @@ -219,10 +254,15 @@ bgi::query(spatial_index, bgi::within(box), std::back_inserter(result)); \param g The Geometry object. */ template inline -detail::spatial_predicate +detail::predicates::spatial_predicate within(Geometry const& g) { - return detail::spatial_predicate(g); + return detail::predicates::spatial_predicate + < + Geometry, + detail::predicates::within_tag, + false + >(g); } /*! @@ -259,10 +299,10 @@ std::back_inserter(result)); \param pred The unary predicate function or function object. */ template inline -detail::satisfies +detail::predicates::satisfies satisfies(UnaryPredicate const& pred) { - return detail::satisfies(pred); + return detail::predicates::satisfies(pred); } /*! @@ -289,10 +329,10 @@ Only one \c nearest() predicate may be used in a query. \param k The maximum number of values to return. */ template inline -detail::nearest +detail::predicates::nearest nearest(Geometry const& geometry, unsigned k) { - return detail::nearest(geometry, k); + return detail::predicates::nearest(geometry, k); } #ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL @@ -319,15 +359,15 @@ Only one distance predicate (\c nearest() or \c path()) may be used in a query. \param k The maximum number of values to return. */ template inline -detail::path +detail::predicates::path path(SegmentOrLinestring const& linestring, unsigned k) { - return detail::path(linestring, k); + return detail::predicates::path(linestring, k); } #endif // BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL -namespace detail { +namespace detail { namespace predicates { // operator! generators @@ -378,7 +418,7 @@ operator&&(boost::tuples::cons const& t, Pred const& p) >::apply(t, p); } -} // namespace detail +}} // namespace detail::predicates }}} // namespace boost::geometry::index From b788a9e4aba44be31f7e33f447491f6dce57fc88 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 19 Mar 2015 23:39:42 +0100 Subject: [PATCH 055/146] [index] Rename node_auto_ptr with subtree_destroyer and auto_deallocator with scoped_dealloactor. --- .../detail/rtree/node/auto_deallocator.hpp | 38 --------------- .../geometry/index/detail/rtree/node/node.hpp | 14 +++--- .../detail/rtree/node/scoped_deallocator.hpp | 48 +++++++++++++++++++ ...ode_auto_ptr.hpp => subtree_destroyer.hpp} | 24 +++++----- .../detail/rtree/node/variant_dynamic.hpp | 2 +- .../index/detail/rtree/node/weak_dynamic.hpp | 2 +- .../index/detail/rtree/pack_create.hpp | 8 ++-- .../index/detail/rtree/visitors/copy.hpp | 10 ++-- .../index/detail/rtree/visitors/insert.hpp | 16 +++---- .../index/detail/rtree/visitors/remove.hpp | 4 +- .../geometry/index/detail/serialization.hpp | 14 +++--- include/boost/geometry/index/rtree.hpp | 6 +-- 12 files changed, 97 insertions(+), 89 deletions(-) delete mode 100644 include/boost/geometry/index/detail/rtree/node/auto_deallocator.hpp create mode 100644 include/boost/geometry/index/detail/rtree/node/scoped_deallocator.hpp rename include/boost/geometry/index/detail/rtree/node/{node_auto_ptr.hpp => subtree_destroyer.hpp} (71%) diff --git a/include/boost/geometry/index/detail/rtree/node/auto_deallocator.hpp b/include/boost/geometry/index/detail/rtree/node/auto_deallocator.hpp deleted file mode 100644 index dd55c6d76..000000000 --- a/include/boost/geometry/index/detail/rtree/node/auto_deallocator.hpp +++ /dev/null @@ -1,38 +0,0 @@ -// Boost.Geometry Index -// -// R-tree auto deallocator -// -// Copyright (c) 2011-2013 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_INDEX_DETAIL_RTREE_NODE_AUTO_DEALLOCATOR_HPP -#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_AUTO_DEALLOCATOR_HPP - -namespace boost { namespace geometry { namespace index { - -namespace detail { namespace rtree { - -template -class auto_deallocator -{ - auto_deallocator(auto_deallocator const&); - auto_deallocator & operator=(auto_deallocator const&); -public: - typedef typename Alloc::pointer pointer; - inline auto_deallocator(Alloc & a, pointer p) : m_alloc(a), m_ptr(p) {} - inline ~auto_deallocator() { if ( m_ptr ) boost::container::allocator_traits::deallocate(m_alloc, m_ptr, 1); } - inline void release() { m_ptr = 0; } - inline pointer ptr() { return m_ptr; } -private: - Alloc & m_alloc; - pointer m_ptr; -}; - -}} // namespace detail::rtree - -}}} // namespace boost::geometry::index - -#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_AUTO_DEALLOCATOR_HPP diff --git a/include/boost/geometry/index/detail/rtree/node/node.hpp b/include/boost/geometry/index/detail/rtree/node/node.hpp index a632ece66..528d47317 100644 --- a/include/boost/geometry/index/detail/rtree/node/node.hpp +++ b/include/boost/geometry/index/detail/rtree/node/node.hpp @@ -2,7 +2,7 @@ // // R-tree nodes // -// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2015 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 @@ -16,8 +16,8 @@ #include #include -#include #include +#include //#include //#include @@ -27,7 +27,7 @@ #include #include -#include +#include #include @@ -70,11 +70,11 @@ struct destroy_element typedef typename rtree::internal_node::type internal_node; typedef typename rtree::leaf::type leaf; - typedef rtree::node_auto_ptr node_auto_ptr; + typedef rtree::subtree_destroyer subtree_destroyer; inline static void apply(typename internal_node::elements_type::value_type & element, Allocators & allocators) { - node_auto_ptr dummy(element.second, allocators); + subtree_destroyer dummy(element.second, allocators); element.second = 0; } @@ -108,11 +108,11 @@ private: inline static void apply_dispatch(It first, It last, Allocators & allocators, boost::mpl::bool_ const& /*is_range_of_values*/) { - typedef rtree::node_auto_ptr node_auto_ptr; + typedef rtree::subtree_destroyer subtree_destroyer; for ( ; first != last ; ++first ) { - node_auto_ptr dummy(first->second, allocators); + subtree_destroyer dummy(first->second, allocators); first->second = 0; } } diff --git a/include/boost/geometry/index/detail/rtree/node/scoped_deallocator.hpp b/include/boost/geometry/index/detail/rtree/node/scoped_deallocator.hpp new file mode 100644 index 000000000..2d08d89ef --- /dev/null +++ b/include/boost/geometry/index/detail/rtree/node/scoped_deallocator.hpp @@ -0,0 +1,48 @@ +// Boost.Geometry Index +// +// R-tree scoped deallocator +// +// Copyright (c) 2011-2015 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_INDEX_DETAIL_RTREE_NODE_SCOPED_DEALLOCATOR_HPP +#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_SCOPED_DEALLOCATOR_HPP + +namespace boost { namespace geometry { namespace index { + +namespace detail { namespace rtree { + +template +class scoped_deallocator +{ + scoped_deallocator(scoped_deallocator const&); + scoped_deallocator & operator=(scoped_deallocator const&); +public: + typedef typename Alloc::pointer pointer; + inline scoped_deallocator(pointer p, Alloc & a) + : m_ptr(p), m_alloc(a) + {} + inline ~scoped_deallocator() + { + if ( m_ptr ) + { + boost::container::allocator_traits::deallocate(m_alloc, m_ptr, 1); + } + } + inline void release() + { + m_ptr = 0; + } +private: + pointer m_ptr; + Alloc & m_alloc; +}; + +}} // namespace detail::rtree + +}}} // namespace boost::geometry::index + +#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_SCOPED_DEALLOCATOR_HPP diff --git a/include/boost/geometry/index/detail/rtree/node/node_auto_ptr.hpp b/include/boost/geometry/index/detail/rtree/node/subtree_destroyer.hpp similarity index 71% rename from include/boost/geometry/index/detail/rtree/node/node_auto_ptr.hpp rename to include/boost/geometry/index/detail/rtree/node/subtree_destroyer.hpp index c19e123b6..3376068ee 100644 --- a/include/boost/geometry/index/detail/rtree/node/node_auto_ptr.hpp +++ b/include/boost/geometry/index/detail/rtree/node/subtree_destroyer.hpp @@ -1,15 +1,15 @@ // Boost.Geometry Index // -// R-tree node auto ptr +// R-tree subtree scoped destroyer // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2015 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_INDEX_DETAIL_RTREE_NODE_NODE_AUTO_PTR_HPP -#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_NODE_AUTO_PTR_HPP +#ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_SUBTREE_DESTROYED_HPP +#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_SUBTREE_DESTROYED_HPP #include @@ -17,31 +17,29 @@ namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { -// TODO - change the name to node_scoped_ptr - template -class node_auto_ptr +class subtree_destroyer { typedef typename rtree::node::type node; typedef typename Allocators::node_pointer pointer; - node_auto_ptr(node_auto_ptr const&); - node_auto_ptr & operator=(node_auto_ptr const&); + subtree_destroyer(subtree_destroyer const&); + subtree_destroyer & operator=(subtree_destroyer const&); public: - node_auto_ptr(pointer ptr, Allocators & allocators) + subtree_destroyer(pointer ptr, Allocators & allocators) : m_ptr(ptr) , m_allocators(allocators) {} - ~node_auto_ptr() + ~subtree_destroyer() { reset(); } void reset(pointer ptr = 0) { - if ( m_ptr ) + if ( m_ptr && m_ptr != ptr ) { detail::rtree::visitors::destroy del_v(m_ptr, m_allocators); detail::rtree::apply_visitor(del_v, *m_ptr); @@ -78,4 +76,4 @@ private: }}} // namespace boost::geometry::index -#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_NODE_AUTO_PTR_HPP +#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_SUBTREE_DESTROYED_HPP diff --git a/include/boost/geometry/index/detail/rtree/node/variant_dynamic.hpp b/include/boost/geometry/index/detail/rtree/node/variant_dynamic.hpp index f5a05f914..8e052e521 100644 --- a/include/boost/geometry/index/detail/rtree/node/variant_dynamic.hpp +++ b/include/boost/geometry/index/detail/rtree/node/variant_dynamic.hpp @@ -181,7 +181,7 @@ struct create_variant_node if ( 0 == p ) throw_runtime_error("boost::geometry::index::rtree node creation failed"); - auto_deallocator deallocator(alloc_node, p); + scoped_deallocator deallocator(p, alloc_node); Al::construct(alloc_node, boost::addressof(*p), Node(alloc_node)); // implicit cast to Variant diff --git a/include/boost/geometry/index/detail/rtree/node/weak_dynamic.hpp b/include/boost/geometry/index/detail/rtree/node/weak_dynamic.hpp index b828b35f4..d49e34782 100644 --- a/include/boost/geometry/index/detail/rtree/node/weak_dynamic.hpp +++ b/include/boost/geometry/index/detail/rtree/node/weak_dynamic.hpp @@ -197,7 +197,7 @@ struct create_weak_node if ( 0 == p ) throw_runtime_error("boost::geometry::index::rtree node creation failed"); - auto_deallocator deallocator(alloc_node, p); + scoped_deallocator deallocator(p, alloc_node); Al::construct(alloc_node, boost::addressof(*p), alloc_node); diff --git a/include/boost/geometry/index/detail/rtree/pack_create.hpp b/include/boost/geometry/index/detail/rtree/pack_create.hpp index 86317e8cd..b7be41ab2 100644 --- a/include/boost/geometry/index/detail/rtree/pack_create.hpp +++ b/include/boost/geometry/index/detail/rtree/pack_create.hpp @@ -122,7 +122,7 @@ class pack typedef typename rtree::leaf::type leaf; typedef typename Allocators::node_pointer node_pointer; - typedef rtree::node_auto_ptr node_auto_ptr; + typedef rtree::subtree_destroyer subtree_destroyer; typedef typename Allocators::size_type size_type; typedef typename geometry::point_type::type point_type; @@ -210,7 +210,7 @@ private: // create new leaf node node_pointer n = rtree::create_node::apply(allocators); // MAY THROW (A) - node_auto_ptr auto_remover(n, allocators); + subtree_destroyer auto_remover(n, allocators); leaf & l = rtree::get(*n); // reserve space for values @@ -238,7 +238,7 @@ private: // create new internal node node_pointer n = rtree::create_node::apply(allocators); // MAY THROW (A) - node_auto_ptr auto_remover(n, allocators); + subtree_destroyer auto_remover(n, allocators); internal_node & in = rtree::get(*n); // reserve space for values @@ -280,7 +280,7 @@ private: // in case if push_back() do throw here // and even if this is not probable (previously reserved memory, nonthrowing pairs copy) // this case is also tested by exceptions test. - node_auto_ptr auto_remover(el.second, allocators); + subtree_destroyer auto_remover(el.second, allocators); // this container should have memory allocated, reserve() called outside elements.push_back(el); // MAY THROW (A?,C) - however in normal conditions shouldn't auto_remover.release(); diff --git a/include/boost/geometry/index/detail/rtree/visitors/copy.hpp b/include/boost/geometry/index/detail/rtree/visitors/copy.hpp index 8fc25ac80..86ffc99ca 100644 --- a/include/boost/geometry/index/detail/rtree/visitors/copy.hpp +++ b/include/boost/geometry/index/detail/rtree/visitors/copy.hpp @@ -2,7 +2,7 @@ // // R-tree deep copying visitor implementation // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2015 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 @@ -24,7 +24,7 @@ public: typedef typename rtree::internal_node::type internal_node; typedef typename rtree::leaf::type leaf; - typedef rtree::node_auto_ptr node_auto_ptr; + typedef rtree::subtree_destroyer subtree_destroyer; typedef typename Allocators::node_pointer node_pointer; explicit inline copy(Allocators & allocators) @@ -35,7 +35,7 @@ public: inline void operator()(internal_node & n) { node_pointer raw_new_node = rtree::create_node::apply(m_allocators); // MAY THROW, STRONG (N: alloc) - node_auto_ptr new_node(raw_new_node, m_allocators); + subtree_destroyer new_node(raw_new_node, m_allocators); typedef typename rtree::elements_type::type elements_type; elements_type & elements = rtree::elements(n); @@ -48,7 +48,7 @@ public: rtree::apply_visitor(*this, *it->second); // MAY THROW (V, E: alloc, copy, N: alloc) // for exception safety - node_auto_ptr auto_result(result, m_allocators); + subtree_destroyer auto_result(result, m_allocators); elements_dst.push_back( rtree::make_ptr_pair(it->first, result) ); // MAY THROW, STRONG (E: alloc, copy) @@ -62,7 +62,7 @@ public: inline void operator()(leaf & l) { node_pointer raw_new_node = rtree::create_node::apply(m_allocators); // MAY THROW, STRONG (N: alloc) - node_auto_ptr new_node(raw_new_node, m_allocators); + subtree_destroyer new_node(raw_new_node, m_allocators); typedef typename rtree::elements_type::type elements_type; elements_type & elements = rtree::elements(l); diff --git a/include/boost/geometry/index/detail/rtree/visitors/insert.hpp b/include/boost/geometry/index/detail/rtree/visitors/insert.hpp index 388b3193f..e697c065e 100644 --- a/include/boost/geometry/index/detail/rtree/visitors/insert.hpp +++ b/include/boost/geometry/index/detail/rtree/visitors/insert.hpp @@ -2,7 +2,7 @@ // // R-tree inserting visitor implementation // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2015 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 @@ -115,7 +115,7 @@ protected: typedef typename rtree::internal_node::type internal_node; typedef typename rtree::leaf::type leaf; - typedef rtree::node_auto_ptr node_auto_ptr; + typedef rtree::subtree_destroyer subtree_destroyer; public: typedef index::detail::varray< @@ -133,8 +133,8 @@ public: { // TODO - consider creating nodes always with sufficient memory allocated - // create additional node, use auto ptr for automatic destruction on exception - node_auto_ptr second_node(rtree::create_node::apply(allocators), allocators); // MAY THROW, STRONG (N: alloc) + // create additional node, use auto destroyer for automatic destruction on exception + subtree_destroyer second_node(rtree::create_node::apply(allocators), allocators); // MAY THROW, STRONG (N: alloc) // create reference to the newly created node Node & n2 = rtree::get(*second_node); @@ -232,7 +232,7 @@ protected: typedef typename rtree::internal_node::type internal_node; typedef typename rtree::leaf::type leaf; - typedef rtree::node_auto_ptr node_auto_ptr; + typedef rtree::subtree_destroyer subtree_destroyer; typedef typename Allocators::node_pointer node_pointer; typedef typename Allocators::size_type size_type; @@ -340,7 +340,7 @@ protected: // Implement template struct node_element_type or something like that // for exception safety - node_auto_ptr additional_node_ptr(additional_nodes[0].second, m_allocators); + subtree_destroyer additional_node_ptr(additional_nodes[0].second, m_allocators); // node is not the root - just add the new node if ( !m_traverse_data.current_is_root() ) @@ -356,7 +356,7 @@ protected: BOOST_GEOMETRY_INDEX_ASSERT(&n == &rtree::get(*m_root_node), "node should be the root"); // create new root and add nodes - node_auto_ptr new_root(rtree::create_node::apply(m_allocators), m_allocators); // MAY THROW, STRONG (N:alloc) + subtree_destroyer new_root(rtree::create_node::apply(m_allocators), m_allocators); // MAY THROW, STRONG (N:alloc) BOOST_TRY { @@ -365,7 +365,7 @@ protected: } BOOST_CATCH(...) { - // clear new root to not delete in the ~node_auto_ptr() potentially stored old root node + // clear new root to not delete in the ~subtree_destroyer() potentially stored old root node rtree::elements(rtree::get(*new_root)).clear(); BOOST_RETHROW // RETHROW } diff --git a/include/boost/geometry/index/detail/rtree/visitors/remove.hpp b/include/boost/geometry/index/detail/rtree/visitors/remove.hpp index a55f5d3fe..494d5a019 100644 --- a/include/boost/geometry/index/detail/rtree/visitors/remove.hpp +++ b/include/boost/geometry/index/detail/rtree/visitors/remove.hpp @@ -30,7 +30,7 @@ class remove typedef typename rtree::internal_node::type internal_node; typedef typename rtree::leaf::type leaf; - typedef rtree::node_auto_ptr node_auto_ptr; + typedef rtree::subtree_destroyer subtree_destroyer; typedef typename Allocators::node_pointer node_pointer; typedef typename Allocators::size_type size_type; @@ -264,7 +264,7 @@ private: // destroy current and remaining nodes for ( ; it != m_underflowed_nodes.rend() ; ++it ) { - node_auto_ptr dummy(it->second, m_allocators); + subtree_destroyer dummy(it->second, m_allocators); } //m_underflowed_nodes.clear(); diff --git a/include/boost/geometry/index/detail/serialization.hpp b/include/boost/geometry/index/detail/serialization.hpp index 34036e390..550a37565 100644 --- a/include/boost/geometry/index/detail/serialization.hpp +++ b/include/boost/geometry/index/detail/serialization.hpp @@ -1,6 +1,6 @@ // Boost.Geometry Index // -// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2015 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 @@ -353,7 +353,7 @@ class load typedef typename Options::parameters_type parameters_type; typedef typename Allocators::node_pointer node_pointer; - typedef rtree::node_auto_ptr node_auto_ptr; + typedef rtree::subtree_destroyer subtree_destroyer; typedef typename Allocators::size_type size_type; public: @@ -385,7 +385,7 @@ private: if ( current_level < leafs_level ) { node_pointer n = rtree::create_node::apply(allocators); // MAY THROW (A) - node_auto_ptr auto_remover(n, allocators); + subtree_destroyer auto_remover(n, allocators); internal_node & in = rtree::get(*n); elements_type & elements = rtree::elements(in); @@ -408,7 +408,7 @@ private: BOOST_GEOMETRY_INDEX_ASSERT(current_level == leafs_level, "unexpected value"); node_pointer n = rtree::create_node::apply(allocators); // MAY THROW (A) - node_auto_ptr auto_remover(n, allocators); + subtree_destroyer auto_remover(n, allocators); leaf & l = rtree::get(*n); typedef typename rtree::elements_type::type elements_type; @@ -537,7 +537,7 @@ void load(Archive & ar, boost::geometry::index::rtree & rt, unsig typedef typename options_type::parameters_type parameters_type; typedef typename allocators_type::node_pointer node_pointer; - typedef detail::rtree::node_auto_ptr node_auto_ptr; + typedef detail::rtree::subtree_destroyer subtree_destroyer; view tree(rt); @@ -554,7 +554,7 @@ void load(Archive & ar, boost::geometry::index::rtree & rt, unsig n = detail::rtree::load ::apply(ar, version, leafs_level, loaded_values_count, params, tree.members().translator(), tree.members().allocators()); // MAY THROW - node_auto_ptr remover(n, tree.members().allocators()); + subtree_destroyer remover(n, tree.members().allocators()); if ( loaded_values_count != values_count ) BOOST_THROW_EXCEPTION(std::runtime_error("unexpected number of values")); // TODO change exception type remover.release(); @@ -564,7 +564,7 @@ void load(Archive & ar, boost::geometry::index::rtree & rt, unsig tree.members().values_count = values_count; tree.members().leafs_level = leafs_level; - node_auto_ptr remover(tree.members().root, tree.members().allocators()); + subtree_destroyer remover(tree.members().root, tree.members().allocators()); tree.members().root = n; } diff --git a/include/boost/geometry/index/rtree.hpp b/include/boost/geometry/index/rtree.hpp index c39dd01b6..1d65ceabf 100644 --- a/include/boost/geometry/index/rtree.hpp +++ b/include/boost/geometry/index/rtree.hpp @@ -3,7 +3,7 @@ // R-tree implementation // // Copyright (c) 2008 Federico J. Fernandez. -// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2015 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 @@ -188,7 +188,7 @@ private: typedef typename allocators_type::node_pointer node_pointer; typedef ::boost::container::allocator_traits allocator_traits_type; - typedef detail::rtree::node_auto_ptr node_auto_ptr; + typedef detail::rtree::subtree_destroyer subtree_destroyer; friend class detail::rtree::utilities::view; #ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL @@ -1357,7 +1357,7 @@ private: dst.m_members.parameters() = src.m_members.parameters(); } - // TODO use node_auto_ptr + // TODO use subtree_destroyer if ( dst.m_members.root ) { detail::rtree::visitors::destroy From 7399df83cc2c60d92ee8a0d595dad5d2f1296bb3 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Fri, 20 Mar 2015 02:01:34 +0100 Subject: [PATCH 056/146] [doc] Format "unspecified" functions return type in a special way in doxygen_xml2qbk alt output synopsis. --- .../tools/doxygen_xml2qbk/quickbook_output.hpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/doc/src/docutils/tools/doxygen_xml2qbk/quickbook_output.hpp b/doc/src/docutils/tools/doxygen_xml2qbk/quickbook_output.hpp index 7fed9f83f..a7829f17e 100644 --- a/doc/src/docutils/tools/doxygen_xml2qbk/quickbook_output.hpp +++ b/doc/src/docutils/tools/doxygen_xml2qbk/quickbook_output.hpp @@ -996,13 +996,19 @@ void quickbook_synopsis_alt(function const& f, std::ostream& out) offset += f.name.size(); break; case function_member : - inline_str_with_links(f.return_type, out); - out << " `" << f.name << "`"; - offset += f.return_type_without_links.size() + 1 + f.name.size(); - break; case function_free : - inline_str_with_links(f.definition, out); - offset += f.definition.size(); + if ( f.return_type == "unspecified" ) + { + out << "/unspecified/"; + offset += 11; + } + else + { + inline_str_with_links(f.return_type, out); + offset += f.return_type_without_links.size(); + } + out << " `" << f.name << "`"; + offset += 1 + f.name.size(); break; case function_define : out << "`#define " << f.name << "`"; From cc4ac4599d8a1dbcc63796420ec931aceb9196a0 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Fri, 20 Mar 2015 02:07:23 +0100 Subject: [PATCH 057/146] [index][doc] Hide details in docs if DOXYGEN_NO_DETAIL is defined. Change functions return types to unspecified. Replace parameters defaults generated by functions/metafunctions with values. Hide base classes. --- doc/index/Doxyfile | 3 +- .../boost/geometry/index/adaptors/query.hpp | 4 ++ include/boost/geometry/index/equal_to.hpp | 2 + include/boost/geometry/index/indexable.hpp | 2 + include/boost/geometry/index/parameters.hpp | 29 +++++++++++- include/boost/geometry/index/predicates.hpp | 44 +++++++++++++++++++ 6 files changed, 82 insertions(+), 2 deletions(-) diff --git a/doc/index/Doxyfile b/doc/index/Doxyfile index 9e73dedbc..9b59645b3 100644 --- a/doc/index/Doxyfile +++ b/doc/index/Doxyfile @@ -284,7 +284,8 @@ SEARCH_INCLUDES = YES INCLUDE_PATH = INCLUDE_FILE_PATTERNS = PREDEFINED = "BOOST_RV_REF(T)=T &&" \ - "BOOST_COPY_ASSIGN_REF(T)=T const &" + "BOOST_COPY_ASSIGN_REF(T)=T const &" \ + DOXYGEN_NO_DETAIL EXPAND_AS_DEFINED = SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- diff --git a/include/boost/geometry/index/adaptors/query.hpp b/include/boost/geometry/index/adaptors/query.hpp index 472b3693b..f1b7ab3eb 100644 --- a/include/boost/geometry/index/adaptors/query.hpp +++ b/include/boost/geometry/index/adaptors/query.hpp @@ -75,7 +75,11 @@ operator|( \param pred Predicates. */ template +#ifndef DOXYGEN_NO_DETAIL detail::query +#else +unspecified +#endif queried(Predicates const& pred) { return detail::query(pred); diff --git a/include/boost/geometry/index/equal_to.hpp b/include/boost/geometry/index/equal_to.hpp index b0cf098f1..099569be7 100644 --- a/include/boost/geometry/index/equal_to.hpp +++ b/include/boost/geometry/index/equal_to.hpp @@ -235,7 +235,9 @@ other types using operator==. */ template struct equal_to +#ifndef DOXYGEN_NO_DETAIL : detail::equal_to +#endif { /*! \brief The type of result returned by function object. */ typedef typename detail::equal_to::result_type result_type; diff --git a/include/boost/geometry/index/indexable.hpp b/include/boost/geometry/index/indexable.hpp index 391b544f3..ed6669689 100644 --- a/include/boost/geometry/index/indexable.hpp +++ b/include/boost/geometry/index/indexable.hpp @@ -195,7 +195,9 @@ and variadic templates are supported. */ template struct indexable +#ifndef DOXYGEN_NO_DETAIL : detail::indexable +#endif { /*! \brief The type of result returned by function object. It should be const Indexable reference. */ typedef typename detail::indexable::result_type result_type; diff --git a/include/boost/geometry/index/parameters.hpp b/include/boost/geometry/index/parameters.hpp index fd6df716e..e94da1163 100644 --- a/include/boost/geometry/index/parameters.hpp +++ b/include/boost/geometry/index/parameters.hpp @@ -70,7 +70,11 @@ inline size_t default_rstar_reinserted_elements_d_calc(size_t max_elements, size \tparam MinElements Minimum number of elements in nodes. Default: 0.3*Max. */ template ::value +#else + size_t MinElements = 0.3*MaxElements +#endif > struct linear { @@ -91,7 +95,12 @@ struct linear \tparam MinElements Minimum number of elements in nodes. Default: 0.3*Max. */ template ::value> +#ifndef DOXYGEN_NO_DETAIL + size_t MinElements = detail::default_min_elements_s::value +#else + size_t MinElements = 0.3*MaxElements +#endif +> struct quadratic { BOOST_MPL_ASSERT_MSG((0 < MinElements && 2*MinElements <= MaxElements+1), @@ -119,8 +128,13 @@ struct quadratic and true minimum overlap cost is calculated. Default: 32. */ template ::value, size_t ReinsertedElements = detail::default_rstar_reinserted_elements_s::value, +#else + size_t MinElements = 0.3*MaxElements, + size_t ReinsertedElements = 0.3*MaxElements, +#endif size_t OverlapCostThreshold = 32> struct rstar { @@ -158,7 +172,11 @@ public: \param min_elements Minimum number of elements in nodes. Default: 0.3*Max. */ dynamic_linear(size_t max_elements, +#ifndef DOXYGEN_NO_DETAIL size_t min_elements = detail::default_min_elements_d()) +#else + size_t min_elements = 0.3*max_elements) +#endif : m_max_elements(max_elements) , m_min_elements(detail::default_min_elements_d_calc(max_elements, min_elements)) { @@ -187,7 +205,11 @@ public: \param min_elements Minimum number of elements in nodes. Default: 0.3*Max. */ dynamic_quadratic(size_t max_elements, +#ifndef DOXYGEN_NO_DETAIL size_t min_elements = detail::default_min_elements_d()) +#else + size_t min_elements = 0.3*max_elements) +#endif : m_max_elements(max_elements) , m_min_elements(detail::default_min_elements_d_calc(max_elements, min_elements)) { @@ -224,8 +246,13 @@ public: and true minimum overlap cost is calculated. Default: 32. */ dynamic_rstar(size_t max_elements, +#ifndef DOXYGEN_NO_DETAIL size_t min_elements = detail::default_min_elements_d(), size_t reinserted_elements = detail::default_rstar_reinserted_elements_d(), +#else + size_t min_elements = 0.3*max_elements, + size_t reinserted_elements = 0.3*max_elements, +#endif size_t overlap_cost_threshold = 32) : m_max_elements(max_elements) , m_min_elements(detail::default_min_elements_d_calc(max_elements, min_elements)) diff --git a/include/boost/geometry/index/predicates.hpp b/include/boost/geometry/index/predicates.hpp index 3bb1bf4d8..06323c59d 100644 --- a/include/boost/geometry/index/predicates.hpp +++ b/include/boost/geometry/index/predicates.hpp @@ -43,7 +43,11 @@ bgi::query(spatial_index, bgi::contains(box), std::back_inserter(result)); \param g The Geometry object. */ template inline +#ifndef DOXYGEN_NO_DETAIL detail::predicates::spatial_predicate +#else +unspecified +#endif contains(Geometry const& g) { return detail::predicates::spatial_predicate @@ -73,7 +77,11 @@ bgi::query(spatial_index, bgi::covered_by(box), std::back_inserter(result)); \param g The Geometry object. */ template inline +#ifndef DOXYGEN_NO_DETAIL detail::predicates::spatial_predicate +#else +unspecified +#endif covered_by(Geometry const& g) { return detail::predicates::spatial_predicate @@ -103,7 +111,11 @@ bgi::query(spatial_index, bgi::covers(box), std::back_inserter(result)); \param g The Geometry object. */ template inline +#ifndef DOXYGEN_NO_DETAIL detail::predicates::spatial_predicate +#else +unspecified +#endif covers(Geometry const& g) { return detail::predicates::spatial_predicate @@ -133,7 +145,11 @@ bgi::query(spatial_index, bgi::disjoint(box), std::back_inserter(result)); \param g The Geometry object. */ template inline +#ifndef DOXYGEN_NO_DETAIL detail::predicates::spatial_predicate +#else +unspecified +#endif disjoint(Geometry const& g) { return detail::predicates::spatial_predicate @@ -165,7 +181,11 @@ bgi::query(spatial_index, bgi::intersects(polygon), std::back_inserter(result)); \param g The Geometry object. */ template inline +#ifndef DOXYGEN_NO_DETAIL detail::predicates::spatial_predicate +#else +unspecified +#endif intersects(Geometry const& g) { return detail::predicates::spatial_predicate @@ -195,7 +215,11 @@ bgi::query(spatial_index, bgi::overlaps(box), std::back_inserter(result)); \param g The Geometry object. */ template inline +#ifndef DOXYGEN_NO_DETAIL detail::predicates::spatial_predicate +#else +unspecified +#endif overlaps(Geometry const& g) { return detail::predicates::spatial_predicate @@ -222,7 +246,11 @@ returns true. \param g The Geometry object. */ template inline +#ifndef DOXYGEN_NO_DETAIL detail::predicates::spatial_predicate +#else +unspecified +#endif touches(Geometry const& g) { return detail::predicates::spatial_predicate @@ -254,7 +282,11 @@ bgi::query(spatial_index, bgi::within(box), std::back_inserter(result)); \param g The Geometry object. */ template inline +#ifndef DOXYGEN_NO_DETAIL detail::predicates::spatial_predicate +#else +unspecified +#endif within(Geometry const& g) { return detail::predicates::spatial_predicate @@ -299,7 +331,11 @@ std::back_inserter(result)); \param pred The unary predicate function or function object. */ template inline +#ifndef DOXYGEN_NO_DETAIL detail::predicates::satisfies +#else +unspecified +#endif satisfies(UnaryPredicate const& pred) { return detail::predicates::satisfies(pred); @@ -329,7 +365,11 @@ Only one \c nearest() predicate may be used in a query. \param k The maximum number of values to return. */ template inline +#ifndef DOXYGEN_NO_DETAIL detail::predicates::nearest +#else +unspecified +#endif nearest(Geometry const& geometry, unsigned k) { return detail::predicates::nearest(geometry, k); @@ -359,7 +399,11 @@ Only one distance predicate (\c nearest() or \c path()) may be used in a query. \param k The maximum number of values to return. */ template inline +#ifndef DOXYGEN_NO_DETAIL detail::predicates::path +#else +unspecified +#endif path(SegmentOrLinestring const& linestring, unsigned k) { return detail::predicates::path(linestring, k); From 3475f339725138f296895b693bbc026de174a1a4 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Fri, 20 Mar 2015 03:39:50 +0100 Subject: [PATCH 058/146] [doc] In doxygen_xml2qbk alt output automaticaly detect details and generate output containing unspecified return type, default paramters values, etc. --- .../doxygen_xml2qbk/quickbook_output.hpp | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/doc/src/docutils/tools/doxygen_xml2qbk/quickbook_output.hpp b/doc/src/docutils/tools/doxygen_xml2qbk/quickbook_output.hpp index a7829f17e..17f20bf42 100644 --- a/doc/src/docutils/tools/doxygen_xml2qbk/quickbook_output.hpp +++ b/doc/src/docutils/tools/doxygen_xml2qbk/quickbook_output.hpp @@ -973,7 +973,11 @@ void quickbook_template_parameter_list_alt(std::vector const& paramet if ( !p.default_value.empty() ) { out << " = "; - inline_str_with_links(p.default_value, out); + // don't display default values from details + if ( p.default_value.find("detail") != std::string::npos ) + out << "/default/"; + else + inline_str_with_links(p.default_value, out); } first = false; @@ -997,7 +1001,8 @@ void quickbook_synopsis_alt(function const& f, std::ostream& out) break; case function_member : case function_free : - if ( f.return_type == "unspecified" ) + // don't display return types from details + if ( f.return_type.find("detail") != std::string::npos ) { out << "/unspecified/"; offset += 11; @@ -1042,7 +1047,11 @@ void quickbook_synopsis_alt(function const& f, std::ostream& out) if ( !p.default_value.empty() ) { out << " = "; - inline_str_with_links(p.default_value, out); + // don't display default values from details + if ( p.default_value.find("detail") != std::string::npos ) + out << "/default/"; + else + inline_str_with_links(p.default_value, out); } first = false; } @@ -1082,20 +1091,24 @@ void quickbook_synopsis_alt(class_or_struct const& cos, configuration const& con if (! cos.base_classes.empty()) { - out << "` : "; bool first = true; BOOST_FOREACH(base_class const& bc, cos.base_classes) { - if (! first) - { + // don't display base classes from details + if ( bc.name.find("detail") != std::string::npos ) + continue; + + if (first) + out << "` : "; + else out << std::endl << " , "; - } out << output_if_different(bc.derivation, "private") << output_if_different(bc.virtuality, "non-virtual") << namespace_skipped(bc.name, config); first = false; } - out << "`" << std::endl; + if (!first) + out << "`" << std::endl; } out << "`{`" << std::endl From d3f95f2cbb01f32e18d3091b25338f1cc654f2ff Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Fri, 20 Mar 2015 03:42:13 +0100 Subject: [PATCH 059/146] [index][doc] Remove manually enabled doxygen code for details since now it should be automatically generated. --- doc/index/Doxyfile | 3 +- .../boost/geometry/index/adaptors/query.hpp | 4 -- include/boost/geometry/index/equal_to.hpp | 2 - include/boost/geometry/index/indexable.hpp | 2 - include/boost/geometry/index/parameters.hpp | 32 +------------- include/boost/geometry/index/predicates.hpp | 44 ------------------- 6 files changed, 3 insertions(+), 84 deletions(-) diff --git a/doc/index/Doxyfile b/doc/index/Doxyfile index 9b59645b3..9e73dedbc 100644 --- a/doc/index/Doxyfile +++ b/doc/index/Doxyfile @@ -284,8 +284,7 @@ SEARCH_INCLUDES = YES INCLUDE_PATH = INCLUDE_FILE_PATTERNS = PREDEFINED = "BOOST_RV_REF(T)=T &&" \ - "BOOST_COPY_ASSIGN_REF(T)=T const &" \ - DOXYGEN_NO_DETAIL + "BOOST_COPY_ASSIGN_REF(T)=T const &" EXPAND_AS_DEFINED = SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- diff --git a/include/boost/geometry/index/adaptors/query.hpp b/include/boost/geometry/index/adaptors/query.hpp index f1b7ab3eb..472b3693b 100644 --- a/include/boost/geometry/index/adaptors/query.hpp +++ b/include/boost/geometry/index/adaptors/query.hpp @@ -75,11 +75,7 @@ operator|( \param pred Predicates. */ template -#ifndef DOXYGEN_NO_DETAIL detail::query -#else -unspecified -#endif queried(Predicates const& pred) { return detail::query(pred); diff --git a/include/boost/geometry/index/equal_to.hpp b/include/boost/geometry/index/equal_to.hpp index 099569be7..b0cf098f1 100644 --- a/include/boost/geometry/index/equal_to.hpp +++ b/include/boost/geometry/index/equal_to.hpp @@ -235,9 +235,7 @@ other types using operator==. */ template struct equal_to -#ifndef DOXYGEN_NO_DETAIL : detail::equal_to -#endif { /*! \brief The type of result returned by function object. */ typedef typename detail::equal_to::result_type result_type; diff --git a/include/boost/geometry/index/indexable.hpp b/include/boost/geometry/index/indexable.hpp index ed6669689..391b544f3 100644 --- a/include/boost/geometry/index/indexable.hpp +++ b/include/boost/geometry/index/indexable.hpp @@ -195,9 +195,7 @@ and variadic templates are supported. */ template struct indexable -#ifndef DOXYGEN_NO_DETAIL : detail::indexable -#endif { /*! \brief The type of result returned by function object. It should be const Indexable reference. */ typedef typename detail::indexable::result_type result_type; diff --git a/include/boost/geometry/index/parameters.hpp b/include/boost/geometry/index/parameters.hpp index e94da1163..2b9490768 100644 --- a/include/boost/geometry/index/parameters.hpp +++ b/include/boost/geometry/index/parameters.hpp @@ -70,12 +70,7 @@ inline size_t default_rstar_reinserted_elements_d_calc(size_t max_elements, size \tparam MinElements Minimum number of elements in nodes. Default: 0.3*Max. */ template ::value -#else - size_t MinElements = 0.3*MaxElements -#endif -> + size_t MinElements = detail::default_min_elements_s::value> struct linear { BOOST_MPL_ASSERT_MSG((0 < MinElements && 2*MinElements <= MaxElements+1), @@ -95,12 +90,7 @@ struct linear \tparam MinElements Minimum number of elements in nodes. Default: 0.3*Max. */ template ::value -#else - size_t MinElements = 0.3*MaxElements -#endif -> + size_t MinElements = detail::default_min_elements_s::value> struct quadratic { BOOST_MPL_ASSERT_MSG((0 < MinElements && 2*MinElements <= MaxElements+1), @@ -128,13 +118,8 @@ struct quadratic and true minimum overlap cost is calculated. Default: 32. */ template ::value, size_t ReinsertedElements = detail::default_rstar_reinserted_elements_s::value, -#else - size_t MinElements = 0.3*MaxElements, - size_t ReinsertedElements = 0.3*MaxElements, -#endif size_t OverlapCostThreshold = 32> struct rstar { @@ -172,11 +157,7 @@ public: \param min_elements Minimum number of elements in nodes. Default: 0.3*Max. */ dynamic_linear(size_t max_elements, -#ifndef DOXYGEN_NO_DETAIL size_t min_elements = detail::default_min_elements_d()) -#else - size_t min_elements = 0.3*max_elements) -#endif : m_max_elements(max_elements) , m_min_elements(detail::default_min_elements_d_calc(max_elements, min_elements)) { @@ -205,11 +186,7 @@ public: \param min_elements Minimum number of elements in nodes. Default: 0.3*Max. */ dynamic_quadratic(size_t max_elements, -#ifndef DOXYGEN_NO_DETAIL size_t min_elements = detail::default_min_elements_d()) -#else - size_t min_elements = 0.3*max_elements) -#endif : m_max_elements(max_elements) , m_min_elements(detail::default_min_elements_d_calc(max_elements, min_elements)) { @@ -246,13 +223,8 @@ public: and true minimum overlap cost is calculated. Default: 32. */ dynamic_rstar(size_t max_elements, -#ifndef DOXYGEN_NO_DETAIL size_t min_elements = detail::default_min_elements_d(), size_t reinserted_elements = detail::default_rstar_reinserted_elements_d(), -#else - size_t min_elements = 0.3*max_elements, - size_t reinserted_elements = 0.3*max_elements, -#endif size_t overlap_cost_threshold = 32) : m_max_elements(max_elements) , m_min_elements(detail::default_min_elements_d_calc(max_elements, min_elements)) diff --git a/include/boost/geometry/index/predicates.hpp b/include/boost/geometry/index/predicates.hpp index 06323c59d..3bb1bf4d8 100644 --- a/include/boost/geometry/index/predicates.hpp +++ b/include/boost/geometry/index/predicates.hpp @@ -43,11 +43,7 @@ bgi::query(spatial_index, bgi::contains(box), std::back_inserter(result)); \param g The Geometry object. */ template inline -#ifndef DOXYGEN_NO_DETAIL detail::predicates::spatial_predicate -#else -unspecified -#endif contains(Geometry const& g) { return detail::predicates::spatial_predicate @@ -77,11 +73,7 @@ bgi::query(spatial_index, bgi::covered_by(box), std::back_inserter(result)); \param g The Geometry object. */ template inline -#ifndef DOXYGEN_NO_DETAIL detail::predicates::spatial_predicate -#else -unspecified -#endif covered_by(Geometry const& g) { return detail::predicates::spatial_predicate @@ -111,11 +103,7 @@ bgi::query(spatial_index, bgi::covers(box), std::back_inserter(result)); \param g The Geometry object. */ template inline -#ifndef DOXYGEN_NO_DETAIL detail::predicates::spatial_predicate -#else -unspecified -#endif covers(Geometry const& g) { return detail::predicates::spatial_predicate @@ -145,11 +133,7 @@ bgi::query(spatial_index, bgi::disjoint(box), std::back_inserter(result)); \param g The Geometry object. */ template inline -#ifndef DOXYGEN_NO_DETAIL detail::predicates::spatial_predicate -#else -unspecified -#endif disjoint(Geometry const& g) { return detail::predicates::spatial_predicate @@ -181,11 +165,7 @@ bgi::query(spatial_index, bgi::intersects(polygon), std::back_inserter(result)); \param g The Geometry object. */ template inline -#ifndef DOXYGEN_NO_DETAIL detail::predicates::spatial_predicate -#else -unspecified -#endif intersects(Geometry const& g) { return detail::predicates::spatial_predicate @@ -215,11 +195,7 @@ bgi::query(spatial_index, bgi::overlaps(box), std::back_inserter(result)); \param g The Geometry object. */ template inline -#ifndef DOXYGEN_NO_DETAIL detail::predicates::spatial_predicate -#else -unspecified -#endif overlaps(Geometry const& g) { return detail::predicates::spatial_predicate @@ -246,11 +222,7 @@ returns true. \param g The Geometry object. */ template inline -#ifndef DOXYGEN_NO_DETAIL detail::predicates::spatial_predicate -#else -unspecified -#endif touches(Geometry const& g) { return detail::predicates::spatial_predicate @@ -282,11 +254,7 @@ bgi::query(spatial_index, bgi::within(box), std::back_inserter(result)); \param g The Geometry object. */ template inline -#ifndef DOXYGEN_NO_DETAIL detail::predicates::spatial_predicate -#else -unspecified -#endif within(Geometry const& g) { return detail::predicates::spatial_predicate @@ -331,11 +299,7 @@ std::back_inserter(result)); \param pred The unary predicate function or function object. */ template inline -#ifndef DOXYGEN_NO_DETAIL detail::predicates::satisfies -#else -unspecified -#endif satisfies(UnaryPredicate const& pred) { return detail::predicates::satisfies(pred); @@ -365,11 +329,7 @@ Only one \c nearest() predicate may be used in a query. \param k The maximum number of values to return. */ template inline -#ifndef DOXYGEN_NO_DETAIL detail::predicates::nearest -#else -unspecified -#endif nearest(Geometry const& geometry, unsigned k) { return detail::predicates::nearest(geometry, k); @@ -399,11 +359,7 @@ Only one distance predicate (\c nearest() or \c path()) may be used in a query. \param k The maximum number of values to return. */ template inline -#ifndef DOXYGEN_NO_DETAIL detail::predicates::path -#else -unspecified -#endif path(SegmentOrLinestring const& linestring, unsigned k) { return detail::predicates::path(linestring, k); From c11f58f08d9be6279024c77b40f818ef39d23537 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Fri, 20 Mar 2015 13:49:09 +0100 Subject: [PATCH 060/146] [test] add bigobj for all tests on MSVC This should fix new failures on wkt, point_on_surface, assemble. get_turns and several others, which appear as of March 2015 on MSVC 14 and 11 now --- test/Jamfile.v2 | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 6963a0575..b49361e55 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -16,6 +16,7 @@ project boost-geometry-test . ../../../boost/geometry/extensions/contrib/ttmath msvc:on + msvc:/bigobj clang:-Wno-unneeded-internal-declaration # supress warning by Boost.None ; From a50c92e510f020519658f8a61108cce08ae93bba Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Fri, 20 Mar 2015 14:16:46 +0100 Subject: [PATCH 061/146] [example] Fix compilation errors in examples. --- example/c03_custom_linestring_example.cpp | 2 -- example/c10_custom_cs_example.cpp | 8 ++------ example/c11_custom_cs_transform_example.cpp | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/example/c03_custom_linestring_example.cpp b/example/c03_custom_linestring_example.cpp index 8c6fd3697..587695749 100644 --- a/example/c03_custom_linestring_example.cpp +++ b/example/c03_custom_linestring_example.cpp @@ -18,8 +18,6 @@ #include #include -// To register the 'geographic' distance function to calculate distance over the earth: -#include #include // Define a GPS point with coordinates in latitude/longitude and some additional values diff --git a/example/c10_custom_cs_example.cpp b/example/c10_custom_cs_example.cpp index 098916cd6..3a802cc79 100644 --- a/example/c10_custom_cs_example.cpp +++ b/example/c10_custom_cs_example.cpp @@ -14,10 +14,6 @@ #include -#ifdef OPTIONALLY_ELLIPSOIDAL // see below -#include -#endif - // 1: declare a coordinate system. For example for Mars // Like for the Earth, we let the use choose between degrees or radians // (Unfortunately, in real life Mars has two coordinate systems: @@ -54,7 +50,7 @@ namespace boost { namespace geometry { namespace strategy { namespace distance { { template -struct default_strategy +struct default_strategy { typedef haversine type; }; @@ -98,7 +94,7 @@ int main() // giving 834.444 km d = boost::geometry::distance(viking1, pathfinder, boost::geometry::strategy::distance::andoyer - (boost::geometry::detail::ellipsoid(3396.2, 3376.2))); + (boost::geometry::srs::spheroid(3396.2, 3376.2))); std::cout << "Ellipsoidal distance: " << d << " km" << std::endl; #endif diff --git a/example/c11_custom_cs_transform_example.cpp b/example/c11_custom_cs_transform_example.cpp index 84c94eb06..b6878b6e7 100644 --- a/example/c11_custom_cs_transform_example.cpp +++ b/example/c11_custom_cs_transform_example.cpp @@ -90,7 +90,7 @@ namespace boost { namespace geometry { namespace strategy { namespace distance { }; template <> - struct default_strategy + struct default_strategy { typedef shift_and_calc_distance type; }; From 37429b3234899fd1b5825eb45b2d6bf0e380d3d2 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Fri, 20 Mar 2015 18:04:50 +0100 Subject: [PATCH 062/146] [test] Fix select_most_precise test for Android. On this platform sizeof(long double) == sizeof(double). Conditionally test the combination of those types only if long double is greater. --- test/util/select_most_precise.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/test/util/select_most_precise.cpp b/test/util/select_most_precise.cpp index ec93b5f25..3ec2dec73 100644 --- a/test/util/select_most_precise.cpp +++ b/test/util/select_most_precise.cpp @@ -27,11 +27,11 @@ void test() bool is_same = boost::is_same::type::value; BOOST_CHECK_MESSAGE(is_same, - "The most precise of types " + "The most precise of types " << "T1: {" << typeid(T1).name() << " | s: " << sizeof(T1) << "}" << - " and " + " and " << "T2: {" << typeid(T2).name() << " | s: " << sizeof(T2) << "}" << - " does not match " + " does not match " << "ExpectedType: {" << typeid(ExpectedType).name() << " | s: " << sizeof(ExpectedType) << "}"); } @@ -56,11 +56,13 @@ int test_main(int, char* []) test(); test(); -#ifndef _MSC_VER - // This cannot be done for MSVC because double/long double is the same - test(); - test(); -#endif + if ( sizeof(long double) > sizeof(double) ) + { + // This cannot be done for MSVC because double/long double is the same + // This is also true for Android + test(); + test(); + } // with any other non-integer/float class test(); From aac92cbd9312aff11624ac39dd95d2f574a4e94d Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Sun, 22 Mar 2015 17:11:36 +0200 Subject: [PATCH 063/146] [extensions][ttmath] rename fmod() free function to mod() --- include/boost/geometry/extensions/contrib/ttmath_stub.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/boost/geometry/extensions/contrib/ttmath_stub.hpp b/include/boost/geometry/extensions/contrib/ttmath_stub.hpp index 5840a9eea..ffe68a729 100644 --- a/include/boost/geometry/extensions/contrib/ttmath_stub.hpp +++ b/include/boost/geometry/extensions/contrib/ttmath_stub.hpp @@ -107,9 +107,10 @@ namespace ttmath return two * ATan((sqrt(x * x + y * y) - x) / y); } - // needed in order to work with boost::geometry::math::fmod + // needed in order to work with boost::geometry::math::mod template - inline Big fmod(Big const& x, Big const& y) + inline Big mod(Big const& x, + Big const& y) { return Mod(x, y); } From 90fcd83f30f935fbf972ee1b4a5b98974e69c990 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Sat, 21 Mar 2015 13:03:42 +0100 Subject: [PATCH 064/146] [test] Remove bigobj flag from Jamfiles now that it is defined in the upper level --- test/algorithms/Jamfile.v2 | 22 +++++++++---------- test/algorithms/buffer/Jamfile.v2 | 16 +++++++------- test/algorithms/distance/Jamfile.v2 | 6 ++--- test/algorithms/overlay/Jamfile.v2 | 2 +- .../relational_operations/Jamfile.v2 | 20 ++++++++--------- .../relational_operations/disjoint/Jamfile.v2 | 6 ++--- .../relational_operations/relate/Jamfile.v2 | 8 +++---- .../relational_operations/within/Jamfile.v2 | 12 +++++----- .../set_operations/difference/Jamfile.v2 | 6 ++--- .../set_operations/intersection/Jamfile.v2 | 4 ++-- .../set_operations/union/Jamfile.v2 | 4 ++-- 11 files changed, 53 insertions(+), 53 deletions(-) diff --git a/test/algorithms/Jamfile.v2 b/test/algorithms/Jamfile.v2 index e6bd3512f..5fd0e3c04 100644 --- a/test/algorithms/Jamfile.v2 +++ b/test/algorithms/Jamfile.v2 @@ -16,21 +16,21 @@ test-suite boost-geometry-algorithms : - [ run append.cpp : : : msvc:/bigobj ] - [ run area.cpp : : : msvc:/bigobj ] + [ run append.cpp ] + [ run area.cpp ] [ run assign.cpp ] [ run buffer.cpp ] - [ run centroid.cpp : : : msvc:/bigobj ] - [ run comparable_distance.cpp : : : msvc:/bigobj ] - [ run convex_hull.cpp : : : msvc:/bigobj ] - [ run correct.cpp : : : msvc:/bigobj ] - [ run convert.cpp : : : msvc:/bigobj ] - [ run envelope.cpp : : : msvc:/bigobj ] + [ run centroid.cpp ] + [ run comparable_distance.cpp ] + [ run convex_hull.cpp ] + [ run correct.cpp ] + [ run convert.cpp ] + [ run envelope.cpp ] [ run expand.cpp ] [ run for_each.cpp ] - [ run is_simple.cpp : : : msvc:/bigobj ] - [ run is_valid.cpp : : : msvc:/bigobj ] - [ run is_valid_failure.cpp : : : msvc:/bigobj ] + [ run is_simple.cpp ] + [ run is_valid.cpp ] + [ run is_valid_failure.cpp ] [ run length.cpp ] [ run make.cpp ] [ run multi_area.cpp ] diff --git a/test/algorithms/buffer/Jamfile.v2 b/test/algorithms/buffer/Jamfile.v2 index 125c600db..c7a37a646 100644 --- a/test/algorithms/buffer/Jamfile.v2 +++ b/test/algorithms/buffer/Jamfile.v2 @@ -14,13 +14,13 @@ project boost-geometry-algorithms-buffer test-suite boost-geometry-algorithms-buffer : - [ run point_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] - [ run linestring_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] - [ run polygon_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] - [ run multi_point_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] - [ run multi_linestring_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] - [ run multi_polygon_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] - [ run aimes_linestring_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] -# [ run country_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] # Uncomment if you want to test this manually; requires access to data/ folder + [ run point_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] + [ run linestring_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] + [ run polygon_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] + [ run multi_point_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] + [ run multi_linestring_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] + [ run multi_polygon_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] + [ run aimes_linestring_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] +# [ run country_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] # Uncomment if you want to test this manually; requires access to data/ folder ; diff --git a/test/algorithms/distance/Jamfile.v2 b/test/algorithms/distance/Jamfile.v2 index 1eb679dd7..bb76a8622 100644 --- a/test/algorithms/distance/Jamfile.v2 +++ b/test/algorithms/distance/Jamfile.v2 @@ -16,9 +16,9 @@ test-suite boost-geometry-algorithms-distance : - [ run distance.cpp : : : msvc:/bigobj ] - [ run distance_areal_areal.cpp : : : msvc:/bigobj ] - [ run distance_linear_areal.cpp : : : msvc:/bigobj ] + [ run distance.cpp ] + [ run distance_areal_areal.cpp ] + [ run distance_linear_areal.cpp ] [ run distance_linear_linear.cpp ] [ run distance_pointlike_areal.cpp ] [ run distance_pointlike_linear.cpp ] diff --git a/test/algorithms/overlay/Jamfile.v2 b/test/algorithms/overlay/Jamfile.v2 index c1758d155..fc27dbf59 100644 --- a/test/algorithms/overlay/Jamfile.v2 +++ b/test/algorithms/overlay/Jamfile.v2 @@ -16,7 +16,7 @@ test-suite boost-geometry-algorithms-overlay : [ run assemble.cpp ] - [ run ccw_traverse.cpp : : : msvc:/bigobj ] + [ run ccw_traverse.cpp ] [ run get_turn_info.cpp ] [ run get_turns.cpp ] [ run get_turns_areal_areal.cpp ] diff --git a/test/algorithms/relational_operations/Jamfile.v2 b/test/algorithms/relational_operations/Jamfile.v2 index 5b432e2e9..2c0c34c9e 100644 --- a/test/algorithms/relational_operations/Jamfile.v2 +++ b/test/algorithms/relational_operations/Jamfile.v2 @@ -16,16 +16,16 @@ test-suite boost-geometry-algorithms-relational : - [ run covered_by.cpp : : : msvc:/bigobj ] - [ run crosses.cpp : : : msvc:/bigobj ] - [ run equals.cpp : : : msvc:/bigobj ] - [ run intersects.cpp : : : msvc:/bigobj ] - [ run multi_covered_by.cpp : : : msvc:/bigobj ] - [ run multi_equals.cpp : : : msvc:/bigobj ] - [ run multi_intersects.cpp : : : msvc:/bigobj ] - [ run multi_touches.cpp : : : msvc:/bigobj ] - [ run overlaps.cpp : : : msvc:/bigobj ] - [ run touches.cpp : : : msvc:/bigobj ] + [ run covered_by.cpp ] + [ run crosses.cpp ] + [ run equals.cpp ] + [ run intersects.cpp ] + [ run multi_covered_by.cpp ] + [ run multi_equals.cpp ] + [ run multi_intersects.cpp ] + [ run multi_touches.cpp ] + [ run overlaps.cpp ] + [ run touches.cpp ] ; build-project disjoint ; diff --git a/test/algorithms/relational_operations/disjoint/Jamfile.v2 b/test/algorithms/relational_operations/disjoint/Jamfile.v2 index a2423a745..8586e9a2c 100644 --- a/test/algorithms/relational_operations/disjoint/Jamfile.v2 +++ b/test/algorithms/relational_operations/disjoint/Jamfile.v2 @@ -16,7 +16,7 @@ test-suite boost-geometry-algorithms-disjoint : - [ run disjoint.cpp : : : msvc:/bigobj ] - [ run disjoint_coverage.cpp : : : msvc:/bigobj ] - [ run multi_disjoint.cpp : : : msvc:/bigobj ] + [ run disjoint.cpp ] + [ run disjoint_coverage.cpp ] + [ run multi_disjoint.cpp ] ; diff --git a/test/algorithms/relational_operations/relate/Jamfile.v2 b/test/algorithms/relational_operations/relate/Jamfile.v2 index 871b8eb17..7e6bb61c9 100644 --- a/test/algorithms/relational_operations/relate/Jamfile.v2 +++ b/test/algorithms/relational_operations/relate/Jamfile.v2 @@ -16,8 +16,8 @@ test-suite boost-geometry-algorithms-relate : - [ run relate_areal_areal.cpp : : : msvc:/bigobj ] - [ run relate_linear_areal.cpp : : : msvc:/bigobj ] - [ run relate_linear_linear.cpp : : : msvc:/bigobj ] - [ run relate_pointlike_xxx.cpp : : : msvc:/bigobj ] + [ run relate_areal_areal.cpp ] + [ run relate_linear_areal.cpp ] + [ run relate_linear_linear.cpp ] + [ run relate_pointlike_xxx.cpp ] ; diff --git a/test/algorithms/relational_operations/within/Jamfile.v2 b/test/algorithms/relational_operations/within/Jamfile.v2 index d2a679571..dc33b40cc 100644 --- a/test/algorithms/relational_operations/within/Jamfile.v2 +++ b/test/algorithms/relational_operations/within/Jamfile.v2 @@ -16,10 +16,10 @@ test-suite boost-geometry-algorithms-within : - [ run multi_within.cpp : : : msvc:/bigobj ] - [ run within.cpp : : : msvc:/bigobj ] - [ run within_areal_areal.cpp : : : msvc:/bigobj ] - [ run within_linear_areal.cpp : : : msvc:/bigobj ] - [ run within_linear_linear.cpp : : : msvc:/bigobj ] - [ run within_pointlike_xxx.cpp : : : msvc:/bigobj ] + [ run multi_within.cpp ] + [ run within.cpp ] + [ run within_areal_areal.cpp ] + [ run within_linear_areal.cpp ] + [ run within_linear_linear.cpp ] + [ run within_pointlike_xxx.cpp ] ; diff --git a/test/algorithms/set_operations/difference/Jamfile.v2 b/test/algorithms/set_operations/difference/Jamfile.v2 index 2903d9cc5..8bbbbbdc6 100644 --- a/test/algorithms/set_operations/difference/Jamfile.v2 +++ b/test/algorithms/set_operations/difference/Jamfile.v2 @@ -16,9 +16,9 @@ test-suite boost-geometry-algorithms-difference : - [ run difference.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] + [ run difference.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] [ run difference_linear_linear.cpp ] [ run difference_pl_pl.cpp ] - [ run multi_difference.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] - [ run multi_difference_spike.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] + [ run multi_difference.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] + [ run multi_difference_spike.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] ; diff --git a/test/algorithms/set_operations/intersection/Jamfile.v2 b/test/algorithms/set_operations/intersection/Jamfile.v2 index c039b1664..b21302819 100644 --- a/test/algorithms/set_operations/intersection/Jamfile.v2 +++ b/test/algorithms/set_operations/intersection/Jamfile.v2 @@ -16,8 +16,8 @@ test-suite boost-geometry-algorithms-intersection : - [ run intersection.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] + [ run intersection.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] [ run intersection_linear_linear.cpp ] [ run intersection_pl_pl.cpp ] - [ run multi_intersection.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] + [ run multi_intersection.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] ; diff --git a/test/algorithms/set_operations/union/Jamfile.v2 b/test/algorithms/set_operations/union/Jamfile.v2 index d4df3ea5c..1f6b4f17e 100644 --- a/test/algorithms/set_operations/union/Jamfile.v2 +++ b/test/algorithms/set_operations/union/Jamfile.v2 @@ -16,8 +16,8 @@ test-suite boost-geometry-algorithms-union : - [ run multi_union.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] - [ run union.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] + [ run multi_union.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] + [ run union.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] [ run union_linear_linear.cpp ] [ run union_pl_pl.cpp ] ; From bd7b7da0008de4584a5442254b0256baf66896dc Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Mon, 23 Mar 2015 17:27:14 +0100 Subject: [PATCH 065/146] [index][doc] Small docs improvements. --- doc/index/introduction.qbk | 4 +++- include/boost/geometry/index/rtree.hpp | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/index/introduction.qbk b/doc/index/introduction.qbk index daf2e39f3..e0c5b03e0 100644 --- a/doc/index/introduction.qbk +++ b/doc/index/introduction.qbk @@ -56,8 +56,10 @@ The examples of structures of trees created by use of different algorithms and e [[*100k knn queries*] [6.37s] [2.09s] [0.64s] [0.52s]] ] +The configuration of the machine used for testing was: /Intel(R) Core(TM) i7 870 @ 2.93GHz, 8GB RAM, MS Windows 7 x64/. +The code was compiled with optimization for speed (`O2`). + The performance of the R-tree for different values of Max parameter and Min=0.5*Max is presented in the table below. -The configuration of the machine used for testing is: /Intel(R) Core(TM) i7 870 @ 2.93GHz, 8GB RAM, MS Windows 7 x64/. In the two upper figures you can see the performance of the __rtree__ storing random, relatively small, non-overlapping, 2d boxes. In the lower ones, the performance of the __rtree__ also storing random, 2d boxes, but this time quite big and possibly overlapping. As you can see, the __rtree__ performance is different in both cases. diff --git a/include/boost/geometry/index/rtree.hpp b/include/boost/geometry/index/rtree.hpp index 1d65ceabf..b0117be43 100644 --- a/include/boost/geometry/index/rtree.hpp +++ b/include/boost/geometry/index/rtree.hpp @@ -126,7 +126,8 @@ container, the default IndexableGetter translates from std::pair c \par EqualTo The object of EqualTo type compares Values and returns true if they're equal. It's similar to std::equal_to<>. The default EqualTo returns the result of boost::geometry::equals() for types adapted to some Geometry concept -defined in Boost.Geometry and the result of operator= for other types. Components of Pairs and Tuples are compared left-to-right. +defined in Boost.Geometry and the result of operator== for other types. +Components of Pairs and Tuples are compared left-to-right. \tparam Value The type of objects stored in the container. \tparam Parameters Compile-time parameters. From efeb592d803e19b43a3c2265c67d88b4b81cc784 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Mon, 23 Mar 2015 17:53:08 +0100 Subject: [PATCH 066/146] [index][doc] Improve the rtree description. --- include/boost/geometry/index/rtree.hpp | 36 ++++++++++++++++---------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/include/boost/geometry/index/rtree.hpp b/include/boost/geometry/index/rtree.hpp index b0117be43..e9ef1a85c 100644 --- a/include/boost/geometry/index/rtree.hpp +++ b/include/boost/geometry/index/rtree.hpp @@ -96,12 +96,13 @@ namespace boost { namespace geometry { namespace index { /*! \brief The R-tree spatial index. -This is self-balancing spatial index capable to store various types of Values and balancing algorithms. +This is self-balancing spatial index capable to store various types of Values +and balancing algorithms. \par Parameters The user must pass a type defining the Parameters which will -be used in rtree creation process. This type is used e.g. to specify balancing algorithm -with specific parameters like min and max number of elements in node. +be used in rtree creation process. This type is used e.g. to specify balancing +algorithm with specific parameters like min and max number of elements in node. \par Predefined algorithms with compile-time parameters are: @@ -116,24 +117,31 @@ Predefined algorithms with run-time parameters are: \li \c boost::geometry::index::dynamic_rstar. \par IndexableGetter -The object of IndexableGetter type translates from Value to Indexable each time r-tree requires it. Which means that this -operation is done for each Value access. Therefore the IndexableGetter should return the Indexable by -const reference instead of a value. Default one can translate all types adapted to Point, Box or Segment -concepts (called Indexables). It also handles std::pair and -boost::tuple. For example, if std::pair is stored in the -container, the default IndexableGetter translates from std::pair const& to Box const&. +The object of IndexableGetter type translates from Value to Indexable each time +r-tree requires it. This means that this operation is done for each Value +access. Therefore the IndexableGetter should return the Indexable by +a reference type. The Indexable should not be calculated since it could harm +the performance. The default IndexableGetter can translate all types adapted +to Point, Box or Segment concepts (called Indexables). Furthermore, it can +handle std::pair, boost::tuple +and std::tuple when possible. For example, for Value +of type std::pair, the default IndexableGetter translates +from std::pair const& to Box const&. \par EqualTo -The object of EqualTo type compares Values and returns true if they're equal. It's similar to std::equal_to<>. -The default EqualTo returns the result of boost::geometry::equals() for types adapted to some Geometry concept -defined in Boost.Geometry and the result of operator== for other types. -Components of Pairs and Tuples are compared left-to-right. +The object of EqualTo type compares Values and returns true if they +are equal. It's similar to std::equal_to<>. The default EqualTo +returns the result of boost::geometry::equals() for types adapted to +some Geometry concept defined in Boost.Geometry and the result of +operator== for other types. Components of Pairs and Tuples are +compared left-to-right. \tparam Value The type of objects stored in the container. \tparam Parameters Compile-time parameters. \tparam IndexableGetter The function object extracting Indexable from Value. \tparam EqualTo The function object comparing objects of type Value. -\tparam Allocator The allocator used to allocate/deallocate memory, construct/destroy nodes and Values. +\tparam Allocator The allocator used to allocate/deallocate memory, + construct/destroy nodes and Values. */ template < typename Value, From 0115da1dd33ca8e1ee989e0e87b3f0cf8446111a Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Tue, 24 Mar 2015 01:23:08 +0100 Subject: [PATCH 067/146] [relate] Rename check() to more specific check_element() and check_matrix(). --- .../geometry/algorithms/detail/relate/result.hpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/relate/result.hpp b/include/boost/geometry/algorithms/detail/relate/result.hpp index c32877852..e26bda67f 100644 --- a/include/boost/geometry/algorithms/detail/relate/result.hpp +++ b/include/boost/geometry/algorithms/detail/relate/result.hpp @@ -236,11 +236,11 @@ struct interrupt_dispatch static inline bool apply(Mask const& mask) { char m = mask.template get(); - return check(m); + return check_element(m); } template - static inline bool check(char m) + static inline bool check_element(char m) { if ( BOOST_GEOMETRY_CONDITION(V >= '0' && V <= '9') ) { @@ -395,7 +395,7 @@ inline bool may_update(Mask const& mask, Matrix const& matrix) ::template apply(mask, matrix); } -// check() +// check_matrix() template struct check_dispatch @@ -486,7 +486,7 @@ struct check_dispatch< boost::tuples::cons > }; template -inline bool check(Mask const& mask, Matrix const& matrix) +inline bool check_matrix(Mask const& mask, Matrix const& matrix) { return check_dispatch::apply(mask, matrix); } @@ -547,7 +547,7 @@ public: result_type result() const { return !interrupt - && check(m_mask, static_cast(*this)); + && check_matrix(m_mask, static_cast(*this)); } template @@ -965,7 +965,7 @@ struct static_check_dispatch }; template -struct static_check +struct static_check_matrix { template static inline bool apply(Matrix const& matrix) @@ -998,7 +998,7 @@ public: result_type result() const { return (!Interrupt || !interrupt) - && static_check:: + && static_check_matrix:: apply(static_cast(*this)); } From 4ecb44389196fdf351c1fb3524aaf6b7598825a4 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Tue, 24 Mar 2015 01:25:50 +0100 Subject: [PATCH 068/146] [test] Add /bigobj compiler flag for all tests run on windows with intel compiler. --- index/test/Jamfile.v2 | 4 +++- index/test/rtree/exceptions/Jamfile.v2 | 1 + index/test/rtree/generated/Jamfile.v2 | 1 + index/test/rtree/interprocess/Jamfile.v2 | 3 ++- test/Jamfile.v2 | 1 + 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/index/test/Jamfile.v2 b/index/test/Jamfile.v2 index fc45a830e..f19f6834c 100644 --- a/index/test/Jamfile.v2 +++ b/index/test/Jamfile.v2 @@ -15,13 +15,15 @@ project boost-geometry-index-test ../../test # libs/geometry/test #../../../../boost/geometry/extensions/contrib/ttmath msvc:on + msvc:/bigobj + windows,intel:/bigobj /boost/timer//boost_timer ; test-suite boost-geometry-index-varray : [ run varray_old.cpp ] - [ run varray.cpp : : : msvc:/bigobj ] + [ run varray.cpp ] ; build-project algorithms ; diff --git a/index/test/rtree/exceptions/Jamfile.v2 b/index/test/rtree/exceptions/Jamfile.v2 index 1728b245b..84855c4fd 100644 --- a/index/test/rtree/exceptions/Jamfile.v2 +++ b/index/test/rtree/exceptions/Jamfile.v2 @@ -17,6 +17,7 @@ rule test_all : # test-files : # requirements msvc:/bigobj + windows,intel:/bigobj ] ; } diff --git a/index/test/rtree/generated/Jamfile.v2 b/index/test/rtree/generated/Jamfile.v2 index f3900741b..a5a6f3e41 100644 --- a/index/test/rtree/generated/Jamfile.v2 +++ b/index/test/rtree/generated/Jamfile.v2 @@ -17,6 +17,7 @@ rule test_all : # test-files : # requirements msvc:/bigobj + windows,intel:/bigobj ] ; } diff --git a/index/test/rtree/interprocess/Jamfile.v2 b/index/test/rtree/interprocess/Jamfile.v2 index f5b9de66c..1a52eb953 100644 --- a/index/test/rtree/interprocess/Jamfile.v2 +++ b/index/test/rtree/interprocess/Jamfile.v2 @@ -23,7 +23,8 @@ rule test_all gcc,windows:"-lole32 -loleaut32 -lpsapi -ladvapi32" windows,clang:"-lole32 -loleaut32 -lpsapi -ladvapi32" msvc:/bigobj - linux:"-lrt" + windows,intel:/bigobj + linux:"-lrt" ] ; } diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index b49361e55..7ba3fa4b6 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -18,6 +18,7 @@ project boost-geometry-test msvc:on msvc:/bigobj clang:-Wno-unneeded-internal-declaration # supress warning by Boost.None + windows,intel:/bigobj ; build-project core ; From e48c80fbeb30a43eae1cb816001e8979a20323a2 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Tue, 24 Mar 2015 03:20:44 +0100 Subject: [PATCH 069/146] [doc] Update 1.58 release notes (tickets and bugs). --- doc/release_notes.qbk | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/release_notes.qbk b/doc/release_notes.qbk index 57dd261b0..a778e4664 100644 --- a/doc/release_notes.qbk +++ b/doc/release_notes.qbk @@ -37,8 +37,11 @@ [*Solved tickets] +* [@https://svn.boost.org/trac/boost/ticket/8379 8379] Invalid comparison of the result of determinant * [@https://svn.boost.org/trac/boost/ticket/10108 10108] Error in overlay operations in specific cases where geometries touch at one point +* [@https://svn.boost.org/trac/boost/ticket/10201 10201] Suggestion to use different function to compare coordinates [wontfix] * [@https://svn.boost.org/trac/boost/ticket/10467 10467] Template parameter name coliding with B0 macro name defined in termios.h +* [@https://svn.boost.org/trac/boost/ticket/10640 10640] Invalid result of buffer() for CCW Polygons. * [@https://svn.boost.org/trac/boost/ticket/10666 10666] MSVC compiler warning C4127: conditional expression is constant * [@https://svn.boost.org/trac/boost/ticket/10747 10747] Error in rescaling causing errors in areal/areal set operations * [@https://svn.boost.org/trac/boost/ticket/10770 10770] Buffer fails for large distances, or rough round joins, where concavities where not intersected properly @@ -48,11 +51,13 @@ * [@https://svn.boost.org/trac/boost/ticket/10890 10890] Invalid result of disjoint() for Point/Segment. * [@https://svn.boost.org/trac/boost/ticket/10904 10904] Invalid calculation of most significant Dimension of a segment in relate_cartesian_segments strategy * [@https://svn.boost.org/trac/boost/ticket/10912 10912] Invalid result of within() and relate() for Areal/Areal +* [@https://svn.boost.org/trac/boost/ticket/10951 10951] Tests failing on windows with intel compiler due to lack of /bigobj flag. * [@https://svn.boost.org/trac/boost/ticket/10957 10957] Assertion failure and invalid results of various relational operations. * [@https://svn.boost.org/trac/boost/ticket/10958 10958] Invalid results of disjoint() L/L and L/A. * [@https://svn.boost.org/trac/boost/ticket/10959 10959] Assertion failure in get_turns() used with no_rescale_policy. * [@https://svn.boost.org/trac/boost/ticket/10960 10960] Invalid result of get_turns() for L/A, missing turn. * [@https://svn.boost.org/trac/boost/ticket/10961 10961] Invalid result of get_turns() for L/A, invalid turn for a Linear spike. +* [@https://svn.boost.org/trac/boost/ticket/11112 11112] Compilation failure on Solaris due to a CS name clash (used for a macro on this platform) [*Bugfixes] @@ -68,6 +73,8 @@ * Bug in buffers for interior rings with large negative buffer distances * Bug in closing_iterator not working properly when the input range is empty * Bug in is_simple, not handling properly closed simple linestrings within multilinestrings +* Bug in rtree constructors taking a pair of Iterators or a Range (packing algorithm), the use of reference to destroyed temporary when Iterator's reference is not true reference, e.g. for some of the Range Adaptors. It also affects distance() and comparable_distance(). This bug may cause unexpected behavior of the rtree or distance() algorithm, e.g. an assertion failure or a SEGFAULT. +* Bugs related to the handling of Ranges, preventing compilation of Geometries using non-Container Ranges in some algorithms (thanks to Samuel Debionne) [/=================] [heading Boost 1.57] From e191a5f562e42d36d054a2a1291198b44310c2f0 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Tue, 24 Mar 2015 09:50:43 +0200 Subject: [PATCH 070/146] [test][strategies][douglas peucker] make case ID argument the first argument of tester; include a label in the case id; --- test/strategies/douglas_peucker.cpp | 97 ++++++++++++++++------------- 1 file changed, 54 insertions(+), 43 deletions(-) diff --git a/test/strategies/douglas_peucker.cpp b/test/strategies/douglas_peucker.cpp index 3306dbcc4..c1705dab1 100644 --- a/test/strategies/douglas_peucker.cpp +++ b/test/strategies/douglas_peucker.cpp @@ -168,11 +168,11 @@ template struct test_one_case { template - static inline void apply(std::string const& wkt, + static inline void apply(std::string const& case_id, + std::string const& wkt, double max_distance, Strategy const& strategy, - Range const& expected_result, - std::string const& case_id) + Range const& expected_result) { typedef typename bg::point_type::type point_type; std::vector result; @@ -218,7 +218,7 @@ struct test_one_case template -inline void test_with_strategy() +inline void test_with_strategy(std::string label) { std::cout.precision(20); Strategy strategy; @@ -228,45 +228,52 @@ inline void test_with_strategy() typedef bg::model::segment segment_type; typedef test_one_case tester; + label = " (" + label + ")"; + { point_type const p1(-6,-13), p2(0,-15); segment_type const s(point_type(12,-3), point_type(-12,5)); if (bg::comparable_distance(p1, s) >= bg::comparable_distance(p2, s)) { - tester::apply("LINESTRING(12 -3, 4 8,-6 -13,-9 4,0 -15,-12 5)", + tester::apply("l01c1" + label, + "LINESTRING(12 -3, 4 8,-6 -13,-9 4,0 -15,-12 5)", 10, strategy, - ba::tuple_list_of(12,-3)(4,8)(-6,-13)(-12,5), - "l01"); + ba::tuple_list_of(12,-3)(4,8)(-6,-13)(-12,5) + ); } else { - tester::apply("LINESTRING(12 -3, 4 8,-6 -13,-9 4,0 -15,-12 5)", + tester::apply("l01c2" + label, + "LINESTRING(12 -3, 4 8,-6 -13,-9 4,0 -15,-12 5)", 10, strategy, - ba::tuple_list_of(12,-3)(4,8)(-6,-13)(-9,4)(0,-15)(-12,5), - "l01"); + ba::tuple_list_of(12,-3)(4,8)(-6,-13)(-9,4)(0,-15)(-12,5) + ); } } - tester::apply("LINESTRING(-6 -13,-9 4,0 -15,-12 5)", + tester::apply("l02" + label, + "LINESTRING(-6 -13,-9 4,0 -15,-12 5)", 10, strategy, - ba::tuple_list_of(-6,-13)(-12,5), - "l02"); + ba::tuple_list_of(-6,-13)(-12,5) + ); - tester::apply("LINESTRING(12 -3, 4 8,-6 -13,-9 4,0 -14,-12 5)", + tester::apply("l03" + label, + "LINESTRING(12 -3, 4 8,-6 -13,-9 4,0 -14,-12 5)", 10, strategy, - ba::tuple_list_of(12,-3)(4,8)(-6,-13)(-12,5), - "l03"); + ba::tuple_list_of(12,-3)(4,8)(-6,-13)(-12,5) + ); - tester::apply("LINESTRING(12 -3, 4 8,-6 -13,-9 4,0 -14,-12 5)", + tester::apply("l04" + label, + "LINESTRING(12 -3, 4 8,-6 -13,-9 4,0 -14,-12 5)", 14, strategy, - ba::tuple_list_of(12,-3)(-6,-13)(-12,5), - "l04"); + ba::tuple_list_of(12,-3)(-6,-13)(-12,5) + ); { segment_type const s(point_type(0,-1), point_type(5,-4)); @@ -308,29 +315,33 @@ inline void test_with_strategy() if (bg::comparable_distance(p1, s) >= bg::comparable_distance(p2, s)) { - tester::apply(wkt, + tester::apply("l05c1" + label, + wkt, 1, strategy, - ba::tuple_list_of(0,0)(5,0)(0,-1)(5,-1)(0,-2)(5,-2)(0,-3)(5,-4)(0,0), - "l05"); - tester::apply(wkt, + ba::tuple_list_of(0,0)(5,0)(0,-1)(5,-1)(0,-2)(5,-2)(0,-3)(5,-4)(0,0) + ); + tester::apply("l05c1a" + label, + wkt, 2, strategy, - ba::tuple_list_of(0,0)(5,0)(0,-1)(5,-1)(0,-2)(5,-4)(0,0), - "l05a"); + ba::tuple_list_of(0,0)(5,0)(0,-1)(5,-1)(0,-2)(5,-4)(0,0) + ); } else { - tester::apply(wkt, + tester::apply("l05c2" + label, + wkt, 1, strategy, - ba::tuple_list_of(0,0)(5,0)(0,-1)(5,-1)(0,-2)(5,-2)(0,-4)(5,-4)(0,0), - "l05"); - tester::apply(wkt, + ba::tuple_list_of(0,0)(5,0)(0,-1)(5,-1)(0,-2)(5,-2)(0,-4)(5,-4)(0,0) + ); + tester::apply("l05c2a" + label, + wkt, 2, strategy, - ba::tuple_list_of(0,0)(5,0)(0,-1)(5,-1)(0,-4)(5,-4)(0,0), - "l05a"); + ba::tuple_list_of(0,0)(5,0)(0,-1)(5,-1)(0,-4)(5,-4)(0,0) + ); } } @@ -346,14 +357,14 @@ inline void test_with_strategy() BOOST_AUTO_TEST_CASE( test_default_strategy ) { - test_with_strategy::type>(); - test_with_strategy::type>(); - test_with_strategy::type>(); + test_with_strategy::type>("i"); + test_with_strategy::type>("f"); + test_with_strategy::type>("d"); test_with_strategy < long double, default_simplify_strategy::type - >(); + >("ld"); } BOOST_AUTO_TEST_CASE( test_with_regular_distance_strategy ) @@ -362,24 +373,24 @@ BOOST_AUTO_TEST_CASE( test_with_regular_distance_strategy ) < int, simplify_regular_distance_strategy::type - >(); + >("i"); test_with_strategy < float, simplify_regular_distance_strategy::type - >(); + >("f"); test_with_strategy < double, simplify_regular_distance_strategy::type - >(); + >("d"); test_with_strategy < long double, simplify_regular_distance_strategy::type - >(); + >("ld"); } BOOST_AUTO_TEST_CASE( test_with_comparable_distance_strategy ) @@ -388,20 +399,20 @@ BOOST_AUTO_TEST_CASE( test_with_comparable_distance_strategy ) < int, simplify_comparable_distance_strategy::type - >(); + >("i"); test_with_strategy < float, simplify_comparable_distance_strategy::type - >(); + >("f"); test_with_strategy < double, simplify_comparable_distance_strategy::type - >(); + >("d"); test_with_strategy < long double, simplify_comparable_distance_strategy::type - >(); + >("ld"); } From 2ecf727c22b958096fdc1c1b741511fca781af8e Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Tue, 24 Mar 2015 10:01:41 +0200 Subject: [PATCH 071/146] [test][strategies][douglas peucker] print both expected and detected output using the same format --- test/strategies/douglas_peucker.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/strategies/douglas_peucker.cpp b/test/strategies/douglas_peucker.cpp index c1705dab1..b8b09f348 100644 --- a/test/strategies/douglas_peucker.cpp +++ b/test/strategies/douglas_peucker.cpp @@ -197,16 +197,20 @@ struct test_one_case "output: "); std::cout << std::endl << std::endl; #endif - std::stringstream sstr; - print_point_range(sstr, boost::begin(expected_result), + std::stringstream stream_expected; + print_point_range(stream_expected, boost::begin(expected_result), boost::end(expected_result), ""); + std::stringstream stream_detected; + print_point_range(stream_detected, boost::begin(result), + boost::end(result), + ""); BOOST_CHECK_MESSAGE(equals::apply(result, expected_result), "case id: " << case_id << " - " << typeid_name << ", geometry: " << wkt - << ", Expected: " << sstr.str() - << " - Detected: " << bg::wkt(result)); + << ", Expected: " << stream_expected.str() + << " - Detected: " << stream_detected.str()); #ifdef BOOST_GEOMETRY_TEST_DEBUG std::cout << "---------------" << std::endl; From 9372cb08d1b2c2c23438f27c1abe1138505f6ad5 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Tue, 24 Mar 2015 12:58:27 +0100 Subject: [PATCH 072/146] [doc] Update the list of supported compilers. --- doc/compiling.qbk | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/doc/compiling.qbk b/doc/compiling.qbk index 01c99fb74..1cde2c6a0 100644 --- a/doc/compiling.qbk +++ b/doc/compiling.qbk @@ -35,22 +35,42 @@ __boost_geometry__ library has been successfully tested with the following compilers: * __msvc__ (including Express Editions) + * 14.0 (__msvc__ 14 CTP) [/reported by develop report on March, 2015] + * 12.0 (__msvc__ 2013) [/reported by develop report on March, 2015] + * 11.0 (__msvc__ 2012) [/reported by develop report on March, 2015] * 10.0 (__msvc__ 2010) [/reported by Trunk report May 8, 2011] * 9.0 (__msvc__ 2008) [/reported by Trunk report May 8, 2011] * 8.0 (__msvc__ 2005) [/reported by Trunk report May 8, 2011] * gcc + * gcc 5.0.0 [/reported by develop report on March, 2015] + * gcc 4.9.2 [/reported by develop report on March, 2015] + * gcc 4.9.0 [/reported by develop report on March, 2015] + * gcc 4.8.4 [/reported by develop report on March, 2015] + * gcc 4.8.1 [/reported by develop report on March, 2015] + * gcc 4.8.0 [/reported by develop report on March, 2015] + * gcc 4.7.3 [/reported by develop report on March, 2015] + * gcc 4.7.2 [/reported by develop report on March, 2015] * gcc 4.7.0 [/reported by Trunk report February 12, 2012] + * gcc 4.6.4 [/reported by develop report on March, 2015] * gcc 4.6.2 [/reported by Trunk report February 12, 2012] * gcc 4.6.1 [/reported by Trunk report May 8, 2011] * gcc 4.6.0 [/reported by Trunk report May 8, 2011] + * gcc 4.5.3 [/reported by develop report on March, 2015] * gcc 4.5.2 [/reported by Trunk report May 8, 2011] + * gcc 4.4.7 [/reported by develop report on March, 2015] * gcc 4.4.0 [/reported by Trunk report May 8, 2011] * gcc 4.3.4 [/reported by Trunk report March 26, 2011] * gcc 4.2.1 [/reported by Trunk report May 8, 2011] * gcc 3.4.6 [/reported by Trunk report March 26, 2011] * clang + * clang 3.6 [/reported by develop report on March, 2015] + * clang 3.5 [/reported by develop report on March, 2015] + * clang 3.4 [/reported by develop report on March, 2015] * clang 3.3 [/reported by mloskot on October, 2013] * clang 3.2 [/reported by Trunk report March 26, 2011] + * clang 3.1 [/reported by develop report on March, 2015] + * clang 3.0 [/reported by develop report on March, 2015] + * clang 2.9 [/reported by develop report on March, 2015] * darwin * darwin 4.0.1 [/reported by Trunk report March 26, 2011] * darwin 4.4 [/reported by Trunk report March 26, 2011] From 57d55eb9641a9f6c843e312975125e8eb7cabc47 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Tue, 24 Mar 2015 19:31:47 +0100 Subject: [PATCH 073/146] [index] Fix count() - access of destroyed temporary if convertible type passed. --- include/boost/geometry/index/rtree.hpp | 41 ++++++++++++++++++++------ 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/include/boost/geometry/index/rtree.hpp b/include/boost/geometry/index/rtree.hpp index e9ef1a85c..9d5d57d05 100644 --- a/include/boost/geometry/index/rtree.hpp +++ b/include/boost/geometry/index/rtree.hpp @@ -1097,6 +1097,8 @@ public: template size_type count(ValueOrIndexable const& vori) const { + // the input should be convertible to Value or Indexable type + enum { as_val = 0, as_ind, dont_know }; typedef boost::mpl::int_ < @@ -1122,15 +1124,9 @@ public: indexable_type >::type value_or_indexable; - if ( !m_members.root ) - return 0; - - detail::rtree::visitors::count - count_v(vori, m_members.translator()); - - detail::rtree::apply_visitor(count_v, *m_members.root); - - return count_v.found_count; + // NOTE: If an object of convertible but not the same type is passed + // into the function, here a temporary will be created. + return this->template raw_count(vori); } /*! @@ -1502,6 +1498,33 @@ private: return distance_v.finish(); } + + /*! + \brief Count elements corresponding to value or indexable. + + \par Exception-safety + strong + */ + template + size_type raw_count(ValueOrIndexable const& vori) const + { + if ( !m_members.root ) + return 0; + + detail::rtree::visitors::count + < + ValueOrIndexable, + value_type, + options_type, + translator_type, + box_type, + allocators_type + > count_v(vori, m_members.translator()); + + detail::rtree::apply_visitor(count_v, *m_members.root); + + return count_v.found_count; + } struct members_holder : public translator_type From 4354ab9ca0a41aeed177f01f7c79d7ebd44bfaa5 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Tue, 24 Mar 2015 19:43:47 +0100 Subject: [PATCH 074/146] [doc] Update 1.58 release notes (bug). --- doc/release_notes.qbk | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/release_notes.qbk b/doc/release_notes.qbk index a778e4664..63b3cde39 100644 --- a/doc/release_notes.qbk +++ b/doc/release_notes.qbk @@ -74,6 +74,7 @@ * Bug in closing_iterator not working properly when the input range is empty * Bug in is_simple, not handling properly closed simple linestrings within multilinestrings * Bug in rtree constructors taking a pair of Iterators or a Range (packing algorithm), the use of reference to destroyed temporary when Iterator's reference is not true reference, e.g. for some of the Range Adaptors. It also affects distance() and comparable_distance(). This bug may cause unexpected behavior of the rtree or distance() algorithm, e.g. an assertion failure or a SEGFAULT. +* Bug in rtree count() member function, the use of reference to destroyed temporary when object of type convertible but not the same as value_type or indexable_type is passed. If this happens, wrong result may be returned, in most cases 0. * Bugs related to the handling of Ranges, preventing compilation of Geometries using non-Container Ranges in some algorithms (thanks to Samuel Debionne) [/=================] From a5535e0f39224268e9924ad5fb1a58d9d92bdaa4 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 25 Mar 2015 12:22:24 +0100 Subject: [PATCH 075/146] [test][buffer] Fix expected values for country_buffer, which were not yet updated after commit 64ee58ed46d371553bb315a0f693fc9ea3737099 (Fix calculation of the number of points in round buffer) New areas are changed max 0.2% w.r.t. old areas, and are in general closer to what PostGIS gives --- test/algorithms/buffer/country_buffer.cpp | 126 +++++++++++----------- 1 file changed, 63 insertions(+), 63 deletions(-) diff --git a/test/algorithms/buffer/country_buffer.cpp b/test/algorithms/buffer/country_buffer.cpp index 66e985728..b4e56f675 100644 --- a/test/algorithms/buffer/country_buffer.cpp +++ b/test/algorithms/buffer/country_buffer.cpp @@ -148,80 +148,80 @@ void test_all() std::string no = read_from_file("data/no.wkt"); std::string uk = read_from_file("data/uk.wkt"); - test_one("gr10", gr, 336274443102, 10); - test_one("gr20", gr, 442303404970, 20); - test_one("gr50", gr, 680414236746, 50); - test_one("gr100", gr, 910435136622, 100); + test_one("gr10", gr, 336279815057, 10); + test_one("gr20", gr, 442317493728, 20); + test_one("gr50", gr, 680442278144, 50); + test_one("gr100", gr, 910474619262, 100); - test_one("gr10", gr, 139315436711, -10); - test_one("gr20", gr, 96996694672, -20); - test_one("gr50", gr, 31400319981, -50); - test_one("gr100", gr, 2038866888, -100); + test_one("gr10", gr, 139313148239, -10); + test_one("gr20", gr, 96991352461, -20); + test_one("gr50", gr, 31391928703, -50); + test_one("gr100", gr, 2035400463, -100); - test_one("it1", it, 569862957683, 1); - test_one("it2", it, 579239031444, 2); - test_one("it5", it, 607624450258, 5); - test_one("it10", it, 655015072045, 10); - test_one("it20", it, 749341988637, 20); - test_one("it50", it, 1018283833002, 50); - test_one("it100", it, 1436371098919, 100); + test_one("it1", it, 569863002352, 1); + test_one("it2", it, 579239205460, 2); + test_one("it5", it, 607625467971, 5); + test_one("it10", it, 655018590164, 10); + test_one("it20", it, 749353300126, 20); + test_one("it50", it, 1018323108593, 50); + test_one("it100", it, 1436451405440, 100); - test_one("it1", it, 551474452673, -1); - test_one("it2", it, 542617896207, -2); - test_one("it5", it, 517403395015, -5); - test_one("it10", it, 477948804826, -10); - test_one("it20", it, 404704185411, -20); - test_one("it50", it, 238775955402, -50); - test_one("it100", it, 69800921399, -100); + test_one("it1", it, 551474409670, -1); + test_one("it2", it, 542617726944, -2); + test_one("it5", it, 517402446347, -5); + test_one("it10", it, 477945526913, -10); + test_one("it20", it, 404693994961, -20); + test_one("it50", it, 238748456044, -50); + test_one("it100", it, 69768639974, -100); test_one("it200", it, 0, -200); - test_one("nl1", nl, 97391149343, 1); - test_one("nl2", nl, 100816629886, 2); - test_one("nl5", nl, 110239413808, 5); - test_one("nl10", nl, 123407160072, 10); - test_one("nl20", nl, 145044379084, 20); - test_one("nl50", nl, 201197559681, 50); - test_one("nl100", nl, 303275571989, 100); + test_one("nl1", nl, 97391171492, 1); + test_one("nl2", nl, 100816708947, 2); + test_one("nl5", nl, 110239800198, 5); + test_one("nl10", nl, 123408276767, 10); + test_one("nl20", nl, 145046916470, 20); + test_one("nl50", nl, 201207309280, 50); + test_one("nl100", nl, 303300936130, 100); - test_one("nl1", nl, 90095062551, -1); - test_one("nl2", nl, 86601922962, -2); - test_one("nl5", nl, 77308154694, -5); - test_one("nl10", nl, 64669734511, -10); - test_one("nl20", nl, 46685545338, -20); - test_one("nl50", nl, 10248593002, -50); + test_one("nl1", nl, 90095047258, -1); + test_one("nl2", nl, 86601864925, -2); + test_one("nl5", nl, 77307843491, -5); + test_one("nl10", nl, 64668873412, -10); + test_one("nl20", nl, 46683532991, -20); + test_one("nl50", nl, 10244522894, -50); test_one("nl100", nl, 0, -100); - test_one("no1", no, 1819566431968, 1); - test_one("no2", no, 1865040587680, 2); - test_one("no5", no, 1973612505198, 5); - test_one("no10", no, 2102026964987, 10); - test_one("no20", no, 2292154347925, 20); - test_one("no50", no, 2725424299143, 50); - test_one("no100", no, 3374865875758, 100); + test_one("no1", no, 1819566643132, 1); + test_one("no2", no, 1865041330273, 2); + test_one("no5", no, 1973615513085, 5); + test_one("no10", no, 2102034197635, 10); + test_one("no20", no, 2292171193871, 20); + test_one("no50", no, 2725475412131, 50); + test_one("no100", no, 3374987097497, 100); - test_one("no1", no, 1725145481020, -1); - test_one("no2", no, 1678942941890, -2); - test_one("no5", no, 1547331904374, -5); - test_one("no10", no, 1361206959153, -10); - test_one("no20", no, 1089865725529, -20); - test_one("no50", no, 649657900609, -50); - test_one("no100", no, 306772606713, -100); + test_one("no1", no, 1725145365167, -1); + test_one("no2", no, 1678942477834, -2); + test_one("no5", no, 1547329288139, -5); + test_one("no10", no, 1361198992659, -10); + test_one("no20", no, 1089847769281, -20); + test_one("no50", no, 649622185906, -50); + test_one("no100", no, 306739135037, -100); - test_one("uk1", uk, 733080699236, 1); - test_one("uk2", uk, 749555588975, 2); - test_one("uk5", uk, 793750965288, 5); - test_one("uk10", uk, 857677152435, 10); - test_one("uk20", uk, 970474644257, 20); - test_one("uk50", uk, 1247789678698, 50); - test_one("uk100", uk, 1659782604299, 100); + test_one("uk1", uk, 733080792661, 1); + test_one("uk2", uk, 749555934157, 2); + test_one("uk5", uk, 793752670139, 5); + test_one("uk10", uk, 857682293758, 10); + test_one("uk20", uk, 970488073372, 20); + test_one("uk50", uk, 1247830326998, 50); + test_one("uk100", uk, 1659861947865, 100); - test_one("uk1", uk, 699378162790, -1); - test_one("uk2", uk, 683086653377, -2); - test_one("uk5", uk, 637326518646, -5); - test_one("uk10", uk, 572560284244, -10); - test_one("uk20", uk, 479267296848, -20); - test_one("uk50", uk, 274851268903, -50); - test_one("uk100", uk, 78225232337, -100); + test_one("uk1", uk, 699378105887, -1); + test_one("uk2", uk, 683086430553, -2); + test_one("uk5", uk, 637325270073, -5); + test_one("uk10", uk, 572556645697, -10); + test_one("uk20", uk, 479258135850, -20); + test_one("uk50", uk, 274828075226, -50); + test_one("uk100", uk, 78205462121, -100); } int test_main(int, char* []) From b3d7f8c82a6ddf981a7150051bb3211c0e00d7c5 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 25 Mar 2015 12:23:20 +0100 Subject: [PATCH 076/146] [test][buffer] Add % difference to verify results more conveniently --- test/algorithms/buffer/test_buffer.hpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/algorithms/buffer/test_buffer.hpp b/test/algorithms/buffer/test_buffer.hpp index dc0177d15..6b0d91105 100644 --- a/test/algorithms/buffer/test_buffer.hpp +++ b/test/algorithms/buffer/test_buffer.hpp @@ -542,13 +542,17 @@ void test_buffer(std::string const& caseid, Geometry const& geometry, if (expected_area > -0.1) { + double const difference = area - expected_area; BOOST_CHECK_MESSAGE ( - bg::math::abs(area - expected_area) < tolerance, + bg::math::abs(difference) < tolerance, complete.str() << " not as expected. " << std::setprecision(18) - << " Expected: " << expected_area - << " Detected: " << area + << " Expected: " << expected_area + << " Detected: " << area + << " Diff: " << difference + << std::setprecision(3) + << " , " << 100.0 * (difference / expected_area) << "%" ); if (check_self_intersections) From abbb664226b6e187b3ab2383e1fdaeeab96cba43 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 26 Mar 2015 08:44:08 +0200 Subject: [PATCH 077/146] [util][promote integral] add meta-function promote_integral that promotes a fundamental integral type T to another integral type with at least twice the size of T --- .../boost/geometry/util/promote_integral.hpp | 156 ++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 include/boost/geometry/util/promote_integral.hpp diff --git a/include/boost/geometry/util/promote_integral.hpp b/include/boost/geometry/util/promote_integral.hpp new file mode 100644 index 000000000..5600a6907 --- /dev/null +++ b/include/boost/geometry/util/promote_integral.hpp @@ -0,0 +1,156 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2015, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_GEOMETRY_UTIL_PROMOTE_INTEGRAL_HPP +#define BOOST_GEOMETRY_UTIL_PROMOTE_INTEGRAL_HPP + +// For now deactivate the use of multiprecision integers +// TODO: activate it later +#define BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER + +#include + +#include +#include +#include +#include +#include + +#if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) +#include +#endif + +#include + + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace promote_integral +{ + +template +< + typename T, + typename List, + bool IsEmpty = boost::mpl::empty::type::value +> +struct promote_to_larger +{ + typedef typename boost::mpl::if_c + < + (sizeof(typename boost::mpl::front::type) >= 2 * sizeof(T)), + typename boost::mpl::front::type, + typename promote_to_larger + < + T, typename boost::mpl::pop_front::type + >::type + >::type type; +}; + +// The following specialization is required to finish the loop over +// all list elements: the empty MPL list does not support +// boost::mpl::front and boost::mpl::pop_front, and thus without this +// specialization we get a compilation error +template +struct promote_to_larger +{ + // if promotion fails, keep the number T + // (and cross fingers that overflow will not occur) + typedef T type; +}; + +}} // namespace detail::promote_integral +#endif // DOXYGEN_NO_DETAIL + + + +/*! + \brief Meta-function to define an integral type with size + than is at least twice the size of T + \ingroup utility + \details + This meta-function tries to promote the fundamental integral type + T to a another integral type with size at least twice the size of T. + + To do this, two times the size of T is tested against the sizes of: + short, int, long, boost::long_long_type, boost::int128_t + and the one that matches is chosen. + + If the macro BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER is not + defined, boost's multiprecision integer cpp_int<> is used as a + last resort. + + If BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER is defined and an + appropriate type cannot be detected, the input type is returned as is. + + Finally, if the passed type is either a floating-point type or a + user-defined type it is returned as is. + + \note boost::long_long_type is considered only if the macro + BOOST_HAS_LONG_LONG is defined + + \note boost::int128_type is considered only if the macro + BOOST_HAS_INT128 is defined +*/ +template +class promote_integral +{ +private: +#if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) + typedef typename boost::mpl::if_c + < + UseCheckedMultiprecisionInteger, + boost::multiprecision::checked, + boost::multiprecision::unchecked + >::type checking_policy_type; + + typedef boost::multiprecision::number + < + boost::multiprecision::cpp_int_backend + < + 2 * CHAR_BIT * sizeof(T), + 2 * CHAR_BIT * sizeof(T), + boost::multiprecision::signed_magnitude, + checking_policy_type, + void + > + > multiprecision_integer_type; +#endif + + typedef boost::mpl::list + < + short, int, long +#if defined(BOOST_HAS_LONG_LONG) + , boost::long_long_type +#endif +#if defined(BOOST_HAS_INT128) + , boost::int128_type +#endif +#if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) + , multiprecision_integer_type +#endif + > integral_types; + +public: + typedef typename boost::mpl::if_c + < + boost::is_integral::type::value, + typename detail::promote_integral::promote_to_larger + < + T, integral_types + >::type, + T + >::type type; +}; + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_UTIL_PROMOTE_INTEGRAL_HPP From b87c59375a8b4b7563bd1b0f7b1834e660179c41 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 26 Mar 2015 08:45:45 +0200 Subject: [PATCH 078/146] [test][util][promote integral] add unit test for the promote_integral meta-function --- test/util/Jamfile.v2 | 11 +- test/util/promote_integral.cpp | 206 +++++++++++++++++++++++++++++++++ 2 files changed, 212 insertions(+), 5 deletions(-) create mode 100644 test/util/promote_integral.cpp diff --git a/test/util/Jamfile.v2 b/test/util/Jamfile.v2 index bfb647dc7..70a463777 100644 --- a/test/util/Jamfile.v2 +++ b/test/util/Jamfile.v2 @@ -1,11 +1,11 @@ # Boost.Geometry (aka GGL, Generic Geometry Library) # -# 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) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +# Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +# Copyright (c) 2009-2015 Mateusz Loskot, London, UK. # -# This file was modified by Oracle on 2014. -# Modifications copyright (c) 2014, Oracle and/or its affiliates. +# This file was modified by Oracle on 2014, 2015. +# Modifications copyright (c) 2014-2015, Oracle and/or its affiliates. # # Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle # @@ -18,6 +18,7 @@ test-suite boost-geometry-util [ run calculation_type.cpp ] [ run for_each_coordinate.cpp ] [ run math_sqrt.cpp ] + [ run promote_integral.cpp ] [ run range.cpp ] [ run rational.cpp ] [ run select_most_precise.cpp ] diff --git a/test/util/promote_integral.cpp b/test/util/promote_integral.cpp new file mode 100644 index 000000000..49f38d3f5 --- /dev/null +++ b/test/util/promote_integral.cpp @@ -0,0 +1,206 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2015, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_promote_integral +#endif + +#if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) +#include +#endif +#include + +#include + +//#include +#include + +#include + +#include + +#if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) +#include +#endif + +#if defined(BOOST_GEOMETRY_TEST_DEBUG) && defined(BOOST_HAS_INT128) +std::ostream& operator<<(std::ostream& os, boost::int128_type i) +{ + os << double(i); + return os; +} +#endif + + +namespace bg = boost::geometry; + +template +inline void test_promote_integral() +{ + typedef typename bg::promote_integral::type promoted_integral_type; + bool const same_types = boost::is_same + < + promoted_integral_type, ExpectedPromotedType + >::type::value; + + BOOST_CHECK(same_types); + +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << "type : " << typeid(Type).name() + << ", sizeof: " << sizeof(Type) + << ", max value: " + << std::numeric_limits::max() + << std::endl; + std::cout << "detected promoted type : " + << typeid(promoted_integral_type).name() + << ", sizeof: " << sizeof(promoted_integral_type) + << ", max value: " + << std::numeric_limits::max() + << std::endl; + std::cout << "expected promoted type : " + << typeid(ExpectedPromotedType).name() + << ", sizeof: " << sizeof(ExpectedPromotedType) + << ", max value: " + << std::numeric_limits::max() + << std::endl; + std::cout << std::endl; +#endif +} + +template +void test_promotion() +{ + if (sizeof(short) >= 2 * sizeof(T)) + { + test_promote_integral(); + } + else if (sizeof(int) >= 2 * sizeof(T)) + { + test_promote_integral(); + } + else if (sizeof(long) >= 2 * sizeof(T)) + { + test_promote_integral(); + } +#if defined(BOOST_HAS_LONG_LONG) + else if (sizeof(boost::long_long_type) >= 2 * sizeof(T)) + { + test_promote_integral(); + } +#endif +#if defined(BOOST_HAS_INT128) + else if (sizeof(boost::int128_type) >= 2 * sizeof(T)) + { + test_promote_integral(); + } +#endif + else + { +#if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) + namespace bm = boost::multiprecision; + typedef bm::number + < + bm::cpp_int_backend + < + 2 * CHAR_BIT * sizeof(T), + 2 * CHAR_BIT * sizeof(T), + bm::signed_magnitude, + bm::unchecked, + void + > + > multiprecision_integer_type; + + test_promote_integral(); +#else + test_promote_integral(); +#endif + } +} + + +BOOST_AUTO_TEST_CASE( test_char ) +{ + test_promotion(); +} + +BOOST_AUTO_TEST_CASE( test_short ) +{ + test_promotion(); +} + +BOOST_AUTO_TEST_CASE( test_int ) +{ + test_promotion(); +} + +BOOST_AUTO_TEST_CASE( test_long ) +{ + test_promotion(); +} + +#ifdef BOOST_HAS_LONG_LONG +BOOST_AUTO_TEST_CASE( test_long_long ) +{ + test_promotion(); +} +#endif + +#if defined(BOOST_HAS_INT128) +BOOST_AUTO_TEST_CASE( test_int128 ) +{ + test_promotion(); +} +#endif + +#if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) +BOOST_AUTO_TEST_CASE( test_custom_types ) +{ + namespace bm = boost::multiprecision; + typedef bm::number + < + bm::cpp_int_backend + < + CHAR_BIT * sizeof(short) + 1, + CHAR_BIT * sizeof(short) + 1, + bm::signed_magnitude, + bm::unchecked, + void + > + > custom_integral_type1; + + typedef bm::number + < + bm::cpp_int_backend + < + 500, + 500, + bm::signed_magnitude, + bm::unchecked, + void + > + > custom_integral_type2; + + // for user defined number types we do not do any promotion + test_promote_integral(); + test_promote_integral(); +} +#endif + +BOOST_AUTO_TEST_CASE( test_floating_point ) +{ + // for floating-point types we do not do any promotion + test_promote_integral(); + test_promote_integral(); + test_promote_integral(); + +#ifdef HAVE_TTMATH + test_promote_integral(); +#endif +} From a5ec906e6f3f9f8df4faf0592cd20814d1abb5e0 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 26 Mar 2015 08:47:44 +0200 Subject: [PATCH 079/146] [test][algorithms][difference] add unit test with the data reported in ticket #10835 --- .../set_operations/difference/difference.cpp | 49 ++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/test/algorithms/set_operations/difference/difference.cpp b/test/algorithms/set_operations/difference/difference.cpp index c1da88ad8..110e025b7 100644 --- a/test/algorithms/set_operations/difference/difference.cpp +++ b/test/algorithms/set_operations/difference/difference.cpp @@ -7,9 +7,10 @@ // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include #include +#include +#include +#include // If defined, tests are run without rescaling-to-integer or robustness policy // Test which would fail then are disabled automatically @@ -86,6 +87,42 @@ void test_areal_linear() test_one_lp("case27", "LINESTRING(4 4,4 5,5 5)", poly_9, 1, 3, 2.0); } +template +void test_ticket_10835(std::string const& wkt_out1, std::string const& wkt_out2) +{ + typedef bg::model::point point_type; + typedef bg::model::linestring linestring_type; + typedef bg::model::multi_linestring multilinestring_type; + typedef bg::model::polygon + < + point_type, /*ClockWise*/false, /*Closed*/false + > polygon_type; + + multilinestring_type multilinestring; + bg::read_wkt("MULTILINESTRING((5239 2113,1020 2986))", multilinestring); + polygon_type polygon1; + bg::read_wkt("POLYGON((5233 2113,5200 2205,1020 2205,1020 2022,5200 2022))", + polygon1); + polygon_type polygon2; + bg::read_wkt("POLYGON((5233 2986,5200 3078,1020 3078,1020 2895,5200 2895))", + polygon2); + + multilinestring_type multilinestringOut1; + bg::difference(multilinestring, polygon1, multilinestringOut1); + std::stringstream stream; + stream << bg::wkt(multilinestringOut1); + + BOOST_CHECK_EQUAL(stream.str(), wkt_out1); + + multilinestring_type multilinestringOut2; + bg::difference(multilinestringOut1, polygon2, multilinestringOut2); + stream.str(""); + stream.clear(); + stream << bg::wkt(multilinestringOut2); + + BOOST_CHECK_EQUAL(stream.str(), wkt_out2); +} + template void test_all() { @@ -566,6 +603,14 @@ int test_main(int, char* []) test_specific, false, false>(); + test_ticket_10835 + ("MULTILINESTRING((5239 2113,5233 2114),(4794 2205,1020 2986))", + "MULTILINESTRING((5239 2113,5233 2114),(4794 2205,1460 2895))"); + + test_ticket_10835 + ("MULTILINESTRING((5239 2113,5232.52 2114.34),(4794.39 2205,1020 2986))", + "MULTILINESTRING((5239 2113,5232.52 2114.34),(4794.39 2205,1459.78 2895))"); + #if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE) test_all >(); From e0a0b8e3b1d5f676737c180668d1b9535512363f Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 26 Mar 2015 08:49:18 +0200 Subject: [PATCH 080/146] [policies][relate][intersection_points] promote values to a larger integral type in order to avoid overflow when computing the products: ratio.numerator() * dx and ratio.numerator() * dy This change fixes ticket #10835 --- .../policies/relate/intersection_points.hpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/include/boost/geometry/policies/relate/intersection_points.hpp b/include/boost/geometry/policies/relate/intersection_points.hpp index eaa8fafd4..9309d6c5a 100644 --- a/include/boost/geometry/policies/relate/intersection_points.hpp +++ b/include/boost/geometry/policies/relate/intersection_points.hpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -60,12 +61,20 @@ struct segments_intersection_points // denominator. In case of integer this results in an integer // division. BOOST_ASSERT(ratio.denominator() != 0); + + typedef typename promote_integral::type promoted_type; + + promoted_type numerator + = boost::numeric_cast(ratio.numerator()); + promoted_type denominator + = boost::numeric_cast(ratio.denominator()); + promoted_type dx_promoted = boost::numeric_cast(dx); + promoted_type dy_promoted = boost::numeric_cast(dy); + set<0>(point, boost::numeric_cast( - get<0, 0>(segment) - + ratio.numerator() * dx / ratio.denominator())); + get<0, 0>(segment) + numerator * dx_promoted / denominator)); set<1>(point, boost::numeric_cast( - get<0, 1>(segment) - + ratio.numerator() * dy / ratio.denominator())); + get<0, 1>(segment) + numerator * dy_promoted / denominator)); } From 620b95acdeff5aa6a03a264631aa0ef1dbba203e Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 26 Mar 2015 08:55:43 +0200 Subject: [PATCH 081/146] [doc][release_notes] update release notes: ticket #10835 is now addressed --- doc/release_notes.qbk | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/release_notes.qbk b/doc/release_notes.qbk index 63b3cde39..24ff23cc0 100644 --- a/doc/release_notes.qbk +++ b/doc/release_notes.qbk @@ -45,6 +45,7 @@ * [@https://svn.boost.org/trac/boost/ticket/10666 10666] MSVC compiler warning C4127: conditional expression is constant * [@https://svn.boost.org/trac/boost/ticket/10747 10747] Error in rescaling causing errors in areal/areal set operations * [@https://svn.boost.org/trac/boost/ticket/10770 10770] Buffer fails for large distances, or rough round joins, where concavities where not intersected properly +* [@https://svn.boost.org/trac/boost/ticket/10835 10835] Difference of multilinestring and polygon yields wrong result * [@https://svn.boost.org/trac/boost/ticket/10861 10861] Rtree failing to compile for Value being a pair or a tuple containing pointer to Geometry and the default equal_to<> used * [@https://svn.boost.org/trac/boost/ticket/10863 10863] Template parameter name coliding with B0 macro name defined in termios.h (duplicate of 10467) * [@https://svn.boost.org/trac/boost/ticket/10887 10887] Invalid result of within() and relate() for Linear/MultiPolygon From b20a6bb209a3fa014d15b736cb7c5876671457f6 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 26 Mar 2015 11:07:08 +0200 Subject: [PATCH 082/146] [test][algorithms][difference] fix output for test case for ticket #10835 --- test/algorithms/set_operations/difference/difference.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/algorithms/set_operations/difference/difference.cpp b/test/algorithms/set_operations/difference/difference.cpp index 110e025b7..59ff0c8a8 100644 --- a/test/algorithms/set_operations/difference/difference.cpp +++ b/test/algorithms/set_operations/difference/difference.cpp @@ -604,8 +604,8 @@ int test_main(int, char* []) test_specific, false, false>(); test_ticket_10835 - ("MULTILINESTRING((5239 2113,5233 2114),(4794 2205,1020 2986))", - "MULTILINESTRING((5239 2113,5233 2114),(4794 2205,1460 2895))"); + ("MULTILINESTRING((5239 2113,5233 2114),(4795 2205,1020 2986))", + "MULTILINESTRING((5239 2113,5233 2114),(4795 2205,1460 2895))"); test_ticket_10835 ("MULTILINESTRING((5239 2113,5232.52 2114.34),(4794.39 2205,1020 2986))", From 6f37921db387e78a3d5b5b7079743a2c11df3beb Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 26 Mar 2015 11:13:58 +0200 Subject: [PATCH 083/146] [test][algorithms][difference] update results for test case "ggl_list_20120717_volker" --- test/algorithms/set_operations/difference/difference.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/algorithms/set_operations/difference/difference.cpp b/test/algorithms/set_operations/difference/difference.cpp index 59ff0c8a8..ec15f677c 100644 --- a/test/algorithms/set_operations/difference/difference.cpp +++ b/test/algorithms/set_operations/difference/difference.cpp @@ -590,7 +590,7 @@ void test_specific() test_one("ggl_list_20120717_volker", ggl_list_20120717_volker[0], ggl_list_20120717_volker[1], 1, 11, 3371540, - 0, 0, 0, 0.001); // output is discarded + 1, 4, 384, 0.001); } From 15e83e1a19018ab696a52dbd9b81161df8bfc987 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 26 Mar 2015 11:20:13 +0200 Subject: [PATCH 084/146] [test][util][promote integral] uncomment commented include; make test for custom integral types always active; --- test/util/promote_integral.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/test/util/promote_integral.cpp b/test/util/promote_integral.cpp index 49f38d3f5..896f2a3f9 100644 --- a/test/util/promote_integral.cpp +++ b/test/util/promote_integral.cpp @@ -19,16 +19,14 @@ #include -//#include +#include #include #include #include -#if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) #include -#endif #if defined(BOOST_GEOMETRY_TEST_DEBUG) && defined(BOOST_HAS_INT128) std::ostream& operator<<(std::ostream& os, boost::int128_type i) @@ -159,7 +157,6 @@ BOOST_AUTO_TEST_CASE( test_int128 ) } #endif -#if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) BOOST_AUTO_TEST_CASE( test_custom_types ) { namespace bm = boost::multiprecision; @@ -167,8 +164,8 @@ BOOST_AUTO_TEST_CASE( test_custom_types ) < bm::cpp_int_backend < - CHAR_BIT * sizeof(short) + 1, - CHAR_BIT * sizeof(short) + 1, + 17, + 17, bm::signed_magnitude, bm::unchecked, void @@ -191,7 +188,6 @@ BOOST_AUTO_TEST_CASE( test_custom_types ) test_promote_integral(); test_promote_integral(); } -#endif BOOST_AUTO_TEST_CASE( test_floating_point ) { From 92d513243d6775d061917df98dd6f14916991215 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 26 Mar 2015 13:38:08 +0200 Subject: [PATCH 085/146] [test][algorithms][overlay] add test cases from Boost Trac tickets #10658, #10835, #10868 and #11121 --- test/algorithms/overlay/overlay_cases.hpp | 30 ++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/test/algorithms/overlay/overlay_cases.hpp b/test/algorithms/overlay/overlay_cases.hpp index ced26da52..1a28e0c06 100644 --- a/test/algorithms/overlay/overlay_cases.hpp +++ b/test/algorithms/overlay/overlay_cases.hpp @@ -1,7 +1,13 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test // -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. + +// This file was modified by Oracle on 2015. +// Modifications copyright (c) 2015, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, 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) @@ -833,7 +839,29 @@ static std::string ticket_10747_e[2] = "POLYGON((0.00000025165824 0.00000025165824,0.00000041943040 0.00000025165824,0.00000041943040 0.00000041943040,0.00000025165824 0.00000041943040,0.00000025165824 0.00000025165824))" }; +static std::string ticket_10658[2] = + { + "POLYGON((516 1608,1308 1932,2094 2466,2094 32767,516 32767,516 1608))", + "POLYGON((516 2484,1308 3066,2094 3150,2094 32767,516 32767,516 2484))" + }; +static std::string ticket_10835[3] = + { + "MULTILINESTRING((5239 2113,1020 2986))", + "POLYGON((5233 2113,5200 2205,1020 2205,1020 2022,5200 2022))", + "POLYGON((5233 2986,5200 3078,1020 3078,1020 2895,5200 2895))" + }; +static std::string ticket_10868[2] = + { + "POLYGON((42817136 -3774506,43029074 -3929862,31446819 18947953,30772384 19615678,30101303 19612322,30114725 16928001,33520458 6878575,35332375 2413654,35725796 2024148))", + "POLYGON((-33386239 -33721784,33721785 -33386239,33386240 33721785,-33721784 33386240))" + }; + +static std::string ticket_11121[2] = + { + "POLYGON((-8042 -1485,-8042 250,-8042 250,15943 254,15943 -1485,-8042 -1485))", + "POLYGON((-7901 -1485,-7901 529,-7901 529,15802 544,15802 -1485,-7901 -1485))" + }; #endif // BOOST_GEOMETRY_TEST_OVERLAY_CASES_HPP From 37baa56009643aa6ce5f58d6d5ac430830ba337d Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 26 Mar 2015 13:40:09 +0200 Subject: [PATCH 086/146] [test][algorithms][difference] add tests for the test cases in Boost Trac tickets #10658 and #11121; modified testing of ticket #10835 by using the data from overlay_cases.hpp --- .../set_operations/difference/difference.cpp | 84 +++++++++++++++++-- 1 file changed, 77 insertions(+), 7 deletions(-) diff --git a/test/algorithms/set_operations/difference/difference.cpp b/test/algorithms/set_operations/difference/difference.cpp index ec15f677c..c6456a009 100644 --- a/test/algorithms/set_operations/difference/difference.cpp +++ b/test/algorithms/set_operations/difference/difference.cpp @@ -1,7 +1,12 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2010-2015 Barend Gehrels, Amsterdam, the Netherlands. + +// This file was modified by Oracle on 2015. +// Modifications copyright (c) 2015, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, 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 @@ -17,6 +22,7 @@ // #define BOOST_GEOMETRY_NO_ROBUSTNESS #include +#include #include #include @@ -87,10 +93,33 @@ void test_areal_linear() test_one_lp("case27", "LINESTRING(4 4,4 5,5 5)", poly_9, 1, 3, 2.0); } +template +void test_ticket_10658(std::string const& wkt_out) +{ + typedef bg::model::point point_type; + typedef bg::model::polygon + < + point_type, /*ClockWise*/false, /*Closed*/false + > polygon_type; + typedef bg::model::multi_polygon multipolygon_type; + + polygon_type polygon1; + bg::read_wkt(ticket_10658[0], polygon1); + polygon_type polygon2; + bg::read_wkt(ticket_10658[1], polygon2); + + multipolygon_type multipolygon_out; + bg::sym_difference(polygon1, polygon2, multipolygon_out); + std::stringstream stream; + stream << bg::wkt(multipolygon_out); + + BOOST_CHECK_EQUAL(stream.str(), wkt_out); +} + template void test_ticket_10835(std::string const& wkt_out1, std::string const& wkt_out2) { - typedef bg::model::point point_type; + typedef bg::model::point point_type; typedef bg::model::linestring linestring_type; typedef bg::model::multi_linestring multilinestring_type; typedef bg::model::polygon @@ -99,13 +128,11 @@ void test_ticket_10835(std::string const& wkt_out1, std::string const& wkt_out2) > polygon_type; multilinestring_type multilinestring; - bg::read_wkt("MULTILINESTRING((5239 2113,1020 2986))", multilinestring); + bg::read_wkt(ticket_10835[0], multilinestring); polygon_type polygon1; - bg::read_wkt("POLYGON((5233 2113,5200 2205,1020 2205,1020 2022,5200 2022))", - polygon1); + bg::read_wkt(ticket_10835[1], polygon1); polygon_type polygon2; - bg::read_wkt("POLYGON((5233 2986,5200 3078,1020 3078,1020 2895,5200 2895))", - polygon2); + bg::read_wkt(ticket_10835[2], polygon2); multilinestring_type multilinestringOut1; bg::difference(multilinestring, polygon1, multilinestringOut1); @@ -123,6 +150,31 @@ void test_ticket_10835(std::string const& wkt_out1, std::string const& wkt_out2) BOOST_CHECK_EQUAL(stream.str(), wkt_out2); } +template +void test_ticket_11121() +{ + typedef bg::model::point point_type; + typedef bg::model::polygon + < + point_type, /*ClockWise*/false, /*Closed*/false + > polygon_type; + typedef bg::model::multi_polygon multipolygon_type; + + polygon_type polygon1; + bg::read_wkt(ticket_11121[0], polygon1); + polygon_type polygon2; + bg::read_wkt(ticket_11121[1], polygon2); + + multipolygon_type diff12, diff21, sym_diff; + bg::difference(polygon1, polygon2, diff12); + bg::difference(polygon2, polygon1, diff21); + bg::sym_difference(polygon1, polygon2, sym_diff); + + BOOST_CHECK(bg::is_valid(diff12)); + BOOST_CHECK(bg::is_valid(diff21)); + BOOST_CHECK(bg::is_valid(sym_diff)); +} + template void test_all() { @@ -591,6 +643,16 @@ void test_specific() ggl_list_20120717_volker[0], ggl_list_20120717_volker[1], 1, 11, 3371540, 1, 4, 384, 0.001); + + test_one("ticket_10658", + ticket_10658[0], ticket_10658[1], + 1, 6, 1510434, + 0, 0, 0); + + test_one("ticket_11121", + ticket_11121[0], ticket_11121[1], + 2, 8, 489763.5, + 1, 4, 6743503.5); } @@ -603,6 +665,12 @@ int test_main(int, char* []) test_specific, false, false>(); + test_ticket_10658 + ("MULTIPOLYGON(((516 2484,516 1608,1308 1932,2094 2466,2094 3150,1308 3066,516 2484)))"); + + test_ticket_10658 + ("MULTIPOLYGON(((516 2484,516 1608,1308 1932,2094 2466,2094 3150,1308 3066,516 2484)))"); + test_ticket_10835 ("MULTILINESTRING((5239 2113,5233 2114),(4795 2205,1020 2986))", "MULTILINESTRING((5239 2113,5233 2114),(4795 2205,1460 2895))"); @@ -611,6 +679,8 @@ int test_main(int, char* []) ("MULTILINESTRING((5239 2113,5232.52 2114.34),(4794.39 2205,1020 2986))", "MULTILINESTRING((5239 2113,5232.52 2114.34),(4794.39 2205,1459.78 2895))"); + test_ticket_11121(); + #if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE) test_all >(); From e3f30bbc15514a0937b760fb5dbc17dfb533b80f Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 26 Mar 2015 13:50:39 +0200 Subject: [PATCH 087/146] [test][algorithms][intersection] add testing for the test case in Boost Trac ticket #10868 --- .../intersection/intersection.cpp | 47 +++++++++++++++++-- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/test/algorithms/set_operations/intersection/intersection.cpp b/test/algorithms/set_operations/intersection/intersection.cpp index b12e7bef7..a812fd3a6 100644 --- a/test/algorithms/set_operations/intersection/intersection.cpp +++ b/test/algorithms/set_operations/intersection/intersection.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-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2015. +// Modifications copyright (c) 2015, 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. @@ -35,6 +40,7 @@ #include #include + BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::vector) @@ -613,6 +619,32 @@ void test_boxes_nd() test_boxes_per_d(p3(0,0,0), p3(5,5,5), p3(3,3,3), p3(6,6,6), true); } +template +void test_ticket_10868(std::string const& wkt_out) +{ + typedef bg::model::point point_type; + typedef bg::model::polygon + < + point_type, /*ClockWise*/false, /*Closed*/false + > polygon_type; + typedef bg::model::multi_polygon multipolygon_type; + + polygon_type polygon1; + bg::read_wkt(ticket_10868[0], polygon1); + polygon_type polygon2; + bg::read_wkt(ticket_10868[1], polygon2); + + multipolygon_type multipolygon_out; + bg::intersection(polygon1, polygon2, multipolygon_out); + std::stringstream stream; + stream << bg::wkt(multipolygon_out); + + BOOST_CHECK_EQUAL(stream.str(), wkt_out); + + test_one("ticket_10868", + ticket_10868[0], ticket_10868[1], + 1, 7, 20266195244586); +} int test_main(int, char* []) { @@ -636,6 +668,15 @@ int test_main(int, char* []) test_boxes_nd(); +#ifdef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS + // ticket #10868 still fails for 32-bit integers + test_ticket_10868("MULTIPOLYGON(((33520458 6878575,33480192 14931538,31446819 18947953,30772384 19615678,30101303 19612322,30114725 16928001,33520458 6878575)))"); +#endif + +#if defined(BOOST_HAS_INT64_T) + test_ticket_10868("MULTIPOLYGON(((33520458 6878575,33480192 14931538,31446819 18947953,30772384 19615678,30101303 19612322,30114725 16928001,33520458 6878575)))"); +#endif + return 0; } From 0c891c7b8ac17c86cbf3c72651065160395f15fa Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 26 Mar 2015 14:04:30 +0200 Subject: [PATCH 088/146] [test][algorithms][intersection] add missing include for BOOST_GEOMETRY_CONDITION; add testing for ticket #10868 with long and boost::long_long_type as coordinate type; --- .../set_operations/intersection/intersection.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/algorithms/set_operations/intersection/intersection.cpp b/test/algorithms/set_operations/intersection/intersection.cpp index a812fd3a6..165780cac 100644 --- a/test/algorithms/set_operations/intersection/intersection.cpp +++ b/test/algorithms/set_operations/intersection/intersection.cpp @@ -17,6 +17,7 @@ // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#include #include #include @@ -29,6 +30,7 @@ #include #include +#include #include #include "test_intersection.hpp" @@ -677,6 +679,14 @@ int test_main(int, char* []) test_ticket_10868("MULTIPOLYGON(((33520458 6878575,33480192 14931538,31446819 18947953,30772384 19615678,30101303 19612322,30114725 16928001,33520458 6878575)))"); #endif + if (BOOST_GEOMETRY_CONDITION(sizeof(long) * CHAR_BIT >= 64)) + { + test_ticket_10868("MULTIPOLYGON(((33520458 6878575,33480192 14931538,31446819 18947953,30772384 19615678,30101303 19612322,30114725 16928001,33520458 6878575)))"); + } + +#if defined(BOOST_HAS_LONG_LONG) + test_ticket_10868("MULTIPOLYGON(((33520458 6878575,33480192 14931538,31446819 18947953,30772384 19615678,30101303 19612322,30114725 16928001,33520458 6878575)))"); +#endif + return 0; } - From 001a73127a47a465ace68fdf7533b824651ded82 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 26 Mar 2015 14:05:48 +0200 Subject: [PATCH 089/146] [test][string_from_type] guard specialization for boost::long_long_type with the BOOST_HAS_LONG_LONG macro; add specializations for long and int64_t (the latter guarded by a macro) and modify the return values for long and boost::long_long_type to match those returned by typeid(type).name() by clang++ and g++; --- test/string_from_type.hpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/test/string_from_type.hpp b/test/string_from_type.hpp index 178ff2ea0..df0141a58 100644 --- a/test/string_from_type.hpp +++ b/test/string_from_type.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-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2015. +// Modifications copyright (c) 2015, 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. @@ -55,9 +60,21 @@ template <> struct string_from_type template <> struct string_from_type { static std::string name() { return "i"; } }; -template <> struct string_from_type +template <> struct string_from_type { static std::string name() { return "l"; } }; +#if defined(BOOST_HAS_LONG_LONG) +// this is what g++ and clang++ use +template <> struct string_from_type +{ static std::string name() { return "x"; } }; +#endif + +#if defined(BOOST_HAS_INT128) +// this is what g++ and clang++ use +template <> struct string_from_type +{ static std::string name() { return "n"; } }; +#endif + #if defined(HAVE_TTMATH) template <> struct string_from_type { static std::string name() { return "t"; } }; From 9412f39b4d6892086e7b607db00b4a18477fff5c Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 26 Mar 2015 14:14:25 +0200 Subject: [PATCH 090/146] [doc][release notes] add (fixed) tickets #10658 and #11121 to release notes --- doc/release_notes.qbk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/release_notes.qbk b/doc/release_notes.qbk index 24ff23cc0..fdbc82768 100644 --- a/doc/release_notes.qbk +++ b/doc/release_notes.qbk @@ -45,6 +45,7 @@ * [@https://svn.boost.org/trac/boost/ticket/10666 10666] MSVC compiler warning C4127: conditional expression is constant * [@https://svn.boost.org/trac/boost/ticket/10747 10747] Error in rescaling causing errors in areal/areal set operations * [@https://svn.boost.org/trac/boost/ticket/10770 10770] Buffer fails for large distances, or rough round joins, where concavities where not intersected properly +* [@https://svn.boost.org/trac/boost/ticket/10658 10658] sym_difference yields bad result for int polygons * [@https://svn.boost.org/trac/boost/ticket/10835 10835] Difference of multilinestring and polygon yields wrong result * [@https://svn.boost.org/trac/boost/ticket/10861 10861] Rtree failing to compile for Value being a pair or a tuple containing pointer to Geometry and the default equal_to<> used * [@https://svn.boost.org/trac/boost/ticket/10863 10863] Template parameter name coliding with B0 macro name defined in termios.h (duplicate of 10467) @@ -59,6 +60,7 @@ * [@https://svn.boost.org/trac/boost/ticket/10960 10960] Invalid result of get_turns() for L/A, missing turn. * [@https://svn.boost.org/trac/boost/ticket/10961 10961] Invalid result of get_turns() for L/A, invalid turn for a Linear spike. * [@https://svn.boost.org/trac/boost/ticket/11112 11112] Compilation failure on Solaris due to a CS name clash (used for a macro on this platform) +* [@https://svn.boost.org/trac/boost/ticket/11121 11121] Invalid result of difference() for integral coordinates [*Bugfixes] From 3e5f6db4a70d26f4cecda92a4919324182ff9a15 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 26 Mar 2015 14:25:47 +0200 Subject: [PATCH 091/146] [test][algorithms][intersection] add missing include boost/config.hpp; add better testing for the existence of int64_t; --- test/algorithms/set_operations/intersection/intersection.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/algorithms/set_operations/intersection/intersection.cpp b/test/algorithms/set_operations/intersection/intersection.cpp index 165780cac..9e191bd84 100644 --- a/test/algorithms/set_operations/intersection/intersection.cpp +++ b/test/algorithms/set_operations/intersection/intersection.cpp @@ -25,6 +25,7 @@ // Test which would fail then are disabled automatically // #define BOOST_GEOMETRY_NO_ROBUSTNESS +#include #include #include @@ -675,7 +676,7 @@ int test_main(int, char* []) test_ticket_10868("MULTIPOLYGON(((33520458 6878575,33480192 14931538,31446819 18947953,30772384 19615678,30101303 19612322,30114725 16928001,33520458 6878575)))"); #endif -#if defined(BOOST_HAS_INT64_T) +#if !defined(BOOST_NO_INT64) || defined(BOOST_HAS_INT64_T) || defined(BOOST_HAS_MS_INT64) test_ticket_10868("MULTIPOLYGON(((33520458 6878575,33480192 14931538,31446819 18947953,30772384 19615678,30101303 19612322,30114725 16928001,33520458 6878575)))"); #endif From 2651afa92b554d8484eab580b4e5bb458feba125 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 26 Mar 2015 16:31:14 +0200 Subject: [PATCH 092/146] [util][promote integral] fix issue with boost::mpl::if_c not allowing enum values as return types --- include/boost/geometry/util/promote_integral.hpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/include/boost/geometry/util/promote_integral.hpp b/include/boost/geometry/util/promote_integral.hpp index 5600a6907..e4ad8e3ab 100644 --- a/include/boost/geometry/util/promote_integral.hpp +++ b/include/boost/geometry/util/promote_integral.hpp @@ -26,6 +26,7 @@ #include #endif +#include #include @@ -108,8 +109,16 @@ private: typedef typename boost::mpl::if_c < UseCheckedMultiprecisionInteger, - boost::multiprecision::checked, - boost::multiprecision::unchecked + boost::integral_constant + < + boost::multiprecision::cpp_int_check_type, + boost::multiprecision::checked + >, + boost::integral_constant + < + boost::multiprecision::cpp_int_check_type, + boost::multiprecision::unchecked + > >::type checking_policy_type; typedef boost::multiprecision::number @@ -119,7 +128,7 @@ private: 2 * CHAR_BIT * sizeof(T), 2 * CHAR_BIT * sizeof(T), boost::multiprecision::signed_magnitude, - checking_policy_type, + checking_policy_type::value, void > > multiprecision_integer_type; From eb0dfd1b5dfd175d86b2e2e03ff5f93ae73cb155 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 26 Mar 2015 18:51:11 +0200 Subject: [PATCH 093/146] [test][util][promote integral] add tests for the unsigned types: unsigned char, unsigned short, unsigned int, unsigned long, std::size_t; add test for the type signed char; --- test/util/promote_integral.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/util/promote_integral.cpp b/test/util/promote_integral.cpp index 896f2a3f9..22249d3c6 100644 --- a/test/util/promote_integral.cpp +++ b/test/util/promote_integral.cpp @@ -15,6 +15,7 @@ #if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) #include #endif +#include #include #include @@ -126,21 +127,31 @@ void test_promotion() BOOST_AUTO_TEST_CASE( test_char ) { test_promotion(); + test_promotion(); + test_promotion(); } BOOST_AUTO_TEST_CASE( test_short ) { test_promotion(); + test_promotion(); } BOOST_AUTO_TEST_CASE( test_int ) { test_promotion(); + test_promotion(); } BOOST_AUTO_TEST_CASE( test_long ) { test_promotion(); + test_promotion(); +} + +BOOST_AUTO_TEST_CASE( test_std_size_t ) +{ + test_promotion(); } #ifdef BOOST_HAS_LONG_LONG From 90c2c5f28801be03b2b50b41d1cd228c2d1a32f4 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Fri, 27 Mar 2015 11:27:27 +0200 Subject: [PATCH 094/146] [policies][relate][intersection points] move calls to get<> out of down-cast of promoted type to coordinate type --- .../geometry/policies/relate/intersection_points.hpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/include/boost/geometry/policies/relate/intersection_points.hpp b/include/boost/geometry/policies/relate/intersection_points.hpp index 9309d6c5a..559b12f9e 100644 --- a/include/boost/geometry/policies/relate/intersection_points.hpp +++ b/include/boost/geometry/policies/relate/intersection_points.hpp @@ -71,10 +71,14 @@ struct segments_intersection_points promoted_type dx_promoted = boost::numeric_cast(dx); promoted_type dy_promoted = boost::numeric_cast(dy); - set<0>(point, boost::numeric_cast( - get<0, 0>(segment) + numerator * dx_promoted / denominator)); - set<1>(point, boost::numeric_cast( - get<0, 1>(segment) + numerator * dy_promoted / denominator)); + set<0>(point, get<0, 0>(segment) + boost::numeric_cast + < + coordinate_type + >(numerator * dx_promoted / denominator)); + set<1>(point, get<0, 1>(segment) + boost::numeric_cast + < + coordinate_type + >(numerator * dy_promoted / denominator)); } From 74556828af5e139b24766e8a3f1711ef1d32f9fe Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Fri, 27 Mar 2015 11:50:38 +0200 Subject: [PATCH 095/146] [util][promote integral] re-implement the mpl::list loop using MPL list iterators; add support for unsigned integral numbers (including a template parameter that indicates whether they should be promoted to signed or unsigned numbers); be more precise on the (bit) sizes required for the promoted type; --- .../boost/geometry/util/promote_integral.hpp | 163 +++++++++++++++--- 1 file changed, 137 insertions(+), 26 deletions(-) diff --git a/include/boost/geometry/util/promote_integral.hpp b/include/boost/geometry/util/promote_integral.hpp index e4ad8e3ab..43e445954 100644 --- a/include/boost/geometry/util/promote_integral.hpp +++ b/include/boost/geometry/util/promote_integral.hpp @@ -15,12 +15,14 @@ #define BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER #include +#include -#include -#include +#include +#include +#include #include #include -#include +#include #if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) #include @@ -28,6 +30,7 @@ #include #include +#include namespace boost { namespace geometry @@ -37,31 +40,34 @@ namespace boost { namespace geometry namespace detail { namespace promote_integral { + template < typename T, - typename List, - bool IsEmpty = boost::mpl::empty::type::value + typename Iterator, + typename EndIterator, + std::size_t MinSize > struct promote_to_larger { typedef typename boost::mpl::if_c < - (sizeof(typename boost::mpl::front::type) >= 2 * sizeof(T)), - typename boost::mpl::front::type, + (sizeof(typename boost::mpl::deref::type) >= MinSize), + typename boost::mpl::deref::type, typename promote_to_larger < - T, typename boost::mpl::pop_front::type + T, + typename boost::mpl::next::type, + EndIterator, + MinSize >::type >::type type; }; // The following specialization is required to finish the loop over -// all list elements: the empty MPL list does not support -// boost::mpl::front and boost::mpl::pop_front, and thus without this -// specialization we get a compilation error -template -struct promote_to_larger +// all list elements +template +struct promote_to_larger { // if promotion fails, keep the number T // (and cross fingers that overflow will not occur) @@ -101,11 +107,19 @@ struct promote_to_larger \note boost::int128_type is considered only if the macro BOOST_HAS_INT128 is defined */ -template +template +< + typename T, + bool PromoteUnsignedToUnsigned = false, + bool UseCheckedMultiprecisionInteger = false +> class promote_integral { private: + static bool const is_unsigned = boost::is_unsigned::type::value; + #if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) + // Define the proper check policy for the multiprecision integer typedef typename boost::mpl::if_c < UseCheckedMultiprecisionInteger, @@ -119,21 +133,88 @@ private: boost::multiprecision::cpp_int_check_type, boost::multiprecision::unchecked > - >::type checking_policy_type; + >::type check_policy_type; - typedef boost::multiprecision::number + // Meta-function to get the multiprecision integer type for the + // given size and type (signed/unsigned) + template + < + unsigned int Size, + boost::multiprecision::cpp_integer_type IntegerType + > + struct multiprecision_integer_type + { + typedef boost::multiprecision::number + < + boost::multiprecision::cpp_int_backend + < + Size, + Size, + IntegerType, + check_policy_type::value, + void + > + > type; + }; + + // Meta-function to get the multiprecision signed integer type for + // the given size + template + struct multiprecision_signed_integer_type + { + typedef typename multiprecision_integer_type + < + Size, boost::multiprecision::signed_magnitude + >::type type; + }; + + // Meta-function to get the multiprecision unsigned integer type for + // the given size + template + struct multiprecision_unsigned_integer_type + { + typedef typename multiprecision_integer_type + < + Size, boost::multiprecision::unsigned_magnitude + >::type type; + }; + + // Define the minimum (and maximum) bit size for the + // multiprecision integer needed + // If T is the input type and P the promoted type, then the + // minimum number of bits for P are (below b stands for the number + // of bits of T): + // * if T is unsigned and P is unsigned: 2 * b + // * if T is signed and P is signed: 2 * b - 1 + // * if T is unsigned and P is signed: 2 * b + 1 + typedef typename boost::mpl::if_c < - boost::multiprecision::cpp_int_backend + (PromoteUnsignedToUnsigned && is_unsigned), + boost::integral_constant < - 2 * CHAR_BIT * sizeof(T), - 2 * CHAR_BIT * sizeof(T), - boost::multiprecision::signed_magnitude, - checking_policy_type::value, - void + unsigned int, (2 * CHAR_BIT * sizeof(T)) + >, + boost::integral_constant + < + unsigned int, + (2 * CHAR_BIT * sizeof(T) + (is_unsigned ? 1 : -1)) > - > multiprecision_integer_type; + >::type multiprecision_integer_min_bit_size_type; #endif + // Define the minimum size (in bytes) for the promoted type + typedef typename boost::mpl::if_c + < + (PromoteUnsignedToUnsigned && is_unsigned), + boost::integral_constant, + boost::integral_constant + < + std::size_t, (2 * sizeof(T) + (is_unsigned ? 1 : -1)) + > + >::type min_size_type; + + // Define the list of signed integral types we are goind to use + // for promotion typedef boost::mpl::list < short, int, long @@ -144,9 +225,35 @@ private: , boost::int128_type #endif #if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) - , multiprecision_integer_type + , typename multiprecision_signed_integer_type + < + multiprecision_integer_min_bit_size_type::value + >::type #endif - > integral_types; + > signed_integral_types; + + // Define the list of unsigned integral types we are goind to use + // for promotion + typedef boost::mpl::list + < + unsigned short, unsigned int, unsigned long, std::size_t +#if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) + , typename multiprecision_unsigned_integer_type + < + multiprecision_integer_min_bit_size_type::value + >::type +#endif + > unsigned_integral_types; + + // Define the list of integral types that will be used for + // promotion (depending in whether we was to promote unsigned to + // unsigned or not) + typedef typename boost::mpl::if_c + < + (is_unsigned && PromoteUnsignedToUnsigned), + unsigned_integral_types, + signed_integral_types + >::type integral_types; public: typedef typename boost::mpl::if_c @@ -154,12 +261,16 @@ public: boost::is_integral::type::value, typename detail::promote_integral::promote_to_larger < - T, integral_types + T, + typename boost::mpl::begin::type, + typename boost::mpl::end::type, + min_size_type::value >::type, T >::type type; }; + }} // namespace boost::geometry #endif // BOOST_GEOMETRY_UTIL_PROMOTE_INTEGRAL_HPP From 3154673657826f8a2dde1bcd3b5bc9f66de7b9b0 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Fri, 27 Mar 2015 11:54:14 +0200 Subject: [PATCH 096/146] [test][util][promote integral] make computation of minimum required size more precise; add testing for unsigned types; --- test/util/promote_integral.cpp | 395 ++++++++++++++++++++++++++------- 1 file changed, 315 insertions(+), 80 deletions(-) diff --git a/test/util/promote_integral.cpp b/test/util/promote_integral.cpp index 22249d3c6..d5b9de1f3 100644 --- a/test/util/promote_integral.cpp +++ b/test/util/promote_integral.cpp @@ -16,15 +16,21 @@ #include #endif #include +#include +#include #include +#include +#include #include #include #include +#include #include +#include #include #include @@ -32,7 +38,25 @@ #if defined(BOOST_GEOMETRY_TEST_DEBUG) && defined(BOOST_HAS_INT128) std::ostream& operator<<(std::ostream& os, boost::int128_type i) { - os << double(i); + if (i == 0) + { + os << "0"; + return os; + } + if (i < 0) + { + i = -i; + os << "-"; + } + std::stringstream stream; + while (i > 0) + { + stream << static_cast(i % 10); + i /= 10; + } + std::string str = stream.str(); + std::reverse(str.begin(), str.end()); + os << str; return os; } #endif @@ -40,135 +64,305 @@ std::ostream& operator<<(std::ostream& os, boost::int128_type i) namespace bg = boost::geometry; -template -inline void test_promote_integral() +template +< + typename T, + bool Signed = boost::is_fundamental::type::value + && ! boost::is_unsigned::type::value +> +struct absolute_value { - typedef typename bg::promote_integral::type promoted_integral_type; - bool const same_types = boost::is_same - < - promoted_integral_type, ExpectedPromotedType - >::type::value; - - BOOST_CHECK(same_types); - -#ifdef BOOST_GEOMETRY_TEST_DEBUG - std::cout << "type : " << typeid(Type).name() - << ", sizeof: " << sizeof(Type) - << ", max value: " - << std::numeric_limits::max() - << std::endl; - std::cout << "detected promoted type : " - << typeid(promoted_integral_type).name() - << ", sizeof: " << sizeof(promoted_integral_type) - << ", max value: " - << std::numeric_limits::max() - << std::endl; - std::cout << "expected promoted type : " - << typeid(ExpectedPromotedType).name() - << ", sizeof: " << sizeof(ExpectedPromotedType) - << ", max value: " - << std::numeric_limits::max() - << std::endl; - std::cout << std::endl; -#endif -} + static inline T apply(T const& t) + { + return t < 0 ? -t : t; + } +}; template -void test_promotion() +struct absolute_value { - if (sizeof(short) >= 2 * sizeof(T)) + static inline T apply(T const& t) { - test_promote_integral(); + return t; } - else if (sizeof(int) >= 2 * sizeof(T)) +}; + + + +template +< + typename Integral, + typename Promoted, + bool Signed = ! boost::is_unsigned::type::value +> +struct test_max_values +{ + static inline void apply() { - test_promote_integral(); + Promoted max_value = std::numeric_limits::max(); + max_value *= max_value; + BOOST_CHECK(absolute_value::apply(max_value) == max_value); } - else if (sizeof(long) >= 2 * sizeof(T)) +}; + +template +struct test_max_values +{ + static inline void apply() { - test_promote_integral(); + Promoted max_value = std::numeric_limits::max(); + Promoted max_value_sqr = max_value * max_value; + BOOST_CHECK(max_value_sqr < std::numeric_limits::max() + && + max_value_sqr > max_value); } +}; + +template +struct test_promote_integral +{ + template + static inline void apply(std::string const& case_id) + { + typedef typename bg::promote_integral + < + Type, PromoteUnsignedToUnsigned + >::type promoted_integral_type; + + bool const same_types = boost::is_same + < + promoted_integral_type, ExpectedPromotedType + >::type::value; + + BOOST_CHECK_MESSAGE(same_types, + "case ID: " << case_id + << "input type: " << typeid(Type).name() + << "; detected: " + << typeid(promoted_integral_type).name() + << "; expected: " + << typeid(ExpectedPromotedType).name()); + + if (BOOST_GEOMETRY_CONDITION((! boost::is_same + < + Type, promoted_integral_type + >::type::value))) + { + test_max_values::apply(); + } + +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << "case ID: " << case_id << std::endl + << "type : " << typeid(Type).name() + << ", sizeof: " << sizeof(Type) + << ", max value: " + << std::numeric_limits::max() + << std::endl; + std::cout << "detected promoted type : " + << typeid(promoted_integral_type).name() + << ", sizeof: " << sizeof(promoted_integral_type) + << ", max value: " + << std::numeric_limits::max() + << std::endl; + std::cout << "expected promoted type : " + << typeid(ExpectedPromotedType).name() + << ", sizeof: " << sizeof(ExpectedPromotedType) + << ", max value: " + << std::numeric_limits::max() + << std::endl; + std::cout << std::endl; +#endif + } +}; + +template +< + typename T, + bool PromoteUnsignedToUnsigned = false, + bool IsSigned = ! boost::is_unsigned::type::value +> +struct test_promotion +{ + static inline void apply(std::string case_id) + { +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << "*** " + << (IsSigned ? "signed" : "unsigned") + << " -> signed ***" << std::endl; +#endif + + typedef test_promote_integral tester; + + case_id += (PromoteUnsignedToUnsigned ? "-t" : "-f"); + + std::size_t min_size = 2 * sizeof(T) - 1; + if (BOOST_GEOMETRY_CONDITION(! IsSigned)) + { + min_size += 2; + } + + if (BOOST_GEOMETRY_CONDITION(sizeof(short) >= min_size)) + { + tester::template apply(case_id); + } + else if (BOOST_GEOMETRY_CONDITION(sizeof(int) >= min_size)) + { + tester::template apply(case_id); + } + else if (BOOST_GEOMETRY_CONDITION(sizeof(long) >= min_size)) + { + tester::template apply(case_id); + } #if defined(BOOST_HAS_LONG_LONG) - else if (sizeof(boost::long_long_type) >= 2 * sizeof(T)) - { - test_promote_integral(); - } + else if (BOOST_GEOMETRY_CONDITION(sizeof(boost::long_long_type) + >= min_size)) + { + tester::template apply(case_id); + } #endif #if defined(BOOST_HAS_INT128) - else if (sizeof(boost::int128_type) >= 2 * sizeof(T)) - { - test_promote_integral(); - } + else if (BOOST_GEOMETRY_CONDITION(sizeof(boost::int128_type) + >= min_size)) + { + tester::template apply(case_id); + } #endif - else - { + else + { #if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) - namespace bm = boost::multiprecision; - typedef bm::number - < - bm::cpp_int_backend + namespace bm = boost::multiprecision; + typedef bm::number + < + bm::cpp_int_backend < - 2 * CHAR_BIT * sizeof(T), - 2 * CHAR_BIT * sizeof(T), + 2 * CHAR_BIT * sizeof(T) + (IsSigned ? -1 : 1), + 2 * CHAR_BIT * sizeof(T) + (IsSigned ? -1 : 1), bm::signed_magnitude, bm::unchecked, void > - > multiprecision_integer_type; + > multiprecision_integer_type; - test_promote_integral(); + tester::template apply(case_id); #else - test_promote_integral(); + tester::template apply(case_id); #endif + } } -} +}; + +template +struct test_promotion +{ + static inline void apply(std::string case_id) + { +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << "*** unsigned -> unsigned ***" << std::endl; +#endif + case_id += "-t"; + + typedef test_promote_integral tester; + + std::size_t const min_size = 2 * sizeof(T); + + if (BOOST_GEOMETRY_CONDITION(sizeof(unsigned short) >= min_size)) + { + tester::apply(case_id); + } + else if (BOOST_GEOMETRY_CONDITION(sizeof(unsigned int) >= min_size)) + { + tester::apply(case_id); + } + else if (BOOST_GEOMETRY_CONDITION(sizeof(unsigned long) >= min_size)) + { + tester::apply(case_id); + } + else if (BOOST_GEOMETRY_CONDITION(sizeof(std::size_t) >= min_size)) + { + tester::apply(case_id); + } + else + { +#if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) + namespace bm = boost::multiprecision; + typedef bm::number + < + bm::cpp_int_backend + < + CHAR_BIT * min_size, + CHAR_BIT * min_size, + bm::unsigned_magnitude, + bm::unchecked, + void + > + > multiprecision_integer_type; + + tester::apply(case_id); +#else + tester::apply(case_id); +#endif + } + } +}; + BOOST_AUTO_TEST_CASE( test_char ) { - test_promotion(); - test_promotion(); - test_promotion(); + test_promotion::apply("char"); + test_promotion::apply("char"); + test_promotion::apply("schar"); + test_promotion::apply("schar"); + test_promotion::apply("uchar"); + test_promotion::apply("uchar"); } BOOST_AUTO_TEST_CASE( test_short ) { - test_promotion(); - test_promotion(); + test_promotion::apply("short"); + test_promotion::apply("short"); + test_promotion::apply("ushort"); + test_promotion::apply("ushort"); } BOOST_AUTO_TEST_CASE( test_int ) { - test_promotion(); - test_promotion(); + test_promotion::apply("int"); + test_promotion::apply("int"); + test_promotion::apply("uint"); + test_promotion::apply("uint"); } BOOST_AUTO_TEST_CASE( test_long ) { - test_promotion(); - test_promotion(); + test_promotion::apply("long"); + test_promotion::apply("long"); + test_promotion::apply("ulong"); + test_promotion::apply("ulong"); } BOOST_AUTO_TEST_CASE( test_std_size_t ) { - test_promotion(); + test_promotion::apply("size_t"); + test_promotion::apply("size_t"); } #ifdef BOOST_HAS_LONG_LONG BOOST_AUTO_TEST_CASE( test_long_long ) { - test_promotion(); + test_promotion::apply("long long"); + test_promotion::apply("long long"); } #endif #if defined(BOOST_HAS_INT128) BOOST_AUTO_TEST_CASE( test_int128 ) { - test_promotion(); + test_promotion::apply("int128_t"); + test_promotion::apply("int128_t"); } #endif -BOOST_AUTO_TEST_CASE( test_custom_types ) +BOOST_AUTO_TEST_CASE( test_user_types ) { namespace bm = boost::multiprecision; typedef bm::number @@ -181,7 +375,19 @@ BOOST_AUTO_TEST_CASE( test_custom_types ) bm::unchecked, void > - > custom_integral_type1; + > user_signed_type1; + + typedef bm::number + < + bm::cpp_int_backend + < + 17, + 17, + bm::unsigned_magnitude, + bm::unchecked, + void + > + > user_unsigned_type1; typedef bm::number < @@ -193,21 +399,50 @@ BOOST_AUTO_TEST_CASE( test_custom_types ) bm::unchecked, void > - > custom_integral_type2; + > user_signed_type2; + + typedef bm::number + < + bm::cpp_int_backend + < + 500, + 500, + bm::unsigned_magnitude, + bm::unchecked, + void + > + > user_unsigned_type2; // for user defined number types we do not do any promotion - test_promote_integral(); - test_promote_integral(); + typedef test_promote_integral tester1; + typedef test_promote_integral tester2; + tester1::apply("u1s"); + tester1::apply("u2s"); + tester1::apply("u1u"); + tester1::apply("u2u"); + + tester2::apply("u1s"); + tester2::apply("u2s"); + tester2::apply("u1u"); + tester2::apply("u1u"); } BOOST_AUTO_TEST_CASE( test_floating_point ) { + typedef test_promote_integral tester1; + typedef test_promote_integral tester2; + // for floating-point types we do not do any promotion - test_promote_integral(); - test_promote_integral(); - test_promote_integral(); + tester1::apply("fp-f"); + tester1::apply("fp-d"); + tester1::apply("fp-ld"); + + tester2::apply("fp-f"); + tester2::apply("fp-d"); + tester2::apply("fp-ld"); #ifdef HAVE_TTMATH - test_promote_integral(); + tester1::apply("fp-tt"); + tester2::apply("fp-tt"); #endif } From 88009aa38b2a9bc47ab4f1c1cc97b84ec854368e Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Fri, 27 Mar 2015 14:18:23 +0200 Subject: [PATCH 097/146] [util][promote integral] replace boost::integral_constant by boost::mpl::size_t when possible (2 instances) --- include/boost/geometry/util/promote_integral.hpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/include/boost/geometry/util/promote_integral.hpp b/include/boost/geometry/util/promote_integral.hpp index 43e445954..96dcc4936 100644 --- a/include/boost/geometry/util/promote_integral.hpp +++ b/include/boost/geometry/util/promote_integral.hpp @@ -23,6 +23,7 @@ #include #include #include +#include #if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) #include @@ -206,11 +207,8 @@ private: typedef typename boost::mpl::if_c < (PromoteUnsignedToUnsigned && is_unsigned), - boost::integral_constant, - boost::integral_constant - < - std::size_t, (2 * sizeof(T) + (is_unsigned ? 1 : -1)) - > + boost::mpl::size_t<(2 * sizeof(T))>, + boost::mpl::size_t<(2 * sizeof(T) + (is_unsigned ? 1 : -1))> >::type min_size_type; // Define the list of signed integral types we are goind to use From af1a3da82387c0421d7513d41728e71af3c862bc Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Fri, 27 Mar 2015 22:45:49 +0200 Subject: [PATCH 098/146] [util][promote integral] add support for unsigned long long and uint128 --- include/boost/geometry/util/promote_integral.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/boost/geometry/util/promote_integral.hpp b/include/boost/geometry/util/promote_integral.hpp index 96dcc4936..9f83b446c 100644 --- a/include/boost/geometry/util/promote_integral.hpp +++ b/include/boost/geometry/util/promote_integral.hpp @@ -235,6 +235,12 @@ private: typedef boost::mpl::list < unsigned short, unsigned int, unsigned long, std::size_t +#if defined(BOOST_HAS_LONG_LONG) + , boost::ulong_long_type +#endif +#if defined(BOOST_HAS_INT128) + , boost::uint128_type +#endif #if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) , typename multiprecision_unsigned_integer_type < From 27e7ad6aa62eab7bdb3b1219dd93fc35c819363a Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Fri, 27 Mar 2015 22:46:34 +0200 Subject: [PATCH 099/146] [test][util][promote integral] update unit test to account for unsigned long long and uint128 --- test/util/promote_integral.cpp | 55 +++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/test/util/promote_integral.cpp b/test/util/promote_integral.cpp index d5b9de1f3..f01ab7d06 100644 --- a/test/util/promote_integral.cpp +++ b/test/util/promote_integral.cpp @@ -36,18 +36,14 @@ #include #if defined(BOOST_GEOMETRY_TEST_DEBUG) && defined(BOOST_HAS_INT128) -std::ostream& operator<<(std::ostream& os, boost::int128_type i) +void print_uint128_t(std::ostream& os, boost::uint128_type i) { if (i == 0) { os << "0"; - return os; - } - if (i < 0) - { - i = -i; - os << "-"; + return; } + std::stringstream stream; while (i > 0) { @@ -57,6 +53,25 @@ std::ostream& operator<<(std::ostream& os, boost::int128_type i) std::string str = stream.str(); std::reverse(str.begin(), str.end()); os << str; +} + +std::ostream& operator<<(std::ostream& os, boost::int128_type i) +{ + if (i < 0) + { + os << "-"; + print_uint128_t(os, static_cast(-i)); + } + else + { + print_uint128_t(os, static_cast(i)); + } + return os; +} + +std::ostream& operator<<(std::ostream& os, boost::uint128_type i) +{ + print_uint128_t(os, i); return os; } #endif @@ -200,6 +215,10 @@ struct test_promotion min_size += 2; } +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << "min size: " << min_size << std::endl; +#endif + if (BOOST_GEOMETRY_CONDITION(sizeof(short) >= min_size)) { tester::template apply(case_id); @@ -264,6 +283,10 @@ struct test_promotion std::size_t const min_size = 2 * sizeof(T); +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << "min size: " << min_size << std::endl; +#endif + if (BOOST_GEOMETRY_CONDITION(sizeof(unsigned short) >= min_size)) { tester::apply(case_id); @@ -280,6 +303,20 @@ struct test_promotion { tester::apply(case_id); } +#if defined(BOOST_HAS_LONG_LONG) + else if (BOOST_GEOMETRY_CONDITION(sizeof(boost::ulong_long_type) + >= min_size)) + { + tester::template apply(case_id); + } +#endif +#if defined(BOOST_HAS_INT128) + else if (BOOST_GEOMETRY_CONDITION(sizeof(boost::uint128_type) + >= min_size)) + { + tester::template apply(case_id); + } +#endif else { #if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) @@ -351,6 +388,8 @@ BOOST_AUTO_TEST_CASE( test_long_long ) { test_promotion::apply("long long"); test_promotion::apply("long long"); + test_promotion::apply("ulong long"); + test_promotion::apply("ulong long"); } #endif @@ -359,6 +398,8 @@ BOOST_AUTO_TEST_CASE( test_int128 ) { test_promotion::apply("int128_t"); test_promotion::apply("int128_t"); + test_promotion::apply("uint128_t"); + test_promotion::apply("uint128_t"); } #endif From e169f80ad3465c51c690f13efb39ad531d51d2ac Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Sat, 28 Mar 2015 01:30:07 +0200 Subject: [PATCH 100/146] [util][promote integral] update inline documentation; polish code; measure all sizes in bits rather than a mixture of bits and bytes; --- .../boost/geometry/util/promote_integral.hpp | 140 ++++++++++-------- 1 file changed, 81 insertions(+), 59 deletions(-) diff --git a/include/boost/geometry/util/promote_integral.hpp b/include/boost/geometry/util/promote_integral.hpp index 9f83b446c..4e22c579d 100644 --- a/include/boost/geometry/util/promote_integral.hpp +++ b/include/boost/geometry/util/promote_integral.hpp @@ -41,6 +41,41 @@ namespace boost { namespace geometry namespace detail { namespace promote_integral { +// meta-function that returns the bit size of a type +// for fundamental integral types, just return CHAR_BIT * sizeof(T) +template +< + typename T, + bool IsIntegral = boost::is_integral::type::value +> +struct bit_size : boost::mpl::size_t<(CHAR_BIT * sizeof(T))> +{}; + + +#if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) +// partial specialization for cpp_int +template +< + unsigned MinSize, + unsigned MaxSize, + boost::multiprecision::cpp_integer_type SignType, + boost::multiprecision::cpp_int_check_type Checked, + typename Allocator +> +struct bit_size + < + boost::multiprecision::number + < + boost::multiprecision::cpp_int_backend + < + MinSize, MaxSize, SignType, Checked, Allocator + > + >, + false + > : boost::mpl::size_t +{}; +#endif + template < @@ -51,9 +86,14 @@ template > struct promote_to_larger { + typedef typename bit_size + < + typename boost::mpl::deref::type + >::type bit_size_type; + typedef typename boost::mpl::if_c < - (sizeof(typename boost::mpl::deref::type) >= MinSize), + (bit_size_type::value >= MinSize), typename boost::mpl::deref::type, typename promote_to_larger < @@ -82,15 +122,28 @@ struct promote_to_larger /*! \brief Meta-function to define an integral type with size - than is at least twice the size of T + than is (roughly) twice the bit size of T \ingroup utility \details - This meta-function tries to promote the fundamental integral type - T to a another integral type with size at least twice the size of T. + This meta-function tries to promote the fundamental integral type T + to a another integral type with size (roughly) twice the bit size of T. - To do this, two times the size of T is tested against the sizes of: + To do this, two times the bit size of T is tested against the bit sizes of: short, int, long, boost::long_long_type, boost::int128_t - and the one that matches is chosen. + and the one that first matches is chosen. + + For unsigned types the bit size of T is tested against the bit + sizes of the types above, if T is promoted to a signed type, or + the bit sizes of + unsigned short, unsigned int, unsigned long, std::size_t, + boost::ulong_long_type, boost::uint128_t + if T is promoted to an unsigned type. + + By default an unsigned type is promoted to a signed type. + This behavior is controlled by the PromoteUnsignedToUnsigned + boolean template parameter, whose default value is "false". + To promote an unsigned type to an unsigned type set the value of + this template parameter to "true". If the macro BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER is not defined, boost's multiprecision integer cpp_int<> is used as a @@ -102,11 +155,11 @@ struct promote_to_larger Finally, if the passed type is either a floating-point type or a user-defined type it is returned as is. - \note boost::long_long_type is considered only if the macro - BOOST_HAS_LONG_LONG is defined + \note boost::long_long_type and boost::ulong_long_type are + considered only if the macro BOOST_HAS_LONG_LONG is defined - \note boost::int128_type is considered only if the macro - BOOST_HAS_INT128 is defined + \note boost::int128_type and boost::uint128_type are considered + only if the macro BOOST_HAS_INT128 is defined */ template < @@ -119,6 +172,8 @@ class promote_integral private: static bool const is_unsigned = boost::is_unsigned::type::value; + typedef detail::promote_integral::bit_size bit_size_type; + #if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) // Define the proper check policy for the multiprecision integer typedef typename boost::mpl::if_c @@ -137,11 +192,11 @@ private: >::type check_policy_type; // Meta-function to get the multiprecision integer type for the - // given size and type (signed/unsigned) + // given size and sign type (signed/unsigned) template < unsigned int Size, - boost::multiprecision::cpp_integer_type IntegerType + boost::multiprecision::cpp_integer_type SignType > struct multiprecision_integer_type { @@ -151,37 +206,15 @@ private: < Size, Size, - IntegerType, + SignType, check_policy_type::value, void > > type; }; +#endif - // Meta-function to get the multiprecision signed integer type for - // the given size - template - struct multiprecision_signed_integer_type - { - typedef typename multiprecision_integer_type - < - Size, boost::multiprecision::signed_magnitude - >::type type; - }; - - // Meta-function to get the multiprecision unsigned integer type for - // the given size - template - struct multiprecision_unsigned_integer_type - { - typedef typename multiprecision_integer_type - < - Size, boost::multiprecision::unsigned_magnitude - >::type type; - }; - - // Define the minimum (and maximum) bit size for the - // multiprecision integer needed + // Define the minimum size (in bits) needed for the promoted type // If T is the input type and P the promoted type, then the // minimum number of bits for P are (below b stands for the number // of bits of T): @@ -191,25 +224,12 @@ private: typedef typename boost::mpl::if_c < (PromoteUnsignedToUnsigned && is_unsigned), - boost::integral_constant + boost::mpl::size_t<(2 * bit_size_type::value)>, + boost::mpl::size_t < - unsigned int, (2 * CHAR_BIT * sizeof(T)) - >, - boost::integral_constant - < - unsigned int, - (2 * CHAR_BIT * sizeof(T) + (is_unsigned ? 1 : -1)) + (2 * bit_size_type::value + (is_unsigned ? 1 : -1)) > - >::type multiprecision_integer_min_bit_size_type; -#endif - - // Define the minimum size (in bytes) for the promoted type - typedef typename boost::mpl::if_c - < - (PromoteUnsignedToUnsigned && is_unsigned), - boost::mpl::size_t<(2 * sizeof(T))>, - boost::mpl::size_t<(2 * sizeof(T) + (is_unsigned ? 1 : -1))> - >::type min_size_type; + >::type min_bit_size_type; // Define the list of signed integral types we are goind to use // for promotion @@ -223,9 +243,10 @@ private: , boost::int128_type #endif #if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) - , typename multiprecision_signed_integer_type + , typename multiprecision_integer_type < - multiprecision_integer_min_bit_size_type::value + min_bit_size_type::value, + boost::multiprecision::signed_magnitude >::type #endif > signed_integral_types; @@ -242,9 +263,10 @@ private: , boost::uint128_type #endif #if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) - , typename multiprecision_unsigned_integer_type + , typename multiprecision_integer_type < - multiprecision_integer_min_bit_size_type::value + min_bit_size_type::value, + boost::multiprecision::unsigned_magnitude >::type #endif > unsigned_integral_types; @@ -268,7 +290,7 @@ public: T, typename boost::mpl::begin::type, typename boost::mpl::end::type, - min_size_type::value + min_bit_size_type::value >::type, T >::type type; From 3df65c1bd4649ff006c78902118b08c7902b961b Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Sat, 28 Mar 2015 01:32:24 +0200 Subject: [PATCH 101/146] [test][util][promote integral] measure all sizes in bits rather than a mixture of bits and bytes; add a few more tests regarding max and min values; --- test/util/promote_integral.cpp | 71 ++++++++++++++++++++++------------ 1 file changed, 47 insertions(+), 24 deletions(-) diff --git a/test/util/promote_integral.cpp b/test/util/promote_integral.cpp index f01ab7d06..b10487cb6 100644 --- a/test/util/promote_integral.cpp +++ b/test/util/promote_integral.cpp @@ -12,9 +12,7 @@ #define BOOST_TEST_MODULE test_promote_integral #endif -#if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) #include -#endif #include #include #include @@ -114,9 +112,18 @@ struct test_max_values { static inline void apply() { + Promoted min_value = std::numeric_limits::min(); + min_value *= min_value; + BOOST_CHECK(absolute_value::apply(min_value) == min_value); Promoted max_value = std::numeric_limits::max(); max_value *= max_value; BOOST_CHECK(absolute_value::apply(max_value) == max_value); + +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << "integral min_value^2: " << min_value << std::endl; + std::cout << "promoted max_value: " + << std::numeric_limits::max() << std::endl; +#endif } }; @@ -130,9 +137,23 @@ struct test_max_values BOOST_CHECK(max_value_sqr < std::numeric_limits::max() && max_value_sqr > max_value); + +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << "integral max_value^2: " << max_value_sqr << std::endl; + std::cout << "promoted max_value: " + << std::numeric_limits::max() << std::endl; +#endif } }; + +// helper function that returns the bit size of a type +template +std::size_t bit_size() +{ + return bg::detail::promote_integral::bit_size::type::value; +} + template struct test_promote_integral { @@ -168,19 +189,25 @@ struct test_promote_integral #ifdef BOOST_GEOMETRY_TEST_DEBUG std::cout << "case ID: " << case_id << std::endl << "type : " << typeid(Type).name() - << ", sizeof: " << sizeof(Type) + << ", sizeof (bits): " << bit_size() + << ", min value: " + << std::numeric_limits::min() << ", max value: " << std::numeric_limits::max() << std::endl; std::cout << "detected promoted type : " << typeid(promoted_integral_type).name() - << ", sizeof: " << sizeof(promoted_integral_type) + << ", sizeof (bits): " << bit_size() + << ", min value: " + << std::numeric_limits::min() << ", max value: " << std::numeric_limits::max() << std::endl; std::cout << "expected promoted type : " << typeid(ExpectedPromotedType).name() - << ", sizeof: " << sizeof(ExpectedPromotedType) + << ", sizeof (bits): " << bit_size() + << ", min value: " + << std::numeric_limits::min() << ", max value: " << std::numeric_limits::max() << std::endl; @@ -209,7 +236,7 @@ struct test_promotion case_id += (PromoteUnsignedToUnsigned ? "-t" : "-f"); - std::size_t min_size = 2 * sizeof(T) - 1; + std::size_t min_size = 2 * bit_size() - 1; if (BOOST_GEOMETRY_CONDITION(! IsSigned)) { min_size += 2; @@ -219,28 +246,26 @@ struct test_promotion std::cout << "min size: " << min_size << std::endl; #endif - if (BOOST_GEOMETRY_CONDITION(sizeof(short) >= min_size)) + if (bit_size() >= min_size) { tester::template apply(case_id); } - else if (BOOST_GEOMETRY_CONDITION(sizeof(int) >= min_size)) + else if (bit_size() >= min_size) { tester::template apply(case_id); } - else if (BOOST_GEOMETRY_CONDITION(sizeof(long) >= min_size)) + else if (bit_size() >= min_size) { tester::template apply(case_id); } #if defined(BOOST_HAS_LONG_LONG) - else if (BOOST_GEOMETRY_CONDITION(sizeof(boost::long_long_type) - >= min_size)) + else if (bit_size() >= min_size) { tester::template apply(case_id); } #endif #if defined(BOOST_HAS_INT128) - else if (BOOST_GEOMETRY_CONDITION(sizeof(boost::int128_type) - >= min_size)) + else if (bit_size() >= min_size) { tester::template apply(case_id); } @@ -281,38 +306,36 @@ struct test_promotion typedef test_promote_integral tester; - std::size_t const min_size = 2 * sizeof(T); + std::size_t min_size = 2 * bit_size(); #ifdef BOOST_GEOMETRY_TEST_DEBUG std::cout << "min size: " << min_size << std::endl; #endif - if (BOOST_GEOMETRY_CONDITION(sizeof(unsigned short) >= min_size)) + if (bit_size() >= min_size) { tester::apply(case_id); } - else if (BOOST_GEOMETRY_CONDITION(sizeof(unsigned int) >= min_size)) + else if (bit_size() >= min_size) { tester::apply(case_id); } - else if (BOOST_GEOMETRY_CONDITION(sizeof(unsigned long) >= min_size)) + else if (bit_size() >= min_size) { tester::apply(case_id); } - else if (BOOST_GEOMETRY_CONDITION(sizeof(std::size_t) >= min_size)) + else if (bit_size() >= min_size) { tester::apply(case_id); } #if defined(BOOST_HAS_LONG_LONG) - else if (BOOST_GEOMETRY_CONDITION(sizeof(boost::ulong_long_type) - >= min_size)) + else if (bit_size() >= min_size) { tester::template apply(case_id); } #endif #if defined(BOOST_HAS_INT128) - else if (BOOST_GEOMETRY_CONDITION(sizeof(boost::uint128_type) - >= min_size)) + else if (bit_size() >= min_size) { tester::template apply(case_id); } @@ -325,8 +348,8 @@ struct test_promotion < bm::cpp_int_backend < - CHAR_BIT * min_size, - CHAR_BIT * min_size, + 2 * CHAR_BIT * sizeof(T), + 2 * CHAR_BIT * sizeof(T), bm::unsigned_magnitude, bm::unchecked, void From 7b515316e7adade5ba9abd7255eefd9d73fe8a19 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Sat, 28 Mar 2015 03:16:35 +0200 Subject: [PATCH 102/146] [util][promote integral] re-implement detail::promote_integral::bit_size<> in a more type safe way; split the implementation of promote_integral<> for (fundamental) integral and other types (non-integral or user-defined) so that for those types the compilation is simpler/faster; --- .../boost/geometry/util/promote_integral.hpp | 61 +++++++++++-------- 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/include/boost/geometry/util/promote_integral.hpp b/include/boost/geometry/util/promote_integral.hpp index 4e22c579d..6b000d7f6 100644 --- a/include/boost/geometry/util/promote_integral.hpp +++ b/include/boost/geometry/util/promote_integral.hpp @@ -30,6 +30,7 @@ #endif #include +#include #include #include @@ -42,13 +43,19 @@ namespace detail { namespace promote_integral { // meta-function that returns the bit size of a type -// for fundamental integral types, just return CHAR_BIT * sizeof(T) template < typename T, - bool IsIntegral = boost::is_integral::type::value + bool IsFundamental = boost::is_fundamental::type::value > -struct bit_size : boost::mpl::size_t<(CHAR_BIT * sizeof(T))> +struct bit_size +{}; + + +// for fundamental types, just return CHAR_BIT * sizeof(T) +template +struct bit_size + : boost::mpl::size_t<(CHAR_BIT * sizeof(T))> {}; @@ -60,7 +67,8 @@ template unsigned MaxSize, boost::multiprecision::cpp_integer_type SignType, boost::multiprecision::cpp_int_check_type Checked, - typename Allocator + typename Allocator, + boost::multiprecision::expression_template_option ExpressionTemplates > struct bit_size < @@ -69,12 +77,13 @@ struct bit_size boost::multiprecision::cpp_int_backend < MinSize, MaxSize, SignType, Checked, Allocator - > + >, + ExpressionTemplates >, false > : boost::mpl::size_t {}; -#endif +#endif // BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER template @@ -86,15 +95,12 @@ template > struct promote_to_larger { - typedef typename bit_size - < - typename boost::mpl::deref::type - >::type bit_size_type; + typedef typename boost::mpl::deref::type current_type; typedef typename boost::mpl::if_c < - (bit_size_type::value >= MinSize), - typename boost::mpl::deref::type, + (bit_size::type::value >= MinSize), + current_type, typename promote_to_larger < T, @@ -165,7 +171,8 @@ template < typename T, bool PromoteUnsignedToUnsigned = false, - bool UseCheckedMultiprecisionInteger = false + bool UseCheckedInteger = false, + bool IsIntegral = boost::is_integral::type::value > class promote_integral { @@ -178,7 +185,7 @@ private: // Define the proper check policy for the multiprecision integer typedef typename boost::mpl::if_c < - UseCheckedMultiprecisionInteger, + UseCheckedInteger, boost::integral_constant < boost::multiprecision::cpp_int_check_type, @@ -282,21 +289,27 @@ private: >::type integral_types; public: - typedef typename boost::mpl::if_c + typedef typename detail::promote_integral::promote_to_larger < - boost::is_integral::type::value, - typename detail::promote_integral::promote_to_larger - < - T, - typename boost::mpl::begin::type, - typename boost::mpl::end::type, - min_bit_size_type::value - >::type, - T + T, + typename boost::mpl::begin::type, + typename boost::mpl::end::type, + min_bit_size_type::value >::type type; }; +template +class promote_integral + < + T, PromoteUnsignedToUnsigned, UseCheckedInteger, false + > +{ +public: + typedef T type; +}; + + }} // namespace boost::geometry #endif // BOOST_GEOMETRY_UTIL_PROMOTE_INTEGRAL_HPP From 1b92041500327d4c5b48c0b407e0d6541bc3f9a8 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Sat, 28 Mar 2015 03:18:59 +0200 Subject: [PATCH 103/146] [test][util][promote integral] (re-)implement bit_size locally in the unit test --- test/util/promote_integral.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/test/util/promote_integral.cpp b/test/util/promote_integral.cpp index b10487cb6..ba878685a 100644 --- a/test/util/promote_integral.cpp +++ b/test/util/promote_integral.cpp @@ -148,10 +148,40 @@ struct test_max_values // helper function that returns the bit size of a type +template +< + typename T, + bool IsFundamental = boost::is_fundamental::type::value +> +struct bit_size_impl : boost::mpl::size_t<0> +{}; + +template +struct bit_size_impl : bg::detail::promote_integral::bit_size::type +{}; + +#if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) +template +< + typename Backend, + boost::multiprecision::expression_template_option ExpressionTemplates +> +struct bit_size_impl + < + boost::multiprecision::number, + false + > : bg::detail::promote_integral::bit_size + < + boost::multiprecision::number + > +{}; +#endif + + template std::size_t bit_size() { - return bg::detail::promote_integral::bit_size::type::value; + return bit_size_impl::type::value; } template From d6ca52c90edf93fef7e57c4f154f88a6d4c3c69f Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sat, 28 Mar 2015 02:46:21 +0100 Subject: [PATCH 104/146] [util] Avoid conversion of negative number to unsigned (MSVC warning). --- include/boost/geometry/util/promote_integral.hpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/boost/geometry/util/promote_integral.hpp b/include/boost/geometry/util/promote_integral.hpp index 6b000d7f6..29d72d821 100644 --- a/include/boost/geometry/util/promote_integral.hpp +++ b/include/boost/geometry/util/promote_integral.hpp @@ -232,10 +232,12 @@ private: < (PromoteUnsignedToUnsigned && is_unsigned), boost::mpl::size_t<(2 * bit_size_type::value)>, - boost::mpl::size_t + typename boost::mpl::if_c < - (2 * bit_size_type::value + (is_unsigned ? 1 : -1)) - > + is_unsigned, + boost::mpl::size_t<(2 * bit_size_type::value + 1)>, + boost::mpl::size_t<(2 * bit_size_type::value - 1)> + >::type >::type min_bit_size_type; // Define the list of signed integral types we are goind to use From 551507ac47366c2cfb94eee431de3a49c013ee1d Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sat, 28 Mar 2015 02:47:20 +0100 Subject: [PATCH 105/146] [test][util] Prevent min/max macro substitution for numeric_limits min/max. --- test/util/promote_integral.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/test/util/promote_integral.cpp b/test/util/promote_integral.cpp index ba878685a..4fd8955ee 100644 --- a/test/util/promote_integral.cpp +++ b/test/util/promote_integral.cpp @@ -112,17 +112,17 @@ struct test_max_values { static inline void apply() { - Promoted min_value = std::numeric_limits::min(); + Promoted min_value = (std::numeric_limits::min)(); min_value *= min_value; BOOST_CHECK(absolute_value::apply(min_value) == min_value); - Promoted max_value = std::numeric_limits::max(); + Promoted max_value = (std::numeric_limits::max)(); max_value *= max_value; BOOST_CHECK(absolute_value::apply(max_value) == max_value); #ifdef BOOST_GEOMETRY_TEST_DEBUG std::cout << "integral min_value^2: " << min_value << std::endl; std::cout << "promoted max_value: " - << std::numeric_limits::max() << std::endl; + << (std::numeric_limits::max)() << std::endl; #endif } }; @@ -132,16 +132,16 @@ struct test_max_values { static inline void apply() { - Promoted max_value = std::numeric_limits::max(); + Promoted max_value = (std::numeric_limits::max)(); Promoted max_value_sqr = max_value * max_value; - BOOST_CHECK(max_value_sqr < std::numeric_limits::max() + BOOST_CHECK(max_value_sqr < (std::numeric_limits::max)() && max_value_sqr > max_value); #ifdef BOOST_GEOMETRY_TEST_DEBUG std::cout << "integral max_value^2: " << max_value_sqr << std::endl; std::cout << "promoted max_value: " - << std::numeric_limits::max() << std::endl; + << (std::numeric_limits::max)() << std::endl; #endif } }; @@ -221,25 +221,25 @@ struct test_promote_integral << "type : " << typeid(Type).name() << ", sizeof (bits): " << bit_size() << ", min value: " - << std::numeric_limits::min() + << (std::numeric_limits::min)() << ", max value: " - << std::numeric_limits::max() + << (std::numeric_limits::max)() << std::endl; std::cout << "detected promoted type : " << typeid(promoted_integral_type).name() << ", sizeof (bits): " << bit_size() << ", min value: " - << std::numeric_limits::min() + << (std::numeric_limits::min)() << ", max value: " - << std::numeric_limits::max() + << (std::numeric_limits::max)() << std::endl; std::cout << "expected promoted type : " << typeid(ExpectedPromotedType).name() << ", sizeof (bits): " << bit_size() << ", min value: " - << std::numeric_limits::min() + << (std::numeric_limits::min)() << ", max value: " - << std::numeric_limits::max() + << (std::numeric_limits::max)() << std::endl; std::cout << std::endl; #endif From 4be353a5e4348ba5ae127050e67536add481effb Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Sat, 28 Mar 2015 14:50:32 +0100 Subject: [PATCH 106/146] [minor] fix typo --- include/boost/geometry/util/promote_integral.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/geometry/util/promote_integral.hpp b/include/boost/geometry/util/promote_integral.hpp index 29d72d821..3bf4d9f89 100644 --- a/include/boost/geometry/util/promote_integral.hpp +++ b/include/boost/geometry/util/promote_integral.hpp @@ -240,7 +240,7 @@ private: >::type >::type min_bit_size_type; - // Define the list of signed integral types we are goind to use + // Define the list of signed integral types we are going to use // for promotion typedef boost::mpl::list < @@ -260,7 +260,7 @@ private: #endif > signed_integral_types; - // Define the list of unsigned integral types we are goind to use + // Define the list of unsigned integral types we are going to use // for promotion typedef boost::mpl::list < From 32ccdc79eb476ed69f57d76a82173c65b1ebc632 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Sat, 28 Mar 2015 14:50:58 +0100 Subject: [PATCH 107/146] [minor] add const --- .../geometry/policies/relate/intersection_points.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/boost/geometry/policies/relate/intersection_points.hpp b/include/boost/geometry/policies/relate/intersection_points.hpp index 559b12f9e..082dc4ca7 100644 --- a/include/boost/geometry/policies/relate/intersection_points.hpp +++ b/include/boost/geometry/policies/relate/intersection_points.hpp @@ -64,12 +64,12 @@ struct segments_intersection_points typedef typename promote_integral::type promoted_type; - promoted_type numerator + promoted_type const numerator = boost::numeric_cast(ratio.numerator()); - promoted_type denominator + promoted_type const denominator = boost::numeric_cast(ratio.denominator()); - promoted_type dx_promoted = boost::numeric_cast(dx); - promoted_type dy_promoted = boost::numeric_cast(dy); + promoted_type const dx_promoted = boost::numeric_cast(dx); + promoted_type const dy_promoted = boost::numeric_cast(dy); set<0>(point, get<0, 0>(segment) + boost::numeric_cast < From c0f4b058068d424b670a908aaa0ce9f3487d4cc1 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sat, 28 Mar 2015 15:07:02 +0100 Subject: [PATCH 108/146] [test][intersection] Disable the test for ticket 10868. --- test/algorithms/set_operations/intersection/intersection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/algorithms/set_operations/intersection/intersection.cpp b/test/algorithms/set_operations/intersection/intersection.cpp index 9e191bd84..e15c3ee54 100644 --- a/test/algorithms/set_operations/intersection/intersection.cpp +++ b/test/algorithms/set_operations/intersection/intersection.cpp @@ -674,7 +674,6 @@ int test_main(int, char* []) #ifdef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS // ticket #10868 still fails for 32-bit integers test_ticket_10868("MULTIPOLYGON(((33520458 6878575,33480192 14931538,31446819 18947953,30772384 19615678,30101303 19612322,30114725 16928001,33520458 6878575)))"); -#endif #if !defined(BOOST_NO_INT64) || defined(BOOST_HAS_INT64_T) || defined(BOOST_HAS_MS_INT64) test_ticket_10868("MULTIPOLYGON(((33520458 6878575,33480192 14931538,31446819 18947953,30772384 19615678,30101303 19612322,30114725 16928001,33520458 6878575)))"); @@ -687,6 +686,7 @@ int test_main(int, char* []) #if defined(BOOST_HAS_LONG_LONG) test_ticket_10868("MULTIPOLYGON(((33520458 6878575,33480192 14931538,31446819 18947953,30772384 19615678,30101303 19612322,30114725 16928001,33520458 6878575)))"); +#endif #endif return 0; From e56561481eaa6359e34170ef75416df6d7cbaa01 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Sun, 29 Mar 2015 00:38:18 +0100 Subject: [PATCH 109/146] [test] Added define to avoid default usage of multiprecision --- test/util/promote_integral.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/util/promote_integral.cpp b/test/util/promote_integral.cpp index 4fd8955ee..bcc80c90c 100644 --- a/test/util/promote_integral.cpp +++ b/test/util/promote_integral.cpp @@ -31,7 +31,9 @@ #include #include +#if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) #include +#endif #if defined(BOOST_GEOMETRY_TEST_DEBUG) && defined(BOOST_HAS_INT128) void print_uint128_t(std::ostream& os, boost::uint128_type i) @@ -456,6 +458,7 @@ BOOST_AUTO_TEST_CASE( test_int128 ) } #endif +#if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) BOOST_AUTO_TEST_CASE( test_user_types ) { namespace bm = boost::multiprecision; @@ -520,6 +523,7 @@ BOOST_AUTO_TEST_CASE( test_user_types ) tester2::apply("u1u"); tester2::apply("u1u"); } +#endif BOOST_AUTO_TEST_CASE( test_floating_point ) { From 494045809e1ce639c8aa8d77b78e59564a4eeda3 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Mon, 30 Mar 2015 17:43:08 +0300 Subject: [PATCH 110/146] [util][promote integral] guard use of int128 and uint128 by the macro BOOST_GEOMETRY_ENABLE_INT128 --- include/boost/geometry/util/promote_integral.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/boost/geometry/util/promote_integral.hpp b/include/boost/geometry/util/promote_integral.hpp index 3bf4d9f89..6b23403be 100644 --- a/include/boost/geometry/util/promote_integral.hpp +++ b/include/boost/geometry/util/promote_integral.hpp @@ -165,7 +165,8 @@ struct promote_to_larger considered only if the macro BOOST_HAS_LONG_LONG is defined \note boost::int128_type and boost::uint128_type are considered - only if the macro BOOST_HAS_INT128 is defined + only if the macros BOOST_HAS_INT128 and BOOST_GEOMETRY_ENABLE_INT128 + are defined */ template < @@ -248,7 +249,7 @@ private: #if defined(BOOST_HAS_LONG_LONG) , boost::long_long_type #endif -#if defined(BOOST_HAS_INT128) +#if defined(BOOST_HAS_INT128) && defined(BOOST_GEOMETRY_ENABLE_INT128) , boost::int128_type #endif #if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) @@ -268,7 +269,7 @@ private: #if defined(BOOST_HAS_LONG_LONG) , boost::ulong_long_type #endif -#if defined(BOOST_HAS_INT128) +#if defined(BOOST_HAS_INT128) && defined(BOOST_GEOMETRY_ENABLE_INT128) , boost::uint128_type #endif #if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) From ba9117b37ee7194dba547bade9c0f1f24c9dea98 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Mon, 30 Mar 2015 17:44:05 +0300 Subject: [PATCH 111/146] [test][util][promote integral] guard use of int128 and uint128 by the macro --- test/util/promote_integral.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test/util/promote_integral.cpp b/test/util/promote_integral.cpp index bcc80c90c..92d1b8ce4 100644 --- a/test/util/promote_integral.cpp +++ b/test/util/promote_integral.cpp @@ -35,7 +35,8 @@ #include #endif -#if defined(BOOST_GEOMETRY_TEST_DEBUG) && defined(BOOST_HAS_INT128) +#if defined(BOOST_GEOMETRY_TEST_DEBUG) +#if defined(BOOST_HAS_INT128) && defined(BOOST_GEOMETRY_ENABLE_INT128) void print_uint128_t(std::ostream& os, boost::uint128_type i) { if (i == 0) @@ -74,8 +75,8 @@ std::ostream& operator<<(std::ostream& os, boost::uint128_type i) print_uint128_t(os, i); return os; } -#endif - +#endif // BOOST_HAS_INT128 && BOOST_GEOMETRY_ENABLE_INT128 +#endif // BOOST_GEOMETRY_TEST_DEBUG namespace bg = boost::geometry; @@ -296,7 +297,7 @@ struct test_promotion tester::template apply(case_id); } #endif -#if defined(BOOST_HAS_INT128) +#if defined(BOOST_HAS_INT128) && defined(BOOST_GEOMETRY_ENABLE_INT128) else if (bit_size() >= min_size) { tester::template apply(case_id); @@ -366,7 +367,7 @@ struct test_promotion tester::template apply(case_id); } #endif -#if defined(BOOST_HAS_INT128) +#if defined(BOOST_HAS_INT128) && defined(BOOST_GEOMETRY_ENABLE_INT128) else if (bit_size() >= min_size) { tester::template apply(case_id); @@ -448,7 +449,7 @@ BOOST_AUTO_TEST_CASE( test_long_long ) } #endif -#if defined(BOOST_HAS_INT128) +#if defined(BOOST_HAS_INT128) && defined(BOOST_GEOMETRY_ENABLE_INT128) BOOST_AUTO_TEST_CASE( test_int128 ) { test_promotion::apply("int128_t"); From 292cbb489b01336d6925296ee377e2570fd24ac6 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Wed, 1 Apr 2015 15:49:34 +0200 Subject: [PATCH 112/146] [test][buffer] Add test for the failing linestring case. --- test/algorithms/buffer/linestring_buffer.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/algorithms/buffer/linestring_buffer.cpp b/test/algorithms/buffer/linestring_buffer.cpp index 337ea2824..5179eff9b 100644 --- a/test/algorithms/buffer/linestring_buffer.cpp +++ b/test/algorithms/buffer/linestring_buffer.cpp @@ -63,6 +63,8 @@ static std::string const mysql_report_2015_03_02a = "LINESTRING(0 0,0 5,5 5,5 0, static std::string const mysql_report_2015_03_02b = "LINESTRING(0 1,0 5,5 5,5 0,1 0)"; // not closed, 1 difference static std::string const mysql_report_2015_03_02c = "LINESTRING(0 2,0 5,5 5,5 0,2 0)"; // not closed, 2 difference +static std::string const mysql_report_2015_04_01 = "LINESTRING(103 5,107 2,111 4,116 -1,115 0,112 4)"; + template void test_all() @@ -201,6 +203,10 @@ void test_all() double const d15 = 1.5; test_one("mysql_report_2015_03_02c_asym1", mysql_report_2015_03_02c, join_round(7), end_round(7), 39.714, d10, d15); test_one("mysql_report_2015_03_02c_asym2", mysql_report_2015_03_02c, join_round(7), end_round(7), 46.116, d15, d10); +#if defined(BOOST_GEOMETRY_BUFFER_INCLUDE_FAILING_TESTS) + double const d100 = 10; + test_one("mysql_report_2015_04_01", mysql_report_2015_04_01, join_round(32), end_round(32), 1.0/*NON ZERO*/, d100); +#endif } From 2808beed3d5e902ec902b74454ccef2315304682 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Wed, 1 Apr 2015 23:52:01 +0200 Subject: [PATCH 113/146] [algorithm][iterator] Avoid preincrementation of temporaries. --- .../algorithms/detail/distance/geometry_to_segment_or_box.hpp | 3 ++- .../geometry/algorithms/detail/is_valid/has_duplicates.hpp | 3 ++- include/boost/geometry/iterators/flatten_iterator.hpp | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/distance/geometry_to_segment_or_box.hpp b/include/boost/geometry/algorithms/detail/distance/geometry_to_segment_or_box.hpp index 57257dbdc..ec5296c35 100644 --- a/include/boost/geometry/algorithms/detail/distance/geometry_to_segment_or_box.hpp +++ b/include/boost/geometry/algorithms/detail/distance/geometry_to_segment_or_box.hpp @@ -220,7 +220,8 @@ public: comparable_return_type cd_min1(0); point_iterator_type pit_min; seg_or_box_iterator_type it_min1 = seg_or_box_points.begin(); - seg_or_box_iterator_type it_min2 = ++seg_or_box_points.begin(); + seg_or_box_iterator_type it_min2 = it_min1; + ++it_min2; bool first = true; for (point_iterator_type pit = points_begin(geometry); diff --git a/include/boost/geometry/algorithms/detail/is_valid/has_duplicates.hpp b/include/boost/geometry/algorithms/detail/is_valid/has_duplicates.hpp index 5878841e7..7527aa521 100644 --- a/include/boost/geometry/algorithms/detail/is_valid/has_duplicates.hpp +++ b/include/boost/geometry/algorithms/detail/is_valid/has_duplicates.hpp @@ -48,7 +48,8 @@ struct has_duplicates geometry::equal_to::type> equal; iterator it = boost::begin(view); - iterator next = ++boost::begin(view); + iterator next = it; + ++next; for (; next != boost::end(view); ++it, ++next) { if ( equal(*it, *next) ) diff --git a/include/boost/geometry/iterators/flatten_iterator.hpp b/include/boost/geometry/iterators/flatten_iterator.hpp index 07450afbe..3243f6f0e 100644 --- a/include/boost/geometry/iterators/flatten_iterator.hpp +++ b/include/boost/geometry/iterators/flatten_iterator.hpp @@ -215,7 +215,8 @@ private: --m_outer_it; } while ( empty(m_outer_it) ); - m_inner_it = --AccessInnerEnd::apply(*m_outer_it); + m_inner_it = AccessInnerEnd::apply(*m_outer_it); + --m_inner_it; } else { From 1113955b88909834b47089b813fd93d242f07f76 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Wed, 1 Apr 2015 23:54:28 +0200 Subject: [PATCH 114/146] [algorithms][buffer] Explicitly get const random iterators. Use Range consistently. --- .../detail/buffer/buffered_piece_collection.hpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp b/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp index a501e3f19..c13e12449 100644 --- a/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp @@ -548,9 +548,8 @@ struct buffered_piece_collection // reliable integer-based ring. All turns can be compared (inside) to this // rings to see if they are inside. - for (typename piece_vector_type::iterator it = boost::begin(m_pieces); - it != boost::end(m_pieces); - ++it) + for (typename boost::range_iterator::type + it = boost::begin(m_pieces); it != boost::end(m_pieces); ++it) { piece& pc = *it; int piece_segment_index = pc.first_seg_id.segment_index; @@ -562,9 +561,9 @@ struct buffered_piece_collection } // Walk through them, in reverse to insert at right index int index_offset = pc.robust_turns.size() - 1; - for (typename std::vector::const_reverse_iterator - rit = pc.robust_turns.rbegin(); - rit != pc.robust_turns.rend(); + for (typename boost::range_reverse_iterator >::type + rit = boost::const_rbegin(pc.robust_turns); + rit != boost::const_rend(pc.robust_turns); ++rit, --index_offset) { int const index_in_vector = 1 + rit->seg_id.segment_index - piece_segment_index; From b8034d1ab2c3c538f17d6ecd319fa3713b90d3a0 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 2 Apr 2015 03:21:10 +0200 Subject: [PATCH 115/146] [extensions][test] Pass /bigobj flag for msvc and intel compilers on windows for all tests. --- extensions/test/Jamfile.v2 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extensions/test/Jamfile.v2 b/extensions/test/Jamfile.v2 index c7e33b210..f7bf7de92 100644 --- a/extensions/test/Jamfile.v2 +++ b/extensions/test/Jamfile.v2 @@ -16,6 +16,8 @@ project boost-geometry-extensions-test ../../test ../../../boost/geometry/extensions/contrib/ttmath msvc:on + msvc:/bigobj + windows,intel:/bigobj /boost/timer//boost_timer ; From 9c7659c9557efceb17a67e09a0aff90c66fab106 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 2 Apr 2015 03:23:11 +0200 Subject: [PATCH 116/146] [extensions][gis][strategies] Rename CS template parameter to CoordinateSystem. --- .../extensions/gis/geographic/strategies/dms_parser.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/boost/geometry/extensions/gis/geographic/strategies/dms_parser.hpp b/include/boost/geometry/extensions/gis/geographic/strategies/dms_parser.hpp index af746e821..884b4b072 100644 --- a/include/boost/geometry/extensions/gis/geographic/strategies/dms_parser.hpp +++ b/include/boost/geometry/extensions/gis/geographic/strategies/dms_parser.hpp @@ -254,15 +254,15 @@ namespace strategy #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS -template class CS> -struct strategy_parse > +template class CoordinateSystem> +struct strategy_parse > { typedef strategy::dms_parser type; }; -template class CS> -struct strategy_parse > +template class CoordinateSystem> +struct strategy_parse > { typedef strategy::dms_parser type; }; From 5a3b023fc8a7d3b13a470bafdcaf8fcee1c5e161 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 2 Apr 2015 03:24:00 +0200 Subject: [PATCH 117/146] [extensions][projections] Rename CS constants to CS_ (and CN to CN_ for consistency). --- .../geometry/extensions/gis/projections/proj/hatano.hpp | 6 +++--- .../geometry/extensions/gis/projections/proj/mbtfpp.hpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/boost/geometry/extensions/gis/projections/proj/hatano.hpp b/include/boost/geometry/extensions/gis/projections/proj/hatano.hpp index 1c34ecec0..b415503c8 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/hatano.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/hatano.hpp @@ -49,8 +49,8 @@ namespace boost { namespace geometry { namespace projections static const int NITER = 20; static const double EPS = 1e-7; static const double ONETOL = 1.000001; - static const double CN = 2.67595; - static const double CS = 2.43763; + static const double CN_ = 2.67595; + static const double CS_ = 2.43763; static const double RCN = 0.37369906014686373063; static const double RCS = 0.41023453108141924738; static const double FYCN = 1.75859; @@ -80,7 +80,7 @@ namespace boost { namespace geometry { namespace projections double th1, c; int i; - c = sin(lp_lat) * (lp_lat < 0. ? CS : CN); + c = sin(lp_lat) * (lp_lat < 0. ? CS_ : CN_); for (i = NITER; i; --i) { lp_lat -= th1 = (lp_lat + sin(lp_lat) - c) / (1. + cos(lp_lat)); if (fabs(th1) < EPS) break; diff --git a/include/boost/geometry/extensions/gis/projections/proj/mbtfpp.hpp b/include/boost/geometry/extensions/gis/projections/proj/mbtfpp.hpp index 3c7af1f48..c25c56376 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/mbtfpp.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/mbtfpp.hpp @@ -46,7 +46,7 @@ namespace boost { namespace geometry { namespace projections { #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace mbtfpp{ - static const double CS = .95257934441568037152; + static const double CS_ = .95257934441568037152; static const double FXC = .92582009977255146156; static const double FYC = 3.40168025708304504493; static const double C23 = .66666666666666666666; @@ -70,7 +70,7 @@ namespace boost { namespace geometry { namespace projections inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const { - lp_lat = asin(CS * sin(lp_lat)); + lp_lat = asin(CS_ * sin(lp_lat)); xy_x = FXC * lp_lon * (2. * cos(C23 * lp_lat) - 1.); xy_y = FYC * sin(C13 * lp_lat); } @@ -84,7 +84,7 @@ namespace boost { namespace geometry { namespace projections } else lp_lat = asin(lp_lat); lp_lon = xy_x / ( FXC * (2. * cos(C23 * (lp_lat *= 3.)) - 1.) ); - if (fabs(lp_lat = sin(lp_lat) / CS) >= 1.) { + if (fabs(lp_lat = sin(lp_lat) / CS_) >= 1.) { if (fabs(lp_lat) > ONEEPS) throw proj_exception(); else lp_lat = (lp_lat < 0.) ? -HALFPI : HALFPI; } else From 7277f1f38b684d328f493e225fdf9ffbb14d6e55 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sat, 4 Apr 2015 18:21:12 +0200 Subject: [PATCH 118/146] [index] Upgrade the category of query iterators to ForwardIterator. --- .../geometry/index/detail/predicates.hpp | 10 +++++++ .../index/detail/rtree/query_iterators.hpp | 27 +++++++++++-------- .../detail/rtree/visitors/distance_query.hpp | 8 ++++++ .../detail/rtree/visitors/spatial_query.hpp | 10 ++++++- 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/include/boost/geometry/index/detail/predicates.hpp b/include/boost/geometry/index/detail/predicates.hpp index 60f80207d..01afd16ba 100644 --- a/include/boost/geometry/index/detail/predicates.hpp +++ b/include/boost/geometry/index/detail/predicates.hpp @@ -25,6 +25,7 @@ namespace predicates { template struct satisfies_impl { + satisfies_impl() : fun(NULL) {} satisfies_impl(Fun f) : fun(f) {} Fun * fun; }; @@ -32,6 +33,7 @@ struct satisfies_impl template struct satisfies_impl { + satisfies_impl() {} satisfies_impl(Fun const& f) : fun(f) {} Fun fun; }; @@ -42,6 +44,7 @@ struct satisfies { typedef satisfies_impl::value> base; + satisfies() {} satisfies(Fun const& f) : base(f) {} satisfies(base const& b) : base(b) {} }; @@ -60,6 +63,7 @@ struct within_tag {}; template struct spatial_predicate { + spatial_predicate() {} spatial_predicate(Geometry const& g) : geometry(g) {} Geometry geometry; }; @@ -75,6 +79,9 @@ struct spatial_predicate template struct nearest { + nearest() +// : count(0) + {} nearest(PointOrRelation const& por, unsigned k) : point_or_relation(por) , count(k) @@ -86,6 +93,9 @@ struct nearest template struct path { + path() +// : count(0) + {} path(SegmentOrLinestring const& g, unsigned k) : geometry(g) , count(k) diff --git a/include/boost/geometry/index/detail/rtree/query_iterators.hpp b/include/boost/geometry/index/detail/rtree/query_iterators.hpp index 74000d03e..83be106b8 100644 --- a/include/boost/geometry/index/detail/rtree/query_iterators.hpp +++ b/include/boost/geometry/index/detail/rtree/query_iterators.hpp @@ -20,7 +20,7 @@ namespace boost { namespace geometry { namespace index { namespace detail { name template struct end_query_iterator { - typedef std::input_iterator_tag iterator_category; + typedef std::forward_iterator_tag iterator_category; typedef Value value_type; typedef typename Allocators::const_reference reference; typedef typename Allocators::difference_type difference_type; @@ -65,12 +65,15 @@ class spatial_query_iterator typedef typename visitor_type::node_pointer node_pointer; public: - typedef std::input_iterator_tag iterator_category; + typedef std::forward_iterator_tag iterator_category; typedef Value value_type; typedef typename Allocators::const_reference reference; typedef typename Allocators::difference_type difference_type; typedef typename Allocators::const_pointer pointer; + inline spatial_query_iterator() + {} + inline spatial_query_iterator(Translator const& t, Predicates const& p) : m_visitor(t, p) {} @@ -130,12 +133,15 @@ class distance_query_iterator typedef typename visitor_type::node_pointer node_pointer; public: - typedef std::input_iterator_tag iterator_category; + typedef std::forward_iterator_tag iterator_category; typedef Value value_type; typedef typename Allocators::const_reference reference; typedef typename Allocators::difference_type difference_type; typedef typename Allocators::const_pointer pointer; + inline distance_query_iterator() + {} + inline distance_query_iterator(Translator const& t, Predicates const& p) : m_visitor(t, p) {} @@ -188,22 +194,19 @@ private: visitor_type m_visitor; }; + template inline bool operator!=(L const& l, R const& r) { return !(l == r); } -}}}}}} // namespace boost::geometry::index::detail::rtree::iterators - - -namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { namespace iterators { template class query_iterator_base { public: - typedef std::input_iterator_tag iterator_category; + typedef std::forward_iterator_tag iterator_category; typedef Value value_type; typedef typename Allocators::const_reference reference; typedef typename Allocators::difference_type difference_type; @@ -226,12 +229,13 @@ class query_iterator_wrapper typedef query_iterator_base base_t; public: - typedef std::input_iterator_tag iterator_category; + typedef std::forward_iterator_tag iterator_category; typedef Value value_type; typedef typename Allocators::const_reference reference; typedef typename Allocators::difference_type difference_type; typedef typename Allocators::const_pointer pointer; + query_iterator_wrapper() : m_iterator() {} explicit query_iterator_wrapper(Iterator const& it) : m_iterator(it) {} virtual base_t * clone() const { return new query_iterator_wrapper(m_iterator); } @@ -258,13 +262,14 @@ class query_iterator typedef boost::scoped_ptr iterator_ptr; public: - typedef std::input_iterator_tag iterator_category; + typedef std::forward_iterator_tag iterator_category; typedef Value value_type; typedef typename Allocators::const_reference reference; typedef typename Allocators::difference_type difference_type; typedef typename Allocators::const_pointer pointer; - query_iterator() {} + query_iterator() + {} template query_iterator(It const& it) diff --git a/include/boost/geometry/index/detail/rtree/visitors/distance_query.hpp b/include/boost/geometry/index/detail/rtree/visitors/distance_query.hpp index fc0929e9e..b93071443 100644 --- a/include/boost/geometry/index/detail/rtree/visitors/distance_query.hpp +++ b/include/boost/geometry/index/detail/rtree/visitors/distance_query.hpp @@ -337,6 +337,13 @@ public: }; typedef std::vector internal_stack_type; + inline distance_query_incremental() + : m_translator(NULL) +// , m_pred() + , current_neighbor((std::numeric_limits::max)()) +// , next_closest_node_distance((std::numeric_limits::max)()) + {} + inline distance_query_incremental(Translator const& translator, Predicates const& pred) : m_translator(::boost::addressof(translator)) , m_pred(pred) @@ -428,6 +435,7 @@ public: { BOOST_GEOMETRY_INDEX_ASSERT(l.current_neighbor != r.current_neighbor || (std::numeric_limits::max)() == l.current_neighbor || + (std::numeric_limits::max)() == r.current_neighbor || l.neighbors[l.current_neighbor].second == r.neighbors[r.current_neighbor].second, "not corresponding iterators"); return l.current_neighbor == r.current_neighbor; diff --git a/include/boost/geometry/index/detail/rtree/visitors/spatial_query.hpp b/include/boost/geometry/index/detail/rtree/visitors/spatial_query.hpp index f00189fe7..b9cd0ae2c 100644 --- a/include/boost/geometry/index/detail/rtree/visitors/spatial_query.hpp +++ b/include/boost/geometry/index/detail/rtree/visitors/spatial_query.hpp @@ -94,10 +94,18 @@ public: static const unsigned predicates_len = index::detail::predicates_length::value; + inline spatial_query_incremental() + : m_translator(NULL) +// , m_pred() + , m_values(NULL) + , m_current() + {} + inline spatial_query_incremental(Translator const& t, Predicates const& p) : m_translator(::boost::addressof(t)) , m_pred(p) - , m_values(0) + , m_values(NULL) + , m_current() {} inline void operator()(internal_node const& n) From 34066a479677f4696ccf25de7f920478d0d1afb7 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sat, 4 Apr 2015 18:21:52 +0200 Subject: [PATCH 119/146] [index] Add begin() and end() functions returning const_iterator to the rtree. Adapt the rtree to the Boost.Range concept. Tweek the description of functions. --- .../geometry/index/detail/rtree/iterators.hpp | 122 +++++++++++++ .../index/detail/rtree/visitors/iterator.hpp | 134 ++++++++++++++ include/boost/geometry/index/rtree.hpp | 167 ++++++++++++++++-- 3 files changed, 406 insertions(+), 17 deletions(-) create mode 100644 include/boost/geometry/index/detail/rtree/iterators.hpp create mode 100644 include/boost/geometry/index/detail/rtree/visitors/iterator.hpp diff --git a/include/boost/geometry/index/detail/rtree/iterators.hpp b/include/boost/geometry/index/detail/rtree/iterators.hpp new file mode 100644 index 000000000..a47dd7ea4 --- /dev/null +++ b/include/boost/geometry/index/detail/rtree/iterators.hpp @@ -0,0 +1,122 @@ +// Boost.Geometry Index +// +// R-tree iterators +// +// Copyright (c) 2011-2015 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_INDEX_DETAIL_RTREE_ITERATORS_HPP +#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_ITERATORS_HPP + +namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { namespace iterators { + +template +struct end_iterator +{ + typedef std::forward_iterator_tag iterator_category; + typedef Value value_type; + typedef typename Allocators::const_reference reference; + typedef typename Allocators::difference_type difference_type; + typedef typename Allocators::const_pointer pointer; + + reference operator*() const + { + BOOST_GEOMETRY_INDEX_ASSERT(false, "iterator not dereferencable"); + pointer p(0); + return *p; + } + + const value_type * operator->() const + { + BOOST_GEOMETRY_INDEX_ASSERT(false, "iterator not dereferencable"); + const value_type * p = 0; + return p; + } + + end_iterator & operator++() + { + BOOST_GEOMETRY_INDEX_ASSERT(false, "iterator not incrementable"); + return *this; + } + + end_iterator operator++(int) + { + BOOST_GEOMETRY_INDEX_ASSERT(false, "iterator not incrementable"); + return *this; + } + + friend bool operator==(end_iterator const& /*l*/, end_iterator const& /*r*/) + { + return true; + } +}; + +template +class iterator +{ + typedef visitors::iterator visitor_type; + typedef typename visitor_type::node_pointer node_pointer; + +public: + typedef std::forward_iterator_tag iterator_category; + typedef Value value_type; + typedef typename Allocators::const_reference reference; + typedef typename Allocators::difference_type difference_type; + typedef typename Allocators::const_pointer pointer; + + inline iterator() + {} + + inline iterator(node_pointer root) + { + m_visitor.initialize(root); + } + + reference operator*() const + { + return m_visitor.dereference(); + } + + const value_type * operator->() const + { + return boost::addressof(m_visitor.dereference()); + } + + iterator & operator++() + { + m_visitor.increment(); + return *this; + } + + iterator operator++(int) + { + iterator temp = *this; + this->operator++(); + return temp; + } + + friend bool operator==(iterator const& l, iterator const& r) + { + return l.m_visitor == r.m_visitor; + } + + friend bool operator==(iterator const& l, end_iterator const& /*r*/) + { + return l.m_visitor.is_end(); + } + + friend bool operator==(end_iterator const& /*l*/, iterator const& r) + { + return r.m_visitor.is_end(); + } + +private: + visitor_type m_visitor; +}; + +}}}}}} // namespace boost::geometry::index::detail::rtree::iterators + +#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_ITERATORS_HPP diff --git a/include/boost/geometry/index/detail/rtree/visitors/iterator.hpp b/include/boost/geometry/index/detail/rtree/visitors/iterator.hpp new file mode 100644 index 000000000..621231ae9 --- /dev/null +++ b/include/boost/geometry/index/detail/rtree/visitors/iterator.hpp @@ -0,0 +1,134 @@ +// Boost.Geometry Index +// +// R-tree iterator visitor implementation +// +// Copyright (c) 2011-2015 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_INDEX_DETAIL_RTREE_VISITORS_ITERATOR_HPP +#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_ITERATOR_HPP + +namespace boost { namespace geometry { namespace index { + +namespace detail { namespace rtree { namespace visitors { + +template +class iterator + : public rtree::visitor::type +{ +public: + typedef typename rtree::node::type node; + typedef typename rtree::internal_node::type internal_node; + typedef typename rtree::leaf::type leaf; + + typedef typename Allocators::size_type size_type; + typedef typename Allocators::const_reference const_reference; + typedef typename Allocators::node_pointer node_pointer; + + typedef typename rtree::elements_type::type::const_iterator internal_iterator; + typedef typename rtree::elements_type::type leaf_elements; + typedef typename rtree::elements_type::type::const_iterator leaf_iterator; + + inline iterator() + : m_values(NULL) + , m_current() + {} + + inline void operator()(internal_node const& n) + { + typedef typename rtree::elements_type::type elements_type; + elements_type const& elements = rtree::elements(n); + + m_internal_stack.push_back(std::make_pair(elements.begin(), elements.end())); + } + + inline void operator()(leaf const& n) + { + m_values = ::boost::addressof(rtree::elements(n)); + m_current = rtree::elements(n).begin(); + } + + const_reference dereference() const + { + BOOST_GEOMETRY_INDEX_ASSERT(m_values, "not dereferencable"); + return *m_current; + } + + void initialize(node_pointer root) + { + rtree::apply_visitor(*this, *root); + search_value(); + } + + void increment() + { + ++m_current; + search_value(); + } + + void search_value() + { + for (;;) + { + // if leaf is choosen, move to the next value in leaf + if ( m_values ) + { + // there are more values in the current leaf + if ( m_current != m_values->end() ) + { + return; + } + // no more values, clear current leaf + else + { + m_values = 0; + } + } + // if leaf isn't choosen, move to the next leaf + else + { + // return if there is no more nodes to traverse + if ( m_internal_stack.empty() ) + return; + + // no more children in current node, remove it from stack + if ( m_internal_stack.back().first == m_internal_stack.back().second ) + { + m_internal_stack.pop_back(); + continue; + } + + internal_iterator it = m_internal_stack.back().first; + ++m_internal_stack.back().first; + + // push the next node to the stack + rtree::apply_visitor(*this, *(it->second)); + } + } + } + + bool is_end() const + { + return 0 == m_values; + } + + friend bool operator==(iterator const& l, iterator const& r) + { + return (l.m_values == r.m_values) && (0 == l.m_values || l.m_current == r.m_current ); + } + +private: + + std::vector< std::pair > m_internal_stack; + const leaf_elements * m_values; + leaf_iterator m_current; +}; + +}}} // namespace detail::rtree::visitors + +}}} // namespace boost::geometry::index + +#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_ITERATOR_HPP diff --git a/include/boost/geometry/index/rtree.hpp b/include/boost/geometry/index/rtree.hpp index 9d5d57d05..b9dbd5704 100644 --- a/include/boost/geometry/index/rtree.hpp +++ b/include/boost/geometry/index/rtree.hpp @@ -59,6 +59,7 @@ #include #include +#include #include #include #include @@ -78,6 +79,7 @@ #include +#include #include #ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL @@ -220,8 +222,17 @@ public: /*! \brief Unsigned integral type used by the container. */ typedef typename allocators_type::size_type size_type; + /*! \brief Type of const iterator. */ + typedef index::detail::rtree::iterators::iterator + < + value_type, options_type, translator_type, box_type, allocators_type + > const_iterator; + /*! \brief Type of const query iterator. */ - typedef index::detail::rtree::iterators::query_iterator const_query_iterator; + typedef index::detail::rtree::iterators::query_iterator + < + value_type, allocators_type + > const_query_iterator; public: @@ -814,6 +825,9 @@ public: If predicates copy throws. If allocation throws. + \warning + The modification of the rtree may invalidate the iterators. + \param predicates Predicates. \return The iterator pointing at the begin of the query range. @@ -842,6 +856,9 @@ public: \par Throws Nothing + + \warning + The modification of the rtree may invalidate the iterators. \return The iterator pointing at the end of the query range. */ @@ -1016,6 +1033,63 @@ private: public: + /*! + \brief Returns the iterator pointing at the begin of the rtree values range. + + This method returns the iterator which may be used to iterate over all values + stored in the rtree. + + \par Example + \verbatim + for ( Rtree::const_iterator it = tree.begin() ; it != tree.end() ; ++it ) + { + // do something with value + } + \endverbatim + + \par Throws + If allocation throws. + + \warning + The modification of the rtree may invalidate the iterators. + + \return The iterator pointing at the begin of the range. + */ + const_iterator begin() const + { + if ( !m_members.root ) + return const_iterator(); + + return const_iterator(m_members.root); + } + + /*! + \brief Returns the iterator pointing at the end of the rtree values range. + + This method returns the iterator which may be compared with the iterator returned by begin() + in order to check if the iteration has ended. + + \par Example + \verbatim + for ( Rtree::const_iterator it = tree.begin() ; it != tree.end() ; ++it ) + { + // do something with value + } + \endverbatim + + \par Throws + Nothing. + + \warning + The modification of the rtree may invalidate the iterators. + + \return The iterator pointing at the end of the range. + */ + const_iterator end() const + { + return const_iterator(); + } + /*! \brief Returns the number of stored values. @@ -1797,14 +1871,7 @@ about the predicates which may be passed to this method see query(). \par Example \verbatim - -for ( Rtree::const_query_iterator it = qbegin(tree, bgi::nearest(pt, 10000)) ; - it != qend(tree) ; ++it ) -{ - // do something with value - if ( has_enough_nearest_values() ) - break; -} +std::for_each(bgi::qbegin(tree, bgi::nearest(pt, 3)), bgi::qend(tree), do_something()); \endverbatim \par Throws @@ -1834,14 +1901,7 @@ This method returns the iterator which may be used to check if the query has end \par Example \verbatim - -for ( Rtree::const_query_iterator it = qbegin(tree, bgi::nearest(pt, 10000)) ; - it != qend(tree) ; ++it ) -{ - // do something with value - if ( has_enough_nearest_values() ) - break; -} +std::for_each(bgi::qbegin(tree, bgi::nearest(pt, 3)), bgi::qend(tree), do_something()); \endverbatim \par Throws @@ -1858,6 +1918,62 @@ qend(rtree const& tree) return tree.qend(); } +/*! +\brief Returns the iterator pointing at the begin of the rtree values range. + +This method returns the iterator which may be used to iterate over all values +stored in the rtree. + +\par Example +\verbatim +std::for_each(bgi::begin(tree), bgi::end(tree), do_something()); +// the same as +std::for_each(boost::begin(tree), boost::end(tree), do_something()); +\endverbatim + +\par Throws +If allocation throws. + +\warning +The modification of the rtree may invalidate the iterators. + +\return The iterator pointing at the begin of the range. +*/ +template inline +typename rtree::const_iterator +begin(rtree const& tree) +{ + return tree.begin(); +} + +/*! +\brief Returns the iterator pointing at the end of the rtree values range. + +This method returns the iterator which may be compared with the iterator returned by begin() +in order to check if the iteration has ended. + +\par Example +\verbatim +std::for_each(bgi::begin(tree), bgi::end(tree), do_something()); +// the same as +std::for_each(boost::begin(tree), boost::end(tree), do_something()); +\endverbatim + +\par Throws +Nothing. + +\warning +The modification of the rtree may invalidate the iterators. + +\return The iterator pointing at the end of the range. +*/ +template inline +typename rtree::const_iterator +end(rtree const& tree) +{ + return tree.end(); +} + /*! \brief Remove all values from the index. @@ -1944,6 +2060,23 @@ inline void swap(rtree & }}} // namespace boost::geometry::index +// Boost.Range adaptation +namespace boost { + +template +struct range_mutable_iterator + < + boost::geometry::index::rtree + > +{ + typedef typename boost::geometry::index::rtree + < + Value, Parameters, IndexableGetter, EqualTo, Allocator + >::const_iterator type; +}; + +} // namespace boost + // TODO: don't include the implementation at the end of the file #include From 2e1690c247e81f1a331813eb3488e40aa80bd145 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sat, 4 Apr 2015 18:32:14 +0200 Subject: [PATCH 120/146] [test][index] Add tests for rtree iterators. Query iterator ForwardIterator category conformance. Iterator usage with STL algorithms, Boost.Range and Boost.Foreach. --- index/test/rtree/test_rtree.hpp | 91 +++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/index/test/rtree/test_rtree.hpp b/index/test/rtree/test_rtree.hpp index 12f5e61a5..75f787947 100644 --- a/index/test/rtree/test_rtree.hpp +++ b/index/test/rtree/test_rtree.hpp @@ -733,6 +733,38 @@ void copy_alt(First first, Last last, Out out) *out = *first; } +// test query iterators +template +void check_fwd_iterators(QItF first, QItL last) +{ + QItF vinit = QItF(); + BOOST_CHECK(vinit == last); + +#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL + QItL vinit2 = QItL(); + BOOST_CHECK(vinit2 == last); +#endif + + QItF def; + BOOST_CHECK(def == last); + +#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL + QItL def2; + BOOST_CHECK(def2 == last); +#endif + + QItF it = first; + for ( ; it != last && first != last ; ++it, ++first) + { + BOOST_CHECK(it == first); + + bg::index::equal_to::value_type> eq; + BOOST_CHECK(eq(*it, *first)); + } + BOOST_CHECK(it == last); + BOOST_CHECK(first == last); +} + // spatial query template @@ -766,6 +798,8 @@ void spatial_query(Rtree & rtree, Predicates const& pred, std::vector con exactly_the_same_outputs(rtree, output3, output4); + check_fwd_iterators(rtree.qbegin(pred), rtree.qend()); + #ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL { std::vector output4; @@ -774,6 +808,9 @@ void spatial_query(Rtree & rtree, Predicates const& pred, std::vector con output4.clear(); copy_alt(rtree.qbegin_(pred), rtree.qend_(), std::back_inserter(output4)); compare_outputs(rtree, output4, expected_output); + + check_fwd_iterators(rtree.qbegin_(pred), rtree.qend_(pred)); + check_fwd_iterators(rtree.qbegin_(pred), rtree.qend_()); } #endif } @@ -1217,6 +1254,8 @@ inline void nearest_query_k(Rtree const& rtree, std::vector const& input, compare_nearest_outputs(rtree, output3, expected_output, pt, greatest_distance); check_sorted_by_distance(rtree, output3, pt); + check_fwd_iterators(rtree.qbegin(bgi::nearest(pt, k)), rtree.qend()); + #ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL { std::vector output4; @@ -1225,6 +1264,9 @@ inline void nearest_query_k(Rtree const& rtree, std::vector const& input, output4.clear(); copy_alt(rtree.qbegin_(bgi::nearest(pt, k)), rtree.qend_(), std::back_inserter(output4)); exactly_the_same_outputs(rtree, output4, output3); + + check_fwd_iterators(rtree.qbegin_(bgi::nearest(pt, k)), rtree.qend_(bgi::nearest(pt, k))); + check_fwd_iterators(rtree.qbegin_(bgi::nearest(pt, k)), rtree.qend_()); } #endif } @@ -1580,6 +1622,31 @@ void clear(Rtree const& tree, std::vector const& input, Box const& qbox) } } +template +void range(Rtree & tree, std::vector const& input) +{ + check_fwd_iterators(tree.begin(), tree.end()); + + size_t count = std::distance(tree.begin(), tree.end()); + BOOST_CHECK(count == tree.size()); + BOOST_CHECK(count == input.size()); + + count = std::distance(boost::begin(tree), boost::end(tree)); + BOOST_CHECK(count == tree.size()); + + count = boost::size(tree); + BOOST_CHECK(count == tree.size()); + + count = 0; + BOOST_FOREACH(Value const& v, tree) + { + boost::ignore_unused(v); + ++count; + } + BOOST_CHECK(count == tree.size()); + +} + // rtree queries template @@ -1806,12 +1873,36 @@ void test_rtree_bounds(Parameters const& parameters, Allocator const& allocator) BOOST_CHECK(bg::equals(t.bounds(), b)); } +// test rtree iterator + +template +void test_rtree_range(Parameters const& parameters, Allocator const& allocator) +{ + typedef std::pair Value; + + typedef bgi::indexable I; + typedef bgi::equal_to E; + typedef typename Allocator::template rebind::other A; + typedef bgi::rtree Tree; + typedef typename Tree::bounds_type B; + + Tree t(parameters, I(), E(), allocator); + std::vector input; + B qbox; + + generate::rtree(t, input, qbox); + + basictest::range(t, input); + basictest::range((Tree const&)t, input); +} + template void test_rtree_additional(Parameters const& parameters, Allocator const& allocator) { test_count_rtree_values(parameters, allocator); test_rtree_count(parameters, allocator); test_rtree_bounds(parameters, allocator); + test_rtree_range(parameters, allocator); } // run all tests for one Algorithm for some number of rtrees From 5d714f94e222ade6856e1fb45d6a07babce0bffa Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sat, 4 Apr 2015 19:53:34 +0200 Subject: [PATCH 121/146] [index][doc] Improve the description of iterator and query related functions. Add info about the iterator category. Add more examples. Add missing doxygen groups for free functions. --- include/boost/geometry/index/rtree.hpp | 176 ++++++++++++++++++++++--- 1 file changed, 155 insertions(+), 21 deletions(-) diff --git a/include/boost/geometry/index/rtree.hpp b/include/boost/geometry/index/rtree.hpp index b9dbd5704..84c4da8a2 100644 --- a/include/boost/geometry/index/rtree.hpp +++ b/include/boost/geometry/index/rtree.hpp @@ -222,13 +222,13 @@ public: /*! \brief Unsigned integral type used by the container. */ typedef typename allocators_type::size_type size_type; - /*! \brief Type of const iterator. */ + /*! \brief Type of const iterator, category ForwardIterator. */ typedef index::detail::rtree::iterators::iterator < value_type, options_type, translator_type, box_type, allocators_type > const_iterator; - /*! \brief Type of const query iterator. */ + /*! \brief Type of const query iterator, category ForwardIterator. */ typedef index::detail::rtree::iterators::query_iterator < value_type, allocators_type @@ -777,6 +777,27 @@ public: tree.query(bgi::overlaps(box) && bgi::satisfies(my_fun), std::back_inserter(result)); // return 5 elements nearest to pt and elements are intersecting box tree.query(bgi::nearest(pt, 5) && bgi::intersects(box), std::back_inserter(result)); + + // For each found value do_something (it is a type of function object) + tree.query(bgi::intersects(box), + boost::make_function_output_iterator(do_something())); + + // For each value stored in the rtree do_something + // always_true is a type of function object always returning true + tree.query(bgi::satisfies(always_true()), + boost::make_function_output_iterator(do_something())); + + // C++11 (lambda expression) + tree.query(bgi::intersects(box), + boost::make_function_output_iterator([](value_type const& val){ + // do something + })); + + // C++14 (generic lambda expression) + tree.query(bgi::intersects(box), + boost::make_function_output_iterator([](auto const& val){ + // do something + })); \endverbatim \par Throws @@ -785,7 +806,7 @@ public: \warning Only one \c nearest() perdicate may be passed to the query. Passing more of them results in compile-time error. - + \param predicates Predicates. \param out_it The output iterator, e.g. generated by std::back_inserter(). @@ -805,11 +826,11 @@ public: } /*! - \brief Returns the query iterator pointing at the begin of the query range. + \brief Returns a query iterator pointing at the begin of the query range. + + This method returns an iterator which may be used to perform iterative queries. + For the information about predicates which may be passed to this method see query(). - This method returns the iterator which may be used to perform iterative queries. For the information - about the predicates which may be passed to this method see query(). - \par Example \verbatim for ( Rtree::const_query_iterator it = tree.qbegin(bgi::nearest(pt, 10000)) ; @@ -819,8 +840,22 @@ public: if ( has_enough_nearest_values() ) break; } + + // C++11 (auto) + for ( auto it = tree.qbegin(bgi::nearest(pt, 3)) ; it != tree.qend() ; ++it ) + { + // do something with value + } + + // C++14 (generic lambda expression) + std::for_each(tree.qbegin(bgi::nearest(pt, 3)), tree.qend(), [](auto const& val){ + // do something with value + }); \endverbatim + \par Iterator category + ForwardIterator + \par Throws If predicates copy throws. If allocation throws. @@ -839,10 +874,10 @@ public: } /*! - \brief Returns the query iterator pointing at the end of the query range. + \brief Returns a query iterator pointing at the end of the query range. + + This method returns an iterator which may be used to check if the query has ended. - This method returns the iterator which may be used to check if the query has ended. - \par Example \verbatim for ( Rtree::const_query_iterator it = tree.qbegin(bgi::nearest(pt, 10000)) ; @@ -852,8 +887,22 @@ public: if ( has_enough_nearest_values() ) break; } + + // C++11 (auto) + for ( auto it = tree.qbegin(bgi::nearest(pt, 3)) ; it != tree.qend() ; ++it ) + { + // do something with value + } + + // C++14 (generic lambda expression) + std::for_each(tree.qbegin(bgi::nearest(pt, 3)), tree.qend(), [](auto const& val){ + // do something with value + }); \endverbatim + \par Iterator category + ForwardIterator + \par Throws Nothing @@ -871,10 +920,10 @@ public: private: #endif /*! - \brief Returns the query iterator pointing at the begin of the query range. + \brief Returns a query iterator pointing at the begin of the query range. - This method returns the iterator which may be used to perform iterative queries. For the information - about the predicates which may be passed to this method see query(). + This method returns an iterator which may be used to perform iterative queries. + For the information about predicates which may be passed to this method see query(). The type of the returned iterator depends on the type of passed Predicates but the iterator of this type may be assigned to the variable of const_query_iterator type. If you'd like to use the type of the iterator @@ -884,16 +933,24 @@ private: \par Example \verbatim // Store the result in the container using std::copy() - it requires both iterators of the same type - std::copy(tree.qbegin(bgi::intersects(box)), tree.qend(bgi::intersects(box)), std::back_inserter(result)); + std::copy(tree.qbegin_(bgi::intersects(box)), tree.qend_(bgi::intersects(box)), std::back_inserter(result)); // Store the result in the container using std::copy() and type-erased iterators - Rtree::const_query_iterator first = tree.qbegin(bgi::intersects(box)); - Rtree::const_query_iterator last = tree.qend(); + Rtree::const_query_iterator first = tree.qbegin_(bgi::intersects(box)); + Rtree::const_query_iterator last = tree.qend_(); std::copy(first, last, std::back_inserter(result)); // Boost.Typeof typedef BOOST_TYPEOF(tree.qbegin(bgi::nearest(pt, 10000))) Iter; - for ( Iter it = tree.qbegin(bgi::nearest(pt, 10000)) ; it != tree.qend() ; ++it ) + for ( Iter it = tree.qbegin_(bgi::nearest(pt, 10000)) ; it != tree.qend_() ; ++it ) + { + // do something with value + if ( has_enough_nearest_values() ) + break; + } + + // C++11 (auto) + for ( auto it = tree.qbegin_(bgi::nearest(pt, 10000)) ; it != tree.qend_() ; ++it ) { // do something with value if ( has_enough_nearest_values() ) @@ -901,10 +958,16 @@ private: } \endverbatim + \par Iterator category + ForwardIterator + \par Throws If predicates copy throws. If allocation throws. + \warning + The modification of the rtree may invalidate the iterators. + \param predicates Predicates. \return The iterator pointing at the begin of the query range. @@ -954,12 +1017,18 @@ private: \par Example \verbatim // Store the result in the container using std::copy() - it requires both iterators of the same type - std::copy(tree.qbegin(bgi::intersects(box)), tree.qend(bgi::intersects(box)), std::back_inserter(result)); + std::copy(tree.qbegin_(bgi::intersects(box)), tree.qend_(bgi::intersects(box)), std::back_inserter(result)); \endverbatim + \par Iterator category + ForwardIterator + \par Throws If predicates copy throws. + \warning + The modification of the rtree may invalidate the iterators. + \param predicates Predicates. \return The iterator pointing at the end of the query range. @@ -1006,13 +1075,21 @@ private: \par Example \verbatim // Store the result in the container using std::copy() and type-erased iterators - Rtree::const_query_iterator first = tree.qbegin(bgi::intersects(box)); - Rtree::const_query_iterator last = tree.qend(); + Rtree::const_query_iterator first = tree.qbegin_(bgi::intersects(box)); + Rtree::const_query_iterator last = tree.qend_(); std::copy(first, last, std::back_inserter(result)); // Boost.Typeof typedef BOOST_TYPEOF(tree.qbegin(bgi::nearest(pt, 10000))) Iter; - for ( Iter it = tree.qbegin(bgi::nearest(pt, 10000)) ; it != tree.qend() ; ++it ) + for ( Iter it = tree.qbegin_(bgi::nearest(pt, 10000)) ; it != tree.qend_() ; ++it ) + { + // do something with value + if ( has_enough_nearest_values() ) + break; + } + + // C++11 (auto) + for ( auto it = tree.qbegin_(bgi::nearest(pt, 10000)) ; it != tree.qend_() ; ++it ) { // do something with value if ( has_enough_nearest_values() ) @@ -1020,8 +1097,14 @@ private: } \endverbatim + \par Iterator category + ForwardIterator + \par Throws Nothing + + \warning + The modification of the rtree may invalidate the iterators. \return The iterator pointing at the end of the query range. */ @@ -1041,12 +1124,29 @@ public: \par Example \verbatim + // Copy all values into the vector + std::copy(tree.begin(), tree.end(), std::back_inserter(vec)); + for ( Rtree::const_iterator it = tree.begin() ; it != tree.end() ; ++it ) { // do something with value } + + // C++11 (auto) + for ( auto it = tree.begin() ; it != tree.end() ; ++it ) + { + // do something with value + } + + // C++14 (generic lambda expression) + std::for_each(tree.begin(), tree.end(), [](auto const& val){ + // do something with value + }) \endverbatim + \par Iterator category + ForwardIterator + \par Throws If allocation throws. @@ -1075,8 +1175,16 @@ public: { // do something with value } + + // C++11 (lambda expression) + std::for_each(tree.begin(), tree.end(), [](value_type const& val){ + // do something with value + }) \endverbatim + \par Iterator category + ForwardIterator + \par Throws Nothing. @@ -1837,6 +1945,10 @@ bgi::query(tree, bgi::intersects(poly) && !bgi::within(box), std::back_inserter( bgi::query(tree, bgi::overlaps(box) && bgi::satisfies(my_fun), std::back_inserter(result)); // return 5 elements nearest to pt and elements are intersecting box bgi::query(tree, bgi::nearest(pt, 5) && bgi::intersects(box), std::back_inserter(result)); + +// For each found value do_something (it is a type of function object) +tree.query(bgi::intersects(box), + boost::make_function_output_iterator(do_something())); \endverbatim \par Throws @@ -1874,10 +1986,16 @@ about the predicates which may be passed to this method see query(). std::for_each(bgi::qbegin(tree, bgi::nearest(pt, 3)), bgi::qend(tree), do_something()); \endverbatim +\par Iterator category +ForwardIterator + \par Throws If predicates copy throws. If allocation throws. +\warning +The modification of the rtree may invalidate the iterators. + \ingroup rtree_functions \param tree The rtree. @@ -1904,9 +2022,15 @@ This method returns the iterator which may be used to check if the query has end std::for_each(bgi::qbegin(tree, bgi::nearest(pt, 3)), bgi::qend(tree), do_something()); \endverbatim +\par Iterator category +ForwardIterator + \par Throws Nothing +\warning +The modification of the rtree may invalidate the iterators. + \ingroup rtree_functions \return The iterator pointing at the end of the query range. @@ -1931,12 +2055,17 @@ std::for_each(bgi::begin(tree), bgi::end(tree), do_something()); std::for_each(boost::begin(tree), boost::end(tree), do_something()); \endverbatim +\par Iterator category +ForwardIterator + \par Throws If allocation throws. \warning The modification of the rtree may invalidate the iterators. +\ingroup rtree_functions + \return The iterator pointing at the begin of the range. */ template inline @@ -1959,12 +2088,17 @@ std::for_each(bgi::begin(tree), bgi::end(tree), do_something()); std::for_each(boost::begin(tree), boost::end(tree), do_something()); \endverbatim +\par Iterator category +ForwardIterator + \par Throws Nothing. \warning The modification of the rtree may invalidate the iterators. +\ingroup rtree_functions + \return The iterator pointing at the end of the range. */ template inline From 91549ce707b8c91838a1396dfe5f24a1f0a9c1ae Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sat, 4 Apr 2015 19:56:23 +0200 Subject: [PATCH 122/146] [doc] Add 1.59 release notes (rtree iterators). --- doc/release_notes.qbk | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/doc/release_notes.qbk b/doc/release_notes.qbk index fdbc82768..8c28368f2 100644 --- a/doc/release_notes.qbk +++ b/doc/release_notes.qbk @@ -18,6 +18,22 @@ [section:release_notes Release Notes] +[/=================] +[heading Boost 1.59] +[/=================] + +[*Additional functionality] + +* Added rtree const_iterator, begin(), end() and the support for Boost.Range. + +[*Improvements] + +* Upgraded rtree const_query_iterator category to ForwardIterator. + +[*Solved tickets] + +* [@https://svn.boost.org/trac/boost/ticket/11113 11113] Support easy enumeration of all elements with BOOST_FOREACH + [/=================] [heading Boost 1.58] [/=================] From 65fa7653babe995cd6d0e6fdde37a87022ed4902 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Wed, 8 Apr 2015 14:18:40 +0200 Subject: [PATCH 123/146] [algorithms][distance][is_valid] Explicitly get const iterators. --- .../distance/geometry_to_segment_or_box.hpp | 23 +++++++++---------- .../detail/is_valid/has_duplicates.hpp | 11 +++++---- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/distance/geometry_to_segment_or_box.hpp b/include/boost/geometry/algorithms/detail/distance/geometry_to_segment_or_box.hpp index ec5296c35..d6de7cac9 100644 --- a/include/boost/geometry/algorithms/detail/distance/geometry_to_segment_or_box.hpp +++ b/include/boost/geometry/algorithms/detail/distance/geometry_to_segment_or_box.hpp @@ -185,10 +185,10 @@ public: Geometry const > segment_iterator_type; - typedef typename std::vector + typedef typename boost::range_const_iterator < - segment_or_box_point - >::const_iterator seg_or_box_iterator_type; + std::vector + >::type seg_or_box_const_iterator; typedef assign_new_min_iterator assign_new_value; @@ -219,8 +219,8 @@ public: // segment or box comparable_return_type cd_min1(0); point_iterator_type pit_min; - seg_or_box_iterator_type it_min1 = seg_or_box_points.begin(); - seg_or_box_iterator_type it_min2 = it_min1; + seg_or_box_const_iterator it_min1 = boost::const_begin(seg_or_box_points); + seg_or_box_const_iterator it_min2 = it_min1; ++it_min2; bool first = true; @@ -230,11 +230,11 @@ public: comparable_return_type cd; std::pair < - seg_or_box_iterator_type, seg_or_box_iterator_type + seg_or_box_const_iterator, seg_or_box_const_iterator > it_pair = point_to_point_range::apply(*pit, - seg_or_box_points.begin(), - seg_or_box_points.end(), + boost::const_begin(seg_or_box_points), + boost::const_end(seg_or_box_points), cstrategy, cd); @@ -251,12 +251,11 @@ public: // segments of the geometry comparable_return_type cd_min2(0); segment_iterator_type sit_min; - typename std::vector::const_iterator it_min; + seg_or_box_const_iterator it_min; first = true; - for (typename std::vector::const_iterator it - = seg_or_box_points.begin(); - it != seg_or_box_points.end(); ++it, first = false) + for (seg_or_box_const_iterator it = boost::const_begin(seg_or_box_points); + it != boost::const_end(seg_or_box_points); ++it, first = false) { comparable_return_type cd; segment_iterator_type sit diff --git a/include/boost/geometry/algorithms/detail/is_valid/has_duplicates.hpp b/include/boost/geometry/algorithms/detail/is_valid/has_duplicates.hpp index 7527aa521..6aa8c98c9 100644 --- a/include/boost/geometry/algorithms/detail/is_valid/has_duplicates.hpp +++ b/include/boost/geometry/algorithms/detail/is_valid/has_duplicates.hpp @@ -36,7 +36,10 @@ struct has_duplicates static inline bool apply(Range const& range, VisitPolicy& visitor) { typedef typename closeable_view::type view_type; - typedef typename boost::range_iterator::type iterator; + typedef typename boost::range_const_iterator + < + view_type const + >::type const_iterator; view_type view(range); @@ -47,10 +50,10 @@ struct has_duplicates geometry::equal_to::type> equal; - iterator it = boost::begin(view); - iterator next = it; + const_iterator it = boost::const_begin(view); + const_iterator next = it; ++next; - for (; next != boost::end(view); ++it, ++next) + for (; next != boost::const_end(view); ++it, ++next) { if ( equal(*it, *next) ) { From fccb4543a39527362452140e672998f717eabbff Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Wed, 8 Apr 2015 14:20:20 +0200 Subject: [PATCH 124/146] [iterators] Remove unneeded else branch in flatten_iterator. --- include/boost/geometry/iterators/flatten_iterator.hpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/include/boost/geometry/iterators/flatten_iterator.hpp b/include/boost/geometry/iterators/flatten_iterator.hpp index 3243f6f0e..da564f116 100644 --- a/include/boost/geometry/iterators/flatten_iterator.hpp +++ b/include/boost/geometry/iterators/flatten_iterator.hpp @@ -216,12 +216,8 @@ private: } while ( empty(m_outer_it) ); m_inner_it = AccessInnerEnd::apply(*m_outer_it); - --m_inner_it; - } - else - { - --m_inner_it; - } + } + --m_inner_it; } }; From e29125aff2ccb25c12ce49b240e4a4c6fda87720 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 9 Apr 2015 16:15:23 +0200 Subject: [PATCH 125/146] [geometries] Enable the support for std::initializer_list. --- include/boost/geometry/geometries/linestring.hpp | 4 ---- include/boost/geometry/geometries/multi_linestring.hpp | 10 ++++------ include/boost/geometry/geometries/multi_point.hpp | 4 ---- include/boost/geometry/geometries/multi_polygon.hpp | 10 ++++------ include/boost/geometry/geometries/polygon.hpp | 9 ++++----- include/boost/geometry/geometries/ring.hpp | 4 ---- 6 files changed, 12 insertions(+), 29 deletions(-) diff --git a/include/boost/geometry/geometries/linestring.hpp b/include/boost/geometry/geometries/linestring.hpp index 68dc87a3c..481fda2f9 100644 --- a/include/boost/geometry/geometries/linestring.hpp +++ b/include/boost/geometry/geometries/linestring.hpp @@ -26,12 +26,10 @@ #include -#ifdef BOOST_GEOMETRY_EXPERIMENTAL_ENABLE_INITIALIZER_LIST #include #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST #include #endif -#endif namespace boost { namespace geometry { @@ -76,7 +74,6 @@ public : : base_type(begin, end) {} -#ifdef BOOST_GEOMETRY_EXPERIMENTAL_ENABLE_INITIALIZER_LIST #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST /// \constructor_initializer_list{linestring} @@ -97,7 +94,6 @@ public : // } //#endif -#endif #endif }; diff --git a/include/boost/geometry/geometries/multi_linestring.hpp b/include/boost/geometry/geometries/multi_linestring.hpp index 195a58139..829da9a22 100644 --- a/include/boost/geometry/geometries/multi_linestring.hpp +++ b/include/boost/geometry/geometries/multi_linestring.hpp @@ -23,12 +23,10 @@ #include #include -#ifdef BOOST_GEOMETRY_EXPERIMENTAL_ENABLE_INITIALIZER_LIST #include #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST #include #endif -#endif namespace boost { namespace geometry { @@ -58,7 +56,10 @@ class multi_linestring : public Container > { BOOST_CONCEPT_ASSERT( (concept::Linestring) ); -#ifdef BOOST_GEOMETRY_EXPERIMENTAL_ENABLE_INITIALIZER_LIST +#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST + + // default constructor and base_type definitions are required only + // if the constructor taking std::initializer_list is defined typedef Container > base_type; @@ -68,8 +69,6 @@ public: : base_type() {} -#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST - /// \constructor_initializer_list{multi_linestring} inline multi_linestring(std::initializer_list l) : base_type(l.begin(), l.end()) @@ -88,7 +87,6 @@ public: // } //#endif -#endif #endif }; diff --git a/include/boost/geometry/geometries/multi_point.hpp b/include/boost/geometry/geometries/multi_point.hpp index a5e64bb91..98cb283a1 100644 --- a/include/boost/geometry/geometries/multi_point.hpp +++ b/include/boost/geometry/geometries/multi_point.hpp @@ -23,12 +23,10 @@ #include #include -#ifdef BOOST_GEOMETRY_EXPERIMENTAL_ENABLE_INITIALIZER_LIST #include #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST #include #endif -#endif namespace boost { namespace geometry { @@ -74,7 +72,6 @@ public : : base_type(begin, end) {} -#ifdef BOOST_GEOMETRY_EXPERIMENTAL_ENABLE_INITIALIZER_LIST #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST /// \constructor_initializer_list{multi_point} @@ -95,7 +92,6 @@ public : // } //#endif -#endif #endif }; diff --git a/include/boost/geometry/geometries/multi_polygon.hpp b/include/boost/geometry/geometries/multi_polygon.hpp index 51fcf235f..10b1ac6a1 100644 --- a/include/boost/geometry/geometries/multi_polygon.hpp +++ b/include/boost/geometry/geometries/multi_polygon.hpp @@ -23,12 +23,10 @@ #include #include -#ifdef BOOST_GEOMETRY_EXPERIMENTAL_ENABLE_INITIALIZER_LIST #include #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST #include #endif -#endif namespace boost { namespace geometry { @@ -57,7 +55,10 @@ class multi_polygon : public Container > { BOOST_CONCEPT_ASSERT( (concept::Polygon) ); -#ifdef BOOST_GEOMETRY_EXPERIMENTAL_ENABLE_INITIALIZER_LIST +#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST + + // default constructor and base_type definitions are required only + // if the constructor taking std::initializer_list is defined typedef Container > base_type; @@ -67,8 +68,6 @@ public: : base_type() {} -#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST - /// \constructor_initializer_list{multi_polygon} inline multi_polygon(std::initializer_list l) : base_type(l.begin(), l.end()) @@ -87,7 +86,6 @@ public: // } //#endif -#endif #endif }; diff --git a/include/boost/geometry/geometries/polygon.hpp b/include/boost/geometry/geometries/polygon.hpp index 5f2e87a11..25b21d98f 100644 --- a/include/boost/geometry/geometries/polygon.hpp +++ b/include/boost/geometry/geometries/polygon.hpp @@ -27,12 +27,10 @@ #include #include -#ifdef BOOST_GEOMETRY_EXPERIMENTAL_ENABLE_INITIALIZER_LIST #include #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST #include #endif -#endif namespace boost { namespace geometry { @@ -91,7 +89,10 @@ public: inline ring_type& outer() { return m_outer; } inline inner_container_type & inners() { return m_inners; } -#ifdef BOOST_GEOMETRY_EXPERIMENTAL_ENABLE_INITIALIZER_LIST +#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST + + // default constructor definition is required only + // if the constructor taking std::initializer_list is defined /// \constructor_default{polygon} inline polygon() @@ -99,7 +100,6 @@ public: , m_inners() {} -#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST /// \constructor_initializer_list{polygon} inline polygon(std::initializer_list l) : m_outer(l.size() > 0 ? *l.begin() : ring_type()) @@ -128,7 +128,6 @@ public: // } //#endif -#endif #endif /// Utility method, clears outer and inner rings diff --git a/include/boost/geometry/geometries/ring.hpp b/include/boost/geometry/geometries/ring.hpp index 502c95d75..a496480b9 100644 --- a/include/boost/geometry/geometries/ring.hpp +++ b/include/boost/geometry/geometries/ring.hpp @@ -27,12 +27,10 @@ #include -#ifdef BOOST_GEOMETRY_EXPERIMENTAL_ENABLE_INITIALIZER_LIST #include #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST #include #endif -#endif namespace boost { namespace geometry { @@ -80,7 +78,6 @@ public : : base_type(begin, end) {} -#ifdef BOOST_GEOMETRY_EXPERIMENTAL_ENABLE_INITIALIZER_LIST #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST /// \constructor_initializer_list{ring} @@ -101,7 +98,6 @@ public : // } //#endif -#endif #endif }; From c086babbd431bc52bc48afb7db2449181c7b45f7 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 9 Apr 2015 16:16:29 +0200 Subject: [PATCH 126/146] [test][geometries] Remove unneeded define enabling experimental support for std::initializer_list. --- test/geometries/Jamfile.v2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/geometries/Jamfile.v2 b/test/geometries/Jamfile.v2 index c09ff95ad..9999c7280 100644 --- a/test/geometries/Jamfile.v2 +++ b/test/geometries/Jamfile.v2 @@ -25,6 +25,6 @@ test-suite boost-geometry-geometries # custom_linestring_test_fail_clear #] [ run custom_linestring.cpp ] - [ run geometries.cpp : : : BOOST_GEOMETRY_EXPERIMENTAL_ENABLE_INITIALIZER_LIST ] + [ run geometries.cpp ] [ run segment.cpp ] ; From aa58f4a0228aa6bd415ed672a63214026872b6af Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 9 Apr 2015 16:25:59 +0200 Subject: [PATCH 127/146] [geometries][doc] Improve the description of constructors of non-complex geometries. Add missing descriptions. Unify the non-initializing default constructors descriptions. --- doc/doxy/Doxyfile | 1 + include/boost/geometry/geometries/box.hpp | 1 + include/boost/geometry/geometries/point.hpp | 2 +- include/boost/geometry/geometries/point_xy.hpp | 2 +- include/boost/geometry/geometries/segment.hpp | 7 +++++++ 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/doc/doxy/Doxyfile b/doc/doxy/Doxyfile index 92098767d..3aa8b86f4 100644 --- a/doc/doxy/Doxyfile +++ b/doc/doxy/Doxyfile @@ -89,6 +89,7 @@ ALIASES = qbk{1}="\xmlonly \1 \endxmlonly" \ param_x="First coordinate (usually x-coordinate)" \ param_y="Second coordinate (usually y-coordinate)" \ param_z="Third coordinate (usually z-coordinate)" \ + constructor_default_no_init="Default constructor, no initialization" \ constructor_default{1}="Default constructor, creating an empty \1" \ constructor_begin_end{1}="Constructor with begin and end, filling the \1" \ constructor_initializer_list{1}="Constructor taking std::initializer_list, filling the \1" \ diff --git a/include/boost/geometry/geometries/box.hpp b/include/boost/geometry/geometries/box.hpp index a2e3d4fd7..6c69f16d4 100644 --- a/include/boost/geometry/geometries/box.hpp +++ b/include/boost/geometry/geometries/box.hpp @@ -50,6 +50,7 @@ class box public: + /// \constructor_default_no_init inline box() {} /*! diff --git a/include/boost/geometry/geometries/point.hpp b/include/boost/geometry/geometries/point.hpp index 056c7d5d0..56046225f 100644 --- a/include/boost/geometry/geometries/point.hpp +++ b/include/boost/geometry/geometries/point.hpp @@ -108,7 +108,7 @@ private: public: - /// @brief Default constructor, no initialization + /// \constructor_default_no_init inline point() { BOOST_STATIC_ASSERT(DimensionCount >= 1); diff --git a/include/boost/geometry/geometries/point_xy.hpp b/include/boost/geometry/geometries/point_xy.hpp index 652930666..0957c282d 100644 --- a/include/boost/geometry/geometries/point_xy.hpp +++ b/include/boost/geometry/geometries/point_xy.hpp @@ -45,7 +45,7 @@ class point_xy : public model::point { public: - /// Default constructor, does not initialize anything + /// \constructor_default_no_init inline point_xy() : model::point() {} diff --git a/include/boost/geometry/geometries/segment.hpp b/include/boost/geometry/geometries/segment.hpp index 3f47f79ec..54e084eda 100644 --- a/include/boost/geometry/geometries/segment.hpp +++ b/include/boost/geometry/geometries/segment.hpp @@ -40,9 +40,13 @@ template class segment : public std::pair { public : + /// \constructor_default_no_init inline segment() {} + /*! + \brief Constructor taking the first and the second point + */ inline segment(Point const& p1, Point const& p2) { this->first = p1; @@ -83,6 +87,9 @@ public: point_type& first; point_type& second; + /*! + \brief Constructor taking the first and the second point + */ inline referring_segment(point_type& p1, point_type& p2) : first(p1) , second(p2) From bbb69c92f7c21940f5a17d96029d70f21a144da7 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 9 Apr 2015 16:48:17 +0200 Subject: [PATCH 128/146] [geometries] Small compile-time check consistency improvement. Add Point concept check to segment. Move DimensionCount check from constructor to the body of a point class and use MPL_ASSERT_MSG instead of STATIC_ASSERT. --- include/boost/geometry/geometries/point.hpp | 11 ++++++----- include/boost/geometry/geometries/segment.hpp | 2 ++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/boost/geometry/geometries/point.hpp b/include/boost/geometry/geometries/point.hpp index 56046225f..fb9ccf3a8 100644 --- a/include/boost/geometry/geometries/point.hpp +++ b/include/boost/geometry/geometries/point.hpp @@ -22,8 +22,8 @@ #include +#include #include -#include #include #include @@ -100,7 +100,10 @@ template > class point { -private: + BOOST_MPL_ASSERT_MSG((DimensionCount >= 1), + DIMENSION_GREATER_THAN_ZERO_EXPECTED, + (boost::mpl::int_)); + // The following enum is used to fully instantiate the // CoordinateSystem class and check the correctness of the units // passed for non-Cartesian coordinate systems. @@ -110,9 +113,7 @@ public: /// \constructor_default_no_init inline point() - { - BOOST_STATIC_ASSERT(DimensionCount >= 1); - } + {} /// @brief Constructor to set one value explicit inline point(CoordinateType const& v0) diff --git a/include/boost/geometry/geometries/segment.hpp b/include/boost/geometry/geometries/segment.hpp index 54e084eda..e93d59456 100644 --- a/include/boost/geometry/geometries/segment.hpp +++ b/include/boost/geometry/geometries/segment.hpp @@ -39,6 +39,8 @@ namespace model template class segment : public std::pair { + BOOST_CONCEPT_ASSERT( (concept::Point) ); + public : /// \constructor_default_no_init inline segment() From 80fe5418151baff22f1f8e064820c8e1b49e4c88 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 9 Apr 2015 17:02:29 +0200 Subject: [PATCH 129/146] [geometries] Make the default ctor of non-complex geometries default function if possible. --- include/boost/geometry/geometries/box.hpp | 9 ++++++++- include/boost/geometry/geometries/point.hpp | 6 ++++++ include/boost/geometry/geometries/point_xy.hpp | 7 ++++++- include/boost/geometry/geometries/segment.hpp | 6 ++++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/include/boost/geometry/geometries/box.hpp b/include/boost/geometry/geometries/box.hpp index 6c69f16d4..04ee6a435 100644 --- a/include/boost/geometry/geometries/box.hpp +++ b/include/boost/geometry/geometries/box.hpp @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -50,8 +51,14 @@ class box public: +#ifndef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS /// \constructor_default_no_init - inline box() {} + box() = default; +#else + /// \constructor_default_no_init + inline box() + {} +#endif /*! \brief Constructor taking the minimum corner point and the maximum corner point diff --git a/include/boost/geometry/geometries/point.hpp b/include/boost/geometry/geometries/point.hpp index fb9ccf3a8..44ebfd988 100644 --- a/include/boost/geometry/geometries/point.hpp +++ b/include/boost/geometry/geometries/point.hpp @@ -22,6 +22,7 @@ #include +#include #include #include @@ -111,9 +112,14 @@ class point public: +#ifndef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS + /// \constructor_default_no_init + point() = default; +#else /// \constructor_default_no_init inline point() {} +#endif /// @brief Constructor to set one value explicit inline point(CoordinateType const& v0) diff --git a/include/boost/geometry/geometries/point_xy.hpp b/include/boost/geometry/geometries/point_xy.hpp index 0957c282d..dabb70b65 100644 --- a/include/boost/geometry/geometries/point_xy.hpp +++ b/include/boost/geometry/geometries/point_xy.hpp @@ -16,6 +16,7 @@ #include +#include #include #include @@ -45,10 +46,14 @@ class point_xy : public model::point { public: +#ifndef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS + /// \constructor_default_no_init + point_xy() = default; +#else /// \constructor_default_no_init inline point_xy() - : model::point() {} +#endif /// Constructor with x/y values inline point_xy(CoordinateType const& x, CoordinateType const& y) diff --git a/include/boost/geometry/geometries/segment.hpp b/include/boost/geometry/geometries/segment.hpp index e93d59456..eb3ce936e 100644 --- a/include/boost/geometry/geometries/segment.hpp +++ b/include/boost/geometry/geometries/segment.hpp @@ -42,9 +42,15 @@ class segment : public std::pair BOOST_CONCEPT_ASSERT( (concept::Point) ); public : + +#ifndef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS + /// \constructor_default_no_init + segment() = default; +#else /// \constructor_default_no_init inline segment() {} +#endif /*! \brief Constructor taking the first and the second point From 55fd4261f595bdb8e35654c9bdf2feca938eef9a Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 9 Apr 2015 17:50:53 +0200 Subject: [PATCH 130/146] [doc][geometries] Simplify the point example (mention only bg::get<> and bg::set<>). --- doc/src/examples/geometries/point.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/src/examples/geometries/point.cpp b/doc/src/examples/geometries/point.cpp index 82774cd83..1e675e197 100644 --- a/doc/src/examples/geometries/point.cpp +++ b/doc/src/examples/geometries/point.cpp @@ -19,11 +19,12 @@ int main() { bg::model::point point1; bg::model::point point2(1.0, 2.0, 3.0); /*< Construct, assigning three coordinates >*/ - point1.set<0>(1.0); /*< Set a coordinate. [*Note]: prefer using `bg::set<0>(point1, 1.0);` >*/ - point1.set<1>(2.0); - double x = point1.get<0>(); /*< Get a coordinate. [*Note]: prefer using `x = bg::get<0>(point1);` >*/ - double y = point1.get<1>(); + bg::set<0>(point1, 1.0); /*< Set a coordinate. >*/ + bg::set<1>(point1, 2.0); + + double x = bg::get<0>(point1); /*< Get a coordinate. >*/ + double y = bg::get<1>(point1); std::cout << x << ", " << y << std::endl; return 0; From c8d97f052881c58223aca856286b20636934d011 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 9 Apr 2015 21:48:06 +0200 Subject: [PATCH 131/146] [doc][geometries] Add example for model::box. --- doc/imports.qbk | 2 + doc/reference/geometries/box.qbk | 16 +++++++ doc/src/examples/geometries/Jamfile.v2 | 1 + doc/src/examples/geometries/box.cpp | 55 +++++++++++++++++++++++ include/boost/geometry/geometries/box.hpp | 25 ++++++----- 5 files changed, 88 insertions(+), 11 deletions(-) create mode 100644 doc/reference/geometries/box.qbk create mode 100644 doc/src/examples/geometries/box.cpp diff --git a/doc/imports.qbk b/doc/imports.qbk index eb49aef9c..dd240c2ba 100644 --- a/doc/imports.qbk +++ b/doc/imports.qbk @@ -83,6 +83,8 @@ [import src/examples/core/tag_cast.cpp] [import src/examples/geometries/point.cpp] +[import src/examples/geometries/box.cpp] + [import src/examples/geometries/adapted/c_array.cpp] [import src/examples/geometries/adapted/boost_array.cpp] [import src/examples/geometries/adapted/boost_fusion.cpp] diff --git a/doc/reference/geometries/box.qbk b/doc/reference/geometries/box.qbk new file mode 100644 index 000000000..100db1387 --- /dev/null +++ b/doc/reference/geometries/box.qbk @@ -0,0 +1,16 @@ +[/============================================================================ + Boost.Geometry (aka GGL, Generic Geometry Library) + + Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands. + Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + Copyright (c) 2009-2012 Bruno Lalande, Paris, France. + Copyright (c) 2015 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) +=============================================================================/] + +[heading Examples] +[box] +[box_output] diff --git a/doc/src/examples/geometries/Jamfile.v2 b/doc/src/examples/geometries/Jamfile.v2 index 68a99b57a..6f6af323c 100644 --- a/doc/src/examples/geometries/Jamfile.v2 +++ b/doc/src/examples/geometries/Jamfile.v2 @@ -14,6 +14,7 @@ project boost-geometry-doc-src-example-geometries ; exe point : point.cpp ; +exe box : box.cpp ; build-project adapted ; build-project register ; diff --git a/doc/src/examples/geometries/box.cpp b/doc/src/examples/geometries/box.cpp new file mode 100644 index 000000000..2ac6a7cbf --- /dev/null +++ b/doc/src/examples/geometries/box.cpp @@ -0,0 +1,55 @@ +// Boost.Geometry +// QuickBook Example + +// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2015 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) + +//[box +//` Declaration and use of the Boost.Geometry model::box, modelling the Box Concept + +#include +#include + +namespace bg = boost::geometry; + +int main() +{ + typedef bg::model::point point_t; + typedef bg::model::box box_t; + + box_t box1; /*< Default-construct a box >*/ + box_t box2(point_t(0.0, 0.0), point_t(5.0, 5.0)); /*< Construct, assigning min and max corner point >*/ +#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + box_t box3{{0.0, 0.0}, {5.0, 5.0}}; /*< Construct, using C++11 unified initialization syntax >*/ +#endif + + bg::set(box1, 1.0); /*< Set a coordinate, generic. >*/ + bg::set(box1, 2.0); + box1.max_corner().set<0>(3.0); /*< Set a coordinate, class-specific ([*Note]: prefer `bg::set();`). >*/ + box1.max_corner().set<1>(4.0); + + double x0 = bg::get(box1); /*< Get a coordinate. >*/ + double y0 = bg::get(box1); + double x1 = box1.max_corner().get<0>(); /*< Get a coordinate, class-specific ([*Note]: prefer `bg::get();`). >*/ + double y1 = box1.max_corner().get<1>(); + + std::cout << x0 << ", " << y0 << ", " << x1 << ", " << y1 << std::endl; + + return 0; +} + +//] + + +//[box_output +/*` +Output: +[pre +1, 2, 3, 4 +] +*/ +//] diff --git a/include/boost/geometry/geometries/box.hpp b/include/boost/geometry/geometries/box.hpp index 04ee6a435..99c6b76e0 100644 --- a/include/boost/geometry/geometries/box.hpp +++ b/include/boost/geometry/geometries/box.hpp @@ -30,18 +30,21 @@ namespace boost { namespace geometry namespace model { - /*! - \brief Class box: defines a box made of two describing points - \ingroup geometries - \details Box is always described by a min_corner() and a max_corner() point. If another - rectangle is used, use linear_ring or polygon. - \note Boxes are for selections and for calculating the envelope of geometries. Not all algorithms - are implemented for box. Boxes are also used in Spatial Indexes. - \tparam Point point type. The box takes a point type as template parameter. - The point type can be any point type. - It can be 2D but can also be 3D or more dimensional. - The box can also take a latlong point type as template parameter. +\brief Class box: defines a box made of two describing points +\ingroup geometries +\details Box is always described by a min_corner() and a max_corner() point. If another + rectangle is used, use linear_ring or polygon. +\note Boxes are for selections and for calculating the envelope of geometries. Not all algorithms +are implemented for box. Boxes are also used in Spatial Indexes. +\tparam Point point type. The box takes a point type as template parameter. +The point type can be any point type. +It can be 2D but can also be 3D or more dimensional. +The box can also take a latlong point type as template parameter. + +\qbk{[include reference/geometries/box.qbk]} +\qbk{before.synopsis, [heading Model of]} +\qbk{before.synopsis, [link geometry.reference.concepts.concept_box Box Concept]} */ template From 877c6686a1c9cd5206ef386c5d95baf72f3cf88c Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 9 Apr 2015 21:49:14 +0200 Subject: [PATCH 132/146] [doc][geometries] Restore the example for class-specific get/set of model::point. --- doc/src/examples/geometries/point.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/src/examples/geometries/point.cpp b/doc/src/examples/geometries/point.cpp index 1e675e197..0d6ebd67c 100644 --- a/doc/src/examples/geometries/point.cpp +++ b/doc/src/examples/geometries/point.cpp @@ -20,11 +20,11 @@ int main() bg::model::point point1; bg::model::point point2(1.0, 2.0, 3.0); /*< Construct, assigning three coordinates >*/ - bg::set<0>(point1, 1.0); /*< Set a coordinate. >*/ - bg::set<1>(point1, 2.0); + bg::set<0>(point1, 1.0); /*< Set a coordinate, generic. >*/ + point1.set<1>(2.0); /*< Set a coordinate, class-specific ([*Note]: prefer `bg::set();`). >*/ - double x = bg::get<0>(point1); /*< Get a coordinate. >*/ - double y = bg::get<1>(point1); + double x = bg::get<0>(point1); /*< Get a coordinate, generic. >*/ + double y = point1.get<1>(); /*< Get a coordinate, class-specific ([*Note]: prefer `bg::get();`). >*/ std::cout << x << ", " << y << std::endl; return 0; From 716e6e656a84224d729d1a836b6cd52d1be587e8 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 9 Apr 2015 23:38:31 +0200 Subject: [PATCH 133/146] [doc][geometries] Add examples (cpp and qbk files) for all models. --- doc/imports.qbk | 9 ++- doc/reference/geometries/linestring.qbk | 16 +++++ doc/reference/geometries/multi_linestring.qbk | 16 +++++ doc/reference/geometries/multi_point.qbk | 16 +++++ doc/reference/geometries/multi_polygon.qbk | 16 +++++ doc/reference/geometries/point_xy.qbk | 18 +++++ doc/reference/geometries/polygon.qbk | 16 +++++ doc/reference/geometries/ring.qbk | 16 +++++ doc/reference/geometries/segment.qbk | 16 +++++ doc/src/examples/geometries/Jamfile.v2 | 10 ++- doc/src/examples/geometries/box.cpp | 16 ++--- doc/src/examples/geometries/linestring.cpp | 51 +++++++++++++ .../examples/geometries/multi_linestring.cpp | 58 +++++++++++++++ doc/src/examples/geometries/multi_point.cpp | 51 +++++++++++++ doc/src/examples/geometries/multi_polygon.cpp | 71 +++++++++++++++++++ doc/src/examples/geometries/point_xy.cpp | 44 ++++++++++++ doc/src/examples/geometries/polygon.cpp | 61 ++++++++++++++++ doc/src/examples/geometries/ring.cpp | 53 ++++++++++++++ doc/src/examples/geometries/segment.cpp | 56 +++++++++++++++ 19 files changed, 600 insertions(+), 10 deletions(-) create mode 100644 doc/reference/geometries/linestring.qbk create mode 100644 doc/reference/geometries/multi_linestring.qbk create mode 100644 doc/reference/geometries/multi_point.qbk create mode 100644 doc/reference/geometries/multi_polygon.qbk create mode 100644 doc/reference/geometries/point_xy.qbk create mode 100644 doc/reference/geometries/polygon.qbk create mode 100644 doc/reference/geometries/ring.qbk create mode 100644 doc/reference/geometries/segment.qbk create mode 100644 doc/src/examples/geometries/linestring.cpp create mode 100644 doc/src/examples/geometries/multi_linestring.cpp create mode 100644 doc/src/examples/geometries/multi_point.cpp create mode 100644 doc/src/examples/geometries/multi_polygon.cpp create mode 100644 doc/src/examples/geometries/point_xy.cpp create mode 100644 doc/src/examples/geometries/polygon.cpp create mode 100644 doc/src/examples/geometries/ring.cpp create mode 100644 doc/src/examples/geometries/segment.cpp diff --git a/doc/imports.qbk b/doc/imports.qbk index dd240c2ba..e7b05e791 100644 --- a/doc/imports.qbk +++ b/doc/imports.qbk @@ -82,8 +82,15 @@ [import src/examples/core/tag.cpp] [import src/examples/core/tag_cast.cpp] -[import src/examples/geometries/point.cpp] [import src/examples/geometries/box.cpp] +[import src/examples/geometries/linestring.cpp] +[import src/examples/geometries/multi_linestring.cpp] +[import src/examples/geometries/multi_point.cpp] +[import src/examples/geometries/multi_polygon.cpp] +[import src/examples/geometries/point.cpp] +[import src/examples/geometries/polygon.cpp] +[import src/examples/geometries/ring.cpp] +[import src/examples/geometries/segment.cpp] [import src/examples/geometries/adapted/c_array.cpp] [import src/examples/geometries/adapted/boost_array.cpp] diff --git a/doc/reference/geometries/linestring.qbk b/doc/reference/geometries/linestring.qbk new file mode 100644 index 000000000..b22e8d2ea --- /dev/null +++ b/doc/reference/geometries/linestring.qbk @@ -0,0 +1,16 @@ +[/============================================================================ + Boost.Geometry (aka GGL, Generic Geometry Library) + + Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands. + Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + Copyright (c) 2009-2012 Bruno Lalande, Paris, France. + Copyright (c) 2015 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) +=============================================================================/] + +[heading Examples] +[linestring] +[linestring_output] diff --git a/doc/reference/geometries/multi_linestring.qbk b/doc/reference/geometries/multi_linestring.qbk new file mode 100644 index 000000000..b2ee9b155 --- /dev/null +++ b/doc/reference/geometries/multi_linestring.qbk @@ -0,0 +1,16 @@ +[/============================================================================ + Boost.Geometry (aka GGL, Generic Geometry Library) + + Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands. + Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + Copyright (c) 2009-2012 Bruno Lalande, Paris, France. + Copyright (c) 2015 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) +=============================================================================/] + +[heading Examples] +[multi_linestring] +[multi_linestring_output] diff --git a/doc/reference/geometries/multi_point.qbk b/doc/reference/geometries/multi_point.qbk new file mode 100644 index 000000000..342242f86 --- /dev/null +++ b/doc/reference/geometries/multi_point.qbk @@ -0,0 +1,16 @@ +[/============================================================================ + Boost.Geometry (aka GGL, Generic Geometry Library) + + Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands. + Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + Copyright (c) 2009-2012 Bruno Lalande, Paris, France. + Copyright (c) 2015 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) +=============================================================================/] + +[heading Examples] +[multi_point] +[multi_point_output] diff --git a/doc/reference/geometries/multi_polygon.qbk b/doc/reference/geometries/multi_polygon.qbk new file mode 100644 index 000000000..1397dba17 --- /dev/null +++ b/doc/reference/geometries/multi_polygon.qbk @@ -0,0 +1,16 @@ +[/============================================================================ + Boost.Geometry (aka GGL, Generic Geometry Library) + + Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands. + Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + Copyright (c) 2009-2012 Bruno Lalande, Paris, France. + Copyright (c) 2015 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) +=============================================================================/] + +[heading Examples] +[multi_polygon] +[multi_polygon_output] diff --git a/doc/reference/geometries/point_xy.qbk b/doc/reference/geometries/point_xy.qbk new file mode 100644 index 000000000..ead56d36f --- /dev/null +++ b/doc/reference/geometries/point_xy.qbk @@ -0,0 +1,18 @@ +[/============================================================================ + Boost.Geometry (aka GGL, Generic Geometry Library) + + Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands. + Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + Copyright (c) 2009-2012 Bruno Lalande, Paris, France. + + 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) +=============================================================================/] + +[heading Examples] +[point_xy] +[point_xy_output] + +[include reference/geometries/point_assign_warning.qbk] + diff --git a/doc/reference/geometries/polygon.qbk b/doc/reference/geometries/polygon.qbk new file mode 100644 index 000000000..7b6909088 --- /dev/null +++ b/doc/reference/geometries/polygon.qbk @@ -0,0 +1,16 @@ +[/============================================================================ + Boost.Geometry (aka GGL, Generic Geometry Library) + + Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands. + Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + Copyright (c) 2009-2012 Bruno Lalande, Paris, France. + Copyright (c) 2015 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) +=============================================================================/] + +[heading Examples] +[polygon] +[polygon_output] diff --git a/doc/reference/geometries/ring.qbk b/doc/reference/geometries/ring.qbk new file mode 100644 index 000000000..746466a44 --- /dev/null +++ b/doc/reference/geometries/ring.qbk @@ -0,0 +1,16 @@ +[/============================================================================ + Boost.Geometry (aka GGL, Generic Geometry Library) + + Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands. + Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + Copyright (c) 2009-2012 Bruno Lalande, Paris, France. + Copyright (c) 2015 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) +=============================================================================/] + +[heading Examples] +[ring] +[ring_output] diff --git a/doc/reference/geometries/segment.qbk b/doc/reference/geometries/segment.qbk new file mode 100644 index 000000000..1336dcaac --- /dev/null +++ b/doc/reference/geometries/segment.qbk @@ -0,0 +1,16 @@ +[/============================================================================ + Boost.Geometry (aka GGL, Generic Geometry Library) + + Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands. + Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + Copyright (c) 2009-2012 Bruno Lalande, Paris, France. + Copyright (c) 2015 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) +=============================================================================/] + +[heading Examples] +[segment] +[segment_output] diff --git a/doc/src/examples/geometries/Jamfile.v2 b/doc/src/examples/geometries/Jamfile.v2 index 6f6af323c..cd0e71e6d 100644 --- a/doc/src/examples/geometries/Jamfile.v2 +++ b/doc/src/examples/geometries/Jamfile.v2 @@ -13,8 +13,16 @@ project boost-geometry-doc-src-example-geometries : # requirements ; -exe point : point.cpp ; exe box : box.cpp ; +exe linestring : linestring.cpp ; +exe point : point.cpp ; +exe point_xy : point_xy.cpp ; +exe polygon : polygon.cpp ; +exe multi_linestring : multi_linestring.cpp ; +exe multi_point : multi_point.cpp ; +exe multi_polygon : multi_polygon.cpp ; +exe ring : ring.cpp ; +exe segment : segment.cpp ; build-project adapted ; build-project register ; diff --git a/doc/src/examples/geometries/box.cpp b/doc/src/examples/geometries/box.cpp index 2ac6a7cbf..8ec272cf7 100644 --- a/doc/src/examples/geometries/box.cpp +++ b/doc/src/examples/geometries/box.cpp @@ -21,10 +21,10 @@ int main() typedef bg::model::point point_t; typedef bg::model::box box_t; - box_t box1; /*< Default-construct a box >*/ - box_t box2(point_t(0.0, 0.0), point_t(5.0, 5.0)); /*< Construct, assigning min and max corner point >*/ + box_t box1; /*< Default-construct a box. >*/ + box_t box2(point_t(0.0, 0.0), point_t(5.0, 5.0)); /*< Construct, assigning min and max corner point. >*/ #ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX - box_t box3{{0.0, 0.0}, {5.0, 5.0}}; /*< Construct, using C++11 unified initialization syntax >*/ + box_t box3{{0.0, 0.0}, {5.0, 5.0}}; /*< Construct, using C++11 unified initialization syntax. >*/ #endif bg::set(box1, 1.0); /*< Set a coordinate, generic. >*/ @@ -32,12 +32,12 @@ int main() box1.max_corner().set<0>(3.0); /*< Set a coordinate, class-specific ([*Note]: prefer `bg::set();`). >*/ box1.max_corner().set<1>(4.0); - double x0 = bg::get(box1); /*< Get a coordinate. >*/ - double y0 = bg::get(box1); - double x1 = box1.max_corner().get<0>(); /*< Get a coordinate, class-specific ([*Note]: prefer `bg::get();`). >*/ - double y1 = box1.max_corner().get<1>(); + double min_x = bg::get(box1); /*< Get a coordinate, generic. >*/ + double min_y = bg::get(box1); + double max_x = box1.max_corner().get<0>(); /*< Get a coordinate, class-specific ([*Note]: prefer `bg::get();`). >*/ + double max_y = box1.max_corner().get<1>(); - std::cout << x0 << ", " << y0 << ", " << x1 << ", " << y1 << std::endl; + std::cout << min_x << ", " << min_y << ", " << max_x << ", " << max_y << std::endl; return 0; } diff --git a/doc/src/examples/geometries/linestring.cpp b/doc/src/examples/geometries/linestring.cpp new file mode 100644 index 000000000..36f767c8f --- /dev/null +++ b/doc/src/examples/geometries/linestring.cpp @@ -0,0 +1,51 @@ +// Boost.Geometry +// QuickBook Example + +// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2015 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) + +//[linestring +//` Declaration and use of the Boost.Geometry model::linestring, modelling the Linestring Concept + +#include +#include +#include + +namespace bg = boost::geometry; + +int main() +{ + typedef bg::model::point point_t; + typedef bg::model::linestring linestring_t; + + linestring_t ls1; /*< Default-construct a linestring. >*/ +#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + linestring_t ls2{{0.0, 0.0}, {1.0, 0.0}, {1.0, 2.0}}; /*< Construct a linestring containing three points, using C++11 unified initialization syntax. >*/ +#endif + + bg::append(ls1, point_t(0.0, 0.0)); /*< Append point. >*/ + bg::append(ls1, point_t(1.0, 0.0)); + bg::append(ls1, point_t(1.0, 2.0)); + + double l = bg::length(ls1); + + std::cout << l << std::endl; + + return 0; +} + +//] + + +//[linestring_output +/*` +Output: +[pre +3 +] +*/ +//] diff --git a/doc/src/examples/geometries/multi_linestring.cpp b/doc/src/examples/geometries/multi_linestring.cpp new file mode 100644 index 000000000..af36df583 --- /dev/null +++ b/doc/src/examples/geometries/multi_linestring.cpp @@ -0,0 +1,58 @@ +// Boost.Geometry +// QuickBook Example + +// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2015 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) + +//[multi_linestring +//` Declaration and use of the Boost.Geometry model::multi_linestring, modelling the MultiLinestring Concept + +#include +#include +#include + +namespace bg = boost::geometry; + +int main() +{ + typedef bg::model::point point_t; + typedef bg::model::linestring linestring_t; + typedef bg::model::multi_linestring mlinestring_t; + + mlinestring_t mls1; /*< Default-construct a multi_linestring. >*/ +#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + mlinestring_t mls2{{{0.0, 0.0}, {0.0, 1.0}, {2.0, 1.0}}, + {{1.0, 0.0}, {2.0, 0.0}}}; /*< Construct a multi_linestring containing two linestrings, using C++11 unified initialization syntax. >*/ +#endif + + mls1.resize(2); /*< Resize a multi_linestring, store two linestrings. >*/ + + bg::append(mls1[0], point_t(0.0, 0.0)); /*< Append point to the first linestring. >*/ + bg::append(mls1[0], point_t(0.0, 1.0)); + bg::append(mls1[0], point_t(2.0, 1.0)); + + bg::append(mls1[1], point_t(1.0, 0.0)); /*< Append point to the second linestring. >*/ + bg::append(mls1[1], point_t(2.0, 0.0)); + + double l = bg::length(mls1); + + std::cout << l << std::endl; + + return 0; +} + +//] + + +//[multi_linestring_output +/*` +Output: +[pre +4 +] +*/ +//] diff --git a/doc/src/examples/geometries/multi_point.cpp b/doc/src/examples/geometries/multi_point.cpp new file mode 100644 index 000000000..209165874 --- /dev/null +++ b/doc/src/examples/geometries/multi_point.cpp @@ -0,0 +1,51 @@ +// Boost.Geometry +// QuickBook Example + +// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2015 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) + +//[multi_point +//` Declaration and use of the Boost.Geometry model::multi_point, modelling the MultiPoint Concept + +#include +#include +#include + +namespace bg = boost::geometry; + +int main() +{ + typedef bg::model::point point_t; + typedef bg::model::multi_point mpoint_t; + + mpoint_t mpt1; /*< Default-construct a multi_point. >*/ +#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + mpoint_t mpt2{{{0.0, 0.0}, {1.0, 1.0}, {2.0, 2.0}}}; /*< Construct a multi_point containing three points, using C++11 unified initialization syntax. >*/ +#endif + + bg::append(mpt1, point_t(0.0, 0.0)); /*< Append point to the multi_point. >*/ + bg::append(mpt1, point_t(1.0, 1.0)); + bg::append(mpt1, point_t(2.0, 2.0)); + + std::size_t count = bg::num_points(mpt1); + + std::cout << count << std::endl; + + return 0; +} + +//] + + +//[multi_point_output +/*` +Output: +[pre +3 +] +*/ +//] diff --git a/doc/src/examples/geometries/multi_polygon.cpp b/doc/src/examples/geometries/multi_polygon.cpp new file mode 100644 index 000000000..ac1c177f8 --- /dev/null +++ b/doc/src/examples/geometries/multi_polygon.cpp @@ -0,0 +1,71 @@ +// Boost.Geometry +// QuickBook Example + +// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2015 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) + +//[multi_polygon +//` Declaration and use of the Boost.Geometry model::multi_polygon, modelling the MultiPolygon Concept + +#include +#include +#include + +namespace bg = boost::geometry; + +int main() +{ + typedef bg::model::point point_t; + typedef bg::model::polygon polygon_t; /*< Default parameters, clockwise, closed polygon. >*/ + typedef bg::model::multi_polygon mpolygon_t; /*< Clockwise, closed multi_polygon. >*/ + + mpolygon_t mpoly1; /*< Default-construct a multi_polygon. >*/ +#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + mpolygon_t mpoly2{{{{0.0, 0.0}, {0.0, 5.0}, {5.0, 5.0}, {5.0, 0.0}, {0.0, 0.0}}, + {{1.0, 1.0}, {4.0, 1.0}, {4.0, 4.0}, {1.0, 4.0}, {1.0, 1.0}}}, + {{{5.0, 5.0}, {5.0, 6.0}, {6.0, 6.0}, {6.0, 5.0}, {5.0, 5.0}}}}; /*< Construct a multi_polygon containing two polygons, using C++11 unified initialization syntax. >*/ +#endif + + mpoly1.resize(2); /*< Resize a multi_polygon, store two polygons. >*/ + + bg::append(mpoly1[0].outer(), point_t(0.0, 0.0)); /*< Append point to the exterior ring of the first polygon. >*/ + bg::append(mpoly1[0].outer(), point_t(0.0, 5.0)); + bg::append(mpoly1[0].outer(), point_t(5.0, 5.0)); + bg::append(mpoly1[0].outer(), point_t(5.0, 0.0)); + bg::append(mpoly1[0].outer(), point_t(0.0, 0.0)); + + mpoly1[0].inners().resize(1); /*< Resize a container of interior rings of the first polygon. >*/ + bg::append(mpoly1[0].inners()[0], point_t(1.0, 1.0)); /*< Append point to the interior ring of the first polygon. >*/ + bg::append(mpoly1[0].inners()[0], point_t(4.0, 1.0)); + bg::append(mpoly1[0].inners()[0], point_t(4.0, 4.0)); + bg::append(mpoly1[0].inners()[0], point_t(1.0, 4.0)); + bg::append(mpoly1[0].inners()[0], point_t(1.0, 1.0)); + + bg::append(mpoly1[1].outer(), point_t(5.0, 5.0)); /*< Append point to the exterior ring of the second polygon. >*/ + bg::append(mpoly1[1].outer(), point_t(5.0, 6.0)); + bg::append(mpoly1[1].outer(), point_t(6.0, 6.0)); + bg::append(mpoly1[1].outer(), point_t(6.0, 5.0)); + bg::append(mpoly1[1].outer(), point_t(5.0, 5.0)); + + double a = bg::area(mpoly1); + + std::cout << a << std::endl; + + return 0; +} + +//] + + +//[multi_polygon_output +/*` +Output: +[pre +17 +] +*/ +//] diff --git a/doc/src/examples/geometries/point_xy.cpp b/doc/src/examples/geometries/point_xy.cpp new file mode 100644 index 000000000..a94965622 --- /dev/null +++ b/doc/src/examples/geometries/point_xy.cpp @@ -0,0 +1,44 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// QuickBook Example + +// Copyright (c) 2011-2012 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) + +//[point_xy +//` Declaration and use of the Boost.Geometry model::d2::point_xy, modelling the Point Concept + +#include +#include +#include + +namespace bg = boost::geometry; + +int main() +{ + bg::model::d2::point_xy point1; + bg::model::d2::point_xy point2(1.0, 2.0); /*< Construct, assigning coordinates. >*/ + + bg::set<0>(point1, 1.0); /*< Set a coordinate, generic. >*/ + point1.y(2.0); /*< Set a coordinate, class-specific ([*Note]: prefer `bg::set();`). >*/ + + double x = bg::get<0>(point1); /*< Get a coordinate, generic. >*/ + double y = point1.y(); /*< Get a coordinate, class-specific ([*Note]: prefer `bg::get();`). >*/ + + std::cout << x << ", " << y << std::endl; + return 0; +} + +//] + + +//[point_xy_output +/*` +Output: +[pre +1, 2 +] +*/ +//] diff --git a/doc/src/examples/geometries/polygon.cpp b/doc/src/examples/geometries/polygon.cpp new file mode 100644 index 000000000..563f842ff --- /dev/null +++ b/doc/src/examples/geometries/polygon.cpp @@ -0,0 +1,61 @@ +// Boost.Geometry +// QuickBook Example + +// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2015 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) + +//[polygon +//` Declaration and use of the Boost.Geometry model::polygon, modelling the Polygon Concept + +#include +#include +#include + +namespace bg = boost::geometry; + +int main() +{ + typedef bg::model::point point_t; + typedef bg::model::polygon polygon_t; /*< Default parameters, clockwise, closed polygon. >*/ + + polygon_t poly1; /*< Default-construct a polygon. >*/ +#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + polygon_t polygon2{{{0.0, 0.0}, {0.0, 5.0}, {5.0, 5.0}, {5.0, 0.0}, {0.0, 0.0}}, + {{1.0, 1.0}, {4.0, 1.0}, {4.0, 4.0}, {1.0, 4.0}, {1.0, 1.0}}}; /*< Construct a polygon containing an exterior and interior ring, using C++11 unified initialization syntax. >*/ +#endif + + bg::append(poly1.outer(), point_t(0.0, 0.0)); /*< Append point to the exterior ring. >*/ + bg::append(poly1.outer(), point_t(0.0, 5.0)); + bg::append(poly1.outer(), point_t(5.0, 5.0)); + bg::append(poly1.outer(), point_t(5.0, 0.0)); + bg::append(poly1.outer(), point_t(0.0, 0.0)); + + poly1.inners().resize(1); /*< Resize a container of interior rings. >*/ + bg::append(poly1.inners()[0], point_t(1.0, 1.0)); /*< Append point to the interior ring. >*/ + bg::append(poly1.inners()[0], point_t(4.0, 1.0)); + bg::append(poly1.inners()[0], point_t(4.0, 4.0)); + bg::append(poly1.inners()[0], point_t(1.0, 4.0)); + bg::append(poly1.inners()[0], point_t(1.0, 1.0)); + + double a = bg::area(poly1); + + std::cout << a << std::endl; + + return 0; +} + +//] + + +//[polygon_output +/*` +Output: +[pre +16 +] +*/ +//] diff --git a/doc/src/examples/geometries/ring.cpp b/doc/src/examples/geometries/ring.cpp new file mode 100644 index 000000000..acad825fd --- /dev/null +++ b/doc/src/examples/geometries/ring.cpp @@ -0,0 +1,53 @@ +// Boost.Geometry +// QuickBook Example + +// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2015 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) + +//[ring +//` Declaration and use of the Boost.Geometry model::ring, modelling the Ring Concept + +#include +#include +#include + +namespace bg = boost::geometry; + +int main() +{ + typedef bg::model::point point_t; + typedef bg::model::ring ring_t; /*< Default parameters, clockwise, closed ring. >*/ + + ring_t ring1; /*< Default-construct a ring. >*/ +#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + ring_t ring2{{0.0, 0.0}, {0.0, 5.0}, {5.0, 5.0}, {5.0, 0.0}, {0.0, 0.0}}; /*< Construct a ring containing four points plus one closing point, using C++11 unified initialization syntax. >*/ +#endif + + bg::append(ring1, point_t(0.0, 0.0)); /*< Append point. >*/ + bg::append(ring1, point_t(0.0, 5.0)); + bg::append(ring1, point_t(5.0, 5.0)); + bg::append(ring1, point_t(5.0, 0.0)); + bg::append(ring1, point_t(0.0, 0.0)); + + double a = bg::area(ring1); + + std::cout << a << std::endl; + + return 0; +} + +//] + + +//[ring_output +/*` +Output: +[pre +25 +] +*/ +//] diff --git a/doc/src/examples/geometries/segment.cpp b/doc/src/examples/geometries/segment.cpp new file mode 100644 index 000000000..66eea43b5 --- /dev/null +++ b/doc/src/examples/geometries/segment.cpp @@ -0,0 +1,56 @@ +// Boost.Geometry +// QuickBook Example + +// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2015 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) + +//[segment +//` Declaration and use of the Boost.Geometry model::segment, modelling the Segment Concept + +#include +#include +#include + +namespace bg = boost::geometry; + +int main() +{ + typedef bg::model::point point_t; + typedef bg::model::segment segment_t; + + segment_t seg1; /*< Default-construct a segment. >*/ + segment_t seg2(point_t(0.0, 0.0), point_t(5.0, 5.0)); /*< Construct, assigning the first and the second point. >*/ +#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + segment_t seg3{{0.0, 0.0}, {5.0, 5.0}}; /*< Construct, using C++11 unified initialization syntax. >*/ +#endif + + bg::set<0, 0>(seg1, 1.0); /*< Set a coordinate. >*/ + bg::set<0, 1>(seg1, 2.0); + bg::set<1, 0>(seg1, 3.0); + bg::set<1, 1>(seg1, 4.0); + + double x0 = bg::get<0, 0>(seg1); /*< Get a coordinate. >*/ + double y0 = bg::get<0, 1>(seg1); + double x1 = bg::get<1, 0>(seg1); + double y1 = bg::get<1, 1>(seg1); + + std::cout << x0 << ", " << y0 << ", " << x1 << ", " << y1 << std::endl; + + return 0; +} + +//] + + +//[segment_output +/*` +Output: +[pre +1, 2, 3, 4 +] +*/ +//] From 34dba9be8542a5f0b33f1ff1f068c6f1a766017c Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 9 Apr 2015 23:39:58 +0200 Subject: [PATCH 134/146] [geometries][doc] Add examples to descriptions of all geometries models. --- include/boost/geometry/geometries/linestring.hpp | 1 + include/boost/geometry/geometries/multi_linestring.hpp | 1 + include/boost/geometry/geometries/multi_point.hpp | 2 ++ include/boost/geometry/geometries/multi_polygon.hpp | 1 + include/boost/geometry/geometries/point_xy.hpp | 1 + include/boost/geometry/geometries/polygon.hpp | 1 + include/boost/geometry/geometries/ring.hpp | 1 + include/boost/geometry/geometries/segment.hpp | 6 ++++++ 8 files changed, 14 insertions(+) diff --git a/include/boost/geometry/geometries/linestring.hpp b/include/boost/geometry/geometries/linestring.hpp index 481fda2f9..22c9c99de 100644 --- a/include/boost/geometry/geometries/linestring.hpp +++ b/include/boost/geometry/geometries/linestring.hpp @@ -44,6 +44,7 @@ namespace model \tparam Container \tparam_container \tparam Allocator \tparam_allocator +\qbk{[include reference/geometries/linestring.qbk]} \qbk{before.synopsis, [heading Model of] [link geometry.reference.concepts.concept_linestring Linestring Concept] diff --git a/include/boost/geometry/geometries/multi_linestring.hpp b/include/boost/geometry/geometries/multi_linestring.hpp index 829da9a22..cd08fdbe1 100644 --- a/include/boost/geometry/geometries/multi_linestring.hpp +++ b/include/boost/geometry/geometries/multi_linestring.hpp @@ -41,6 +41,7 @@ namespace model e.g. a highway (with interruptions) \ingroup geometries +\qbk{[include reference/geometries/multi_linestring.qbk]} \qbk{before.synopsis, [heading Model of] [link geometry.reference.concepts.concept_multi_linestring MultiLineString Concept] diff --git a/include/boost/geometry/geometries/multi_point.hpp b/include/boost/geometry/geometries/multi_point.hpp index 98cb283a1..ab4cd8817 100644 --- a/include/boost/geometry/geometries/multi_point.hpp +++ b/include/boost/geometry/geometries/multi_point.hpp @@ -43,6 +43,8 @@ namespace model \tparam Allocator \tparam_allocator \details Multipoint can be used to group points belonging to each other, e.g. a constellation, or the result set of an intersection + +\qbk{[include reference/geometries/multi_point.qbk]} \qbk{before.synopsis, [heading Model of] [link geometry.reference.concepts.concept_multi_point MultiPoint Concept] diff --git a/include/boost/geometry/geometries/multi_polygon.hpp b/include/boost/geometry/geometries/multi_polygon.hpp index 10b1ac6a1..9db74b4ec 100644 --- a/include/boost/geometry/geometries/multi_polygon.hpp +++ b/include/boost/geometry/geometries/multi_polygon.hpp @@ -40,6 +40,7 @@ namespace model e.g. Hawaii \ingroup geometries +\qbk{[include reference/geometries/multi_polygon.qbk]} \qbk{before.synopsis, [heading Model of] [link geometry.reference.concepts.concept_multi_polygon MultiPolygon Concept] diff --git a/include/boost/geometry/geometries/point_xy.hpp b/include/boost/geometry/geometries/point_xy.hpp index dabb70b65..bbc35d5ce 100644 --- a/include/boost/geometry/geometries/point_xy.hpp +++ b/include/boost/geometry/geometries/point_xy.hpp @@ -33,6 +33,7 @@ namespace model { namespace d2 \tparam CoordinateType numeric type, for example, double, float, int \tparam CoordinateSystem coordinate system, defaults to cs::cartesian +\qbk{[include reference/geometries/point_xy.qbk]} \qbk{before.synopsis, [heading Model of] [link geometry.reference.concepts.concept_point Point Concept] diff --git a/include/boost/geometry/geometries/polygon.hpp b/include/boost/geometry/geometries/polygon.hpp index 25b21d98f..5e6064e89 100644 --- a/include/boost/geometry/geometries/polygon.hpp +++ b/include/boost/geometry/geometries/polygon.hpp @@ -55,6 +55,7 @@ namespace model \note The container collecting the points in the rings can be different from the container collecting the inner rings. They all default to vector. +\qbk{[include reference/geometries/polygon.qbk]} \qbk{before.synopsis, [heading Model of] [link geometry.reference.concepts.concept_polygon Polygon Concept] diff --git a/include/boost/geometry/geometries/ring.hpp b/include/boost/geometry/geometries/ring.hpp index a496480b9..01bcf58cf 100644 --- a/include/boost/geometry/geometries/ring.hpp +++ b/include/boost/geometry/geometries/ring.hpp @@ -48,6 +48,7 @@ namespace model \tparam Container container type, for example std::vector, std::deque \tparam Allocator container-allocator-type +\qbk{[include reference/geometries/ring.qbk]} \qbk{before.synopsis, [heading Model of] [link geometry.reference.concepts.concept_ring Ring Concept] diff --git a/include/boost/geometry/geometries/segment.hpp b/include/boost/geometry/geometries/segment.hpp index eb3ce936e..af406aa09 100644 --- a/include/boost/geometry/geometries/segment.hpp +++ b/include/boost/geometry/geometries/segment.hpp @@ -35,6 +35,12 @@ namespace model by two distinct end points, and contains every point on the line between its end points. \note There is also a point-referring-segment, class referring_segment, containing point references, where points are NOT copied + +\qbk{[include reference/geometries/segment.qbk]} +\qbk{before.synopsis, +[heading Model of] +[link geometry.reference.concepts.concept_segment Segment Concept] +} */ template class segment : public std::pair From ff67f4a6d08f098cfbf24a9cc69b10ca1c9807a1 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Fri, 10 Apr 2015 00:20:15 +0200 Subject: [PATCH 135/146] [doc][geometries] Small fixes in examples of models. Add mising #ifdef conditions enabling the example of std::initializer_list support. Remove unneeded semicolons from comments. Add missing QBK import (point_xy). --- doc/imports.qbk | 1 + doc/src/examples/geometries/box.cpp | 7 +++++-- doc/src/examples/geometries/linestring.cpp | 6 +++++- doc/src/examples/geometries/multi_linestring.cpp | 6 +++++- doc/src/examples/geometries/multi_point.cpp | 6 +++++- doc/src/examples/geometries/multi_polygon.cpp | 6 +++++- doc/src/examples/geometries/point.cpp | 4 ++-- doc/src/examples/geometries/point_xy.cpp | 4 ++-- doc/src/examples/geometries/polygon.cpp | 6 +++++- doc/src/examples/geometries/ring.cpp | 6 +++++- doc/src/examples/geometries/segment.cpp | 3 +++ 11 files changed, 43 insertions(+), 12 deletions(-) diff --git a/doc/imports.qbk b/doc/imports.qbk index e7b05e791..3625fc2e8 100644 --- a/doc/imports.qbk +++ b/doc/imports.qbk @@ -87,6 +87,7 @@ [import src/examples/geometries/multi_linestring.cpp] [import src/examples/geometries/multi_point.cpp] [import src/examples/geometries/multi_polygon.cpp] +[import src/examples/geometries/point_xy.cpp] [import src/examples/geometries/point.cpp] [import src/examples/geometries/polygon.cpp] [import src/examples/geometries/ring.cpp] diff --git a/doc/src/examples/geometries/box.cpp b/doc/src/examples/geometries/box.cpp index 8ec272cf7..0dfecc83d 100644 --- a/doc/src/examples/geometries/box.cpp +++ b/doc/src/examples/geometries/box.cpp @@ -23,18 +23,21 @@ int main() box_t box1; /*< Default-construct a box. >*/ box_t box2(point_t(0.0, 0.0), point_t(5.0, 5.0)); /*< Construct, assigning min and max corner point. >*/ + #ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + box_t box3{{0.0, 0.0}, {5.0, 5.0}}; /*< Construct, using C++11 unified initialization syntax. >*/ + #endif bg::set(box1, 1.0); /*< Set a coordinate, generic. >*/ bg::set(box1, 2.0); - box1.max_corner().set<0>(3.0); /*< Set a coordinate, class-specific ([*Note]: prefer `bg::set();`). >*/ + box1.max_corner().set<0>(3.0); /*< Set a coordinate, class-specific ([*Note]: prefer `bg::set()`). >*/ box1.max_corner().set<1>(4.0); double min_x = bg::get(box1); /*< Get a coordinate, generic. >*/ double min_y = bg::get(box1); - double max_x = box1.max_corner().get<0>(); /*< Get a coordinate, class-specific ([*Note]: prefer `bg::get();`). >*/ + double max_x = box1.max_corner().get<0>(); /*< Get a coordinate, class-specific ([*Note]: prefer `bg::get()`). >*/ double max_y = box1.max_corner().get<1>(); std::cout << min_x << ", " << min_y << ", " << max_x << ", " << max_y << std::endl; diff --git a/doc/src/examples/geometries/linestring.cpp b/doc/src/examples/geometries/linestring.cpp index 36f767c8f..b2ba1ae8b 100644 --- a/doc/src/examples/geometries/linestring.cpp +++ b/doc/src/examples/geometries/linestring.cpp @@ -23,8 +23,12 @@ int main() typedef bg::model::linestring linestring_t; linestring_t ls1; /*< Default-construct a linestring. >*/ -#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + +#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) \ + && !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + linestring_t ls2{{0.0, 0.0}, {1.0, 0.0}, {1.0, 2.0}}; /*< Construct a linestring containing three points, using C++11 unified initialization syntax. >*/ + #endif bg::append(ls1, point_t(0.0, 0.0)); /*< Append point. >*/ diff --git a/doc/src/examples/geometries/multi_linestring.cpp b/doc/src/examples/geometries/multi_linestring.cpp index af36df583..b7a039cf9 100644 --- a/doc/src/examples/geometries/multi_linestring.cpp +++ b/doc/src/examples/geometries/multi_linestring.cpp @@ -24,9 +24,13 @@ int main() typedef bg::model::multi_linestring mlinestring_t; mlinestring_t mls1; /*< Default-construct a multi_linestring. >*/ -#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + +#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) \ + && !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + mlinestring_t mls2{{{0.0, 0.0}, {0.0, 1.0}, {2.0, 1.0}}, {{1.0, 0.0}, {2.0, 0.0}}}; /*< Construct a multi_linestring containing two linestrings, using C++11 unified initialization syntax. >*/ + #endif mls1.resize(2); /*< Resize a multi_linestring, store two linestrings. >*/ diff --git a/doc/src/examples/geometries/multi_point.cpp b/doc/src/examples/geometries/multi_point.cpp index 209165874..89d63d737 100644 --- a/doc/src/examples/geometries/multi_point.cpp +++ b/doc/src/examples/geometries/multi_point.cpp @@ -23,8 +23,12 @@ int main() typedef bg::model::multi_point mpoint_t; mpoint_t mpt1; /*< Default-construct a multi_point. >*/ -#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + +#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) \ + && !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + mpoint_t mpt2{{{0.0, 0.0}, {1.0, 1.0}, {2.0, 2.0}}}; /*< Construct a multi_point containing three points, using C++11 unified initialization syntax. >*/ + #endif bg::append(mpt1, point_t(0.0, 0.0)); /*< Append point to the multi_point. >*/ diff --git a/doc/src/examples/geometries/multi_polygon.cpp b/doc/src/examples/geometries/multi_polygon.cpp index ac1c177f8..d5414868f 100644 --- a/doc/src/examples/geometries/multi_polygon.cpp +++ b/doc/src/examples/geometries/multi_polygon.cpp @@ -24,10 +24,14 @@ int main() typedef bg::model::multi_polygon mpolygon_t; /*< Clockwise, closed multi_polygon. >*/ mpolygon_t mpoly1; /*< Default-construct a multi_polygon. >*/ -#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + +#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) \ + && !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + mpolygon_t mpoly2{{{{0.0, 0.0}, {0.0, 5.0}, {5.0, 5.0}, {5.0, 0.0}, {0.0, 0.0}}, {{1.0, 1.0}, {4.0, 1.0}, {4.0, 4.0}, {1.0, 4.0}, {1.0, 1.0}}}, {{{5.0, 5.0}, {5.0, 6.0}, {6.0, 6.0}, {6.0, 5.0}, {5.0, 5.0}}}}; /*< Construct a multi_polygon containing two polygons, using C++11 unified initialization syntax. >*/ + #endif mpoly1.resize(2); /*< Resize a multi_polygon, store two polygons. >*/ diff --git a/doc/src/examples/geometries/point.cpp b/doc/src/examples/geometries/point.cpp index 0d6ebd67c..6373217c8 100644 --- a/doc/src/examples/geometries/point.cpp +++ b/doc/src/examples/geometries/point.cpp @@ -21,10 +21,10 @@ int main() bg::model::point point2(1.0, 2.0, 3.0); /*< Construct, assigning three coordinates >*/ bg::set<0>(point1, 1.0); /*< Set a coordinate, generic. >*/ - point1.set<1>(2.0); /*< Set a coordinate, class-specific ([*Note]: prefer `bg::set();`). >*/ + point1.set<1>(2.0); /*< Set a coordinate, class-specific ([*Note]: prefer `bg::set()`). >*/ double x = bg::get<0>(point1); /*< Get a coordinate, generic. >*/ - double y = point1.get<1>(); /*< Get a coordinate, class-specific ([*Note]: prefer `bg::get();`). >*/ + double y = point1.get<1>(); /*< Get a coordinate, class-specific ([*Note]: prefer `bg::get()`). >*/ std::cout << x << ", " << y << std::endl; return 0; diff --git a/doc/src/examples/geometries/point_xy.cpp b/doc/src/examples/geometries/point_xy.cpp index a94965622..96eedf82b 100644 --- a/doc/src/examples/geometries/point_xy.cpp +++ b/doc/src/examples/geometries/point_xy.cpp @@ -22,10 +22,10 @@ int main() bg::model::d2::point_xy point2(1.0, 2.0); /*< Construct, assigning coordinates. >*/ bg::set<0>(point1, 1.0); /*< Set a coordinate, generic. >*/ - point1.y(2.0); /*< Set a coordinate, class-specific ([*Note]: prefer `bg::set();`). >*/ + point1.y(2.0); /*< Set a coordinate, class-specific ([*Note]: prefer `bg::set()`). >*/ double x = bg::get<0>(point1); /*< Get a coordinate, generic. >*/ - double y = point1.y(); /*< Get a coordinate, class-specific ([*Note]: prefer `bg::get();`). >*/ + double y = point1.y(); /*< Get a coordinate, class-specific ([*Note]: prefer `bg::get()`). >*/ std::cout << x << ", " << y << std::endl; return 0; diff --git a/doc/src/examples/geometries/polygon.cpp b/doc/src/examples/geometries/polygon.cpp index 563f842ff..199a00824 100644 --- a/doc/src/examples/geometries/polygon.cpp +++ b/doc/src/examples/geometries/polygon.cpp @@ -23,9 +23,13 @@ int main() typedef bg::model::polygon polygon_t; /*< Default parameters, clockwise, closed polygon. >*/ polygon_t poly1; /*< Default-construct a polygon. >*/ -#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + +#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) \ + && !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + polygon_t polygon2{{{0.0, 0.0}, {0.0, 5.0}, {5.0, 5.0}, {5.0, 0.0}, {0.0, 0.0}}, {{1.0, 1.0}, {4.0, 1.0}, {4.0, 4.0}, {1.0, 4.0}, {1.0, 1.0}}}; /*< Construct a polygon containing an exterior and interior ring, using C++11 unified initialization syntax. >*/ + #endif bg::append(poly1.outer(), point_t(0.0, 0.0)); /*< Append point to the exterior ring. >*/ diff --git a/doc/src/examples/geometries/ring.cpp b/doc/src/examples/geometries/ring.cpp index acad825fd..1818ee127 100644 --- a/doc/src/examples/geometries/ring.cpp +++ b/doc/src/examples/geometries/ring.cpp @@ -23,8 +23,12 @@ int main() typedef bg::model::ring ring_t; /*< Default parameters, clockwise, closed ring. >*/ ring_t ring1; /*< Default-construct a ring. >*/ -#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + +#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) \ + && !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + ring_t ring2{{0.0, 0.0}, {0.0, 5.0}, {5.0, 5.0}, {5.0, 0.0}, {0.0, 0.0}}; /*< Construct a ring containing four points plus one closing point, using C++11 unified initialization syntax. >*/ + #endif bg::append(ring1, point_t(0.0, 0.0)); /*< Append point. >*/ diff --git a/doc/src/examples/geometries/segment.cpp b/doc/src/examples/geometries/segment.cpp index 66eea43b5..3cbb4453c 100644 --- a/doc/src/examples/geometries/segment.cpp +++ b/doc/src/examples/geometries/segment.cpp @@ -24,8 +24,11 @@ int main() segment_t seg1; /*< Default-construct a segment. >*/ segment_t seg2(point_t(0.0, 0.0), point_t(5.0, 5.0)); /*< Construct, assigning the first and the second point. >*/ + #ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + segment_t seg3{{0.0, 0.0}, {5.0, 5.0}}; /*< Construct, using C++11 unified initialization syntax. >*/ + #endif bg::set<0, 0>(seg1, 1.0); /*< Set a coordinate. >*/ From f6a95d92296051338c6119be891f3a28f609dbb1 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Fri, 10 Apr 2015 14:21:30 +0200 Subject: [PATCH 136/146] [test][buffer] Add failing test for MultiLinestring. --- test/algorithms/buffer/multi_linestring_buffer.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/algorithms/buffer/multi_linestring_buffer.cpp b/test/algorithms/buffer/multi_linestring_buffer.cpp index 0f125f064..1f09ceeb8 100644 --- a/test/algorithms/buffer/multi_linestring_buffer.cpp +++ b/test/algorithms/buffer/multi_linestring_buffer.cpp @@ -29,6 +29,7 @@ static std::string const mikado2 = "MULTILINESTRING((-6.117647058823528993798390 static std::string const mikado3 = "MULTILINESTRING((1 18,4.0559006211180124168436122999992 7.8136645962732922399140989000443),(6.7243816254416959310447055031545 -1.0812720848056533995418249105569,7 -2,7 -8,14 3.6666666666666669627261399000417),(15.297872340425531234586742357351 5.8297872340425538340014099958353,16 7,15.214285714285713524418497399893 5.8445378151260509724806979647838),(13.685863874345550073030608473346 3.5968586387434555717845796607435,-1 -18,-3.7900797165633304253162805252941 -11.117803365810452476125647081062),(-11.540540540540540348501963308081 8,-16 19,8 14),(1 -10,6.5999999999999996447286321199499 -1.200000000000000177635683940025),(11.5 6.5,15 12),(19 10,11.564231738035264385189293534495 6.4886649874055422060337150469422),(-13.438785504407443127661281323526 -5.3183153770812925387190261972137,-17 -7,-12.970074812967581578959652688354 -7.7556109725685784539450651209336),(-2.3532338308457703135445626685396 -9.7462686567164187323442092747428,-1 -10,12.285714285714286475581502600107 3.2857142857142864755815026001073),(14.90000000000000035527136788005 5.9000000000000003552713678800501,15 6,14.893004115226338157640384451952 5.9012345679012341292946075554937),(11.987804878048780921062643756159 3.2195121951219514144781896902714,-11 -18),(-12.210826210826210669324609625619 -11.703703703703702387883822666481,-15 -15,-11.463576158940396609864365018439 -15.589403973509934786534358863719),(-8.9189189189189193029960733838379 -16.013513513513512265262761502527,-3 -17,-7.0297239915074314353660156484693 -14.210191082802548834251865628175),(-12.450511945392491952588898129761 -10.457337883959045399251408525743,-16 -8,-12.923076923076923350208744523115 -8),(-0.52380952380952372493538859998807 -8,18 -8),(2 -19,-2.2961165048543685784920853620861 -9.6917475728155331182733789319173),(6.0463576158940393057150686217938 -1.7284768211920527036795647291001,7 -3,6.4482758620689653028534848999698 -1.3448275862068967967388744000345),(-1.3333333333333339254522798000835 8,4 16,2.9090909090909091716525836091023 8),(0.64705882352941168633719826175366 -6.8823529411764710062016092706472,-3 -16))"; static std::string const mikado4 = "MULTILINESTRING((-15 2,-15 -17,-6 11,-1.9358288770053475591481628725887 10.572192513368984023713892383967),(2.1545064377682408007785852532834 10.14163090128755406738036981551,6.87603305785123986026974307606 9.6446280991735537924114396446384),(8.4810810810810810522752944962122 9.475675675675674369813350494951,13 9),(-15 0,-8 9,-2.9850746268656713766631582984701 4.4865671641791049495395782287233),(-1.8235294117647056211239942058455 3.4411764705882355031008046353236,-1.1428571428571423496123315999284 2.8285714285714291804652020800859),(1.2307692307692308375521861307789 0.69230769230769229061195346730528,1.2857142857142858094476878250134 0.64285714285714290472384391250671,2 0,1.9459459459459460539676456392044 0.51351351351351348650808859019889),(1.908127208480565384363103476062 0.87279151943462895957281943992712,1.9078014184397162900097555393586 0.87588652482269502286271745106205),(1.4685990338164249813246442499803 5.0483091787439615671928550000302,0.63551401869158885560295857430901 12.962616822429906093816498469096,0 19,2.9565217391304345895264304999728 8.6521739130434784925682834000327),(0 19,3.4942528735632185643567027000245 6.770114942528735468840750399977),(4.75 2.375,5.2427184466019420838733822165523 0.65048543689320226235395239200443),(5.5384615384615383248956277384423 -0.38461538461538458122390693461057,5.7358490566037731994697423942853 -1.0754716981132084185901476303115),(5.9777777777777778567269706400111 -1.9222222222222207221875578397885,6.867052023121386739035187929403 -5.0346820809248553629799971531611,10 -16,-14 -19,-12 -12),(0 10,1.9476439790575916788384347455576 5.4554973821989527493769855936989),(-4 1,-4.2790697674418600726653494348284 0.16279069767441856075862460784265))"; +static std::string const mysql_15_04_10 = "MULTILINESTRING((-58 19, 61 88),(1.922421e+307 1.520384e+308, 15 42, 89 -93,-89 -22),(-63 -5, -262141 -536870908, -3 87, 77 -69))"; template void test_all() @@ -97,6 +98,10 @@ void test_all() test_one("mikado4_large", mikado4, join_round32, end_round32, 11212832197.267, 59772.0); test_one("mikado4_small", mikado4, join_round32, end_round32, 2103.686, 10.0); test_one("mikado4_small", mikado4, join_round32, end_flat, 1930.785, 10.0); + +#ifdef BOOST_GEOMETRY_BUFFER_INCLUDE_FAILING_TESTS + test_one("mysql_15_04_10", mysql_15_04_10, join_round32, end_round32, 29151950703.779/*something big*/, 0x98); +#endif } From 50539f96b46f187d82e7d80110fce3caf261e8ae Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sun, 12 Apr 2015 05:11:51 +0200 Subject: [PATCH 137/146] [doc] Update 1.59 release notes (support for std::initializer_list). --- doc/release_notes.qbk | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/release_notes.qbk b/doc/release_notes.qbk index 8c28368f2..68a26d961 100644 --- a/doc/release_notes.qbk +++ b/doc/release_notes.qbk @@ -25,6 +25,7 @@ [*Additional functionality] * Added rtree const_iterator, begin(), end() and the support for Boost.Range. +* The support for C++11 `std::initializer_list` in geometries models. [*Improvements] From ff267b8c5078862efed761122a0f9997d3e6c5fb Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Tue, 21 Apr 2015 21:05:23 +0200 Subject: [PATCH 138/146] [test][centroid] Fix uninitialized variable usage reported by asan. --- test/algorithms/centroid.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test/algorithms/centroid.cpp b/test/algorithms/centroid.cpp index dc6993996..b5fb87a81 100644 --- a/test/algorithms/centroid.cpp +++ b/test/algorithms/centroid.cpp @@ -145,6 +145,7 @@ void test_large_integers() bg::centroid(double_poly, double_centroid); int_point_type double_centroid_as_int; + bg::assign_zero(double_centroid_as_int); bg::assign(int_centroid, double_centroid_as_int); BOOST_CHECK_EQUAL(bg::get<0>(int_centroid), bg::get<0>(double_centroid_as_int)); From 86df91ed5670e25f0520e44d32ea04c7ae6b415b Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Tue, 21 Apr 2015 21:26:48 +0200 Subject: [PATCH 139/146] [geometries] Implement detection of access to uninitialized or destroyed point/box. --- include/boost/geometry/geometries/box.hpp | 56 +++++++++++++++++++-- include/boost/geometry/geometries/point.hpp | 48 +++++++++++++++++- 2 files changed, 98 insertions(+), 6 deletions(-) diff --git a/include/boost/geometry/geometries/box.hpp b/include/boost/geometry/geometries/box.hpp index 99c6b76e0..912592ab1 100644 --- a/include/boost/geometry/geometries/box.hpp +++ b/include/boost/geometry/geometries/box.hpp @@ -22,6 +22,9 @@ #include #include +#if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) +#include +#endif namespace boost { namespace geometry @@ -54,7 +57,8 @@ class box public: -#ifndef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS +#if !defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) +#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) /// \constructor_default_no_init box() = default; #else @@ -62,6 +66,16 @@ public: inline box() {} #endif +#else // defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) + inline box() + { + m_magic = 1; + } + ~box() + { + m_magic = 0; + } +#endif /*! \brief Constructor taking the minimum corner point and the maximum corner point @@ -70,18 +84,50 @@ public: { geometry::convert(min_corner, m_min_corner); geometry::convert(max_corner, m_max_corner); + +#if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) + m_magic = 1; +#endif } - inline Point const& min_corner() const { return m_min_corner; } - inline Point const& max_corner() const { return m_max_corner; } + inline Point const& min_corner() const + { +#if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) + BOOST_ASSERT(m_magic == 1); +#endif + return m_min_corner; + } + inline Point const& max_corner() const + { +#if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) + BOOST_ASSERT(m_magic == 1); +#endif + return m_max_corner; + } - inline Point& min_corner() { return m_min_corner; } - inline Point& max_corner() { return m_max_corner; } + inline Point& min_corner() + { +#if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) + BOOST_ASSERT(m_magic == 1); +#endif + return m_min_corner; + } + inline Point& max_corner() + { +#if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) + BOOST_ASSERT(m_magic == 1); +#endif + return m_max_corner; + } private: Point m_min_corner; Point m_max_corner; + +#if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) + int m_magic; +#endif }; diff --git a/include/boost/geometry/geometries/point.hpp b/include/boost/geometry/geometries/point.hpp index 44ebfd988..dadbe0e06 100644 --- a/include/boost/geometry/geometries/point.hpp +++ b/include/boost/geometry/geometries/point.hpp @@ -31,6 +31,11 @@ #include #include +#if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) +#include +#include +#endif + namespace boost { namespace geometry { @@ -112,7 +117,8 @@ class point public: -#ifndef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS +#if !defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) +#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) /// \constructor_default_no_init point() = default; #else @@ -120,6 +126,18 @@ public: inline point() {} #endif +#else // defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) + point() + { + m_magic = 1; + std::fill_n(m_magic_values, DimensionCount, 0); + } + ~point() + { + m_magic = 0; + std::fill_n(m_magic_values, DimensionCount, 0); + } +#endif /// @brief Constructor to set one value explicit inline point(CoordinateType const& v0) @@ -127,6 +145,11 @@ public: detail::array_assign::apply(m_values, v0); detail::array_assign::apply(m_values, CoordinateType()); detail::array_assign::apply(m_values, CoordinateType()); + +#if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) + m_magic = 1; + std::fill_n(m_magic_values, (std::min)(std::size_t(3), DimensionCount), 1); +#endif } /// @brief Constructor to set two values @@ -135,6 +158,11 @@ public: detail::array_assign::apply(m_values, v0); detail::array_assign::apply(m_values, v1); detail::array_assign::apply(m_values, CoordinateType()); + +#if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) + m_magic = 1; + std::fill_n(m_magic_values, (std::min)(std::size_t(3), DimensionCount), 1); +#endif } /// @brief Constructor to set three values @@ -144,6 +172,11 @@ public: detail::array_assign::apply(m_values, v0); detail::array_assign::apply(m_values, v1); detail::array_assign::apply(m_values, v2); + +#if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) + m_magic = 1; + std::fill_n(m_magic_values, (std::min)(std::size_t(3), DimensionCount), 1); +#endif } /// @brief Get a coordinate @@ -152,6 +185,10 @@ public: template inline CoordinateType const& get() const { +#if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) + BOOST_ASSERT(m_magic == 1); + BOOST_ASSERT(m_magic_values[K] == 1); +#endif BOOST_STATIC_ASSERT(K < DimensionCount); return m_values[K]; } @@ -162,6 +199,10 @@ public: template inline void set(CoordinateType const& value) { +#if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) + BOOST_ASSERT(m_magic == 1); + m_magic_values[K] = 1; +#endif BOOST_STATIC_ASSERT(K < DimensionCount); m_values[K] = value; } @@ -169,6 +210,11 @@ public: private: CoordinateType m_values[DimensionCount]; + +#if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) + int m_magic; + int m_magic_values[DimensionCount]; +#endif }; From 0851688794677d2722de78bb065033a006247cfc Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Wed, 22 Apr 2015 03:04:05 +0200 Subject: [PATCH 140/146] [test][intersection] Fix uninitialized variable usage. --- test/algorithms/set_operations/intersection/intersection.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test/algorithms/set_operations/intersection/intersection.cpp b/test/algorithms/set_operations/intersection/intersection.cpp index e15c3ee54..f89e70fab 100644 --- a/test/algorithms/set_operations/intersection/intersection.cpp +++ b/test/algorithms/set_operations/intersection/intersection.cpp @@ -358,6 +358,7 @@ void test_boxes(std::string const& wkt1, std::string const& wkt2, double expecte bg::read_wkt(wkt2, box2); Box box_out; + bg::assign_zero(box_out); bool detected = bg::intersection(box1, box2, box_out); typename bg::default_area_result::type area = bg::area(box_out); From e94cc655f36a6cdb159c71881f3f4f80d2962a50 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 22 Apr 2015 12:06:11 +0200 Subject: [PATCH 141/146] [extensions][projections] change usage of fpc of Boost.Test because does not exist in master --- extensions/test/gis/projections/projections.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/extensions/test/gis/projections/projections.cpp b/extensions/test/gis/projections/projections.cpp index 097539d2c..a684525fd 100644 --- a/extensions/test/gis/projections/projections.cpp +++ b/extensions/test/gis/projections/projections.cpp @@ -42,16 +42,8 @@ inline void check(double v, double ve, std::string const& name, std::string const& axis) { - //BOOST_CHECK_CLOSE(v, ve, 0.001); - // Instead of (non-existing) BOOST_CHECK_CLOSE_MESSAGE(v, ve, 0.001, bla bla) - - if (! boost::test_tools::check_is_close(v, ve, boost::test_tools::fpc::percent_tolerance(0.001))) - { - std::ostringstream out; - out << "\n" << name << " " << axis << " -> " << v << " != " << ve; - BOOST_ERROR(out.str()); - } - + // (non-existing) BOOST_CHECK_CLOSE_MESSAGE(v, ve, 0.001, "\n" << name << " " << axis << " -> " << v << " != " << ve); + BOOST_CHECK_CLOSE(v, ve, 0.001); } template From 34bdc44b1016c87459af75134c832d8f34fca5b1 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Wed, 22 Apr 2015 15:19:28 +0200 Subject: [PATCH 142/146] [geometries] Rename magic names into more meaningful ones. --- include/boost/geometry/geometries/box.hpp | 16 +++++------ include/boost/geometry/geometries/point.hpp | 32 ++++++++++----------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/include/boost/geometry/geometries/box.hpp b/include/boost/geometry/geometries/box.hpp index 912592ab1..5fcf171f0 100644 --- a/include/boost/geometry/geometries/box.hpp +++ b/include/boost/geometry/geometries/box.hpp @@ -69,11 +69,11 @@ public: #else // defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) inline box() { - m_magic = 1; + m_created = 1; } ~box() { - m_magic = 0; + m_created = 0; } #endif @@ -86,21 +86,21 @@ public: geometry::convert(max_corner, m_max_corner); #if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) - m_magic = 1; + m_created = 1; #endif } inline Point const& min_corner() const { #if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) - BOOST_ASSERT(m_magic == 1); + BOOST_ASSERT(m_created == 1); #endif return m_min_corner; } inline Point const& max_corner() const { #if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) - BOOST_ASSERT(m_magic == 1); + BOOST_ASSERT(m_created == 1); #endif return m_max_corner; } @@ -108,14 +108,14 @@ public: inline Point& min_corner() { #if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) - BOOST_ASSERT(m_magic == 1); + BOOST_ASSERT(m_created == 1); #endif return m_min_corner; } inline Point& max_corner() { #if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) - BOOST_ASSERT(m_magic == 1); + BOOST_ASSERT(m_created == 1); #endif return m_max_corner; } @@ -126,7 +126,7 @@ private: Point m_max_corner; #if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) - int m_magic; + int m_created; #endif }; diff --git a/include/boost/geometry/geometries/point.hpp b/include/boost/geometry/geometries/point.hpp index dadbe0e06..5f78bcff2 100644 --- a/include/boost/geometry/geometries/point.hpp +++ b/include/boost/geometry/geometries/point.hpp @@ -129,13 +129,13 @@ public: #else // defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) point() { - m_magic = 1; - std::fill_n(m_magic_values, DimensionCount, 0); + m_created = 1; + std::fill_n(m_values_initialized, DimensionCount, 0); } ~point() { - m_magic = 0; - std::fill_n(m_magic_values, DimensionCount, 0); + m_created = 0; + std::fill_n(m_values_initialized, DimensionCount, 0); } #endif @@ -147,8 +147,8 @@ public: detail::array_assign::apply(m_values, CoordinateType()); #if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) - m_magic = 1; - std::fill_n(m_magic_values, (std::min)(std::size_t(3), DimensionCount), 1); + m_created = 1; + std::fill_n(m_values_initialized, (std::min)(std::size_t(3), DimensionCount), 1); #endif } @@ -160,8 +160,8 @@ public: detail::array_assign::apply(m_values, CoordinateType()); #if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) - m_magic = 1; - std::fill_n(m_magic_values, (std::min)(std::size_t(3), DimensionCount), 1); + m_created = 1; + std::fill_n(m_values_initialized, (std::min)(std::size_t(3), DimensionCount), 1); #endif } @@ -174,8 +174,8 @@ public: detail::array_assign::apply(m_values, v2); #if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) - m_magic = 1; - std::fill_n(m_magic_values, (std::min)(std::size_t(3), DimensionCount), 1); + m_created = 1; + std::fill_n(m_values_initialized, (std::min)(std::size_t(3), DimensionCount), 1); #endif } @@ -186,8 +186,8 @@ public: inline CoordinateType const& get() const { #if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) - BOOST_ASSERT(m_magic == 1); - BOOST_ASSERT(m_magic_values[K] == 1); + BOOST_ASSERT(m_created == 1); + BOOST_ASSERT(m_values_initialized[K] == 1); #endif BOOST_STATIC_ASSERT(K < DimensionCount); return m_values[K]; @@ -200,8 +200,8 @@ public: inline void set(CoordinateType const& value) { #if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) - BOOST_ASSERT(m_magic == 1); - m_magic_values[K] = 1; + BOOST_ASSERT(m_created == 1); + m_values_initialized[K] = 1; #endif BOOST_STATIC_ASSERT(K < DimensionCount); m_values[K] = value; @@ -212,8 +212,8 @@ private: CoordinateType m_values[DimensionCount]; #if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) - int m_magic; - int m_magic_values[DimensionCount]; + int m_created; + int m_values_initialized[DimensionCount]; #endif }; From 3b79baadba87e11a268a93aa25d31e0dfab5aaf5 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 22 Apr 2015 15:53:07 +0200 Subject: [PATCH 143/146] [projections] commit changes for new generation (whitespace only) --- .../boost/geometry/extensions/gis/projections/proj/aeqd.hpp | 2 +- .../boost/geometry/extensions/gis/projections/proj/goode.hpp | 1 - .../boost/geometry/extensions/gis/projections/proj/putp6.hpp | 2 +- .../boost/geometry/extensions/gis/projections/proj/sterea.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/tmerc.hpp | 4 ++-- 5 files changed, 4 insertions(+), 7 deletions(-) diff --git a/include/boost/geometry/extensions/gis/projections/proj/aeqd.hpp b/include/boost/geometry/extensions/gis/projections/proj/aeqd.hpp index a0b599763..5e240ee1a 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/aeqd.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/aeqd.hpp @@ -115,7 +115,7 @@ namespace boost { namespace geometry { namespace projections ct = cos(t); st = sin(t); Az = atan2(sin(lp_lon) * ct, this->m_proj_parm.cosph0 * st - this->m_proj_parm.sinph0 * coslam * ct); cA = cos(Az); sA = sin(Az); - s = aasin( fabs(sA) < TOL ? + s = aasin(fabs(sA) < TOL ? (this->m_proj_parm.cosph0 * st - this->m_proj_parm.sinph0 * coslam * ct) / cA : sin(lp_lon) * ct / sA ); H = this->m_proj_parm.He * cA; diff --git a/include/boost/geometry/extensions/gis/projections/proj/goode.hpp b/include/boost/geometry/extensions/gis/projections/proj/goode.hpp index 56204bf83..2058f2c47 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/goode.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/goode.hpp @@ -41,7 +41,6 @@ #include #include #include - #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/putp6.hpp b/include/boost/geometry/extensions/gis/projections/proj/putp6.hpp index c04842e82..c91d847f8 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/putp6.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/putp6.hpp @@ -98,7 +98,7 @@ namespace boost { namespace geometry { namespace projections lp_lat = xy_y / this->m_proj_parm.C_y; r = sqrt(1. + lp_lat * lp_lat); lp_lon = xy_x / (this->m_proj_parm.C_x * (this->m_proj_parm.D - r)); - lp_lat = aasin( ( (this->m_proj_parm.A - r) * lp_lat - log(lp_lat + r) ) / this->m_proj_parm.B); + lp_lat = aasin(( (this->m_proj_parm.A - r) * lp_lat - log(lp_lat + r) ) / this->m_proj_parm.B); } }; diff --git a/include/boost/geometry/extensions/gis/projections/proj/sterea.hpp b/include/boost/geometry/extensions/gis/projections/proj/sterea.hpp index 95ed81a89..05bc9f5cd 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/sterea.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/sterea.hpp @@ -116,9 +116,7 @@ namespace boost { namespace geometry { namespace projections template void setup_sterea(Parameters& par, par_sterea& proj_parm) { - - double R; proj_parm.en = detail::gauss::gauss_ini(par.e, par.phi0, proj_parm.phic0, R); proj_parm.sinc0 = sin(proj_parm.phic0); diff --git a/include/boost/geometry/extensions/gis/projections/proj/tmerc.hpp b/include/boost/geometry/extensions/gis/projections/proj/tmerc.hpp index fff3798fd..fcacc828f 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/tmerc.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/tmerc.hpp @@ -98,7 +98,7 @@ namespace boost { namespace geometry { namespace projections { xy_x = HUGE_VAL; xy_y = HUGE_VAL; - throw proj_exception( -14 ); + throw proj_exception(-14 ); return; } @@ -184,7 +184,7 @@ namespace boost { namespace geometry { namespace projections { xy_x = HUGE_VAL; xy_y = HUGE_VAL; - throw proj_exception( -14 ); + throw proj_exception(-14 ); return; } From aa1ec1c832ead914dec156dd2fda9233cdec1081 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 22 Apr 2015 15:53:29 +0200 Subject: [PATCH 144/146] [projections] commit changes for new generation (comments only) --- .../boost/geometry/extensions/gis/projections/proj/aitoff.hpp | 2 ++ .../boost/geometry/extensions/gis/projections/proj/putp3.hpp | 1 - .../boost/geometry/extensions/gis/projections/proj/urm5.hpp | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/boost/geometry/extensions/gis/projections/proj/aitoff.hpp b/include/boost/geometry/extensions/gis/projections/proj/aitoff.hpp index dfa18b963..b20ca3fcb 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/aitoff.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/aitoff.hpp @@ -135,6 +135,7 @@ namespace boost { namespace geometry { namespace projections \par Projection characteristics - Miscellaneous - Spheroid + - no inverse \par Example \image html ex_aitoff.gif */ @@ -156,6 +157,7 @@ namespace boost { namespace geometry { namespace projections \par Projection characteristics - Miscellaneous - Spheroid + - no inverse - lat_1 \par Example \image html ex_wintri.gif diff --git a/include/boost/geometry/extensions/gis/projections/proj/putp3.hpp b/include/boost/geometry/extensions/gis/projections/proj/putp3.hpp index 4a674f8e3..46ac57bd9 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/putp3.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/putp3.hpp @@ -142,7 +142,6 @@ namespace boost { namespace geometry { namespace projections \tparam Parameters parameter type \par Projection characteristics - Pseudocylindrical - - no inverse - Spheroid \par Example \image html ex_putp3p.gif diff --git a/include/boost/geometry/extensions/gis/projections/proj/urm5.hpp b/include/boost/geometry/extensions/gis/projections/proj/urm5.hpp index 05c1501a6..7d1fba571 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/urm5.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/urm5.hpp @@ -106,7 +106,8 @@ namespace boost { namespace geometry { namespace projections \par Projection characteristics - Pseudocylindrical - Spheroid - - n= q= alphi= + - no inverse + - n= q= alpha= \par Example \image html ex_urm5.gif */ From 8a66ade71af1670c48bde7560fccec4f03ce03d4 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 22 Apr 2015 15:54:04 +0200 Subject: [PATCH 145/146] [projections] commit changes for new generation (minor code changes) --- .../boost/geometry/extensions/gis/projections/proj/lcca.hpp | 5 +++-- .../geometry/extensions/gis/projections/proj/sconics.hpp | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp b/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp index 7fd3bcabb..3c7cdffe5 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp @@ -117,7 +117,8 @@ namespace boost { namespace geometry { namespace projections template void setup_lcca(Parameters& par, par_lcca& proj_parm) { - double s2p0, N0, R0, tan0/*, tan20*/; + double s2p0, N0, R0, tan0, tan20; + boost::ignore_unused(tan20); pj_enfn(par.es, proj_parm.en); if (!pj_param(par.params, "tlat_0").i) throw proj_exception(50); if (par.phi0 == 0.) throw proj_exception(51); @@ -128,7 +129,7 @@ namespace boost { namespace geometry { namespace projections N0 = sqrt(R0); R0 *= par.one_es * N0; tan0 = tan(par.phi0); - //tan20 = tan0 * tan0; + tan20 = tan0 * tan0; proj_parm.r0 = N0 / tan0; proj_parm.C = 1. / (6. * R0 * N0); // par.inv = e_inverse; diff --git a/include/boost/geometry/extensions/gis/projections/proj/sconics.hpp b/include/boost/geometry/extensions/gis/projections/proj/sconics.hpp index f5a536af0..191d3e018 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/sconics.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/sconics.hpp @@ -112,7 +112,6 @@ namespace boost { namespace geometry { namespace projections break; case PCONIC: rho = this->m_proj_parm.c2 * (this->m_proj_parm.c1 - tan(lp_lat - this->m_proj_parm.sig)); - // rho = this->m_proj_parm.c2 * (this->m_proj_parm.c1 - tan(lp_lat)); BUG STILL IN proj (reported 2012-03-03) break; default: rho = this->m_proj_parm.rho_c - lp_lat; From cb7521056f3d1ea17d9d3637d5641b9e386aec0a Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 22 Apr 2015 16:36:08 +0200 Subject: [PATCH 146/146] [projections] use proj4 4.8, changes in projection Robin --- .../test/gis/projections/projections.cpp | 4 +- .../extensions/gis/projections/proj/robin.hpp | 89 ++++++++++--------- 2 files changed, 49 insertions(+), 44 deletions(-) diff --git a/extensions/test/gis/projections/projections.cpp b/extensions/test/gis/projections/projections.cpp index a684525fd..a825b3ff9 100644 --- a/extensions/test/gis/projections/projections.cpp +++ b/extensions/test/gis/projections/projections.cpp @@ -202,7 +202,7 @@ void test_all() test_forward

("putp6", 4.897000, 52.371000, 324931.055842, 5842588.644796, "+proj=putp6 +ellps=WGS84 +units=m"); test_forward

("putp6p", 4.897000, 52.371000, 338623.512107, 6396742.919679, "+proj=putp6p +ellps=WGS84 +units=m"); test_forward

("qua_aut", 4.897000, 52.371000, 370892.621714, 5629072.862494, "+proj=qua_aut +ellps=WGS84 +units=m"); - test_forward

("robin", 4.897000, 52.371000, 394576.507489, 5571243.439235, "+proj=robin +ellps=WGS84 +units=m"); + test_forward

("robin", 4.897000, 52.371000, 394576.507489, 5570940.631371, "+proj=robin +ellps=WGS84 +units=m"); test_forward

("rouss", 4.897000, 52.371000, 412826.227669, 6248368.849775, "+proj=rouss +ellps=WGS84 +units=m"); test_forward

("rpoly", 4.897000, 52.371000, 332447.130797, 5841164.662431, "+proj=rpoly +ellps=WGS84 +units=m"); test_forward

("sinu", 4.897000, 52.371000, 333528.909809, 5804625.044313, "+proj=sinu +ellps=WGS84 +units=m"); @@ -317,7 +317,7 @@ void test_all() test_inverse

("putp6", 324931.055842, 5842588.644796, 4.897000, 52.371000, "+proj=putp6 +ellps=WGS84 +units=m"); test_inverse

("putp6p", 338623.512107, 6396742.919679, 4.897000, 52.371000, "+proj=putp6p +ellps=WGS84 +units=m"); test_inverse

("qua_aut", 370892.621714, 5629072.862494, 4.897000, 52.371000, "+proj=qua_aut +ellps=WGS84 +units=m"); - test_inverse

("robin", 394576.507489, 5571243.439235, 4.897000, 52.371000, "+proj=robin +ellps=WGS84 +units=m"); + test_inverse

("robin", 394576.507489, 5570940.631371, 4.897000, 52.371000, "+proj=robin +ellps=WGS84 +units=m"); test_inverse

("rouss", 412826.227669, 6248368.849775, 4.959853, 52.433747, "+proj=rouss +ellps=WGS84 +units=m"); // F/I: 8188.459174 test_inverse

("sinu", 333528.909809, 5804625.044313, 4.897000, 52.371000, "+proj=sinu +ellps=WGS84 +units=m"); test_inverse

("somerc", 545131.546415, 6833623.829215, 4.897000, 52.371000, "+proj=somerc +ellps=WGS84 +units=m"); diff --git a/include/boost/geometry/extensions/gis/projections/proj/robin.hpp b/include/boost/geometry/extensions/gis/projections/proj/robin.hpp index 53769ceb9..8397c71a6 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/robin.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/robin.hpp @@ -55,49 +55,54 @@ namespace boost { namespace geometry { namespace projections static const double ONEEPS = 1.000001; static const double EPS = 1e-8; - /* note: following terms based upon 5 deg. intervals in degrees. */ - static struct COEFS { + + + struct COEFS { double c0, c1, c2, c3; - } X[] = { - {1, -5.67239e-12, -7.15511e-05, 3.11028e-06}, - {0.9986, -0.000482241, -2.4897e-05, -1.33094e-06}, - {0.9954, -0.000831031, -4.4861e-05, -9.86588e-07}, - {0.99, -0.00135363, -5.96598e-05, 3.67749e-06}, - {0.9822, -0.00167442, -4.4975e-06, -5.72394e-06}, - {0.973, -0.00214869, -9.03565e-05, 1.88767e-08}, - {0.96, -0.00305084, -9.00732e-05, 1.64869e-06}, - {0.9427, -0.00382792, -6.53428e-05, -2.61493e-06}, - {0.9216, -0.00467747, -0.000104566, 4.8122e-06}, - {0.8962, -0.00536222, -3.23834e-05, -5.43445e-06}, - {0.8679, -0.00609364, -0.0001139, 3.32521e-06}, - {0.835, -0.00698325, -6.40219e-05, 9.34582e-07}, - {0.7986, -0.00755337, -5.00038e-05, 9.35532e-07}, - {0.7597, -0.00798325, -3.59716e-05, -2.27604e-06}, - {0.7186, -0.00851366, -7.0112e-05, -8.63072e-06}, - {0.6732, -0.00986209, -0.000199572, 1.91978e-05}, - {0.6213, -0.010418, 8.83948e-05, 6.24031e-06}, - {0.5722, -0.00906601, 0.000181999, 6.24033e-06}, - {0.5322, 0.,0.,0.} }, - Y[] = { - {0, 0.0124, 3.72529e-10, 1.15484e-09}, - {0.062, 0.0124001, 1.76951e-08, -5.92321e-09}, - {0.124, 0.0123998, -7.09668e-08, 2.25753e-08}, - {0.186, 0.0124008, 2.66917e-07, -8.44523e-08}, - {0.248, 0.0123971, -9.99682e-07, 3.15569e-07}, - {0.31, 0.0124108, 3.73349e-06, -1.1779e-06}, - {0.372, 0.0123598, -1.3935e-05, 4.39588e-06}, - {0.434, 0.0125501, 5.20034e-05, -1.00051e-05}, - {0.4958, 0.0123198, -9.80735e-05, 9.22397e-06}, - {0.5571, 0.0120308, 4.02857e-05, -5.2901e-06}, - {0.6176, 0.0120369, -3.90662e-05, 7.36117e-07}, - {0.6769, 0.0117015, -2.80246e-05, -8.54283e-07}, - {0.7346, 0.0113572, -4.08389e-05, -5.18524e-07}, - {0.7903, 0.0109099, -4.86169e-05, -1.0718e-06}, - {0.8435, 0.0103433, -6.46934e-05, 5.36384e-09}, - {0.8936, 0.00969679, -6.46129e-05, -8.54894e-06}, - {0.9394, 0.00840949, -0.000192847, -4.21023e-06}, - {0.9761, 0.00616525, -0.000256001, -4.21021e-06}, - {1., 0.,0.,0} }; + }; + + static const struct COEFS X[] = { + {1, 2.2199e-17, -7.15515e-05, 3.1103e-06}, + {0.9986, -0.000482243, -2.4897e-05, -1.3309e-06}, + {0.9954, -0.00083103, -4.48605e-05, -9.86701e-07}, + {0.99, -0.00135364, -5.9661e-05, 3.6777e-06}, + {0.9822, -0.00167442, -4.49547e-06, -5.72411e-06}, + {0.973, -0.00214868, -9.03571e-05, 1.8736e-08}, + {0.96, -0.00305085, -9.00761e-05, 1.64917e-06}, + {0.9427, -0.00382792, -6.53386e-05, -2.6154e-06}, + {0.9216, -0.00467746, -0.00010457, 4.81243e-06}, + {0.8962, -0.00536223, -3.23831e-05, -5.43432e-06}, + {0.8679, -0.00609363, -0.000113898, 3.32484e-06}, + {0.835, -0.00698325, -6.40253e-05, 9.34959e-07}, + {0.7986, -0.00755338, -5.00009e-05, 9.35324e-07}, + {0.7597, -0.00798324, -3.5971e-05, -2.27626e-06}, + {0.7186, -0.00851367, -7.01149e-05, -8.6303e-06}, + {0.6732, -0.00986209, -0.000199569, 1.91974e-05}, + {0.6213, -0.010418, 8.83923e-05, 6.24051e-06}, + {0.5722, -0.00906601, 0.000182, 6.24051e-06}, + {0.5322, -0.00677797, 0.000275608, 6.24051e-06} + }; + static const struct COEFS Y[] = { + {-5.20417e-18, 0.0124, 1.21431e-18, -8.45284e-11}, + {0.062, 0.0124, -1.26793e-09, 4.22642e-10}, + {0.124, 0.0124, 5.07171e-09, -1.60604e-09}, + {0.186, 0.0123999, -1.90189e-08, 6.00152e-09}, + {0.248, 0.0124002, 7.10039e-08, -2.24e-08}, + {0.31, 0.0123992, -2.64997e-07, 8.35986e-08}, + {0.372, 0.0124029, 9.88983e-07, -3.11994e-07}, + {0.434, 0.0123893, -3.69093e-06, -4.35621e-07}, + {0.4958, 0.0123198, -1.02252e-05, -3.45523e-07}, + {0.5571, 0.0121916, -1.54081e-05, -5.82288e-07}, + {0.6176, 0.0119938, -2.41424e-05, -5.25327e-07}, + {0.6769, 0.011713, -3.20223e-05, -5.16405e-07}, + {0.7346, 0.0113541, -3.97684e-05, -6.09052e-07}, + {0.7903, 0.0109107, -4.89042e-05, -1.04739e-06}, + {0.8435, 0.0103431, -6.4615e-05, -1.40374e-09}, + {0.8936, 0.00969686, -6.4636e-05, -8.547e-06}, + {0.9394, 0.00840947, -0.000192841, -4.2106e-06}, + {0.9761, 0.00616527, -0.000256, -4.2106e-06}, + {1, 0.00328947, -0.000319159, -4.2106e-06} + }; // template class, using CRTP to implement forward/inverse template