// Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2008-2014 Bruno Lalande, Paris, France. // Copyright (c) 2009-2014 Mateusz Loskot, London, UK. // Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland. // This file was modified by Oracle on 2013-2015. // Modifications copyright (c) 2013-2015, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, 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. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_AREAL_HPP #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_AREAL_HPP #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace boost { namespace geometry { #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace disjoint { template ::type, typename Tag1OrMulti = typename tag_cast::type> struct disjoint_no_intersections_policy { static inline bool apply(Geometry1 const& g1, Geometry2 const& g2) { typedef typename point_type::type point1_type; point1_type p; geometry::point_on_border(p, g1); return !geometry::covered_by(p, g2); } }; template struct disjoint_no_intersections_policy { static inline bool apply(Geometry1 const& g1, Geometry2 const& g2) { // TODO: use partition or rtree on g2 typedef typename boost::range_iterator::type iterator; for ( iterator it = boost::begin(g1) ; it != boost::end(g1) ; ++it ) { typedef typename boost::range_value::type value_type; if ( ! disjoint_no_intersections_policy ::apply(*it, g2) ) { return false; } } return true; } }; template > struct disjoint_linear_areal { static inline bool apply(Geometry1 const& g1, Geometry2 const& g2) { // if there are intersections - return false if ( !disjoint_linear::apply(g1, g2) ) { return false; } return NoIntersectionsPolicy::apply(g1, g2); } }; template < typename Segment, typename Areal, typename Tag = typename tag::type > struct disjoint_segment_areal : not_implemented {}; template class disjoint_segment_areal { private: template static inline bool check_interior_rings(InteriorRings const& interior_rings, Segment const& segment) { typedef typename boost::range_value::type ring_type; typedef unary_disjoint_geometry_to_query_geometry < Segment, disjoint_range_segment_or_box < ring_type, closure::value, Segment > > unary_predicate_type; return check_iterator_range < unary_predicate_type >::apply(boost::begin(interior_rings), boost::end(interior_rings), unary_predicate_type(segment)); } public: static inline bool apply(Segment const& segment, Polygon const& polygon) { typedef typename geometry::ring_type::type ring; if ( !disjoint_range_segment_or_box < ring, closure::value, Segment >::apply(geometry::exterior_ring(polygon), segment) ) { return false; } if ( !check_interior_rings(geometry::interior_rings(polygon), segment) ) { return false; } typename point_type::type p; detail::assign_point_from_index<0>(segment, p); return !geometry::covered_by(p, polygon); } }; template struct disjoint_segment_areal { static inline bool apply(Segment const& segment, MultiPolygon const& multipolygon) { return multirange_constant_size_geometry < MultiPolygon, Segment >::apply(multipolygon, segment); } }; template struct disjoint_segment_areal { static inline bool apply(Segment const& segment, Ring const& ring) { if ( !disjoint_range_segment_or_box < Ring, closure::value, Segment >::apply(ring, segment) ) { return false; } typename point_type::type p; detail::assign_point_from_index<0>(segment, p); return !geometry::covered_by(p, ring); } }; }} // namespace detail::disjoint #endif // DOXYGEN_NO_DETAIL #ifndef DOXYGEN_NO_DISPATCH namespace dispatch { template struct disjoint : public detail::disjoint::disjoint_linear_areal {}; template struct disjoint { static inline bool apply(Areal const& areal, Linear const& linear) { return detail::disjoint::disjoint_linear_areal < Linear, Areal >::apply(linear, areal); } }; template struct disjoint { static inline bool apply(Areal const& g1, Segment const& g2) { return detail::disjoint::disjoint_segment_areal < Segment, Areal >::apply(g2, g1); } }; template struct disjoint : detail::disjoint::disjoint_segment_areal {}; } // namespace dispatch #endif // DOXYGEN_NO_DISPATCH }} // namespace boost::geometry #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_AREAL_HPP