From ecd38531935fe69a891cc8c5f787495c7bd40b7d Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Fri, 13 Jun 2014 14:58:09 +0300 Subject: [PATCH] [algorithms][is_valid] merge code from linestring.hpp and multi_linestring.hpp into linear.hpp --- .../algorithms/detail/is_valid/linear.hpp | 32 ++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/is_valid/linear.hpp b/include/boost/geometry/algorithms/detail/is_valid/linear.hpp index af889903a..f96587fe6 100644 --- a/include/boost/geometry/algorithms/detail/is_valid/linear.hpp +++ b/include/boost/geometry/algorithms/detail/is_valid/linear.hpp @@ -7,8 +7,8 @@ // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html -#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_LINESTRING_HPP -#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_LINESTRING_HPP +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_LINEAR_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_LINEAR_HPP #include #include @@ -50,9 +50,8 @@ struct number_of_distinct_points { typedef typename point_type::type point; typedef typename boost::range_iterator::type iterator; - typedef typename boost::range_size::type size_type; - size_type size = boost::size(range); + std::size_t size = boost::size(range); if ( size < two ) { @@ -148,6 +147,29 @@ struct is_valid }; +// A MultiLinestring is a MultiCurve +// A MultiCurve is simple if all of its elements are simple and the +// only intersections between any two elements occur at Points that +// are on the boundaries of both elements. +// +// Reference: OGC 06-103r4 (ยง6.1.8.1; Fig. 9) +template +struct is_valid +{ + static inline bool apply(MultiLinestring const& multilinestring) + { + return detail::check_iterator_range + < + dispatch::is_valid + < + typename boost::range_value::type + > + >::apply(boost::begin(multilinestring), + boost::end(multilinestring)); + } +}; + + } // namespace dispatch #endif // DOXYGEN_NO_DISPATCH @@ -155,4 +177,4 @@ struct is_valid }} // namespace boost::geometry -#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_LINESTRING_HPP +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_LINEAR_HPP