diff options
Diffstat (limited to 'boost/geometry/algorithms/detail/within/within_no_turns.hpp')
-rw-r--r-- | boost/geometry/algorithms/detail/within/within_no_turns.hpp | 93 |
1 files changed, 50 insertions, 43 deletions
diff --git a/boost/geometry/algorithms/detail/within/within_no_turns.hpp b/boost/geometry/algorithms/detail/within/within_no_turns.hpp index 8da05e58fd..d6d0417c3b 100644 --- a/boost/geometry/algorithms/detail/within/within_no_turns.hpp +++ b/boost/geometry/algorithms/detail/within/within_no_turns.hpp @@ -4,8 +4,9 @@ // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. -// This file was modified by Oracle on 2013. -// Modifications copyright (c) 2013, Oracle and/or its affiliates. +// This file was modified by Oracle on 2013-2023. +// Modifications copyright (c) 2013-2023, Oracle and/or its affiliates. +// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -41,8 +42,10 @@ struct within_no_turns { typedef typename geometry::point_type<Geometry1>::type point1_type; point1_type p; - if ( !geometry::point_on_border(p, geometry1) ) + if (! geometry::point_on_border(p, geometry1)) + { return false; + } return detail::within::point_in_geometry(p, geometry2, strategy) >= 0; } @@ -57,25 +60,28 @@ struct within_no_turns<Geometry1, Geometry2, ring_tag, polygon_tag> typedef typename geometry::point_type<Geometry1>::type point1_type; typedef typename geometry::point_type<Geometry2>::type point2_type; point1_type p; - if ( !geometry::point_on_border(p, geometry1) ) + if (! geometry::point_on_border(p, geometry1)) + { return false; + } // check if one of ring points is outside the polygon - if ( detail::within::point_in_geometry(p, geometry2, strategy) < 0 ) + if (detail::within::point_in_geometry(p, geometry2, strategy) < 0) + { return false; + } // Now check if holes of G2 aren't inside G1 - typedef typename boost::range_const_iterator - < - typename geometry::interior_type<Geometry2>::type - >::type iterator; - for ( iterator it = boost::begin(geometry::interior_rings(geometry2)) ; - it != boost::end(geometry::interior_rings(geometry2)) ; - ++it ) + auto const& rings2 = geometry::interior_rings(geometry2); + for (auto it = boost::begin(rings2); it != boost::end(rings2); ++it) { point2_type p; - if ( !geometry::point_on_border(p, *it) ) + if (! geometry::point_on_border(p, *it)) + { return false; - if ( detail::within::point_in_geometry(p, geometry1, strategy) > 0 ) + } + if (detail::within::point_in_geometry(p, geometry1, strategy) > 0) + { return false; + } } return true; } @@ -90,44 +96,42 @@ struct within_no_turns<Geometry1, Geometry2, polygon_tag, polygon_tag> typedef typename geometry::point_type<Geometry1>::type point1_type; typedef typename geometry::point_type<Geometry2>::type point2_type; point1_type p; - if ( !geometry::point_on_border(p, geometry1) ) + if (! geometry::point_on_border(p, geometry1)) + { return false; + } // check if one of ring points is outside the polygon - if ( detail::within::point_in_geometry(p, geometry2, strategy) < 0 ) + if (detail::within::point_in_geometry(p, geometry2, strategy) < 0) + { return false; + } // Now check if holes of G2 aren't inside G1 - typedef typename boost::range_const_iterator - < - typename geometry::interior_type<Geometry2>::type - >::type iterator2; - for ( iterator2 it = boost::begin(geometry::interior_rings(geometry2)) ; - it != boost::end(geometry::interior_rings(geometry2)) ; - ++it ) + auto const& rings2 = geometry::interior_rings(geometry2); + for (auto it2 = boost::begin(rings2); it2 != boost::end(rings2); ++it2) { point2_type p2; - if ( !geometry::point_on_border(p2, *it) ) + if (! geometry::point_on_border(p2, *it2)) + { return false; + } // if the hole of G2 is inside G1 - if ( detail::within::point_in_geometry(p2, geometry1, strategy) > 0 ) + if (detail::within::point_in_geometry(p2, geometry1, strategy) > 0) { // if it's also inside one of the G1 holes, it's ok bool ok = false; - typedef typename boost::range_const_iterator - < - typename geometry::interior_type<Geometry1>::type - >::type iterator1; - for ( iterator1 it1 = boost::begin(geometry::interior_rings(geometry1)) ; - it1 != boost::end(geometry::interior_rings(geometry1)) ; - ++it1 ) + auto const& rings1 = geometry::interior_rings(geometry1); + for (auto it1 = boost::begin(rings1); it1 != boost::end(rings1); ++it1) { - if ( detail::within::point_in_geometry(p2, *it1, strategy) < 0 ) + if (detail::within::point_in_geometry(p2, *it1, strategy) < 0) { ok = true; break; } } - if ( !ok ) + if (! ok) + { return false; + } } } return true; @@ -157,11 +161,12 @@ struct within_no_turns_multi<Geometry1, Geometry2, Tag1, Tag2, true, false> { // All values of G1 must be inside G2 typedef typename boost::range_value<Geometry1>::type subgeometry1; - typedef typename boost::range_const_iterator<Geometry1>::type iterator; - for ( iterator it = boost::begin(geometry1) ; it != boost::end(geometry1) ; ++it ) + for (auto it = boost::begin(geometry1) ; it != boost::end(geometry1) ; ++it ) { - if ( !within_no_turns<subgeometry1, Geometry2>::apply(*it, geometry2, strategy) ) + if (! within_no_turns<subgeometry1, Geometry2>::apply(*it, geometry2, strategy)) + { return false; + } } return true; } @@ -175,11 +180,12 @@ struct within_no_turns_multi<Geometry1, Geometry2, Tag1, Tag2, false, true> { // G1 must be within at least one value of G2 typedef typename boost::range_value<Geometry2>::type subgeometry2; - typedef typename boost::range_const_iterator<Geometry2>::type iterator; - for ( iterator it = boost::begin(geometry2) ; it != boost::end(geometry2) ; ++it ) + for (auto it = boost::begin(geometry2); it != boost::end(geometry2); ++it) { - if ( within_no_turns<Geometry1, subgeometry2>::apply(geometry1, *it, strategy) ) + if (within_no_turns<Geometry1, subgeometry2>::apply(geometry1, *it, strategy)) + { return true; + } } return false; } @@ -193,11 +199,12 @@ struct within_no_turns_multi<Geometry1, Geometry2, Tag1, Tag2, true, true> { // each value of G1 must be inside at least one value of G2 typedef typename boost::range_value<Geometry1>::type subgeometry1; - typedef typename boost::range_const_iterator<Geometry1>::type iterator; - for ( iterator it = boost::begin(geometry1) ; it != boost::end(geometry1) ; ++it ) + for (auto it = boost::begin(geometry1) ; it != boost::end(geometry1) ; ++it) { - if ( !within_no_turns_multi<subgeometry1, Geometry2>::apply(*it, geometry2, strategy) ) + if (! within_no_turns_multi<subgeometry1, Geometry2>::apply(*it, geometry2, strategy)) + { return false; + } } return true; } |