summaryrefslogtreecommitdiff log msg author committer range
diff options
 context: 12345678910152025303540 space: includeignore mode: unifiedssdiffstat only
Diffstat (limited to 'boost/geometry/algorithms/detail/point_on_border.hpp')
-rw-r--r--boost/geometry/algorithms/detail/point_on_border.hpp193
1 files changed, 104 insertions, 89 deletions
 diff --git a/boost/geometry/algorithms/detail/point_on_border.hpp b/boost/geometry/algorithms/detail/point_on_border.hppindex 1c751c23e4..831081aa69 100644--- a/boost/geometry/algorithms/detail/point_on_border.hpp+++ b/boost/geometry/algorithms/detail/point_on_border.hpp@@ -4,6 +4,10 @@ // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +// This file was modified by Oracle on 2017.+// Modifications copyright (c) 2017 Oracle and/or its affiliates.+// Contributed and/or modified by Adam Wulkiewicz, 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. @@ -18,6 +22,7 @@ #include #include +#include #include #include @@ -29,6 +34,8 @@ #include #include +#include + namespace boost { namespace geometry {@@ -39,10 +46,10 @@ namespace detail { namespace point_on_border { -template struct get_point {- static inline bool apply(Point& destination, Point const& source, bool)+ template + static inline bool apply(Point& destination, Point const& source) { destination = source; return true;@@ -74,66 +81,77 @@ struct midpoint_helper }; -template+template struct point_on_range {- static inline bool apply(Point& point, Range const& range, bool midpoint)+ // Version with iterator+ template+ static inline bool apply(Point& point, Iterator begin, Iterator end) {- const std::size_t n = boost::size(range);- if (midpoint && n > 1)+ Iterator it = begin;+ if (it == end) {- typedef typename boost::range_iterator- <- Range const- >::type iterator;-- iterator it = boost::begin(range);- iterator prev = it++;- while (it != boost::end(range)- && detail::equals::equals_point_point(*it, *prev))- {- prev = it++;- }- if (it != boost::end(range))- {- return midpoint_helper- <- Point,- 0, dimension::value- >::apply(point, *prev, *it);- }+ return false; } - if (n > 0)+ if (! Midpoint) {- geometry::detail::conversion::convert_point_to_point(*boost::begin(range), point);+ geometry::detail::conversion::convert_point_to_point(*it, point); return true; }++ Iterator prev = it++;++ // Go to next non-duplicate point+ while (it != end+ && detail::equals::equals_point_point(*it, *prev))+ {+ prev = it++;+ }+ if (it != end)+ {+ return midpoint_helper+ <+ Point,+ 0, dimension::value+ >::apply(point, *prev, *it);+ } return false; }++ // Version with range+ template+ static inline bool apply(Point& point, Range const& range)+ {+ typedef typename geometry::cs_tag::type cs_tag;+ BOOST_STATIC_ASSERT((! Midpoint || boost::is_same::value));++ return apply(point, boost::begin(range), boost::end(range));+ } }; -template+template struct point_on_polygon {- static inline bool apply(Point& point, Polygon const& polygon, bool midpoint)+ template+ static inline bool apply(Point& point, Polygon const& polygon) { return point_on_range <- Point,- typename ring_type::type- >::apply(point, exterior_ring(polygon), midpoint);+ Midpoint+ >::apply(point, exterior_ring(polygon)); } }; -template+template struct point_on_box {- static inline bool apply(Point& point, Box const& box, bool midpoint)+ template+ static inline bool apply(Point& point, Box const& box) {- if (midpoint)+ if (BOOST_GEOMETRY_CONDITION(Midpoint)) { Point p1, p2; detail::assign::assign_box_2d_corner(box, p1);@@ -154,15 +172,11 @@ struct point_on_box }; -template-<- typename Point,- typename MultiGeometry,- typename Policy->+template struct point_on_multi {- static inline bool apply(Point& point, MultiGeometry const& multi, bool midpoint)+ template+ static inline bool apply(Point& point, MultiGeometry const& multi) { // Take a point on the first multi-geometry // (i.e. the first that is not empty)@@ -173,7 +187,7 @@ struct point_on_multi it != boost::end(multi); ++it) {- if (Policy::apply(point, *it, midpoint))+ if (Policy::apply(point, *it)) { return true; }@@ -195,70 +209,57 @@ namespace dispatch template < typename GeometryTag,- typename Point,- typename Geometry+ bool Midpoint > struct point_on_border {}; -template-struct point_on_border- : detail::point_on_border::get_point+template +struct point_on_border+ : detail::point_on_border::get_point {}; -template-struct point_on_border- : detail::point_on_border::point_on_range+template +struct point_on_border+ : detail::point_on_border::point_on_range {}; -template-struct point_on_border- : detail::point_on_border::point_on_range+template +struct point_on_border+ : detail::point_on_border::point_on_range {}; -template-struct point_on_border- : detail::point_on_border::point_on_polygon+template +struct point_on_border+ : detail::point_on_border::point_on_polygon {}; -template-struct point_on_border- : detail::point_on_border::point_on_box+template +struct point_on_border+ : detail::point_on_border::point_on_box {}; -template-struct point_on_border+template +struct point_on_border : detail::point_on_border::point_on_multi <- Point,- Multi,- detail::point_on_border::point_on_polygon- <- Point,- typename boost::range_value::type- >+ detail::point_on_border::point_on_polygon > {}; -template-struct point_on_border+template +struct point_on_border : detail::point_on_border::point_on_multi <- Point,- Multi,- detail::point_on_border::point_on_range- <- Point,- typename boost::range_value::type- >+ detail::point_on_border::point_on_range > {}; @@ -273,18 +274,12 @@ struct point_on_border \tparam Geometry geometry type. This also defines the type of the output point \param point to assign \param geometry geometry to take point from-\param midpoint boolean flag, true if the point should not be a vertex, but some point- in between of two vertices \return TRUE if successful, else false. It is only false if polygon/line have no points \note for a polygon, it is always a point on the exterior ring-\note for take_midpoint, it is not taken from two consecutive duplicate vertices,- (unless there are no other). */ template -inline bool point_on_border(Point& point,- Geometry const& geometry,- bool midpoint = false)+inline bool point_on_border(Point& point, Geometry const& geometry) { concepts::check(); concepts::check();@@ -292,12 +287,32 @@ inline bool point_on_border(Point& point, return dispatch::point_on_border < typename tag::type,- Point,- Geometry- >::apply(point, geometry, midpoint);+ false+ >::apply(point, geometry); } +/*!+\tparam Midpoint boolean flag, true if the point should not be a vertex, but some point+ in between of two vertices+\note for Midpoint, it is not taken from two consecutive duplicate vertices,+ (unless there are no other).+ */+/*+template +inline bool point_on_border(Point& point, Geometry const& geometry)+{+ concepts::check();+ concepts::check();++ return dispatch::point_on_border+ <+ typename tag::type,+ Midpoint+ >::apply(point, geometry);+}+*/+ }} // namespace boost::geometry