From 3f6a81d61bcd24b675200a464f3e2aab756ef985 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Sun, 20 Nov 2011 14:53:36 +0000 Subject: [PATCH] Linestring/polygon overlay, phase 6 (ring, counter clockwise) [SVN r75574] --- .../algorithms/detail/overlay/follow.hpp | 20 +++----- .../detail/overlay/intersection_insert.hpp | 35 +++++++++++-- .../multi/algorithms/intersection.hpp | 50 ++++++++++++++++--- 3 files changed, 79 insertions(+), 26 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/overlay/follow.hpp b/include/boost/geometry/algorithms/detail/overlay/follow.hpp index aa84ab497..43186aeb8 100644 --- a/include/boost/geometry/algorithms/detail/overlay/follow.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/follow.hpp @@ -66,15 +66,10 @@ class follow { // (Blocked means: blocked for polygon/polygon intersection, because // they are reversed. But for polygon/line it is similar to continue) - switch(op.operation) - { - case operation_intersection : - case operation_continue : - case operation_blocked : - return true; - } - - return false; + return op.operation == operation_intersection + || op.operation == operation_continue + || op.operation == operation_blocked + ; } template @@ -105,12 +100,9 @@ class follow return false; } - switch(op.operation) + if (is_entering(turn, op)) { - case operation_intersection : - case operation_continue : - case operation_blocked : - return entered || (first && geometry::within(linestring[0], polygon)); + return entered || (first && geometry::within(linestring[0], polygon)); } return false; diff --git a/include/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp b/include/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp index 0352e401d..c16cc1e36 100644 --- a/include/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp @@ -105,11 +105,11 @@ struct intersection_linestring_linestring_point /*! \brief Version of linestring with an areal feature (polygon or multipolygon) -\ingroup intersection */ template < typename LineString, typename Areal, + bool ReverseAreal, typename OutputIterator, typename LineStringOut, typename Strategy > @@ -150,7 +150,7 @@ struct intersection_of_linestring_with_areal detail::get_turns::no_interrupt_policy policy; geometry::get_turns < - false, false, detail::overlay::calculate_distance_policy + false, ReverseAreal, detail::overlay::calculate_distance_policy >(linestring, areal, turns, policy); if (turns.empty()) @@ -355,7 +355,7 @@ struct intersection_insert template < typename Linestring, typename Polygon, - bool Reverse1, bool Reverse2, bool ReverseOut, + bool ReverseLinestring, bool ReversePolygon, bool ReverseOut, typename OutputIterator, typename GeometryOut, overlay_type OverlayType, typename Strategy @@ -365,19 +365,46 @@ struct intersection_insert linestring_tag, polygon_tag, linestring_tag, false, true, false, Linestring, Polygon, - Reverse1, Reverse2, ReverseOut, + ReverseLinestring, ReversePolygon, ReverseOut, OutputIterator, GeometryOut, OverlayType, Strategy > : detail::intersection::intersection_of_linestring_with_areal < Linestring, Polygon, + ReversePolygon, OutputIterator, GeometryOut, Strategy > {}; +template +< + typename Linestring, typename Ring, + bool ReverseLinestring, bool ReverseRing, bool ReverseOut, + typename OutputIterator, typename GeometryOut, + overlay_type OverlayType, + typename Strategy +> +struct intersection_insert + < + linestring_tag, ring_tag, linestring_tag, + false, true, false, + Linestring, Ring, + ReverseLinestring, ReverseRing, ReverseOut, + OutputIterator, GeometryOut, + OverlayType, + Strategy + > : detail::intersection::intersection_of_linestring_with_areal + < + Linestring, Ring, + ReverseRing, + OutputIterator, GeometryOut, + Strategy + > +{}; + template < typename Segment, typename Box, diff --git a/include/boost/geometry/multi/algorithms/intersection.hpp b/include/boost/geometry/multi/algorithms/intersection.hpp index 25c236a98..5198535aa 100644 --- a/include/boost/geometry/multi/algorithms/intersection.hpp +++ b/include/boost/geometry/multi/algorithms/intersection.hpp @@ -114,6 +114,7 @@ struct intersection_linestring_multi_linestring_point template < typename MultiLinestring, typename Areal, + bool ReverseAreal, typename OutputIterator, typename LineStringOut, typename Strategy > @@ -133,7 +134,7 @@ struct intersection_of_multi_linestring_with_areal out = intersection_of_linestring_with_areal < typename boost::range_value::type, - Areal, + Areal, ReverseAreal, OutputIterator, LineStringOut, Strategy >::apply(*it, areal, out, strategy); } @@ -147,6 +148,7 @@ struct intersection_of_multi_linestring_with_areal template < typename Areal, typename MultiLinestring, + bool ReverseAreal, typename OutputIterator, typename LineStringOut, typename Strategy > @@ -158,7 +160,7 @@ struct intersection_of_areal_with_multi_linestring { return intersection_of_multi_linestring_with_areal < - MultiLinestring, Areal, + MultiLinestring, Areal, ReverseAreal, OutputIterator, LineStringOut, Strategy >::apply(ml, areal, out, strategy); @@ -283,7 +285,7 @@ struct intersection_insert template < typename Linestring, typename MultiPolygon, - bool Reverse1, bool Reverse2, bool ReverseOut, + bool ReverseLinestring, bool ReverseMultiPolygon, bool ReverseOut, typename OutputIterator, typename GeometryOut, overlay_type OverlayType, typename Strategy @@ -293,13 +295,14 @@ struct intersection_insert linestring_tag, multi_polygon_tag, linestring_tag, false, true, false, Linestring, MultiPolygon, - Reverse1, Reverse2, ReverseOut, + ReverseLinestring, ReverseMultiPolygon, ReverseOut, OutputIterator, GeometryOut, OverlayType, Strategy > : detail::intersection::intersection_of_linestring_with_areal < Linestring, MultiPolygon, + ReverseMultiPolygon, OutputIterator, GeometryOut, Strategy > @@ -311,7 +314,7 @@ struct intersection_insert template < typename Polygon, typename MultiLinestring, - bool Reverse1, bool Reverse2, bool ReverseOut, + bool ReversePolygon, bool ReverseMultiLinestring, bool ReverseOut, typename OutputIterator, typename GeometryOut, overlay_type OverlayType, typename Strategy @@ -321,23 +324,53 @@ struct intersection_insert polygon_tag, multi_linestring_tag, linestring_tag, true, false, false, Polygon, MultiLinestring, - Reverse1, Reverse2, ReverseOut, + ReversePolygon, ReverseMultiLinestring, ReverseOut, OutputIterator, GeometryOut, OverlayType, Strategy > : detail::intersection::intersection_of_areal_with_multi_linestring < Polygon, MultiLinestring, + ReversePolygon, OutputIterator, GeometryOut, Strategy > {}; +template +< + typename MultiLinestring, typename Ring, + bool ReverseMultiLinestring, bool ReverseRing, bool ReverseOut, + typename OutputIterator, typename GeometryOut, + overlay_type OverlayType, + typename Strategy +> +struct intersection_insert + < + multi_linestring_tag, ring_tag, linestring_tag, + false, true, false, + MultiLinestring, Ring, + ReverseMultiLinestring, ReverseRing, ReverseOut, + OutputIterator, GeometryOut, + OverlayType, + Strategy + > : detail::intersection::intersection_of_multi_linestring_with_areal + < + MultiLinestring, Ring, + ReverseRing, + OutputIterator, GeometryOut, + Strategy + > +{}; + + + + template < typename MultiLinestring, typename MultiPolygon, - bool Reverse1, bool Reverse2, bool ReverseOut, + bool ReverseMultiLinestring, bool ReverseMultiPolygon, bool ReverseOut, typename OutputIterator, typename GeometryOut, overlay_type OverlayType, typename Strategy @@ -347,13 +380,14 @@ struct intersection_insert multi_linestring_tag, multi_polygon_tag, linestring_tag, false, true, false, MultiLinestring, MultiPolygon, - Reverse1, Reverse2, ReverseOut, + ReverseMultiLinestring, ReverseMultiPolygon, ReverseOut, OutputIterator, GeometryOut, OverlayType, Strategy > : detail::intersection::intersection_of_multi_linestring_with_areal < MultiLinestring, MultiPolygon, + ReverseMultiPolygon, OutputIterator, GeometryOut, Strategy >