mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-11 11:52:11 +00:00
added point_in_point agnostic strategy and point_in_geometry() for Point and MultiPoint
This commit is contained in:
@@ -83,6 +83,17 @@ template <typename Geometry,
|
||||
struct point_in_geometry : not_implemented<Tag>
|
||||
{};
|
||||
|
||||
template <typename Point2>
|
||||
struct point_in_geometry<Point2, point_tag>
|
||||
{
|
||||
template <typename Point1, typename Strategy> static inline
|
||||
int apply(Point1 const& point1, Point2 const& point2, Strategy const& strategy)
|
||||
{
|
||||
boost::ignore_unused_variable_warning(strategy);
|
||||
return strategy.apply(point1, point2) ? 1 : -1;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Linestring>
|
||||
struct point_in_geometry<Linestring, linestring_tag>
|
||||
{
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
|
||||
// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// 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, 2014.
|
||||
// Modifications copyright (c) 2013, 2014 Oracle and/or its affiliates.
|
||||
|
||||
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
||||
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
||||
@@ -113,6 +113,26 @@ struct point_in_geometry<Geometry, multi_linestring_tag>
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geometry>
|
||||
struct point_in_geometry<Geometry, multi_point_tag>
|
||||
{
|
||||
template <typename Point, typename Strategy> static inline
|
||||
int apply(Point const& point, Geometry const& geometry, Strategy const& strategy)
|
||||
{
|
||||
typedef typename boost::range_value<Geometry>::type point_type;
|
||||
typedef typename boost::range_const_iterator<Geometry>::type iterator;
|
||||
for ( iterator it = boost::begin(geometry) ; it != boost::end(geometry) ; ++it )
|
||||
{
|
||||
int pip = point_in_geometry<point_type>::apply(point, *it, strategy);
|
||||
|
||||
if ( pip > 0 ) // inside
|
||||
return 1;
|
||||
}
|
||||
|
||||
return -1; // outside
|
||||
}
|
||||
};
|
||||
|
||||
}} // namespace detail_dispatch::within
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2014 Oracle and/or its affiliates.
|
||||
|
||||
// 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)
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
#ifndef BOOST_GEOMETRY_STRATEGY_AGNOSTIC_POINT_IN_POINT_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGY_AGNOSTIC_POINT_IN_POINT_HPP
|
||||
|
||||
#include <boost/geometry/algorithms/detail/disjoint/point_point.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/covered_by.hpp>
|
||||
#include <boost/geometry/strategies/within.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace within
|
||||
{
|
||||
|
||||
template
|
||||
<
|
||||
typename Point1, typename Point2
|
||||
>
|
||||
struct point_in_point
|
||||
{
|
||||
static inline bool apply(Point1 const& point1, Point2 const& point2)
|
||||
{
|
||||
return detail::equals::equals_point_point(point1, point2);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
namespace services
|
||||
{
|
||||
|
||||
template <typename Point1, typename Point2, typename AnyCS1, typename AnyCS2>
|
||||
struct default_strategy<point_tag, point_tag, point_tag, point_tag, AnyCS1, AnyCS2, Point1, Point2>
|
||||
{
|
||||
typedef strategy::within::point_in_point<Point1, Point2> type;
|
||||
};
|
||||
|
||||
template <typename Point, typename MultiPoint, typename AnyCS1, typename AnyCS2>
|
||||
struct default_strategy<point_tag, multi_point_tag, point_tag, multi_point_tag, AnyCS1, AnyCS2, Point, MultiPoint>
|
||||
{
|
||||
typedef strategy::within::point_in_point<Point, typename point_type<MultiPoint>::type> type;
|
||||
};
|
||||
|
||||
} // namespace services
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
}} // namespace strategy::within
|
||||
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
namespace strategy { namespace covered_by { namespace services
|
||||
{
|
||||
|
||||
template <typename Point1, typename Point2, typename AnyCS1, typename AnyCS2>
|
||||
struct default_strategy<point_tag, point_tag, point_tag, point_tag, AnyCS1, AnyCS2, Point1, Point2>
|
||||
{
|
||||
typedef strategy::within::point_in_point<Point1, Point2> type;
|
||||
};
|
||||
|
||||
template <typename Point, typename MultiPoint, typename AnyCS1, typename AnyCS2>
|
||||
struct default_strategy<point_tag, multi_point_tag, point_tag, multi_point_tag, AnyCS1, AnyCS2, Point, MultiPoint>
|
||||
{
|
||||
typedef strategy::within::point_in_point<Point, typename point_type<MultiPoint>::type> type;
|
||||
};
|
||||
|
||||
}}} // namespace strategy::covered_by::services
|
||||
#endif
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGY_AGNOSTIC_POINT_IN_POINT_HPP
|
||||
@@ -4,6 +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 2014.
|
||||
// Modifications copyright (c) 2014 Oracle and/or its affiliates.
|
||||
|
||||
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
||||
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
||||
|
||||
@@ -11,6 +14,8 @@
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
#ifndef BOOST_GEOMETRY_STRATEGIES_STRATEGIES_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_STRATEGIES_HPP
|
||||
|
||||
@@ -46,6 +51,7 @@
|
||||
|
||||
#include <boost/geometry/strategies/agnostic/hull_graham_andrew.hpp>
|
||||
#include <boost/geometry/strategies/agnostic/point_in_box_by_side.hpp>
|
||||
#include <boost/geometry/strategies/agnostic/point_in_point.hpp>
|
||||
#include <boost/geometry/strategies/agnostic/point_in_poly_winding.hpp>
|
||||
#include <boost/geometry/strategies/agnostic/simplify_douglas_peucker.hpp>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user