diff --git a/include/boost/geometry/algorithms/detail/overlay/get_turn_info_for_endpoint.hpp b/include/boost/geometry/algorithms/detail/overlay/get_turn_info_for_endpoint.hpp index b78489b04..ceb291691 100644 --- a/include/boost/geometry/algorithms/detail/overlay/get_turn_info_for_endpoint.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/get_turn_info_for_endpoint.hpp @@ -82,10 +82,14 @@ public: inline i_info_type const& i_info() const { return m_result.template get<0>(); } inline d_info_type const& d_info() const { return m_result.template get<1>(); } + // TODO: not it's more like is_spike_ip_p inline bool is_spike_p() const { if ( m_side_calc.pk_wrt_p1() == 0 ) { + if ( ! is_ip_j<0>() ) + return false; + int const qk_p1 = m_side_calc.qk_wrt_p1(); int const qk_p2 = m_side_calc.qk_wrt_p2(); @@ -103,10 +107,14 @@ public: return false; } + // TODO: not it's more like is_spike_ip_q inline bool is_spike_q() const { if ( m_side_calc.qk_wrt_q1() == 0 ) { + if ( ! is_ip_j<1>() ) + return false; + int const pk_q1 = m_side_calc.pk_wrt_q1(); int const pk_q2 = m_side_calc.pk_wrt_q2(); @@ -143,6 +151,36 @@ private: return result.template get<0>().count == 2; } + template + bool is_ip_j() const + { + int arrival = d_info().arrival[OpId]; + bool same_dirs = d_info().dir_a == 0 && d_info().dir_b == 0; + + if ( same_dirs ) + { + if ( i_info().count == 2 ) + { + if ( ! d_info().opposite ) + { + return arrival != -1; + } + else + { + return arrival != -1; + } + } + else + { + return arrival == 0; + } + } + else + { + return arrival == 1; + } + } + result_type m_result; side_calculator_type m_side_calc; RobustPolicy const& m_robust_policy; @@ -472,7 +510,8 @@ struct get_turn_info_for_endpoint // handle spikes // P is spike and should be handled - if ( !is_p_last && ip_info.is_pj + if ( !is_p_last + && ip_info.is_pj // this check is redundant (also in is_spike_p) but faster && inters.i_info().count == 2 && inters.is_spike_p() ) { @@ -482,7 +521,8 @@ struct get_turn_info_for_endpoint p_pos, q_pos, tp_model, out); } // Q is spike and should be handled - else if ( !is_q_last && ip_info.is_qj + else if ( !is_q_last + && ip_info.is_qj // this check is redundant (also in is_spike_q) but faster && inters.i_info().count == 2 && inters.is_spike_q() ) { diff --git a/include/boost/geometry/algorithms/detail/within/point_in_geometry.hpp b/include/boost/geometry/algorithms/detail/within/point_in_geometry.hpp index fc386d84b..36ac44d36 100644 --- a/include/boost/geometry/algorithms/detail/within/point_in_geometry.hpp +++ b/include/boost/geometry/algorithms/detail/within/point_in_geometry.hpp @@ -37,13 +37,13 @@ namespace boost { namespace geometry { #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace within { -int check_result_type(int result) +inline int check_result_type(int result) { return result; } template -void check_result_type(T result) +inline void check_result_type(T result) { BOOST_ASSERT(false); } diff --git a/include/boost/geometry/extensions/algorithms/dissolve.hpp b/include/boost/geometry/extensions/algorithms/dissolve.hpp index 14e4a9b9f..6190cd8f0 100644 --- a/include/boost/geometry/extensions/algorithms/dissolve.hpp +++ b/include/boost/geometry/extensions/algorithms/dissolve.hpp @@ -99,10 +99,13 @@ struct dissolve_ring_or_polygon RescalePolicy const& rescale_policy, OutputIterator out) { + typedef typename point_type::type point_type; + // Get the self-intersection points, including turns typedef detail::overlay::traversal_turn_info < - typename point_type::type + point_type, + typename segment_ratio_type::type > turn_info; std::vector turns; @@ -212,6 +215,7 @@ template typename GeometryOut > struct dissolve + : not_implemented {}; diff --git a/include/boost/geometry/policies/robustness/get_rescale_policy.hpp b/include/boost/geometry/policies/robustness/get_rescale_policy.hpp index 8b92567e3..142a3592e 100644 --- a/include/boost/geometry/policies/robustness/get_rescale_policy.hpp +++ b/include/boost/geometry/policies/robustness/get_rescale_policy.hpp @@ -16,6 +16,7 @@ #include #include +#include #include @@ -211,14 +212,16 @@ struct rescale_policy_type #endif > { - BOOST_STATIC_ASSERT - (( - boost::is_same - < - typename geometry::tag::type, - geometry::point_tag - >::type::value - )); + static const bool is_point + = boost::is_same + < + typename geometry::tag::type, + geometry::point_tag + >::type::value; + + BOOST_MPL_ASSERT_MSG((is_point), + INVALID_INPUT_GEOMETRY, + (typename geometry::tag::type)); }; diff --git a/test/algorithms/overlay/get_turns_linear_linear.cpp b/test/algorithms/overlay/get_turns_linear_linear.cpp index 4a02a459a..30760b3bc 100644 --- a/test/algorithms/overlay/get_turns_linear_linear.cpp +++ b/test/algorithms/overlay/get_turns_linear_linear.cpp @@ -237,6 +237,14 @@ void test_all() test_geometry("LINESTRING(2 2,5 -1,15 2,18 0,20 0)", "LINESTRING(30 0,19 0,18 0,0 0)", expected("iuu")("iuu")("tiu")("mxi")); + + test_geometry("MULTILINESTRING((0 0,10 0,5 0))", + "MULTILINESTRING((1 0,8 0,4 0))", + expected("mii")("mix")("mux")("mui")("mix")("mii")("mxu")("mxi")); + + /*test_geometry("MULTILINESTRING((0 0,10 0,5 0))", + "MULTILINESTRING((1 0,8 0,4 0),(2 0,9 0,5 0))", + expected("mii")("ccc")("ccc")("txx"));*/ } int test_main(int, char* [])