// Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2007-2011 Barend Gehrels, 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_OVERLAY_WITHIN_UTIL_HPP #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_WITHIN_UTIL_HPP #include #include namespace boost { namespace geometry { #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace overlay { template struct within_code {}; template struct within_code { static inline int apply(Point const& point, Box const& box) { // 1. Check outside if (get<0>(point) < get(box) || get<0>(point) > get(box) || get<1>(point) < get(box) || get<1>(point) > get(box)) { return -1; } // 2. Check border if (geometry::math::equals(get<0>(point), get(box)) || geometry::math::equals(get<0>(point), get(box)) || geometry::math::equals(get<1>(point), get(box)) || geometry::math::equals(get<1>(point), get(box))) { return 0; } return 1; } }; template struct within_code { static inline int apply(Point const& point, Ring const& ring) { // Same as point_in_ring but here ALWAYS with winding. typedef strategy::within::winding strategy_type; return detail::within::point_in_ring < Point, Ring, order_as_direction::value>::value, geometry::closure::value, strategy_type >::apply(point, ring, strategy_type()); } }; template inline int point_in_ring(Point const& point, Geometry const& geometry) { return within_code::type, Point, Geometry> ::apply(point, geometry); } template inline bool within_or_touch(Point const& point, Geometry const& geometry) { return within_code::type, Point, Geometry> ::apply(point, geometry) >= 0; } }} // namespace detail::overlay #endif // DOXYGEN_NO_DETAIL }} // namespace boost::geometry #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_WITHIN_UTIL_HPP