From 2349c817e2a070780fdbc60f42766d782f9bb63d Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Mon, 28 Apr 2014 12:21:06 +0200 Subject: [PATCH 1/4] [get_turns] Fix turns generation for double collinear spikes. Add check if a spike Point is realy an IP. --- .../overlay/get_turn_info_for_endpoint.hpp | 44 ++++++++++++++++++- .../overlay/get_turns_linear_linear.cpp | 8 ++++ 2 files changed, 50 insertions(+), 2 deletions(-) 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/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* []) From d44e1a1e016fa5060df52b2ebd74c6e57366c55e Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Tue, 29 Apr 2014 13:06:04 +0200 Subject: [PATCH 2/4] [get_turns][extensions/dissolve] Fix VS compilation error (STATIC_ASSERT + template). Add not_implemented<> info to extensions/dissolve. --- .../extensions/algorithms/dissolve.hpp | 1 + .../robustness/get_rescale_policy.hpp | 19 +++++++++++-------- .../overlay/get_turns_linear_areal.cpp | 19 +++++++++++++++++++ 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/include/boost/geometry/extensions/algorithms/dissolve.hpp b/include/boost/geometry/extensions/algorithms/dissolve.hpp index 14e4a9b9f..6d2e8e5c6 100644 --- a/include/boost/geometry/extensions/algorithms/dissolve.hpp +++ b/include/boost/geometry/extensions/algorithms/dissolve.hpp @@ -212,6 +212,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_areal.cpp b/test/algorithms/overlay/get_turns_linear_areal.cpp index 804516afb..5bf808a43 100644 --- a/test/algorithms/overlay/get_turns_linear_areal.cpp +++ b/test/algorithms/overlay/get_turns_linear_areal.cpp @@ -133,8 +133,27 @@ void test_all() expected("mcu")("mxc")("mcc")("mxu")); } +#include +#include +#include +#include + +void test () +{ + typedef boost::geometry::model::d2::point_xy boostPoint; + typedef boost::geometry::model::polygon< boostPoint > boostPolygon; + typedef boostPolygon::ring_type boostRing; + + boostRing ring1,ring2; + boost::geometry::dissolve(ring1,ring2); + + return; +} + int test_main(int, char* []) { + test(); + test_all(); test_all(); From d682a74c1b3ab64a69dce3675b276f47e7f490b7 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Tue, 29 Apr 2014 13:19:11 +0200 Subject: [PATCH 3/4] [extensions/dissolve] Fix compilation error - pass segment_ratio<> to traversal_turn_info<>. Remove mistankenly commited test change --- .../extensions/algorithms/dissolve.hpp | 5 ++++- .../overlay/get_turns_linear_areal.cpp | 19 ------------------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/include/boost/geometry/extensions/algorithms/dissolve.hpp b/include/boost/geometry/extensions/algorithms/dissolve.hpp index 6d2e8e5c6..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; diff --git a/test/algorithms/overlay/get_turns_linear_areal.cpp b/test/algorithms/overlay/get_turns_linear_areal.cpp index 5bf808a43..804516afb 100644 --- a/test/algorithms/overlay/get_turns_linear_areal.cpp +++ b/test/algorithms/overlay/get_turns_linear_areal.cpp @@ -133,27 +133,8 @@ void test_all() expected("mcu")("mxc")("mcc")("mxu")); } -#include -#include -#include -#include - -void test () -{ - typedef boost::geometry::model::d2::point_xy boostPoint; - typedef boost::geometry::model::polygon< boostPoint > boostPolygon; - typedef boostPolygon::ring_type boostRing; - - boostRing ring1,ring2; - boost::geometry::dissolve(ring1,ring2); - - return; -} - int test_main(int, char* []) { - test(); - test_all(); test_all(); From 118a750e9e2fe78931fa1ef3f0eafe1dcdf58fc6 Mon Sep 17 00:00:00 2001 From: Samuel Debione Date: Tue, 29 Apr 2014 13:47:09 +0200 Subject: [PATCH 4/4] check_result_type is missing inline qualifier Function check_result_type is missing inline qualifier. --- .../geometry/algorithms/detail/within/point_in_geometry.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); }