diff options
author | Chanho Park <chanho61.park@samsung.com> | 2014-12-11 18:55:56 +0900 |
---|---|---|
committer | Chanho Park <chanho61.park@samsung.com> | 2014-12-11 18:55:56 +0900 |
commit | 08c1e93fa36a49f49325a07fe91ff92c964c2b6c (patch) | |
tree | 7a7053ceb8874b28ec4b868d4c49b500008a102e /boost/geometry/algorithms/correct.hpp | |
parent | bb4dd8289b351fae6b55e303f189127a394a1edd (diff) | |
download | boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.gz boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.bz2 boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.zip |
Imported Upstream version 1.57.0upstream/1.57.0
Diffstat (limited to 'boost/geometry/algorithms/correct.hpp')
-rw-r--r-- | boost/geometry/algorithms/correct.hpp | 100 |
1 files changed, 86 insertions, 14 deletions
diff --git a/boost/geometry/algorithms/correct.hpp b/boost/geometry/algorithms/correct.hpp index 583e395f8e..3c61b2c0d2 100644 --- a/boost/geometry/algorithms/correct.hpp +++ b/boost/geometry/algorithms/correct.hpp @@ -3,6 +3,7 @@ // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +// Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -21,25 +22,37 @@ #include <boost/mpl/assert.hpp> #include <boost/range.hpp> -#include <boost/typeof/typeof.hpp> +#include <boost/type_traits/remove_reference.hpp> +#include <boost/variant/static_visitor.hpp> +#include <boost/variant/apply_visitor.hpp> +#include <boost/variant/variant_fwd.hpp> + +#include <boost/geometry/algorithms/detail/interior_iterator.hpp> #include <boost/geometry/core/closure.hpp> #include <boost/geometry/core/cs.hpp> -#include <boost/geometry/core/mutable_range.hpp> -#include <boost/geometry/core/ring_type.hpp> #include <boost/geometry/core/exterior_ring.hpp> #include <boost/geometry/core/interior_rings.hpp> +#include <boost/geometry/core/mutable_range.hpp> +#include <boost/geometry/core/ring_type.hpp> +#include <boost/geometry/core/tags.hpp> #include <boost/geometry/geometries/concepts/check.hpp> #include <boost/geometry/algorithms/area.hpp> #include <boost/geometry/algorithms/disjoint.hpp> +#include <boost/geometry/algorithms/detail/multi_modify.hpp> #include <boost/geometry/util/order_as_direction.hpp> - namespace boost { namespace geometry { +// Silence warning C4127: conditional expression is constant +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable : 4127) +#endif + #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace correct { @@ -119,10 +132,8 @@ struct correct_ring typedef detail::area::ring_area < - Ring, order_as_direction<geometry::point_order<Ring>::value>::value, - geometry::closure<Ring>::value, - strategy_type + geometry::closure<Ring>::value > ring_area_type; @@ -139,7 +150,7 @@ struct correct_ring { geometry::append(r, *boost::begin(r)); } - if (! disjoint && geometry::closure<Ring>::value != closed) + if (! disjoint && s != closed) { // Open it by removing last point geometry::traits::resize<Ring>::apply(r, boost::size(r) - 1); @@ -172,9 +183,10 @@ struct correct_polygon std::less<area_result_type> >::apply(exterior_ring(poly)); - typename interior_return_type<Polygon>::type rings - = interior_rings(poly); - for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it) + typename interior_return_type<Polygon>::type + rings = interior_rings(poly); + for (typename detail::interior_iterator<Polygon>::type + it = boost::begin(rings); it != boost::end(rings); ++it) { correct_ring < @@ -234,10 +246,69 @@ struct correct<Polygon, polygon_tag> {}; +template <typename MultiPoint> +struct correct<MultiPoint, multi_point_tag> + : detail::correct::correct_nop<MultiPoint> +{}; + + +template <typename MultiLineString> +struct correct<MultiLineString, multi_linestring_tag> + : detail::correct::correct_nop<MultiLineString> +{}; + + +template <typename Geometry> +struct correct<Geometry, multi_polygon_tag> + : detail::multi_modify + < + Geometry, + detail::correct::correct_polygon + < + typename boost::range_value<Geometry>::type + > + > +{}; + + } // namespace dispatch #endif // DOXYGEN_NO_DISPATCH +namespace resolve_variant { + +template <typename Geometry> +struct correct +{ + static inline void apply(Geometry& geometry) + { + concept::check<Geometry const>(); + dispatch::correct<Geometry>::apply(geometry); + } +}; + +template <BOOST_VARIANT_ENUM_PARAMS(typename T)> +struct correct<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> > +{ + struct visitor: boost::static_visitor<void> + { + template <typename Geometry> + void operator()(Geometry& geometry) const + { + correct<Geometry>::apply(geometry); + } + }; + + static inline void + apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>& geometry) + { + boost::apply_visitor(visitor(), geometry); + } +}; + +} // namespace resolve_variant + + /*! \brief Corrects a geometry \details Corrects a geometry: all rings which are wrongly oriented with respect @@ -253,11 +324,12 @@ struct correct<Polygon, polygon_tag> template <typename Geometry> inline void correct(Geometry& geometry) { - concept::check<Geometry const>(); - - dispatch::correct<Geometry>::apply(geometry); + resolve_variant::correct<Geometry>::apply(geometry); } +#if defined(_MSC_VER) +#pragma warning(pop) +#endif }} // namespace boost::geometry |