Skip to content

Feature/get turn info add retrieve policy #531

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
83ccebd
[overlay] replace 4 booleans is_p/q_first/last by a RetrievePolicy,
barendgehrels Nov 21, 2018
8afd678
[overlay] propagate retrieve_policy to end points
barendgehrels Nov 21, 2018
4d00b88
[overlay] split retrieve policy in two, because they are completely
barendgehrels Nov 21, 2018
edac2ef
[buffer] adapt call to get_turn_info
barendgehrels Nov 21, 2018
445dcac
[test] fix get_turn_info test for new retrieve_policy
barendgehrels Nov 21, 2018
0074145
[get_turns] let retrieve_policy get point pk and qk
barendgehrels Nov 24, 2018
d5cc998
[buffer] move functionality to retrieve next point into retrieve policy
barendgehrels Nov 25, 2018
a517138
[get_turns] create specific policy for box and pass box as array.
barendgehrels Nov 25, 2018
15b0c48
[get_turns] make retrieve policy for view, replacing the null_policy
barendgehrels Nov 25, 2018
4484b0e
[get_turn] remove pk/qk from turn handlers,
barendgehrels Nov 25, 2018
c1a0353
[get_turns] propagate retrieve polices to endpoint function
barendgehrels Nov 26, 2018
4fd5983
[get_turn_info] let the base itself return the swapped side calculator
barendgehrels Nov 27, 2018
c61c15e
[relate] create specific strategy for relate l/a
barendgehrels Nov 27, 2018
dcc6550
[get_turn_info] replace real intersection (for the sake of counting)
barendgehrels Nov 27, 2018
a47fee9
[get_turn_info] Make specific side calculator for other calculations
barendgehrels Nov 27, 2018
51c4e27
[get_turn_info] call get_swapped_sides for linear/linear
barendgehrels Nov 27, 2018
e24041e
[get_turn_info] pass retrieve policy template argument
barendgehrels Nov 27, 2018
e198744
[get_turn_info] pass retrieve policies i/o pk/qk
barendgehrels Nov 28, 2018
02971ec
[get_turn_info] remove redundant methods, use robust point methods
barendgehrels Nov 28, 2018
ea7ab83
[get_turn_info] retrieve pk/qk on demand
barendgehrels Nov 28, 2018
a9dc805
[get_turn_info] make methods const& (needed) and remove pk/pq
barendgehrels Nov 28, 2018
065489a
[get_turn_info] don't precalculate pk/qk in robust points
barendgehrels Nov 28, 2018
2a4777e
[get_turn_info] undo making side strategy a const reference
barendgehrels Nov 28, 2018
5cb39aa
[get_turn_info] changes in side calculator
barendgehrels Nov 28, 2018
c12b048
[test] fix get_turn_info unit test by adding correct strategy
barendgehrels Nov 28, 2018
5bf8066
[get_turn_info] process review remarks, rename policies, methods
barendgehrels Dec 1, 2018
f1b9c19
[get_turn_info] bugfix, never return false for has_k for areal features
barendgehrels Dec 1, 2018
812dc41
[get_turn_info] incorporate pi/pj qi/qj into retriever
barendgehrels Dec 3, 2018
e7ff373
[get_turn_info] remove pi,pj / qi,qj from crosses
barendgehrels Dec 3, 2018
c418492
[get_turn_info] remove pi,qj / qi,qj from end_points and other analyses
barendgehrels Dec 3, 2018
6bd612f
[get_turn_info] remove pi,pj / qi,qj from other basic turn handlers
barendgehrels Dec 3, 2018
b38de44
[get_turn_info] rename RetrieveAdditionalInfoPolicy to UniqueSubRange
barendgehrels Dec 3, 2018
9a31ac7
[get_turn_info] Replace get_point_i/j/k by at, and has_p by size()
barendgehrels Dec 4, 2018
2653bf5
[get_turn_info] Adapt unit test to latest state
barendgehrels Dec 4, 2018
5cc0ac1
[get_turn_info] move is_p_last info is_spike_p which avoids many extra
barendgehrels Dec 4, 2018
11b33d6
[buffer] propagate change retrieve -> sub_range to buffer
barendgehrels Dec 4, 2018
83a1e07
[buffer] do not calculate robust points in assign, but before.
barendgehrels Dec 4, 2018
64126a9
[get_turn_info][test] add point_type, rename policy
barendgehrels Dec 4, 2018
e5b1711
[get_turns] fix new code, use correct type
barendgehrels Dec 5, 2018
e0a44b8
[get_turn_info] rename has_k back to is_last
barendgehrels Dec 5, 2018
413e590
[get_turn_info] rename typedef'ed PointQ to point1_type and similar
barendgehrels Dec 5, 2018
3644f81
[get_turn_info] avoid typedef, omit pj/qj used once
barendgehrels Dec 5, 2018
b6a537f
[get_turn_info] now that buffer does not use assign_policy::apply any…
barendgehrels Dec 5, 2018
fdac1fb
[get_turn_info] now pi/qi are neither necessary, being used only once
barendgehrels Dec 5, 2018
daf901a
[get_turn_info] minor, comments, style
barendgehrels Dec 5, 2018
35bdde4
[get_turn_info] review remarks, pass ranges first, use iterators, com…
barendgehrels Dec 8, 2018
7ce6dfc
[get_turn_info] review remarks, add assert
barendgehrels Dec 8, 2018
668e9b1
[get_turn_info] Add conditions to avoid assert in collinear turn handler
barendgehrels Dec 8, 2018
8626ae1
[get_turn_info] avoid assertion by refactoring away side_calculator_f…
barendgehrels Dec 8, 2018
9a6a578
[get_turn_info] get rid of confusing names
barendgehrels Dec 8, 2018
a02a464
[get_turn_info] revise operations_of_equal, pass sides instead of ranges
barendgehrels Dec 8, 2018
ca22e24
[get_turn_info] rename wrongly named variables to more proper symboli…
barendgehrels Dec 8, 2018
2c14e92
[test] put ranges first
barendgehrels Dec 8, 2018
bec490d
[get_turn_info] review remark, i/o size use is_last_segment
barendgehrels Dec 8, 2018
b5d44b7
[test] fix get_turn_info test
barendgehrels Dec 8, 2018
2dce9c3
[get_turn_info] verify more pk/qk to avoid assertions
barendgehrels Dec 8, 2018
bac949d
[get_turn_info] add ranges
barendgehrels Dec 8, 2018
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
145 changes: 86 additions & 59 deletions include/boost/geometry/algorithms/detail/buffer/get_piece_turns.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <boost/core/ignore_unused.hpp>
#include <boost/range.hpp>

#include <boost/geometry/core/assert.hpp>
#include <boost/geometry/algorithms/equals.hpp>
#include <boost/geometry/algorithms/expand.hpp>
#include <boost/geometry/algorithms/detail/disjoint/box_box.hpp>
Expand All @@ -34,34 +35,81 @@ namespace boost { namespace geometry
namespace detail { namespace buffer
{


#if defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION)
struct buffer_assign_turn
// Implements a unique_sub_range for a buffered piece,
// the range can return subsequent points
// known as "i", "j" and "k" (and further), indexed as 0,1,2,3
template <typename Ring>
struct unique_sub_range_from_piece
{
static bool const include_no_turn = false;
static bool const include_degenerate = false;
static bool const include_opposite = false;

template
<
typename Info,
typename Point1,
typename Point2,
typename IntersectionInfo
>
static inline void apply(Info& info,
Point1 const& /*p1*/,
Point2 const& /*p2*/,
IntersectionInfo const& iinfo)
typedef typename boost::range_iterator<Ring const>::type iterator_type;
typedef typename geometry::point_type<Ring const>::type point_type;

unique_sub_range_from_piece(Ring const& ring,
iterator_type iterator_at_i, iterator_type iterator_at_j)
: m_ring(ring)
, m_iterator_at_i(iterator_at_i)
, m_iterator_at_j(iterator_at_j)
, m_point_retrieved(false)
{}

static inline bool is_first_segment() { return false; }
static inline bool is_last_segment() { return false; }

static inline std::size_t size() { return 3u; }

inline point_type const& at(std::size_t index) const
{
info.rob_pi = iinfo.rpi();
info.rob_pj = iinfo.rpj();
info.rob_qi = iinfo.rqi();
info.rob_qj = iinfo.rqj();
BOOST_GEOMETRY_ASSERT(index < size());
switch (index)
{
case 0 : return *m_iterator_at_i;
case 1 : return *m_iterator_at_j;
case 2 : return get_point_k();
default : return *m_iterator_at_i;
}
}

private :

inline point_type const& get_point_k() const
{
if (! m_point_retrieved)
{
m_iterator_at_k = advance_one(m_iterator_at_j);
m_point_retrieved = true;
}
return *m_iterator_at_k;
}

inline void circular_advance_one(iterator_type& next) const
{
++next;
if (next == boost::end(m_ring))
{
next = boost::begin(m_ring) + 1;
}
}

inline iterator_type advance_one(iterator_type it) const
{
iterator_type result = it;
circular_advance_one(result);

// TODO: we could also use piece-boundaries
// to check if the point equals the last one
while (geometry::equals(*it, *result))
{
circular_advance_one(result);
}
return result;
}

Ring const& m_ring;
iterator_type m_iterator_at_i;
iterator_type m_iterator_at_j;
mutable iterator_type m_iterator_at_k;
mutable bool m_point_retrieved;
};
#endif

template
<
Expand Down Expand Up @@ -102,29 +150,6 @@ class piece_turn_visitor
return ! m_rings[piece1.first_seg_id.multi_index].has_concave;
}

template <typename Range, typename Iterator>
inline void move_to_next_point(Range const& range, Iterator& next) const
{
++next;
if (next == boost::end(range))
{
next = boost::begin(range) + 1;
}
}

template <typename Range, typename Iterator>
inline Iterator next_point(Range const& range, Iterator it) const
{
Iterator result = it;
move_to_next_point(range, result);
// TODO: we could use either piece-boundaries, or comparison with
// robust points, to check if the point equals the last one
while(geometry::equals(*it, *result))
{
move_to_next_point(range, result);
}
return result;
}

template <std::size_t Dimension, typename Iterator, typename Box>
inline void move_begin_iterator(Iterator& it_begin, Iterator it_beyond,
Expand Down Expand Up @@ -229,15 +254,23 @@ class piece_turn_visitor
the_model.operations[1].piece_index = piece2.index;
the_model.operations[1].seg_id = piece2.first_seg_id;
the_model.operations[1].seg_id.segment_index = index2; // override
#if defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION)
geometry::recalculate(the_model.rob_pi, *prev1, m_robust_policy);
geometry::recalculate(the_model.rob_pj, *it1, m_robust_policy);
#endif

iterator next1 = next_point(ring1, it1);
unique_sub_range_from_piece<ring_type> unique_sub_range1(ring1, prev1, it1);

iterator it2 = it2_first;
for (iterator prev2 = it2++;
it2 != it2_beyond;
prev2 = it2++, the_model.operations[1].seg_id.segment_index++)
{
iterator next2 = next_point(ring2, it2);
unique_sub_range_from_piece<ring_type> unique_sub_range2(ring2, prev2, it2);
#if defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION)
geometry::recalculate(the_model.rob_qi, *prev2, m_robust_policy);
geometry::recalculate(the_model.rob_qj, *it2, m_robust_policy);
#endif

// TODO: internally get_turn_info calculates robust points.
// But they are already calculated.
Expand All @@ -246,20 +279,14 @@ class piece_turn_visitor
// and iterating in sync with them...
typedef detail::overlay::get_turn_info
<
#if defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION)
buffer_assign_turn
#else
detail::overlay::assign_null_policy
#endif
> turn_policy;

turn_policy::apply(*prev1, *it1, *next1,
*prev2, *it2, *next2,
false, false, false, false,
the_model,
m_intersection_strategy,
m_robust_policy,
std::back_inserter(m_turns));
turn_policy::apply(unique_sub_range1, unique_sub_range2,
the_model,
m_intersection_strategy,
m_robust_policy,
std::back_inserter(m_turns));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,6 @@ struct assign_disjoint_policy
static bool const include_no_turn = true;
static bool const include_degenerate = true;
static bool const include_opposite = true;

// We don't assign extra info:
template
<
typename Info,
typename Point1,
typename Point2,
typename IntersectionInfo
>
static inline void apply(Info& , Point1 const& , Point2 const&,
IntersectionInfo const&)
{}
};


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,16 @@ template
>
struct get_turn_without_info
{
template <typename Strategy, typename RobustPolicy, typename OutputIterator>
static inline OutputIterator apply(
Point1 const& pi, Point1 const& pj, Point1 const& /*pk*/,
Point2 const& qi, Point2 const& qj, Point2 const& /*qk*/,
bool /*is_p_first*/, bool /*is_p_last*/,
bool /*is_q_first*/, bool /*is_q_last*/,
template
<
typename UniqueSubRange1,
typename UniqueSubRange2,
typename Strategy,
typename RobustPolicy,
typename OutputIterator
>
static inline OutputIterator apply(UniqueSubRange1 const& range_p,
UniqueSubRange2 const& range_q,
TurnInfo const& ,
Strategy const& strategy,
RobustPolicy const& robust_policy,
Expand All @@ -71,6 +75,10 @@ struct get_turn_without_info

typedef model::referring_segment<Point1 const> segment_type1;
typedef model::referring_segment<Point2 const> segment_type2;
Point1 const& pi = range_p.at(0);
Point1 const& pj = range_p.at(1);
Point2 const& qi = range_q.at(0);
Point2 const& qj = range_q.at(1);
segment_type1 p1(pi, pj);
segment_type2 q1(qi, qj);

Expand Down
Loading