[within] Add support for GC

This commit is contained in:
Adam Wulkiewicz
2022-06-08 21:57:51 +02:00
parent fc6ddc9dee
commit ceec0d938b
4 changed files with 81 additions and 104 deletions

View File

@@ -23,15 +23,12 @@
#include <cstddef>
#include <boost/variant/apply_visitor.hpp>
#include <boost/variant/static_visitor.hpp>
#include <boost/variant/variant_fwd.hpp>
#include <boost/geometry/core/coordinate_dimension.hpp>
#include <boost/geometry/core/reverse_dispatch.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tag_cast.hpp>
#include <boost/geometry/geometries/adapted/boost_variant.hpp>
#include <boost/geometry/geometries/concepts/check.hpp>
#include <boost/geometry/algorithms/not_implemented.hpp>

View File

@@ -166,6 +166,7 @@ struct relate<Geometry1, Geometry2, geometry_collection_tag, geometry_collection
{
inters_found[0][1] = true;
inters_found[1][1] = true;
// ERROR: This is wrong and will create an additional boundary
mls2_t mls2_diff_mpo1;
geometry::difference(boost::get<1>(tuple2), boost::get<2>(tuple1), mls2_diff_mpo1);
mls1_t mls1_diff_mpo2;
@@ -191,6 +192,7 @@ struct relate<Geometry1, Geometry2, geometry_collection_tag, geometry_collection
inters_found[1][1] = true;
if (is_ll_handled)
{
// ERROR: This is wrong and will create an additional boundary
mls1_t mls2_inters_mpo1;
geometry::intersection(boost::get<1>(tuple2), boost::get<2>(tuple1), mls2_inters_mpo1);
if (! geometry::is_empty(mls2_inters_mpo1))
@@ -217,6 +219,7 @@ struct relate<Geometry1, Geometry2, geometry_collection_tag, geometry_collection
inters_found[1][2] = true;
if (is_ll_handled)
{
// ERROR: This is wrong and will create an additional boundary
mls1_t mls1_inters_mpo2;
geometry::intersection(boost::get<1>(tuple1), boost::get<2>(tuple2), mls1_inters_mpo2);
if (! geometry::is_empty(mls1_inters_mpo2))

View File

@@ -30,6 +30,8 @@
#include <boost/geometry/algorithms/detail/within/multi_point.hpp>
#include <boost/geometry/algorithms/detail/within/point_in_geometry.hpp>
#include <boost/geometry/algorithms/detail/relate/implementation.hpp>
#include <boost/geometry/algorithms/detail/relate/implementation_gc.hpp>
#include <boost/geometry/algorithms/detail/relate/relate_impl.hpp>
#include <boost/geometry/core/access.hpp>
#include <boost/geometry/core/closure.hpp>
@@ -68,11 +70,12 @@ struct use_relate
template <typename Geometry1, typename Geometry2, typename Strategy>
static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy)
{
typedef typename detail::de9im::static_mask_within_type
return detail::relate::relate_impl
<
Geometry1, Geometry2
>::type within_mask;
return geometry::relate(geometry1, geometry2, within_mask(), strategy);
detail::de9im::static_mask_within_type,
Geometry1,
Geometry2
>::apply(geometry1, geometry2, strategy);
}
};
@@ -291,6 +294,21 @@ struct within<MultiPolygon1, MultiPolygon2, multi_polygon_tag, multi_polygon_tag
: public detail::within::use_relate
{};
template <typename Geometry1, typename Geometry2>
struct within<Geometry1, Geometry2, geometry_collection_tag, geometry_collection_tag>
: detail::within::use_relate
{};
template <typename Geometry1, typename Geometry2, typename Tag1>
struct within<Geometry1, Geometry2, Tag1, geometry_collection_tag>
: detail::within::use_relate
{};
template <typename Geometry1, typename Geometry2, typename Tag2>
struct within<Geometry1, Geometry2, geometry_collection_tag, Tag2>
: detail::within::use_relate
{};
} // namespace dispatch
#endif // DOXYGEN_NO_DISPATCH

View File

@@ -4,8 +4,8 @@
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
// This file was modified by Oracle on 2013-2021.
// Modifications copyright (c) 2013-2021 Oracle and/or its affiliates.
// This file was modified by Oracle on 2013-2022.
// Modifications copyright (c) 2013-2022 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
@@ -21,16 +21,14 @@
#include <boost/concept_check.hpp>
#include <boost/variant/apply_visitor.hpp>
#include <boost/variant/static_visitor.hpp>
#include <boost/variant/variant_fwd.hpp>
#include <boost/geometry/algorithms/not_implemented.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tag_cast.hpp>
#include <boost/geometry/geometries/adapted/boost_variant.hpp>
#include <boost/geometry/geometries/concepts/check.hpp>
#include <boost/geometry/strategies/concepts/within_concept.hpp>
#include <boost/geometry/strategies/default_strategy.hpp>
#include <boost/geometry/strategies/detail.hpp>
@@ -126,10 +124,15 @@ struct within<default_strategy, false>
} // namespace resolve_strategy
namespace resolve_variant
namespace resolve_dynamic
{
template <typename Geometry1, typename Geometry2>
template
<
typename Geometry1, typename Geometry2,
typename Tag1 = typename geometry::tag<Geometry1>::type,
typename Tag2 = typename geometry::tag<Geometry2>::type
>
struct within
{
template <typename Strategy>
@@ -148,110 +151,66 @@ struct within
}
};
template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Geometry2>
struct within<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Geometry2>
template <typename Geometry1, typename Geometry2, typename Tag2>
struct within<Geometry1, Geometry2, dynamic_geometry_tag, Tag2>
{
template <typename Strategy>
struct visitor: boost::static_visitor<bool>
static inline bool apply(Geometry1 const& geometry1,
Geometry2 const& geometry2,
Strategy const& strategy)
{
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
bool result = false;
traits::visit<Geometry1>::apply([&](auto const& g1)
{
return within<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);
result = within
<
util::remove_cref_t<decltype(g1)>,
Geometry2
>::apply(g1, geometry2, strategy);
}, geometry1);
return result;
}
};
template <typename Geometry1, BOOST_VARIANT_ENUM_PARAMS(typename T)>
struct within<Geometry1, boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
template <typename Geometry1, typename Geometry2, typename Tag1>
struct within<Geometry1, Geometry2, Tag1, dynamic_geometry_tag>
{
template <typename Strategy>
struct visitor: boost::static_visitor<bool>
static inline bool apply(Geometry1 const& geometry1,
Geometry2 const& geometry2,
Strategy const& strategy)
{
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
bool result = false;
traits::visit<Geometry2>::apply([&](auto const& g2)
{
return within<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
);
result = within
<
Geometry1,
util::remove_cref_t<decltype(g2)>
>::apply(geometry1, g2, strategy);
}, geometry2);
return result;
}
};
template <
BOOST_VARIANT_ENUM_PARAMS(typename T1),
BOOST_VARIANT_ENUM_PARAMS(typename T2)
>
struct within<
boost::variant<BOOST_VARIANT_ENUM_PARAMS(T1)>,
boost::variant<BOOST_VARIANT_ENUM_PARAMS(T2)>
>
template <typename Geometry1, typename Geometry2>
struct within<Geometry1, Geometry2, dynamic_geometry_tag, dynamic_geometry_tag>
{
template <typename Strategy>
struct visitor: boost::static_visitor<bool>
static inline bool apply(Geometry1 const& geometry1,
Geometry2 const& geometry2,
Strategy const& strategy)
{
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
bool result = false;
traits::visit<Geometry1, Geometry2>::apply([&](auto const& g1, auto const& g2)
{
return within<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);
result = within
<
util::remove_cref_t<decltype(g1)>,
util::remove_cref_t<decltype(g2)>
>::apply(g1, g2, strategy);
}, geometry1, geometry2);
return result;
}
};
@@ -282,7 +241,7 @@ struct within<
template<typename Geometry1, typename Geometry2>
inline bool within(Geometry1 const& geometry1, Geometry2 const& geometry2)
{
return resolve_variant::within
return resolve_dynamic::within
<
Geometry1,
Geometry2
@@ -320,7 +279,7 @@ inline bool within(Geometry1 const& geometry1,
Geometry2 const& geometry2,
Strategy const& strategy)
{
return resolve_variant::within
return resolve_dynamic::within
<
Geometry1,
Geometry2