Skip to content

Commit

Permalink
feat: include changes and tests changes
Browse files Browse the repository at this point in the history
  • Loading branch information
barendgehrels committed Jan 16, 2025
1 parent cda90e5 commit 7b53735
Show file tree
Hide file tree
Showing 22 changed files with 566 additions and 77 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)

// Copyright (c) 2007-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2023-2024 Adam Wulkiewicz, Lodz, Poland.

// This file was modified by Oracle on 2017-2024.
// Modifications copyright (c) 2017-2024 Oracle and/or its affiliates.
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle

// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DEBUG_TRAVERSE_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DEBUG_TRAVERSE_HPP

#include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>

#if defined(BOOST_GEOMETRY_DEBUG_INTERSECTION) \
|| defined(BOOST_GEOMETRY_OVERLAY_REPORT_WKT) \
|| defined(BOOST_GEOMETRY_DEBUG_TRAVERSE)
# include <string>
# include <boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp>
# include <boost/geometry/io/wkt/wkt.hpp>
#endif

namespace boost { namespace geometry
{

#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace overlay
{

template <typename Turn, typename Operation>
#ifdef BOOST_GEOMETRY_DEBUG_TRAVERSE
inline void debug_traverse(Turn const& turn, Operation op,
std::string const& header, bool condition = true)
{
if (! condition)
{
return;
}
std::cout << " " << header
<< " at " << op.seg_id
<< " meth: " << method_char(turn.method)
<< " op: " << operation_char(op.operation)
<< " of: " << operation_char(turn.operations[0].operation)
<< operation_char(turn.operations[1].operation)
<< " " << geometry::wkt(turn.point)
<< std::endl;

if (boost::contains(header, "Finished"))
{
std::cout << std::endl;
}
}
#else
inline void debug_traverse(Turn const& , Operation, const char*, bool = true)
{
}
#endif

}} // namespace detail::overlay
#endif // DOXYGEN_NO_DETAIL

}} // namespace boost::geometry

#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DEBUG_TRAVERSE_HPP
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ inline void enrich_assign(Operations& operations, Turns& turns)
&& op.seg_id == next_operation().seg_id
&& indexed.turn_index != operations[next_index].turn_index)
{
// In same cluster, on same segment, but not same turn
next_index = advance(next_index);
}

Expand Down Expand Up @@ -286,15 +287,9 @@ inline auto create_map(Turns const& turns, IncludePolicy const& include_policy)
auto const& op = op_item.value;
if (include_policy.include(op.operation))
{
ring_identifier const ring_id
mapped_vector[ring_id_by_seg_id(op.seg_id)].emplace_back
(
op.seg_id.source_index,
op.seg_id.multi_index,
op.seg_id.ring_index
);
mapped_vector[ring_id].emplace_back
(
index, op_index, op, turn.operations[1 - op_index].seg_id
index, op_index, op, turn.operations[1 - op_index].seg_id
);
}
}
Expand Down Expand Up @@ -403,8 +398,6 @@ inline void enrich_intersection_points(Turns& turns,
// For all operations, discard xx and none/none
// For intersections, remove uu to avoid the need to travel
// a union (during intersection) in uu/cc clusters (e.g. #31,#32,#33)
// The ux is necessary to indicate impossible paths
// (especially if rescaling is removed)

// Similarly, for union, discard ii and ix

Expand Down Expand Up @@ -457,6 +450,8 @@ inline void enrich_intersection_points(Turns& turns,
strategy);
}

// After cleaning up clusters assign the next turns

for (auto& pair : mapped_vector)
{
#ifdef BOOST_GEOMETRY_DEBUG_ENRICH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <boost/geometry/algorithms/detail/covered_by/implementation.hpp>
#include <boost/geometry/algorithms/detail/overlay/append_no_duplicates.hpp>
#include <boost/geometry/algorithms/detail/overlay/copy_segments.hpp>
#include <boost/geometry/algorithms/detail/overlay/debug_traverse.hpp>
#include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
#include <boost/geometry/algorithms/detail/point_on_border.hpp>
#include <boost/geometry/algorithms/detail/relate/turns.hpp>
Expand Down
31 changes: 1 addition & 30 deletions include/boost/geometry/algorithms/detail/overlay/traversal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <boost/range/value_type.hpp>

#include <boost/geometry/algorithms/detail/overlay/cluster_info.hpp>
#include <boost/geometry/algorithms/detail/overlay/debug_traverse.hpp>
#include <boost/geometry/algorithms/detail/overlay/is_self_turn.hpp>
#include <boost/geometry/algorithms/detail/overlay/sort_by_side.hpp>
#include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
Expand All @@ -44,36 +45,6 @@ namespace boost { namespace geometry
namespace detail { namespace overlay
{

template <typename Turn, typename Operation>
#ifdef BOOST_GEOMETRY_DEBUG_TRAVERSE
inline void debug_traverse(Turn const& turn, Operation op,
std::string const& header, bool condition = true)
{
if (! condition)
{
return;
}
std::cout << " " << header
<< " at " << op.seg_id
<< " meth: " << method_char(turn.method)
<< " op: " << operation_char(op.operation)
<< " vis: " << visited_char(op.visited)
<< " of: " << operation_char(turn.operations[0].operation)
<< operation_char(turn.operations[1].operation)
<< " " << geometry::wkt(turn.point)
<< std::endl;

if (boost::contains(header, "Finished"))
{
std::cout << std::endl;
}
}
#else
inline void debug_traverse(Turn const& , Operation, const char*, bool = true)
{
}
#endif

template
<
bool Reverse1,
Expand Down
9 changes: 9 additions & 0 deletions include/boost/geometry/strategies/relate/cartesian.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <boost/geometry/strategies/cartesian/point_in_poly_winding.hpp>
#include <boost/geometry/strategies/cartesian/disjoint_box_box.hpp>

#include <boost/geometry/strategies/distance/detail.hpp>
#include <boost/geometry/strategies/distance/services.hpp>
#include <boost/geometry/strategies/envelope/cartesian.hpp>
#include <boost/geometry/strategies/relate/services.hpp>
#include <boost/geometry/strategies/detail.hpp>
Expand Down Expand Up @@ -155,6 +157,13 @@ class cartesian
return strategy::intersection::cartesian_segments<CalculationType>();
}

template <typename Geometry1, typename Geometry2>
static auto comparable_distance(Geometry1 const&, Geometry2 const&,
distance::detail::enable_if_pp_t<Geometry1, Geometry2> * = nullptr)
{
return strategy::distance::comparable::pythagoras<CalculationType>();
}

// side

static auto side()
Expand Down
12 changes: 12 additions & 0 deletions include/boost/geometry/strategies/relate/geographic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include <boost/geometry/strategies/spherical/point_in_point.hpp>
#include <boost/geometry/strategies/spherical/disjoint_box_box.hpp>

#include <boost/geometry/strategies/distance/detail.hpp>
#include <boost/geometry/strategies/distance/services.hpp>
#include <boost/geometry/strategies/envelope/geographic.hpp>
#include <boost/geometry/strategies/relate/services.hpp>
#include <boost/geometry/strategies/detail.hpp>
Expand Down Expand Up @@ -78,6 +80,16 @@ class geographic
>(base_t::m_spheroid);
}

template <typename Geometry1, typename Geometry2>
auto comparable_distance(Geometry1 const&, Geometry2 const&,
distance::detail::enable_if_pp_t<Geometry1, Geometry2> * = nullptr) const
{
return strategy::distance::geographic
<
FormulaPolicy, Spheroid, CalculationType
>(base_t::m_spheroid);
}

// covered_by

template <typename Geometry1, typename Geometry2>
Expand Down
12 changes: 12 additions & 0 deletions include/boost/geometry/strategies/relate/spherical.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include <boost/geometry/strategies/spherical/point_in_poly_winding.hpp>
#include <boost/geometry/strategies/spherical/disjoint_box_box.hpp>

#include <boost/geometry/strategies/distance/detail.hpp>
#include <boost/geometry/strategies/distance/services.hpp>
#include <boost/geometry/strategies/envelope/spherical.hpp>
#include <boost/geometry/strategies/relate/services.hpp>
#include <boost/geometry/strategies/detail.hpp>
Expand Down Expand Up @@ -77,6 +79,16 @@ class spherical
>(base_t::radius());
}

template <typename Geometry1, typename Geometry2>
auto comparable_distance(Geometry1 const&, Geometry2 const&,
distance::detail::enable_if_pp_t<Geometry1, Geometry2> * = nullptr) const
{
return strategy::distance::comparable::haversine
<
typename base_t::radius_type, CalculationType
>(base_t::radius());
}

// covered_by

template <typename Geometry1, typename Geometry2>
Expand Down
12 changes: 11 additions & 1 deletion test/algorithms/buffer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ endforeach()
# Tests for all geometry types, cartesian, for one floating point type
foreach(item IN ITEMS
buffer_point
buffer_linestring
buffer_ring
buffer_polygon
buffer_multi_point
Expand All @@ -38,6 +37,17 @@ foreach(item IN ITEMS
target_compile_definitions(${BOOST_GEOMETRY_UNIT_TEST_NAME} PRIVATE BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE)
endforeach()

# Tests which take a long time and are not run by default.
# Besides that, the buffer_countries test requires the WKT files.
foreach(item IN ITEMS
buffer_countries
buffer_linestring
buffer_linestring_geo
)
boost_geometry_add_unit_test("algorithms" ${item} "not_run")
target_compile_definitions(${BOOST_GEOMETRY_UNIT_TEST_NAME} PRIVATE BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE)
endforeach()

# Other tests
foreach(item IN ITEMS
buffer_with_strategies
Expand Down
Loading

0 comments on commit 7b53735

Please sign in to comment.