Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various minor improvements #1202

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/boost/geometry/algorithms/assign.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ template <typename Geometry1, typename Geometry2>
struct assign
{
static inline void
apply(Geometry1& geometry1, const Geometry2& geometry2)
apply(Geometry1& geometry1, Geometry2 const& geometry2)
{
concepts::check<Geometry1>();
concepts::check<Geometry2 const>();
Expand Down
1 change: 1 addition & 0 deletions include/boost/geometry/algorithms/correct_closure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <boost/geometry/geometries/concepts/check.hpp>

#include <boost/geometry/util/range.hpp>
#include <boost/range/size.hpp>

namespace boost { namespace geometry
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ struct buffered_piece_collection
BOOST_GEOMETRY_ASSERT(pc.offsetted_count >= 0);
}

inline void add_piece_point(piece& pc, const point_type& point, bool add_to_original)
inline void add_piece_point(piece& pc, point_type const& point, bool add_to_original)
{
if (add_to_original && pc.type != strategy::buffer::buffered_concave)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ struct line_line_intersection
// | pa pa |
// | qb qb |
auto const denominator_pq = determinant<line, &line::a, &line::b>(p, q);
constexpr decltype(denominator_pq) const zero = 0;
static decltype(denominator_pq) const zero = 0;

if (equidistant)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <array>

#include <boost/core/addressof.hpp>
#include <boost/range/size.hpp>

#include <boost/geometry/core/assert.hpp>
#include <boost/geometry/core/config.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@


#include <boost/core/ignore_unused.hpp>
#include <boost/geometry/core/coordinate_type.hpp>
#include <boost/range/size.hpp>

#include <boost/geometry/core/coordinate_type.hpp>
#include <boost/geometry/algorithms/detail/buffer/buffer_policies.hpp>
#include <boost/geometry/algorithms/detail/disjoint/interface.hpp>
#include <boost/geometry/algorithms/expand.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#include <vector>

#include <boost/range/size.hpp>

#include <boost/geometry/algorithms/area.hpp>
#include <boost/geometry/core/point_order.hpp>
#include <boost/geometry/core/radian_access.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/size.hpp>

#include <boost/geometry/core/assert.hpp>
#include <boost/geometry/core/closure.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

#include <iterator>

#include <boost/range/size.hpp>

#include <boost/geometry/algorithms/covered_by.hpp>
#include <boost/geometry/algorithms/detail/closest_points/range_to_geometry_rtree.hpp>
#include <boost/geometry/algorithms/detail/closest_points/utilities.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include <algorithm>
#include <vector>

#include <boost/range/size.hpp>

#include <boost/geometry/algorithms/detail/for_each_range.hpp>
#include <boost/geometry/core/assert.hpp>
#include <boost/geometry/core/closure.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

#include <array>

#include <boost/range/size.hpp>

#include <boost/geometry/algorithms/detail/assign_box_corners.hpp>
#include <boost/geometry/algorithms/detail/convex_hull/graham_andrew.hpp>
#include <boost/geometry/algorithms/detail/equals/point_point.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_SEGMENT_OR_BOX_HPP


#include <boost/range/size.hpp>

#include <boost/geometry/algorithms/detail/disjoint/multirange_geometry.hpp>
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
#include <boost/geometry/algorithms/not_implemented.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

#include <vector>

#include <boost/range/size.hpp>

#include <boost/geometry/algorithms/dispatch/distance.hpp>
#include <boost/geometry/algorithms/detail/visit.hpp>
#include <boost/geometry/core/assert.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@


#include <boost/numeric/conversion/cast.hpp>
#include <boost/range/size.hpp>

#include <boost/geometry/algorithms/detail/normalize.hpp>
#include <boost/geometry/algorithms/not_implemented.hpp>
Expand Down
2 changes: 2 additions & 0 deletions include/boost/geometry/algorithms/detail/intersection/gc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

#include <tuple>

#include <boost/range/size.hpp>

#include <boost/geometry/algorithms/detail/gc_make_rtree.hpp>
#include <boost/geometry/algorithms/detail/intersection/interface.hpp>
#include <boost/geometry/views/detail/geometry_collection_view.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include <boost/iterator/filter_iterator.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/size.hpp>
#include <boost/range/value_type.hpp>

#include <boost/geometry/core/exterior_ring.hpp>
Expand Down
5 changes: 3 additions & 2 deletions include/boost/geometry/algorithms/detail/is_valid/ring.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

#include <deque>

#include <boost/range/size.hpp>

#include <boost/core/ignore_unused.hpp>

#include <boost/geometry/core/closure.hpp>
Expand All @@ -38,12 +40,11 @@
#include <boost/geometry/algorithms/detail/is_valid/has_valid_self_turns.hpp>
#include <boost/geometry/algorithms/dispatch/is_valid.hpp>

// TEMP - with UmberllaStrategy this will be not needed
// TEMP - with UmbrellaStrategy this will be not needed
#include <boost/geometry/strategy/area.hpp>
#include <boost/geometry/strategies/area/services.hpp>
// TODO: use point_order instead of area


#ifdef BOOST_GEOMETRY_TEST_DEBUG
#include <boost/geometry/io/dsv/write.hpp>
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ inline void append_no_dups_or_spikes(Range& range, Point const& point,
return;
}

auto append = [](auto& r, const auto& p)
auto append = [](auto& r, auto const& p)
{
using point_t = typename boost::range_value<Range>::type;
point_t rp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,26 @@ namespace detail { namespace overlay
{

// Value for approximately_equals used by get_cluster and sort_by_side
// This is an "epsilon_multiplier" and, therefore, multiplied the epsilon
// belonging to the used floating point type with this value.
template <typename T>
struct common_approximately_equals_epsilon
struct common_approximately_equals_epsilon_multiplier
{
static T value()
{
// The value is (a bit) arbitrary. For sort_by_side it should be large
// enough to not take a point which is too close by, to calculate the
// side value correctly. For get_cluster it is arbitrary as well, points
// close to each other should form a cluster, which is also important
// for subsequent side calculations. Points too far apart should not be
// clustered.
//
// The value of 100 is currently considered as a sweet spot.
// If the value changes (as of 2023-09-13):
// 10: too small, failing unit test(s):
// - union: issue_1108
// 50: this would be fine, no tests failing
// 1000: this would be fine, no tests failing
return T(100);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ inline void assign_parents(Geometry1 const& geometry1,
}
else if (info.parent.source_index >= 0)
{
const ring_info_type& parent = ring_map[info.parent];
ring_info_type const& parent = ring_map[info.parent];
bool const pos = math::larger(info.get_area(), 0);
bool const parent_pos = math::larger(parent.area, 0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ struct cluster_colocator<Point, CoordinateType, geometry::cartesian_tag, false>
{
CoordinateType centroid_0 = 0;
CoordinateType centroid_1 = 0;
for (const auto& index : indices)
for (auto const& index : indices)
{
centroid_0 += geometry::get<0>(turns[index].point);
centroid_1 += geometry::get<1>(turns[index].point);
}
centroid_0 /= indices.size();
centroid_1 /= indices.size();
for (const auto& index : indices)
for (auto const& index : indices)
{
geometry::set<0>(turns[index].point, centroid_0);
geometry::set<1>(turns[index].point, centroid_1);
Expand All @@ -86,14 +86,14 @@ inline void colocate_clusters(Clusters const& clusters, Turns& turns)
{
for (auto const& pair : clusters)
{
auto const& indices = pair.second.turn_indices;
if (indices.size() < 2)
auto const& turn_indices = pair.second.turn_indices;
if (turn_indices.size() < 2)
{
// Defensive check
continue;
}
using point_t = decltype(turns[*indices.begin()].point);
cluster_colocator<point_t>::apply(indices, turns);
using point_t = decltype(turns[*turn_indices.begin()].point);
cluster_colocator<point_t>::apply(turn_indices, turns);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ inline void discard_duplicate_start_turns(Turns& turns,
{
if (turn.method == method_start)
{
for (const auto& op : turn.operations)
for (auto const& op : turn.operations)
{
start_turns_per_segment[adapt_id(op.seg_id)].push_back(index);
}
Expand All @@ -130,7 +130,7 @@ inline void discard_duplicate_start_turns(Turns& turns,
// Also avoid comparing "start" with itself.
if (turn.method != method_crosses && turn.method != method_start)
{
for (const auto& op : turn.operations)
for (auto const& op : turn.operations)
{
auto it = start_turns_per_segment.find(adapt_id(op.seg_id));
if (it != start_turns_per_segment.end())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,22 @@ struct sweep_equal_policy
{

public:
// Returns true if point are considered equal (within an epsilon)
// Returns true if point are considered equal
template <typename P>
static inline bool equals(P const& p1, P const& p2)
{
using coor_t = typename coordinate_type<P>::type;
return approximately_equals(p1, p2, common_approximately_equals_epsilon<coor_t>::value());
static auto const tolerance
= common_approximately_equals_epsilon_multiplier<coor_t>::value();
return approximately_equals(p1, p2, tolerance);
}

template <typename T>
static inline bool exceeds(T value)
{
T const limit = T(1) / common_approximately_equals_epsilon<T>::value();
static auto const tolerance
= common_approximately_equals_epsilon_multiplier<T>::value();
T const limit = T(1) / tolerance;
return value > limit;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ struct get_distance_measure<CalculationType, spherical_tag>
static result_type apply(SegmentPoint const& , SegmentPoint const& ,
Point const& )
{
const result_type result;
result_type const result;
return result;
}
};
Expand Down Expand Up @@ -125,7 +125,7 @@ inline auto get_distance_measure(SegmentPoint const& p1, SegmentPoint const& p2,
// Verify equality, without using a tolerance
// (so don't use equals or equals_point_point)
// because it is about very tiny differences.
auto identical = [](const auto& point1, const auto& point2)
auto identical = [](auto const& point1, auto const& point2)
{
return geometry::get<0>(point1) == geometry::get<0>(point2)
&& geometry::get<1>(point1) == geometry::get<1>(point2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ struct touch : public base_turn_handler
// >----->P qj is LEFT of P1 and pi is LEFT of Q2
// (the other way round is also possible)

auto has_distance = [&](const auto& r1, const auto& r2) -> bool
auto has_distance = [&](auto const& r1, auto const& r2) -> bool
{
auto const d1 = get_distance_measure(r1.at(0), r1.at(1), r2.at(1), umbrella_strategy);
auto const d2 = get_distance_measure(r2.at(1), r2.at(2), r1.at(0), umbrella_strategy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ struct get_turn_info_linear_areal
namespace ov = overlay;
typedef ov::get_turn_info_for_endpoint<EnableFirst, EnableLast> get_info_e;

const std::size_t ip_count = inters.i_info().count;
std::size_t const ip_count = inters.i_info().count;
// no intersection points
if (ip_count == 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ inline void assign_cluster_ids(Turns& turns, Clusters const& clusters)
}
for (auto const& kv : clusters)
{
for (const auto& index : kv.second.turn_indices)
for (auto const& index : kv.second.turn_indices)
{
turns[index].cluster_id = kv.first;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private :
template <typename Turns, typename Clusters>
static inline
bool is_self_cluster(signed_size_type cluster_id,
const Turns& turns, Clusters const& clusters)
Turns const& turns, Clusters const& clusters)
{
auto cit = clusters.find(cluster_id);
if (cit == clusters.end())
Expand Down
Loading
Loading