add boost on mac
This commit is contained in:
@@ -0,0 +1,213 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
|
||||
// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2013-2019.
|
||||
// Modifications copyright (c) 2013-2019, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
// Contributed and/or modified by Menelaos Karavelas, 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.
|
||||
|
||||
// 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)
|
||||
|
||||
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_AREAL_AREAL_HPP
|
||||
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_AREAL_AREAL_HPP
|
||||
|
||||
#include <boost/geometry/core/point_type.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/covered_by.hpp>
|
||||
#include <boost/geometry/algorithms/detail/for_each_range.hpp>
|
||||
#include <boost/geometry/algorithms/detail/point_on_border.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/disjoint/linear_linear.hpp>
|
||||
#include <boost/geometry/algorithms/detail/disjoint/segment_box.hpp>
|
||||
|
||||
#include <boost/geometry/iterators/segment_iterator.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace disjoint
|
||||
{
|
||||
|
||||
template <typename Geometry1, typename Geometry2, typename Strategy>
|
||||
inline bool point_on_border_covered_by(Geometry1 const& geometry1,
|
||||
Geometry2 const& geometry2,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
typename geometry::point_type<Geometry1>::type pt;
|
||||
return geometry::point_on_border(pt, geometry1)
|
||||
&& geometry::covered_by(pt, geometry2, strategy);
|
||||
}
|
||||
|
||||
/*!
|
||||
\tparam Strategy point_in_geometry strategy
|
||||
*/
|
||||
template<typename Geometry, typename Strategy>
|
||||
struct check_each_ring_for_within
|
||||
{
|
||||
bool not_disjoint;
|
||||
Geometry const& m_geometry;
|
||||
Strategy const& m_strategy;
|
||||
|
||||
inline check_each_ring_for_within(Geometry const& g,
|
||||
Strategy const& strategy)
|
||||
: not_disjoint(false)
|
||||
, m_geometry(g)
|
||||
, m_strategy(strategy)
|
||||
{}
|
||||
|
||||
template <typename Range>
|
||||
inline void apply(Range const& range)
|
||||
{
|
||||
not_disjoint = not_disjoint
|
||||
|| point_on_border_covered_by(range, m_geometry, m_strategy);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
\tparam Strategy point_in_geometry strategy
|
||||
*/
|
||||
template <typename FirstGeometry, typename SecondGeometry, typename Strategy>
|
||||
inline bool rings_containing(FirstGeometry const& geometry1,
|
||||
SecondGeometry const& geometry2,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
check_each_ring_for_within
|
||||
<
|
||||
FirstGeometry, Strategy
|
||||
> checker(geometry1, strategy);
|
||||
geometry::detail::for_each_range(geometry2, checker);
|
||||
return checker.not_disjoint;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <typename Geometry1, typename Geometry2>
|
||||
struct areal_areal
|
||||
{
|
||||
/*!
|
||||
\tparam Strategy relate (segments intersection) strategy
|
||||
*/
|
||||
template <typename Strategy>
|
||||
static inline bool apply(Geometry1 const& geometry1,
|
||||
Geometry2 const& geometry2,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
if ( ! disjoint_linear<Geometry1, Geometry2>::apply(geometry1, geometry2, strategy) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// If there is no intersection of segments, they might located
|
||||
// inside each other
|
||||
|
||||
// We check that using a point on the border (external boundary),
|
||||
// and see if that is contained in the other geometry. And vice versa.
|
||||
|
||||
if ( rings_containing(geometry1, geometry2,
|
||||
strategy.template get_point_in_geometry_strategy<Geometry2, Geometry1>())
|
||||
|| rings_containing(geometry2, geometry1,
|
||||
strategy.template get_point_in_geometry_strategy<Geometry1, Geometry2>()) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename Areal, typename Box>
|
||||
struct areal_box
|
||||
{
|
||||
/*!
|
||||
\tparam Strategy relate (segments intersection) strategy
|
||||
*/
|
||||
template <typename Strategy>
|
||||
static inline bool apply(Areal const& areal,
|
||||
Box const& box,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
if ( ! for_each_segment(geometry::segments_begin(areal),
|
||||
geometry::segments_end(areal),
|
||||
box,
|
||||
strategy.get_disjoint_segment_box_strategy()) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// If there is no intersection of any segment and box,
|
||||
// the box might be located inside areal geometry
|
||||
|
||||
if ( point_on_border_covered_by(box, areal,
|
||||
strategy.template get_point_in_geometry_strategy<Box, Areal>()) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename SegIter, typename Strategy>
|
||||
static inline bool for_each_segment(SegIter first,
|
||||
SegIter last,
|
||||
Box const& box,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
for ( ; first != last ; ++first)
|
||||
{
|
||||
if (! disjoint_segment_box::apply(*first, box, strategy))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}} // namespace detail::disjoint
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DISPATCH
|
||||
namespace dispatch
|
||||
{
|
||||
|
||||
|
||||
template <typename Areal1, typename Areal2>
|
||||
struct disjoint<Areal1, Areal2, 2, areal_tag, areal_tag, false>
|
||||
: detail::disjoint::areal_areal<Areal1, Areal2>
|
||||
{};
|
||||
|
||||
|
||||
template <typename Areal, typename Box>
|
||||
struct disjoint<Areal, Box, 2, areal_tag, box_tag, false>
|
||||
: detail::disjoint::areal_box<Areal, Box>
|
||||
{};
|
||||
|
||||
|
||||
} // namespace dispatch
|
||||
#endif // DOXYGEN_NO_DISPATCH
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_AREAL_AREAL_HPP
|
||||
@@ -0,0 +1,80 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
|
||||
// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2013-2018.
|
||||
// Modifications copyright (c) 2013-2018, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
// Contributed and/or modified by Menelaos Karavelas, 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.
|
||||
|
||||
// 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)
|
||||
|
||||
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_BOX_BOX_HPP
|
||||
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_BOX_BOX_HPP
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
|
||||
|
||||
// For backward compatibility
|
||||
#include <boost/geometry/strategies/cartesian/disjoint_box_box.hpp>
|
||||
#include <boost/geometry/strategies/spherical/disjoint_box_box.hpp>
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace disjoint
|
||||
{
|
||||
|
||||
|
||||
/*!
|
||||
\brief Internal utility function to detect if boxes are disjoint
|
||||
\note Is used from other algorithms, declared separately
|
||||
to avoid circular references
|
||||
*/
|
||||
template <typename Box1, typename Box2, typename Strategy>
|
||||
inline bool disjoint_box_box(Box1 const& box1, Box2 const& box2, Strategy const&)
|
||||
{
|
||||
return Strategy::apply(box1, box2);
|
||||
}
|
||||
|
||||
|
||||
}} // namespace detail::disjoint
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DISPATCH
|
||||
namespace dispatch
|
||||
{
|
||||
|
||||
|
||||
template <typename Box1, typename Box2, std::size_t DimensionCount>
|
||||
struct disjoint<Box1, Box2, DimensionCount, box_tag, box_tag, false>
|
||||
{
|
||||
template <typename Strategy>
|
||||
static inline bool apply(Box1 const& box1, Box2 const& box2, Strategy const&)
|
||||
{
|
||||
return Strategy::apply(box1, box2);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace dispatch
|
||||
#endif // DOXYGEN_NO_DISPATCH
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_BOX_BOX_HPP
|
||||
@@ -0,0 +1,37 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
|
||||
// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2013-2017.
|
||||
// Modifications copyright (c) 2013-2017, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
// Contributed and/or modified by Menelaos Karavelas, 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.
|
||||
|
||||
// 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)
|
||||
|
||||
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_IMPLEMENTATION_HPP
|
||||
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_IMPLEMENTATION_HPP
|
||||
|
||||
|
||||
#include <boost/geometry/algorithms/detail/disjoint/areal_areal.hpp>
|
||||
#include <boost/geometry/algorithms/detail/disjoint/linear_areal.hpp>
|
||||
#include <boost/geometry/algorithms/detail/disjoint/linear_linear.hpp>
|
||||
#include <boost/geometry/algorithms/detail/disjoint/point_geometry.hpp>
|
||||
#include <boost/geometry/algorithms/detail/disjoint/multipoint_geometry.hpp>
|
||||
#include <boost/geometry/algorithms/detail/disjoint/point_point.hpp>
|
||||
#include <boost/geometry/algorithms/detail/disjoint/point_box.hpp>
|
||||
#include <boost/geometry/algorithms/detail/disjoint/box_box.hpp>
|
||||
#include <boost/geometry/algorithms/detail/disjoint/segment_box.hpp>
|
||||
#include <boost/geometry/algorithms/detail/disjoint/linear_segment_or_box.hpp>
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_IMPLEMENTATION_HPP
|
||||
@@ -0,0 +1,246 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
|
||||
// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2013-2017.
|
||||
// Modifications copyright (c) 2013-2017, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
// Contributed and/or modified by Menelaos Karavelas, 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.
|
||||
|
||||
// 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)
|
||||
|
||||
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_INTERFACE_HPP
|
||||
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_INTERFACE_HPP
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <boost/variant/apply_visitor.hpp>
|
||||
#include <boost/variant/static_visitor.hpp>
|
||||
#include <boost/variant/variant_fwd.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/relate/interface.hpp>
|
||||
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/concepts/check.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/disjoint.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace resolve_strategy
|
||||
{
|
||||
|
||||
struct disjoint
|
||||
{
|
||||
template <typename Geometry1, typename Geometry2, typename Strategy>
|
||||
static inline bool apply(Geometry1 const& geometry1,
|
||||
Geometry2 const& geometry2,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return dispatch::disjoint
|
||||
<
|
||||
Geometry1, Geometry2
|
||||
>::apply(geometry1, geometry2, strategy);
|
||||
}
|
||||
|
||||
template <typename Geometry1, typename Geometry2>
|
||||
static inline bool apply(Geometry1 const& geometry1,
|
||||
Geometry2 const& geometry2,
|
||||
default_strategy)
|
||||
{
|
||||
typedef typename strategy::disjoint::services::default_strategy
|
||||
<
|
||||
Geometry1, Geometry2
|
||||
>::type strategy_type;
|
||||
|
||||
return dispatch::disjoint
|
||||
<
|
||||
Geometry1, Geometry2
|
||||
>::apply(geometry1, geometry2, strategy_type());
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace resolve_strategy
|
||||
|
||||
|
||||
namespace resolve_variant {
|
||||
|
||||
template <typename Geometry1, typename Geometry2>
|
||||
struct disjoint
|
||||
{
|
||||
template <typename Strategy>
|
||||
static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy)
|
||||
{
|
||||
concepts::check_concepts_and_equal_dimensions
|
||||
<
|
||||
Geometry1 const,
|
||||
Geometry2 const
|
||||
>();
|
||||
|
||||
return resolve_strategy::disjoint::apply(geometry1, geometry2, strategy);
|
||||
}
|
||||
};
|
||||
|
||||
template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Geometry2>
|
||||
struct disjoint<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Geometry2>
|
||||
{
|
||||
template <typename Strategy>
|
||||
struct visitor: boost::static_visitor<bool>
|
||||
{
|
||||
Geometry2 const& m_geometry2;
|
||||
Strategy const& m_strategy;
|
||||
|
||||
visitor(Geometry2 const& geometry2, Strategy const& strategy)
|
||||
: m_geometry2(geometry2)
|
||||
, m_strategy(strategy)
|
||||
{}
|
||||
|
||||
template <typename Geometry1>
|
||||
bool operator()(Geometry1 const& geometry1) const
|
||||
{
|
||||
return disjoint<Geometry1, Geometry2>::apply(geometry1, m_geometry2, m_strategy);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Strategy>
|
||||
static inline bool apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry1,
|
||||
Geometry2 const& geometry2,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return boost::apply_visitor(visitor<Strategy>(geometry2, strategy), geometry1);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geometry1, BOOST_VARIANT_ENUM_PARAMS(typename T)>
|
||||
struct disjoint<Geometry1, boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
|
||||
{
|
||||
template <typename Strategy>
|
||||
struct visitor: boost::static_visitor<bool>
|
||||
{
|
||||
Geometry1 const& m_geometry1;
|
||||
Strategy const& m_strategy;
|
||||
|
||||
visitor(Geometry1 const& geometry1, Strategy const& strategy)
|
||||
: m_geometry1(geometry1)
|
||||
, m_strategy(strategy)
|
||||
{}
|
||||
|
||||
template <typename Geometry2>
|
||||
bool operator()(Geometry2 const& geometry2) const
|
||||
{
|
||||
return disjoint<Geometry1, Geometry2>::apply(m_geometry1, geometry2, m_strategy);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Strategy>
|
||||
static inline bool apply(Geometry1 const& geometry1,
|
||||
boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry2,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return boost::apply_visitor(visitor<Strategy>(geometry1, strategy), geometry2);
|
||||
}
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
BOOST_VARIANT_ENUM_PARAMS(typename T1),
|
||||
BOOST_VARIANT_ENUM_PARAMS(typename T2)
|
||||
>
|
||||
struct disjoint
|
||||
<
|
||||
boost::variant<BOOST_VARIANT_ENUM_PARAMS(T1)>,
|
||||
boost::variant<BOOST_VARIANT_ENUM_PARAMS(T2)>
|
||||
>
|
||||
{
|
||||
template <typename Strategy>
|
||||
struct visitor: boost::static_visitor<bool>
|
||||
{
|
||||
Strategy const& m_strategy;
|
||||
|
||||
visitor(Strategy const& strategy)
|
||||
: m_strategy(strategy)
|
||||
{}
|
||||
|
||||
template <typename Geometry1, typename Geometry2>
|
||||
bool operator()(Geometry1 const& geometry1,
|
||||
Geometry2 const& geometry2) const
|
||||
{
|
||||
return disjoint<Geometry1, Geometry2>::apply(geometry1, geometry2, m_strategy);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Strategy>
|
||||
static inline bool apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T1)> const& geometry1,
|
||||
boost::variant<BOOST_VARIANT_ENUM_PARAMS(T2)> const& geometry2,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return boost::apply_visitor(visitor<Strategy>(strategy), geometry1, geometry2);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace resolve_variant
|
||||
|
||||
|
||||
/*!
|
||||
\brief \brief_check2{are disjoint}
|
||||
\ingroup disjoint
|
||||
\tparam Geometry1 \tparam_geometry
|
||||
\tparam Geometry2 \tparam_geometry
|
||||
\tparam Strategy \tparam_strategy{Disjoint}
|
||||
\param geometry1 \param_geometry
|
||||
\param geometry2 \param_geometry
|
||||
\param strategy \param_strategy{disjoint}
|
||||
\return \return_check2{are disjoint}
|
||||
|
||||
\qbk{distinguish,with strategy}
|
||||
\qbk{[include reference/algorithms/disjoint.qbk]}
|
||||
*/
|
||||
template <typename Geometry1, typename Geometry2, typename Strategy>
|
||||
inline bool disjoint(Geometry1 const& geometry1,
|
||||
Geometry2 const& geometry2,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return resolve_variant::disjoint
|
||||
<
|
||||
Geometry1, Geometry2
|
||||
>::apply(geometry1, geometry2, strategy);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief \brief_check2{are disjoint}
|
||||
\ingroup disjoint
|
||||
\tparam Geometry1 \tparam_geometry
|
||||
\tparam Geometry2 \tparam_geometry
|
||||
\param geometry1 \param_geometry
|
||||
\param geometry2 \param_geometry
|
||||
\return \return_check2{are disjoint}
|
||||
|
||||
\qbk{[include reference/algorithms/disjoint.qbk]}
|
||||
*/
|
||||
template <typename Geometry1, typename Geometry2>
|
||||
inline bool disjoint(Geometry1 const& geometry1,
|
||||
Geometry2 const& geometry2)
|
||||
{
|
||||
return resolve_variant::disjoint
|
||||
<
|
||||
Geometry1, Geometry2
|
||||
>::apply(geometry1, geometry2, default_strategy());
|
||||
}
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_INTERFACE_HPP
|
||||
@@ -0,0 +1,302 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
|
||||
// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2013-2018.
|
||||
// Modifications copyright (c) 2013-2018, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
// Contributed and/or modified by Menelaos Karavelas, 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.
|
||||
|
||||
// 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)
|
||||
|
||||
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_AREAL_HPP
|
||||
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_AREAL_HPP
|
||||
|
||||
#include <iterator>
|
||||
|
||||
#include <boost/range.hpp>
|
||||
|
||||
#include <boost/geometry/core/closure.hpp>
|
||||
#include <boost/geometry/core/point_type.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/tag.hpp>
|
||||
#include <boost/geometry/core/tag_cast.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/covered_by.hpp>
|
||||
#include <boost/geometry/algorithms/not_implemented.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/assign_indexed_point.hpp>
|
||||
#include <boost/geometry/algorithms/detail/check_iterator_range.hpp>
|
||||
#include <boost/geometry/algorithms/detail/point_on_border.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/disjoint/linear_linear.hpp>
|
||||
#include <boost/geometry/algorithms/detail/disjoint/linear_segment_or_box.hpp>
|
||||
#include <boost/geometry/algorithms/detail/disjoint/multirange_geometry.hpp>
|
||||
#include <boost/geometry/algorithms/detail/disjoint/point_box.hpp>
|
||||
#include <boost/geometry/algorithms/detail/disjoint/segment_box.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace disjoint
|
||||
{
|
||||
|
||||
template <typename Geometry1, typename Geometry2,
|
||||
typename Tag1 = typename tag<Geometry1>::type,
|
||||
typename Tag1OrMulti = typename tag_cast<Tag1, multi_tag>::type>
|
||||
struct disjoint_no_intersections_policy
|
||||
{
|
||||
/*!
|
||||
\tparam Strategy point_in_geometry strategy
|
||||
*/
|
||||
template <typename Strategy>
|
||||
static inline bool apply(Geometry1 const& g1, Geometry2 const& g2, Strategy const& strategy)
|
||||
{
|
||||
typedef typename point_type<Geometry1>::type point1_type;
|
||||
point1_type p;
|
||||
geometry::point_on_border(p, g1);
|
||||
|
||||
return !geometry::covered_by(p, g2, strategy);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geometry1, typename Geometry2, typename Tag1>
|
||||
struct disjoint_no_intersections_policy<Geometry1, Geometry2, Tag1, multi_tag>
|
||||
{
|
||||
/*!
|
||||
\tparam Strategy point_in_geometry strategy
|
||||
*/
|
||||
template <typename Strategy>
|
||||
static inline bool apply(Geometry1 const& g1, Geometry2 const& g2, Strategy const& strategy)
|
||||
{
|
||||
// TODO: use partition or rtree on g2
|
||||
typedef typename boost::range_iterator<Geometry1 const>::type iterator;
|
||||
for ( iterator it = boost::begin(g1) ; it != boost::end(g1) ; ++it )
|
||||
{
|
||||
typedef typename boost::range_value<Geometry1 const>::type value_type;
|
||||
if ( ! disjoint_no_intersections_policy<value_type const, Geometry2>
|
||||
::apply(*it, g2, strategy) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename Geometry1, typename Geometry2,
|
||||
typename NoIntersectionsPolicy
|
||||
= disjoint_no_intersections_policy<Geometry1, Geometry2> >
|
||||
struct disjoint_linear_areal
|
||||
{
|
||||
/*!
|
||||
\tparam Strategy relate (segments intersection) strategy
|
||||
*/
|
||||
template <typename Strategy>
|
||||
static inline bool apply(Geometry1 const& g1, Geometry2 const& g2, Strategy const& strategy)
|
||||
{
|
||||
// if there are intersections - return false
|
||||
if ( !disjoint_linear<Geometry1, Geometry2>::apply(g1, g2, strategy) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return NoIntersectionsPolicy
|
||||
::apply(g1, g2,
|
||||
strategy.template get_point_in_geometry_strategy<Geometry1, Geometry2>());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
typename Segment,
|
||||
typename Areal,
|
||||
typename Tag = typename tag<Areal>::type
|
||||
>
|
||||
struct disjoint_segment_areal
|
||||
: not_implemented<Segment, Areal>
|
||||
{};
|
||||
|
||||
|
||||
template <typename Segment, typename Polygon>
|
||||
class disjoint_segment_areal<Segment, Polygon, polygon_tag>
|
||||
{
|
||||
private:
|
||||
template <typename InteriorRings, typename Strategy>
|
||||
static inline
|
||||
bool check_interior_rings(InteriorRings const& interior_rings,
|
||||
Segment const& segment,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
typedef typename boost::range_value<InteriorRings>::type ring_type;
|
||||
|
||||
typedef unary_disjoint_geometry_to_query_geometry
|
||||
<
|
||||
Segment,
|
||||
Strategy,
|
||||
disjoint_range_segment_or_box
|
||||
<
|
||||
ring_type, closure<ring_type>::value, Segment
|
||||
>
|
||||
> unary_predicate_type;
|
||||
|
||||
return check_iterator_range
|
||||
<
|
||||
unary_predicate_type
|
||||
>::apply(boost::begin(interior_rings),
|
||||
boost::end(interior_rings),
|
||||
unary_predicate_type(segment, strategy));
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
template <typename IntersectionStrategy>
|
||||
static inline bool apply(Segment const& segment,
|
||||
Polygon const& polygon,
|
||||
IntersectionStrategy const& strategy)
|
||||
{
|
||||
typedef typename geometry::ring_type<Polygon>::type ring;
|
||||
|
||||
if ( !disjoint_range_segment_or_box
|
||||
<
|
||||
ring, closure<Polygon>::value, Segment
|
||||
>::apply(geometry::exterior_ring(polygon), segment, strategy) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !check_interior_rings(geometry::interior_rings(polygon), segment, strategy) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
typename point_type<Segment>::type p;
|
||||
detail::assign_point_from_index<0>(segment, p);
|
||||
|
||||
return !geometry::covered_by(p, polygon,
|
||||
strategy.template get_point_in_geometry_strategy<Segment, Polygon>());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename Segment, typename MultiPolygon>
|
||||
struct disjoint_segment_areal<Segment, MultiPolygon, multi_polygon_tag>
|
||||
{
|
||||
template <typename IntersectionStrategy>
|
||||
static inline bool apply(Segment const& segment, MultiPolygon const& multipolygon,
|
||||
IntersectionStrategy const& strategy)
|
||||
{
|
||||
return multirange_constant_size_geometry
|
||||
<
|
||||
MultiPolygon, Segment
|
||||
>::apply(multipolygon, segment, strategy);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename Segment, typename Ring>
|
||||
struct disjoint_segment_areal<Segment, Ring, ring_tag>
|
||||
{
|
||||
template <typename IntersectionStrategy>
|
||||
static inline bool apply(Segment const& segment,
|
||||
Ring const& ring,
|
||||
IntersectionStrategy const& strategy)
|
||||
{
|
||||
if ( !disjoint_range_segment_or_box
|
||||
<
|
||||
Ring, closure<Ring>::value, Segment
|
||||
>::apply(ring, segment, strategy) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
typename point_type<Segment>::type p;
|
||||
detail::assign_point_from_index<0>(segment, p);
|
||||
|
||||
return !geometry::covered_by(p, ring,
|
||||
strategy.template get_point_in_geometry_strategy<Segment, Ring>());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}} // namespace detail::disjoint
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DISPATCH
|
||||
namespace dispatch
|
||||
{
|
||||
|
||||
|
||||
template <typename Linear, typename Areal>
|
||||
struct disjoint<Linear, Areal, 2, linear_tag, areal_tag, false>
|
||||
: public detail::disjoint::disjoint_linear_areal<Linear, Areal>
|
||||
{};
|
||||
|
||||
|
||||
template <typename Areal, typename Linear>
|
||||
struct disjoint<Areal, Linear, 2, areal_tag, linear_tag, false>
|
||||
{
|
||||
template <typename Strategy>
|
||||
static inline bool apply(Areal const& areal, Linear const& linear,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return detail::disjoint::disjoint_linear_areal
|
||||
<
|
||||
Linear, Areal
|
||||
>::apply(linear, areal, strategy);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename Areal, typename Segment>
|
||||
struct disjoint<Areal, Segment, 2, areal_tag, segment_tag, false>
|
||||
{
|
||||
template <typename Strategy>
|
||||
static inline bool apply(Areal const& g1, Segment const& g2,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return detail::disjoint::disjoint_segment_areal
|
||||
<
|
||||
Segment, Areal
|
||||
>::apply(g2, g1, strategy);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename Segment, typename Areal>
|
||||
struct disjoint<Segment, Areal, 2, segment_tag, areal_tag, false>
|
||||
: detail::disjoint::disjoint_segment_areal<Segment, Areal>
|
||||
{};
|
||||
|
||||
|
||||
} // namespace dispatch
|
||||
#endif // DOXYGEN_NO_DISPATCH
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_AREAL_HPP
|
||||
@@ -0,0 +1,179 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
|
||||
// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2013-2017.
|
||||
// Modifications copyright (c) 2013-2017, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
// Contributed and/or modified by Menelaos Karavelas, 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.
|
||||
|
||||
// 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)
|
||||
|
||||
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_LINEAR_HPP
|
||||
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_LINEAR_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <deque>
|
||||
|
||||
#include <boost/range.hpp>
|
||||
#include <boost/geometry/util/range.hpp>
|
||||
|
||||
#include <boost/geometry/core/point_type.hpp>
|
||||
#include <boost/geometry/core/tag.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
|
||||
#include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
|
||||
#include <boost/geometry/algorithms/detail/overlay/do_reverse.hpp>
|
||||
|
||||
#include <boost/geometry/policies/disjoint_interrupt_policy.hpp>
|
||||
#include <boost/geometry/policies/robustness/no_rescale_policy.hpp>
|
||||
#include <boost/geometry/policies/robustness/segment_ratio_type.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace disjoint
|
||||
{
|
||||
|
||||
template <typename Segment1, typename Segment2>
|
||||
struct disjoint_segment
|
||||
{
|
||||
template <typename Strategy>
|
||||
static inline bool apply(Segment1 const& segment1, Segment2 const& segment2,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
typedef typename point_type<Segment1>::type point_type;
|
||||
|
||||
// We don't need to rescale to detect disjointness
|
||||
typedef no_rescale_policy rescale_policy_type;
|
||||
rescale_policy_type robust_policy;
|
||||
|
||||
typedef segment_intersection_points
|
||||
<
|
||||
point_type,
|
||||
typename segment_ratio_type
|
||||
<
|
||||
point_type,
|
||||
rescale_policy_type
|
||||
>::type
|
||||
> intersection_return_type;
|
||||
|
||||
typedef policies::relate::segments_intersection_points
|
||||
<
|
||||
intersection_return_type
|
||||
> intersection_policy;
|
||||
|
||||
intersection_return_type is = strategy.apply(segment1, segment2,
|
||||
intersection_policy(),
|
||||
robust_policy);
|
||||
|
||||
return is.count == 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct assign_disjoint_policy
|
||||
{
|
||||
// We want to include all points:
|
||||
static bool const include_no_turn = true;
|
||||
static bool const include_degenerate = true;
|
||||
static bool const include_opposite = true;
|
||||
};
|
||||
|
||||
|
||||
template <typename Geometry1, typename Geometry2>
|
||||
struct disjoint_linear
|
||||
{
|
||||
template <typename Strategy>
|
||||
static inline bool apply(Geometry1 const& geometry1,
|
||||
Geometry2 const& geometry2,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
typedef typename geometry::point_type<Geometry1>::type point_type;
|
||||
typedef detail::no_rescale_policy rescale_policy_type;
|
||||
typedef typename geometry::segment_ratio_type
|
||||
<
|
||||
point_type, rescale_policy_type
|
||||
>::type segment_ratio_type;
|
||||
typedef overlay::turn_info
|
||||
<
|
||||
point_type,
|
||||
segment_ratio_type,
|
||||
typename detail::get_turns::turn_operation_type
|
||||
<
|
||||
Geometry1, Geometry2, segment_ratio_type
|
||||
>::type
|
||||
> turn_info_type;
|
||||
|
||||
std::deque<turn_info_type> turns;
|
||||
|
||||
// Specify two policies:
|
||||
// 1) Stop at any intersection
|
||||
// 2) In assignment, include also degenerate points (which are normally skipped)
|
||||
disjoint_interrupt_policy interrupt_policy;
|
||||
dispatch::get_turns
|
||||
<
|
||||
typename geometry::tag<Geometry1>::type,
|
||||
typename geometry::tag<Geometry2>::type,
|
||||
Geometry1,
|
||||
Geometry2,
|
||||
overlay::do_reverse<geometry::point_order<Geometry1>::value>::value, // should be false
|
||||
overlay::do_reverse<geometry::point_order<Geometry2>::value>::value, // should be false
|
||||
detail::get_turns::get_turn_info_type
|
||||
<
|
||||
Geometry1, Geometry2, assign_disjoint_policy
|
||||
>
|
||||
>::apply(0, geometry1, 1, geometry2,
|
||||
strategy, rescale_policy_type(), turns, interrupt_policy);
|
||||
|
||||
return !interrupt_policy.has_intersections;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}} // namespace detail::disjoint
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DISPATCH
|
||||
namespace dispatch
|
||||
{
|
||||
|
||||
|
||||
template <typename Linear1, typename Linear2>
|
||||
struct disjoint<Linear1, Linear2, 2, linear_tag, linear_tag, false>
|
||||
: detail::disjoint::disjoint_linear<Linear1, Linear2>
|
||||
{};
|
||||
|
||||
|
||||
template <typename Segment1, typename Segment2>
|
||||
struct disjoint<Segment1, Segment2, 2, segment_tag, segment_tag, false>
|
||||
: detail::disjoint::disjoint_segment<Segment1, Segment2>
|
||||
{};
|
||||
|
||||
|
||||
} // namespace dispatch
|
||||
#endif // DOXYGEN_NO_DISPATCH
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_LINEAR_HPP
|
||||
@@ -0,0 +1,171 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
|
||||
// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2013-2014.
|
||||
// Modifications copyright (c) 2013-2014, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
// Contributed and/or modified by Menelaos Karavelas, 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.
|
||||
|
||||
// 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)
|
||||
|
||||
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_SEGMENT_OR_BOX_HPP
|
||||
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_SEGMENT_OR_BOX_HPP
|
||||
|
||||
#include <boost/range.hpp>
|
||||
#include <boost/geometry/util/range.hpp>
|
||||
|
||||
#include <boost/geometry/core/closure.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/segment.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/not_implemented.hpp>
|
||||
|
||||
#include <boost/geometry/views/closeable_view.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/disjoint/multirange_geometry.hpp>
|
||||
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace disjoint
|
||||
{
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
typename Range,
|
||||
closure_selector Closure,
|
||||
typename SegmentOrBox
|
||||
>
|
||||
struct disjoint_range_segment_or_box
|
||||
{
|
||||
template <typename Strategy>
|
||||
static inline bool apply(Range const& range,
|
||||
SegmentOrBox const& segment_or_box,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
typedef typename closeable_view<Range const, Closure>::type view_type;
|
||||
|
||||
typedef typename ::boost::range_value<view_type>::type point_type;
|
||||
typedef typename ::boost::range_iterator
|
||||
<
|
||||
view_type const
|
||||
>::type const_iterator;
|
||||
|
||||
typedef typename ::boost::range_size<view_type>::type size_type;
|
||||
|
||||
typedef typename geometry::model::referring_segment
|
||||
<
|
||||
point_type const
|
||||
> range_segment;
|
||||
|
||||
view_type view(range);
|
||||
|
||||
const size_type count = ::boost::size(view);
|
||||
|
||||
if ( count == 0 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if ( count == 1 )
|
||||
{
|
||||
return dispatch::disjoint
|
||||
<
|
||||
point_type, SegmentOrBox
|
||||
>::apply(geometry::range::front<view_type const>(view),
|
||||
segment_or_box,
|
||||
strategy.template get_point_in_geometry_strategy<Range, SegmentOrBox>());
|
||||
}
|
||||
else
|
||||
{
|
||||
const_iterator it0 = ::boost::begin(view);
|
||||
const_iterator it1 = ::boost::begin(view) + 1;
|
||||
const_iterator last = ::boost::end(view);
|
||||
|
||||
for ( ; it1 != last ; ++it0, ++it1 )
|
||||
{
|
||||
range_segment rng_segment(*it0, *it1);
|
||||
if ( !dispatch::disjoint
|
||||
<
|
||||
range_segment, SegmentOrBox
|
||||
>::apply(rng_segment, segment_or_box, strategy) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
typename Linear,
|
||||
typename SegmentOrBox,
|
||||
typename Tag = typename tag<Linear>::type
|
||||
>
|
||||
struct disjoint_linear_segment_or_box
|
||||
: not_implemented<Linear, SegmentOrBox>
|
||||
{};
|
||||
|
||||
|
||||
template <typename Linestring, typename SegmentOrBox>
|
||||
struct disjoint_linear_segment_or_box<Linestring, SegmentOrBox, linestring_tag>
|
||||
: disjoint_range_segment_or_box<Linestring, closed, SegmentOrBox>
|
||||
{};
|
||||
|
||||
|
||||
template <typename MultiLinestring, typename SegmentOrBox>
|
||||
struct disjoint_linear_segment_or_box
|
||||
<
|
||||
MultiLinestring, SegmentOrBox, multi_linestring_tag
|
||||
> : multirange_constant_size_geometry<MultiLinestring, SegmentOrBox>
|
||||
{};
|
||||
|
||||
|
||||
}} // namespace detail::disjoint
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DISPATCH
|
||||
namespace dispatch
|
||||
{
|
||||
|
||||
|
||||
template <typename Linear, typename Segment>
|
||||
struct disjoint<Linear, Segment, 2, linear_tag, segment_tag, false>
|
||||
: detail::disjoint::disjoint_linear_segment_or_box<Linear, Segment>
|
||||
{};
|
||||
|
||||
|
||||
template <typename Linear, typename Box, std::size_t DimensionCount>
|
||||
struct disjoint<Linear, Box, DimensionCount, linear_tag, box_tag, false>
|
||||
: detail::disjoint::disjoint_linear_segment_or_box<Linear, Box>
|
||||
{};
|
||||
|
||||
|
||||
} // namespace dispatch
|
||||
#endif // DOXYGEN_NO_DISPATCH
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_SEGMENT_OR_BOX_HPP
|
||||
@@ -0,0 +1,554 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// Copyright (c) 2014-2018, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Licensed under the Boost Software License version 1.0.
|
||||
// http://www.boost.org/users/license.html
|
||||
|
||||
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_MULTIPOINT_GEOMETRY_HPP
|
||||
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_MULTIPOINT_GEOMETRY_HPP
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/range.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
|
||||
#include <boost/geometry/core/assert.hpp>
|
||||
#include <boost/geometry/core/tag.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/box.hpp>
|
||||
|
||||
#include <boost/geometry/iterators/segment_iterator.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/envelope.hpp>
|
||||
#include <boost/geometry/algorithms/expand.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/check_iterator_range.hpp>
|
||||
#include <boost/geometry/algorithms/detail/partition.hpp>
|
||||
#include <boost/geometry/algorithms/detail/disjoint/box_box.hpp>
|
||||
#include <boost/geometry/algorithms/detail/disjoint/multirange_geometry.hpp>
|
||||
#include <boost/geometry/algorithms/detail/disjoint/point_box.hpp>
|
||||
#include <boost/geometry/algorithms/detail/disjoint/point_point.hpp>
|
||||
#include <boost/geometry/algorithms/detail/disjoint/point_geometry.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
|
||||
|
||||
#include <boost/geometry/policies/compare.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace disjoint
|
||||
{
|
||||
|
||||
|
||||
template <typename MultiPoint1, typename MultiPoint2>
|
||||
class multipoint_multipoint
|
||||
{
|
||||
private:
|
||||
template <typename Iterator>
|
||||
class unary_disjoint_predicate
|
||||
: geometry::less<>
|
||||
{
|
||||
private:
|
||||
typedef geometry::less<> base_type;
|
||||
|
||||
public:
|
||||
unary_disjoint_predicate(Iterator first, Iterator last)
|
||||
: base_type(), m_first(first), m_last(last)
|
||||
{}
|
||||
|
||||
template <typename Point>
|
||||
inline bool apply(Point const& point) const
|
||||
{
|
||||
return !std::binary_search(m_first,
|
||||
m_last,
|
||||
point,
|
||||
static_cast<base_type const&>(*this));
|
||||
}
|
||||
|
||||
private:
|
||||
Iterator m_first, m_last;
|
||||
};
|
||||
|
||||
public:
|
||||
static inline bool apply(MultiPoint1 const& multipoint1,
|
||||
MultiPoint2 const& multipoint2)
|
||||
{
|
||||
BOOST_GEOMETRY_ASSERT( boost::size(multipoint1) <= boost::size(multipoint2) );
|
||||
|
||||
typedef typename boost::range_value<MultiPoint1>::type point1_type;
|
||||
|
||||
std::vector<point1_type> points1(boost::begin(multipoint1),
|
||||
boost::end(multipoint1));
|
||||
|
||||
std::sort(points1.begin(), points1.end(), geometry::less<>());
|
||||
|
||||
typedef unary_disjoint_predicate
|
||||
<
|
||||
typename std::vector<point1_type>::const_iterator
|
||||
> predicate_type;
|
||||
|
||||
return check_iterator_range
|
||||
<
|
||||
predicate_type
|
||||
>::apply(boost::begin(multipoint2),
|
||||
boost::end(multipoint2),
|
||||
predicate_type(points1.begin(), points1.end()));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename MultiPoint, typename Linear>
|
||||
class multipoint_linear
|
||||
{
|
||||
private:
|
||||
struct expand_box_point
|
||||
{
|
||||
template <typename Box, typename Point>
|
||||
static inline void apply(Box& total, Point const& point)
|
||||
{
|
||||
geometry::expand(total, point);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename EnvelopeStrategy>
|
||||
struct expand_box_segment
|
||||
{
|
||||
explicit expand_box_segment(EnvelopeStrategy const& strategy)
|
||||
: m_strategy(strategy)
|
||||
{}
|
||||
|
||||
template <typename Box, typename Segment>
|
||||
inline void apply(Box& total, Segment const& segment) const
|
||||
{
|
||||
geometry::expand(total,
|
||||
geometry::return_envelope<Box>(segment, m_strategy));
|
||||
}
|
||||
|
||||
EnvelopeStrategy const& m_strategy;
|
||||
};
|
||||
|
||||
template <typename DisjointPointBoxStrategy>
|
||||
struct overlaps_box_point
|
||||
{
|
||||
template <typename Box, typename Point>
|
||||
static inline bool apply(Box const& box, Point const& point)
|
||||
{
|
||||
// The default strategy is enough in this case
|
||||
return ! detail::disjoint::disjoint_point_box(point, box,
|
||||
DisjointPointBoxStrategy());
|
||||
}
|
||||
};
|
||||
|
||||
template <typename DisjointStrategy>
|
||||
struct overlaps_box_segment
|
||||
{
|
||||
explicit overlaps_box_segment(DisjointStrategy const& strategy)
|
||||
: m_strategy(strategy)
|
||||
{}
|
||||
|
||||
template <typename Box, typename Segment>
|
||||
inline bool apply(Box const& box, Segment const& segment) const
|
||||
{
|
||||
return ! dispatch::disjoint<Segment, Box>::apply(segment, box, m_strategy);
|
||||
}
|
||||
|
||||
DisjointStrategy const& m_strategy;
|
||||
};
|
||||
|
||||
template <typename PtSegStrategy>
|
||||
class item_visitor_type
|
||||
{
|
||||
public:
|
||||
item_visitor_type(PtSegStrategy const& strategy)
|
||||
: m_intersection_found(false)
|
||||
, m_strategy(strategy)
|
||||
{}
|
||||
|
||||
template <typename Item1, typename Item2>
|
||||
inline bool apply(Item1 const& item1, Item2 const& item2)
|
||||
{
|
||||
if (! m_intersection_found
|
||||
&& ! dispatch::disjoint<Item1, Item2>::apply(item1, item2, m_strategy))
|
||||
{
|
||||
m_intersection_found = true;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool intersection_found() const { return m_intersection_found; }
|
||||
|
||||
private:
|
||||
bool m_intersection_found;
|
||||
PtSegStrategy const& m_strategy;
|
||||
};
|
||||
// structs for partition -- end
|
||||
|
||||
class segment_range
|
||||
{
|
||||
public:
|
||||
typedef geometry::segment_iterator<Linear const> const_iterator;
|
||||
typedef const_iterator iterator;
|
||||
|
||||
segment_range(Linear const& linear)
|
||||
: m_linear(linear)
|
||||
{}
|
||||
|
||||
const_iterator begin() const
|
||||
{
|
||||
return geometry::segments_begin(m_linear);
|
||||
}
|
||||
|
||||
const_iterator end() const
|
||||
{
|
||||
return geometry::segments_end(m_linear);
|
||||
}
|
||||
|
||||
private:
|
||||
Linear const& m_linear;
|
||||
};
|
||||
|
||||
public:
|
||||
template <typename Strategy>
|
||||
static inline bool apply(MultiPoint const& multipoint, Linear const& linear, Strategy const& strategy)
|
||||
{
|
||||
item_visitor_type<Strategy> visitor(strategy);
|
||||
|
||||
typedef typename Strategy::envelope_strategy_type envelope_strategy_type;
|
||||
typedef typename Strategy::disjoint_strategy_type disjoint_strategy_type;
|
||||
typedef typename Strategy::disjoint_point_box_strategy_type disjoint_pb_strategy_type;
|
||||
|
||||
// TODO: disjoint Segment/Box may be called in partition multiple times
|
||||
// possibly for non-cartesian segments which could be slow. We should consider
|
||||
// passing a range of bounding boxes of segments after calculating them once.
|
||||
// Alternatively instead of a range of segments a range of Segment/Envelope pairs
|
||||
// should be passed, where envelope would be lazily calculated when needed the first time
|
||||
geometry::partition
|
||||
<
|
||||
geometry::model::box<typename point_type<MultiPoint>::type>
|
||||
>::apply(multipoint, segment_range(linear), visitor,
|
||||
expand_box_point(),
|
||||
overlaps_box_point<disjoint_pb_strategy_type>(),
|
||||
expand_box_segment<envelope_strategy_type>(strategy.get_envelope_strategy()),
|
||||
overlaps_box_segment<disjoint_strategy_type>(strategy.get_disjoint_strategy()));
|
||||
|
||||
return ! visitor.intersection_found();
|
||||
}
|
||||
|
||||
template <typename Strategy>
|
||||
static inline bool apply(Linear const& linear, MultiPoint const& multipoint, Strategy const& strategy)
|
||||
{
|
||||
return apply(multipoint, linear, strategy);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename MultiPoint, typename SingleGeometry>
|
||||
class multi_point_single_geometry
|
||||
{
|
||||
public:
|
||||
template <typename Strategy>
|
||||
static inline bool apply(MultiPoint const& multi_point,
|
||||
SingleGeometry const& single_geometry,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
typedef typename Strategy::disjoint_point_box_strategy_type d_pb_strategy_type;
|
||||
|
||||
typedef typename point_type<MultiPoint>::type point1_type;
|
||||
typedef typename point_type<SingleGeometry>::type point2_type;
|
||||
typedef model::box<point2_type> box2_type;
|
||||
|
||||
box2_type box2;
|
||||
geometry::envelope(single_geometry, box2, strategy.get_envelope_strategy());
|
||||
geometry::detail::expand_by_epsilon(box2);
|
||||
|
||||
typedef typename boost::range_const_iterator<MultiPoint>::type iterator;
|
||||
for ( iterator it = boost::begin(multi_point) ; it != boost::end(multi_point) ; ++it )
|
||||
{
|
||||
// The default strategy is enough for Point/Box
|
||||
if (! detail::disjoint::disjoint_point_box(*it, box2, d_pb_strategy_type())
|
||||
&& ! dispatch::disjoint<point1_type, SingleGeometry>::apply(*it, single_geometry, strategy))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename Strategy>
|
||||
static inline bool apply(SingleGeometry const& single_geometry, MultiPoint const& multi_point, Strategy const& strategy)
|
||||
{
|
||||
return apply(multi_point, single_geometry, strategy);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename MultiPoint, typename MultiGeometry>
|
||||
class multi_point_multi_geometry
|
||||
{
|
||||
private:
|
||||
struct expand_box_point
|
||||
{
|
||||
template <typename Box, typename Point>
|
||||
static inline void apply(Box& total, Point const& point)
|
||||
{
|
||||
geometry::expand(total, point);
|
||||
}
|
||||
};
|
||||
|
||||
struct expand_box_box_pair
|
||||
{
|
||||
template <typename Box, typename BoxPair>
|
||||
inline void apply(Box& total, BoxPair const& box_pair) const
|
||||
{
|
||||
geometry::expand(total, box_pair.first);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename DisjointPointBoxStrategy>
|
||||
struct overlaps_box_point
|
||||
{
|
||||
template <typename Box, typename Point>
|
||||
static inline bool apply(Box const& box, Point const& point)
|
||||
{
|
||||
// The default strategy is enough for Point/Box
|
||||
return ! detail::disjoint::disjoint_point_box(point, box,
|
||||
DisjointPointBoxStrategy());
|
||||
}
|
||||
};
|
||||
|
||||
template <typename DisjointBoxBoxStrategy>
|
||||
struct overlaps_box_box_pair
|
||||
{
|
||||
template <typename Box, typename BoxPair>
|
||||
inline bool apply(Box const& box, BoxPair const& box_pair) const
|
||||
{
|
||||
// The default strategy is enough for Box/Box
|
||||
return ! detail::disjoint::disjoint_box_box(box_pair.first, box,
|
||||
DisjointBoxBoxStrategy());
|
||||
}
|
||||
};
|
||||
|
||||
template <typename PtSegStrategy>
|
||||
class item_visitor_type
|
||||
{
|
||||
public:
|
||||
item_visitor_type(MultiGeometry const& multi_geometry,
|
||||
PtSegStrategy const& strategy)
|
||||
: m_intersection_found(false)
|
||||
, m_multi_geometry(multi_geometry)
|
||||
, m_strategy(strategy)
|
||||
{}
|
||||
|
||||
template <typename Point, typename BoxPair>
|
||||
inline bool apply(Point const& point, BoxPair const& box_pair)
|
||||
{
|
||||
typedef typename PtSegStrategy::disjoint_point_box_strategy_type d_pb_strategy_type;
|
||||
|
||||
typedef typename boost::range_value<MultiGeometry>::type single_type;
|
||||
|
||||
// The default strategy is enough for Point/Box
|
||||
if (! m_intersection_found
|
||||
&& ! detail::disjoint::disjoint_point_box(point, box_pair.first, d_pb_strategy_type())
|
||||
&& ! dispatch::disjoint<Point, single_type>::apply(point, range::at(m_multi_geometry, box_pair.second), m_strategy))
|
||||
{
|
||||
m_intersection_found = true;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool intersection_found() const { return m_intersection_found; }
|
||||
|
||||
private:
|
||||
bool m_intersection_found;
|
||||
MultiGeometry const& m_multi_geometry;
|
||||
PtSegStrategy const& m_strategy;
|
||||
};
|
||||
// structs for partition -- end
|
||||
|
||||
public:
|
||||
template <typename Strategy>
|
||||
static inline bool apply(MultiPoint const& multi_point, MultiGeometry const& multi_geometry, Strategy const& strategy)
|
||||
{
|
||||
typedef typename point_type<MultiPoint>::type point1_type;
|
||||
typedef typename point_type<MultiGeometry>::type point2_type;
|
||||
typedef model::box<point1_type> box1_type;
|
||||
typedef model::box<point2_type> box2_type;
|
||||
typedef std::pair<box2_type, std::size_t> box_pair_type;
|
||||
|
||||
typename Strategy::envelope_strategy_type const
|
||||
envelope_strategy = strategy.get_envelope_strategy();
|
||||
|
||||
std::size_t count2 = boost::size(multi_geometry);
|
||||
std::vector<box_pair_type> boxes(count2);
|
||||
for (std::size_t i = 0 ; i < count2 ; ++i)
|
||||
{
|
||||
geometry::envelope(range::at(multi_geometry, i), boxes[i].first, envelope_strategy);
|
||||
geometry::detail::expand_by_epsilon(boxes[i].first);
|
||||
boxes[i].second = i;
|
||||
}
|
||||
|
||||
item_visitor_type<Strategy> visitor(multi_geometry, strategy);
|
||||
|
||||
typedef overlaps_box_point
|
||||
<
|
||||
typename Strategy::disjoint_point_box_strategy_type
|
||||
> overlaps_box_point_type;
|
||||
typedef overlaps_box_box_pair
|
||||
<
|
||||
typename Strategy::disjoint_box_box_strategy_type
|
||||
> overlaps_box_box_pair_type;
|
||||
|
||||
geometry::partition
|
||||
<
|
||||
box1_type
|
||||
>::apply(multi_point, boxes, visitor,
|
||||
expand_box_point(),
|
||||
overlaps_box_point_type(),
|
||||
expand_box_box_pair(),
|
||||
overlaps_box_box_pair_type());
|
||||
|
||||
return ! visitor.intersection_found();
|
||||
}
|
||||
|
||||
template <typename Strategy>
|
||||
static inline bool apply(MultiGeometry const& multi_geometry, MultiPoint const& multi_point, Strategy const& strategy)
|
||||
{
|
||||
return apply(multi_point, multi_geometry, strategy);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename MultiPoint, typename Areal, typename Tag = typename tag<Areal>::type>
|
||||
struct multipoint_areal
|
||||
: multi_point_single_geometry<MultiPoint, Areal>
|
||||
{};
|
||||
|
||||
template <typename MultiPoint, typename Areal>
|
||||
struct multipoint_areal<MultiPoint, Areal, multi_polygon_tag>
|
||||
: multi_point_multi_geometry<MultiPoint, Areal>
|
||||
{};
|
||||
|
||||
|
||||
}} // namespace detail::disjoint
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DISPATCH
|
||||
namespace dispatch
|
||||
{
|
||||
|
||||
|
||||
template <typename Point, typename MultiPoint, std::size_t DimensionCount>
|
||||
struct disjoint
|
||||
<
|
||||
Point, MultiPoint, DimensionCount, point_tag, multi_point_tag, false
|
||||
> : detail::disjoint::multirange_constant_size_geometry<MultiPoint, Point>
|
||||
{};
|
||||
|
||||
|
||||
template <typename MultiPoint, typename Segment, std::size_t DimensionCount>
|
||||
struct disjoint
|
||||
<
|
||||
MultiPoint, Segment, DimensionCount, multi_point_tag, segment_tag, false
|
||||
> : detail::disjoint::multirange_constant_size_geometry<MultiPoint, Segment>
|
||||
{};
|
||||
|
||||
|
||||
template <typename MultiPoint, typename Box, std::size_t DimensionCount>
|
||||
struct disjoint
|
||||
<
|
||||
MultiPoint, Box, DimensionCount, multi_point_tag, box_tag, false
|
||||
> : detail::disjoint::multirange_constant_size_geometry<MultiPoint, Box>
|
||||
{};
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
typename MultiPoint1,
|
||||
typename MultiPoint2,
|
||||
std::size_t DimensionCount
|
||||
>
|
||||
struct disjoint
|
||||
<
|
||||
MultiPoint1, MultiPoint2, DimensionCount,
|
||||
multi_point_tag, multi_point_tag, false
|
||||
>
|
||||
{
|
||||
template <typename Strategy>
|
||||
static inline bool apply(MultiPoint1 const& multipoint1,
|
||||
MultiPoint2 const& multipoint2,
|
||||
Strategy const& )
|
||||
{
|
||||
if ( boost::size(multipoint2) < boost::size(multipoint1) )
|
||||
{
|
||||
return detail::disjoint::multipoint_multipoint
|
||||
<
|
||||
MultiPoint2, MultiPoint1
|
||||
>::apply(multipoint2, multipoint1);
|
||||
}
|
||||
|
||||
return detail::disjoint::multipoint_multipoint
|
||||
<
|
||||
MultiPoint1, MultiPoint2
|
||||
>::apply(multipoint1, multipoint2);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename Linear, typename MultiPoint, std::size_t DimensionCount>
|
||||
struct disjoint
|
||||
<
|
||||
Linear, MultiPoint, DimensionCount, linear_tag, multi_point_tag, false
|
||||
> : detail::disjoint::multipoint_linear<MultiPoint, Linear>
|
||||
{};
|
||||
|
||||
|
||||
template <typename MultiPoint, typename Linear, std::size_t DimensionCount>
|
||||
struct disjoint
|
||||
<
|
||||
MultiPoint, Linear, DimensionCount, multi_point_tag, linear_tag, false
|
||||
> : detail::disjoint::multipoint_linear<MultiPoint, Linear>
|
||||
{};
|
||||
|
||||
|
||||
template <typename Areal, typename MultiPoint, std::size_t DimensionCount>
|
||||
struct disjoint
|
||||
<
|
||||
Areal, MultiPoint, DimensionCount, areal_tag, multi_point_tag, false
|
||||
> : detail::disjoint::multipoint_areal<MultiPoint, Areal>
|
||||
{};
|
||||
|
||||
|
||||
template <typename MultiPoint, typename Areal, std::size_t DimensionCount>
|
||||
struct disjoint
|
||||
<
|
||||
MultiPoint, Areal, DimensionCount, multi_point_tag, areal_tag, false
|
||||
> : detail::disjoint::multipoint_areal<MultiPoint, Areal>
|
||||
{};
|
||||
|
||||
|
||||
} // namespace dispatch
|
||||
#endif // DOXYGEN_NO_DISPATCH
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_MULTIPOINT_GEOMETRY_HPP
|
||||
@@ -0,0 +1,94 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2014-2017, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Licensed under the Boost Software License version 1.0.
|
||||
// http://www.boost.org/users/license.html
|
||||
|
||||
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_MULTIRANGE_GEOMETRY_HPP
|
||||
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_MULTIRANGE_GEOMETRY_HPP
|
||||
|
||||
#include <boost/range.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/check_iterator_range.hpp>
|
||||
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace disjoint
|
||||
{
|
||||
|
||||
|
||||
template <typename Geometry, typename Strategy, typename BinaryPredicate>
|
||||
class unary_disjoint_geometry_to_query_geometry
|
||||
{
|
||||
public:
|
||||
unary_disjoint_geometry_to_query_geometry(Geometry const& geometry,
|
||||
Strategy const& strategy)
|
||||
: m_geometry(geometry)
|
||||
, m_strategy(strategy)
|
||||
{}
|
||||
|
||||
template <typename QueryGeometry>
|
||||
inline bool apply(QueryGeometry const& query_geometry) const
|
||||
{
|
||||
return BinaryPredicate::apply(query_geometry, m_geometry, m_strategy);
|
||||
}
|
||||
|
||||
private:
|
||||
Geometry const& m_geometry;
|
||||
Strategy const& m_strategy;
|
||||
};
|
||||
|
||||
|
||||
template<typename MultiRange, typename ConstantSizeGeometry>
|
||||
struct multirange_constant_size_geometry
|
||||
{
|
||||
template <typename Strategy>
|
||||
static inline bool apply(MultiRange const& multirange,
|
||||
ConstantSizeGeometry const& constant_size_geometry,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
typedef unary_disjoint_geometry_to_query_geometry
|
||||
<
|
||||
ConstantSizeGeometry,
|
||||
Strategy,
|
||||
dispatch::disjoint
|
||||
<
|
||||
typename boost::range_value<MultiRange>::type,
|
||||
ConstantSizeGeometry
|
||||
>
|
||||
> unary_predicate_type;
|
||||
|
||||
return detail::check_iterator_range
|
||||
<
|
||||
unary_predicate_type
|
||||
>::apply(boost::begin(multirange), boost::end(multirange),
|
||||
unary_predicate_type(constant_size_geometry, strategy));
|
||||
}
|
||||
|
||||
template <typename Strategy>
|
||||
static inline bool apply(ConstantSizeGeometry const& constant_size_geometry,
|
||||
MultiRange const& multirange,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return apply(multirange, constant_size_geometry, strategy);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}} // namespace detail::disjoint
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_MULTIRANGE_GEOMETRY_HPP
|
||||
@@ -0,0 +1,78 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
|
||||
// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland
|
||||
|
||||
// This file was modified by Oracle on 2013-2018.
|
||||
// Modifications copyright (c) 2013-2018, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
// Contributed and/or modified by Menelaos Karavelas, 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.
|
||||
|
||||
// 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)
|
||||
|
||||
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_POINT_BOX_HPP
|
||||
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_POINT_BOX_HPP
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <boost/geometry/core/access.hpp>
|
||||
#include <boost/geometry/core/coordinate_dimension.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
|
||||
#include <boost/geometry/strategies/disjoint.hpp>
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace disjoint
|
||||
{
|
||||
|
||||
|
||||
/*!
|
||||
\brief Internal utility function to detect if point/box are disjoint
|
||||
*/
|
||||
template <typename Point, typename Box, typename Strategy>
|
||||
inline bool disjoint_point_box(Point const& point, Box const& box, Strategy const& )
|
||||
{
|
||||
// ! covered_by(point, box)
|
||||
return ! Strategy::apply(point, box);
|
||||
}
|
||||
|
||||
|
||||
}} // namespace detail::disjoint
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DISPATCH
|
||||
namespace dispatch
|
||||
{
|
||||
|
||||
|
||||
template <typename Point, typename Box, std::size_t DimensionCount>
|
||||
struct disjoint<Point, Box, DimensionCount, point_tag, box_tag, false>
|
||||
{
|
||||
template <typename Strategy>
|
||||
static inline bool apply(Point const& point, Box const& box, Strategy const& )
|
||||
{
|
||||
// ! covered_by(point, box)
|
||||
return ! Strategy::apply(point, box);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace dispatch
|
||||
#endif // DOXYGEN_NO_DISPATCH
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_POINT_BOX_HPP
|
||||
@@ -0,0 +1,89 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
|
||||
// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2013, 2014, 2015.
|
||||
// Modifications copyright (c) 2013-2015, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
// Contributed and/or modified by Menelaos Karavelas, 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.
|
||||
|
||||
// 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)
|
||||
|
||||
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_POINT_GEOMETRY_HPP
|
||||
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_POINT_GEOMETRY_HPP
|
||||
|
||||
#include <boost/geometry/algorithms/covered_by.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/disjoint/linear_linear.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace disjoint
|
||||
{
|
||||
|
||||
|
||||
struct reverse_covered_by
|
||||
{
|
||||
template <typename Geometry1, typename Geometry2, typename Strategy>
|
||||
static inline bool apply(Geometry1 const& geometry1,
|
||||
Geometry2 const& geometry2,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return ! geometry::covered_by(geometry1, geometry2, strategy);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}} // namespace detail::disjoint
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DISPATCH
|
||||
namespace dispatch
|
||||
{
|
||||
|
||||
|
||||
template<typename Point, typename Linear, std::size_t DimensionCount>
|
||||
struct disjoint<Point, Linear, DimensionCount, point_tag, linear_tag, false>
|
||||
: detail::disjoint::reverse_covered_by
|
||||
{};
|
||||
|
||||
|
||||
template <typename Point, typename Areal, std::size_t DimensionCount>
|
||||
struct disjoint<Point, Areal, DimensionCount, point_tag, areal_tag, false>
|
||||
: detail::disjoint::reverse_covered_by
|
||||
{};
|
||||
|
||||
|
||||
template<typename Point, typename Segment, std::size_t DimensionCount>
|
||||
struct disjoint<Point, Segment, DimensionCount, point_tag, segment_tag, false>
|
||||
: detail::disjoint::reverse_covered_by
|
||||
{};
|
||||
|
||||
|
||||
} // namespace dispatch
|
||||
#endif // DOXYGEN_NO_DISPATCH
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_POINT_GEOMETRY_HPP
|
||||
@@ -0,0 +1,83 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
|
||||
// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland
|
||||
|
||||
// This file was modified by Oracle on 2013, 2014, 2015, 2017, 2018.
|
||||
// Modifications copyright (c) 2013-2018, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
// Contributed and/or modified by Menelaos Karavelas, 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.
|
||||
|
||||
// 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)
|
||||
|
||||
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_POINT_POINT_HPP
|
||||
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_POINT_POINT_HPP
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
|
||||
|
||||
// For backward compatibility
|
||||
#include <boost/geometry/strategies/disjoint.hpp>
|
||||
#include <boost/geometry/strategies/cartesian/point_in_point.hpp>
|
||||
#include <boost/geometry/strategies/spherical/point_in_point.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace disjoint
|
||||
{
|
||||
|
||||
|
||||
/*!
|
||||
\brief Internal utility function to detect of points are disjoint
|
||||
\note To avoid circular references
|
||||
*/
|
||||
template <typename Point1, typename Point2, typename Strategy>
|
||||
inline bool disjoint_point_point(Point1 const& point1, Point2 const& point2,
|
||||
Strategy const& )
|
||||
{
|
||||
return ! Strategy::apply(point1, point2);
|
||||
}
|
||||
|
||||
|
||||
}} // namespace detail::disjoint
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DISPATCH
|
||||
namespace dispatch
|
||||
{
|
||||
|
||||
|
||||
template <typename Point1, typename Point2, std::size_t DimensionCount>
|
||||
struct disjoint<Point1, Point2, DimensionCount, point_tag, point_tag, false>
|
||||
{
|
||||
template <typename Strategy>
|
||||
static inline bool apply(Point1 const& point1, Point2 const& point2,
|
||||
Strategy const& )
|
||||
{
|
||||
return ! Strategy::apply(point1, point2);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace dispatch
|
||||
#endif // DOXYGEN_NO_DISPATCH
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_POINT_POINT_HPP
|
||||
@@ -0,0 +1,276 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
|
||||
// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2013-2019.
|
||||
// Modifications copyright (c) 2013-2019, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
// 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.
|
||||
|
||||
// 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)
|
||||
|
||||
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_SEGMENT_BOX_HPP
|
||||
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_SEGMENT_BOX_HPP
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
#include <boost/geometry/core/radian_access.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/assign_indexed_point.hpp>
|
||||
#include <boost/geometry/algorithms/detail/disjoint/point_box.hpp>
|
||||
#include <boost/geometry/algorithms/detail/disjoint/box_box.hpp>
|
||||
#include <boost/geometry/algorithms/detail/envelope/segment.hpp>
|
||||
#include <boost/geometry/algorithms/detail/normalize.hpp>
|
||||
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
|
||||
#include <boost/geometry/algorithms/envelope.hpp>
|
||||
|
||||
#include <boost/geometry/formulas/vertex_longitude.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/box.hpp>
|
||||
|
||||
// Temporary, for envelope_segment_impl
|
||||
#include <boost/geometry/strategies/spherical/envelope_segment.hpp>
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace disjoint
|
||||
{
|
||||
|
||||
template <typename CS_Tag>
|
||||
struct disjoint_segment_box_sphere_or_spheroid
|
||||
{
|
||||
struct disjoint_info
|
||||
{
|
||||
enum type
|
||||
{
|
||||
intersect,
|
||||
disjoint_no_vertex,
|
||||
disjoint_vertex
|
||||
};
|
||||
disjoint_info(type t) : m_(t){}
|
||||
operator type () const {return m_;}
|
||||
type m_;
|
||||
private :
|
||||
//prevent automatic conversion for any other built-in types
|
||||
template <typename T>
|
||||
operator T () const;
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename Segment, typename Box,
|
||||
typename AzimuthStrategy,
|
||||
typename NormalizeStrategy,
|
||||
typename DisjointPointBoxStrategy,
|
||||
typename DisjointBoxBoxStrategy
|
||||
>
|
||||
static inline bool apply(Segment const& segment,
|
||||
Box const& box,
|
||||
AzimuthStrategy const& azimuth_strategy,
|
||||
NormalizeStrategy const& normalize_strategy,
|
||||
DisjointPointBoxStrategy const& disjoint_point_box_strategy,
|
||||
DisjointBoxBoxStrategy const& disjoint_box_box_strategy)
|
||||
{
|
||||
typedef typename point_type<Segment>::type segment_point;
|
||||
segment_point vertex;
|
||||
return apply(segment, box, vertex,
|
||||
azimuth_strategy,
|
||||
normalize_strategy,
|
||||
disjoint_point_box_strategy,
|
||||
disjoint_box_box_strategy) != disjoint_info::intersect;
|
||||
}
|
||||
|
||||
template
|
||||
<
|
||||
typename Segment, typename Box,
|
||||
typename P,
|
||||
typename AzimuthStrategy,
|
||||
typename NormalizeStrategy,
|
||||
typename DisjointPointBoxStrategy,
|
||||
typename DisjointBoxBoxStrategy
|
||||
>
|
||||
static inline disjoint_info apply(Segment const& segment,
|
||||
Box const& box,
|
||||
P& vertex,
|
||||
AzimuthStrategy const& azimuth_strategy,
|
||||
NormalizeStrategy const& ,
|
||||
DisjointPointBoxStrategy const& disjoint_point_box_strategy,
|
||||
DisjointBoxBoxStrategy const& disjoint_box_box_strategy)
|
||||
{
|
||||
assert_dimension_equal<Segment, Box>();
|
||||
|
||||
typedef typename point_type<Segment>::type segment_point_type;
|
||||
|
||||
segment_point_type p0, p1;
|
||||
geometry::detail::assign_point_from_index<0>(segment, p0);
|
||||
geometry::detail::assign_point_from_index<1>(segment, p1);
|
||||
|
||||
//vertex not computed here
|
||||
disjoint_info disjoint_return_value = disjoint_info::disjoint_no_vertex;
|
||||
|
||||
// Simplest cases first
|
||||
|
||||
// Case 1: if box contains one of segment's endpoints then they are not disjoint
|
||||
if ( ! disjoint_point_box(p0, box, disjoint_point_box_strategy)
|
||||
|| ! disjoint_point_box(p1, box, disjoint_point_box_strategy) )
|
||||
{
|
||||
return disjoint_info::intersect;
|
||||
}
|
||||
|
||||
// Case 2: disjoint if bounding boxes are disjoint
|
||||
|
||||
typedef typename coordinate_type<segment_point_type>::type CT;
|
||||
|
||||
segment_point_type p0_normalized;
|
||||
NormalizeStrategy::apply(p0, p0_normalized);
|
||||
segment_point_type p1_normalized;
|
||||
NormalizeStrategy::apply(p1, p1_normalized);
|
||||
|
||||
CT lon1 = geometry::get_as_radian<0>(p0_normalized);
|
||||
CT lat1 = geometry::get_as_radian<1>(p0_normalized);
|
||||
CT lon2 = geometry::get_as_radian<0>(p1_normalized);
|
||||
CT lat2 = geometry::get_as_radian<1>(p1_normalized);
|
||||
|
||||
if (lon1 > lon2)
|
||||
{
|
||||
std::swap(lon1, lon2);
|
||||
std::swap(lat1, lat2);
|
||||
}
|
||||
|
||||
geometry::model::box<segment_point_type> box_seg;
|
||||
|
||||
strategy::envelope::detail::envelope_segment_impl
|
||||
<
|
||||
CS_Tag
|
||||
>::template apply<geometry::radian>(lon1, lat1,
|
||||
lon2, lat2,
|
||||
box_seg,
|
||||
azimuth_strategy);
|
||||
|
||||
if (disjoint_box_box(box, box_seg, disjoint_box_box_strategy))
|
||||
{
|
||||
return disjoint_return_value;
|
||||
}
|
||||
|
||||
// Case 3: test intersection by comparing angles
|
||||
|
||||
CT alp1, a_b0, a_b1, a_b2, a_b3;
|
||||
|
||||
CT b_lon_min = geometry::get_as_radian<geometry::min_corner, 0>(box);
|
||||
CT b_lat_min = geometry::get_as_radian<geometry::min_corner, 1>(box);
|
||||
CT b_lon_max = geometry::get_as_radian<geometry::max_corner, 0>(box);
|
||||
CT b_lat_max = geometry::get_as_radian<geometry::max_corner, 1>(box);
|
||||
|
||||
azimuth_strategy.apply(lon1, lat1, lon2, lat2, alp1);
|
||||
azimuth_strategy.apply(lon1, lat1, b_lon_min, b_lat_min, a_b0);
|
||||
azimuth_strategy.apply(lon1, lat1, b_lon_max, b_lat_min, a_b1);
|
||||
azimuth_strategy.apply(lon1, lat1, b_lon_min, b_lat_max, a_b2);
|
||||
azimuth_strategy.apply(lon1, lat1, b_lon_max, b_lat_max, a_b3);
|
||||
|
||||
bool b0 = formula::azimuth_side_value(alp1, a_b0) > 0;
|
||||
bool b1 = formula::azimuth_side_value(alp1, a_b1) > 0;
|
||||
bool b2 = formula::azimuth_side_value(alp1, a_b2) > 0;
|
||||
bool b3 = formula::azimuth_side_value(alp1, a_b3) > 0;
|
||||
|
||||
if (!(b0 && b1 && b2 && b3) && (b0 || b1 || b2 || b3))
|
||||
{
|
||||
return disjoint_info::intersect;
|
||||
}
|
||||
|
||||
// Case 4: The only intersection case not covered above is when all four
|
||||
// points of the box are above (below) the segment in northern (southern)
|
||||
// hemisphere. Then we have to compute the vertex of the segment
|
||||
|
||||
CT vertex_lat;
|
||||
CT lat_sum = lat1 + lat2;
|
||||
|
||||
if ((lat1 < b_lat_min && lat_sum > CT(0))
|
||||
|| (lat1 > b_lat_max && lat_sum < CT(0)))
|
||||
{
|
||||
CT b_lat_below; //latitude of box closest to equator
|
||||
|
||||
if (lat_sum > CT(0))
|
||||
{
|
||||
vertex_lat = geometry::get_as_radian<geometry::max_corner, 1>(box_seg);
|
||||
b_lat_below = b_lat_min;
|
||||
} else {
|
||||
vertex_lat = geometry::get_as_radian<geometry::min_corner, 1>(box_seg);
|
||||
b_lat_below = b_lat_max;
|
||||
}
|
||||
|
||||
//optimization TODO: computing the spherical longitude should suffice for
|
||||
// the majority of cases
|
||||
CT vertex_lon = geometry::formula::vertex_longitude<CT, CS_Tag>
|
||||
::apply(lon1, lat1,
|
||||
lon2, lat2,
|
||||
vertex_lat,
|
||||
alp1,
|
||||
azimuth_strategy);
|
||||
|
||||
geometry::set_from_radian<0>(vertex, vertex_lon);
|
||||
geometry::set_from_radian<1>(vertex, vertex_lat);
|
||||
disjoint_return_value = disjoint_info::disjoint_vertex; //vertex_computed
|
||||
|
||||
// Check if the vertex point is within the band defined by the
|
||||
// minimum and maximum longitude of the box; if yes, then return
|
||||
// false if the point is above the min latitude of the box; return
|
||||
// true in all other cases
|
||||
if (vertex_lon >= b_lon_min && vertex_lon <= b_lon_max
|
||||
&& std::abs(vertex_lat) > std::abs(b_lat_below))
|
||||
{
|
||||
return disjoint_info::intersect;
|
||||
}
|
||||
}
|
||||
|
||||
return disjoint_return_value;
|
||||
}
|
||||
};
|
||||
|
||||
struct disjoint_segment_box
|
||||
{
|
||||
template <typename Segment, typename Box, typename Strategy>
|
||||
static inline bool apply(Segment const& segment,
|
||||
Box const& box,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return strategy.apply(segment, box);
|
||||
}
|
||||
};
|
||||
|
||||
}} // namespace detail::disjoint
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DISPATCH
|
||||
namespace dispatch
|
||||
{
|
||||
|
||||
|
||||
template <typename Segment, typename Box, std::size_t DimensionCount>
|
||||
struct disjoint<Segment, Box, DimensionCount, segment_tag, box_tag, false>
|
||||
: detail::disjoint::disjoint_segment_box
|
||||
{};
|
||||
|
||||
|
||||
} // namespace dispatch
|
||||
#endif // DOXYGEN_NO_DISPATCH
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_SEGMENT_BOX_HPP
|
||||
Reference in New Issue
Block a user