mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-20 02:42:10 +00:00
[algorithms][is_valid] add the following free functions:
* bool is_valid(geometry, string) * bool is_valid(geometry, visitor) * bool is_valid(geometry, failure value)
This commit is contained in:
@@ -10,6 +10,9 @@
|
||||
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_INTERFACE_HPP
|
||||
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_INTERFACE_HPP
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include <boost/variant/apply_visitor.hpp>
|
||||
#include <boost/variant/static_visitor.hpp>
|
||||
#include <boost/variant/variant_fwd.hpp>
|
||||
@@ -18,6 +21,8 @@
|
||||
|
||||
#include <boost/geometry/algorithms/dispatch/is_valid.hpp>
|
||||
#include <boost/geometry/policies/is_valid/default_policy.hpp>
|
||||
#include <boost/geometry/policies/is_valid/failing_reason_policy.hpp>
|
||||
#include <boost/geometry/policies/is_valid/failure_type_policy.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
@@ -67,6 +72,14 @@ struct is_valid<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
|
||||
} // namespace resolve_variant
|
||||
|
||||
|
||||
// Undocumented for now
|
||||
template <typename Geometry, typename VisitPolicy>
|
||||
inline bool is_valid(Geometry const& geometry, VisitPolicy& visitor)
|
||||
{
|
||||
return resolve_variant::is_valid<Geometry>::apply(geometry, visitor);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief \brief_check{is valid (in the OGC sense)}
|
||||
\ingroup is_valid
|
||||
@@ -81,10 +94,42 @@ template <typename Geometry>
|
||||
inline bool is_valid(Geometry const& geometry)
|
||||
{
|
||||
is_valid_default_policy<> policy_visitor;
|
||||
return resolve_variant::is_valid
|
||||
<
|
||||
Geometry
|
||||
>::apply(geometry, policy_visitor);
|
||||
return is_valid(geometry, policy_visitor);
|
||||
}
|
||||
|
||||
|
||||
// Undocumented for now
|
||||
template <typename Geometry>
|
||||
inline bool is_valid(Geometry const& geometry, validity_failure_type& failure)
|
||||
{
|
||||
failure_type_policy<> policy_visitor;
|
||||
bool result = is_valid(geometry, policy_visitor);
|
||||
failure = policy_visitor.failure();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief \brief_check{is valid (in the OGC sense)}
|
||||
\ingroup is_valid
|
||||
\tparam Geometry \tparam_geometry
|
||||
\param geometry \param_geometry
|
||||
\param message A string containing a message stating if the geometry
|
||||
is valid or not, and if not valid a reason why
|
||||
\return \return_check{is valid (in the OGC sense), with one exception:
|
||||
multi-geometries with no elements are considered valid}
|
||||
|
||||
\qbk{distinguish,with message}
|
||||
\qbk{[include reference/algorithms/is_valid_with_message.qbk]}
|
||||
*/
|
||||
template <typename Geometry>
|
||||
inline bool is_valid(Geometry const& geometry, std::string& message)
|
||||
{
|
||||
std::ostringstream stream;
|
||||
failing_reason_policy<> policy_visitor(stream);
|
||||
bool result = is_valid(geometry, policy_visitor);
|
||||
message = stream.str();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user