mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-11 13:34:10 +00:00
[touches][relate] Replace use_relate with relate_base<> for automatic support generation. Also implement static_mask_touches_type<> as 2 parameter template.
This commit is contained in:
parent
bdacc633aa
commit
f9c51246c2
@ -1131,7 +1131,7 @@ template <typename Geometry1,
|
||||
typename Geometry2,
|
||||
std::size_t Dim1 = topological_dimension<Geometry1>::value,
|
||||
std::size_t Dim2 = topological_dimension<Geometry2>::value>
|
||||
struct static_mask_touches_type
|
||||
struct static_mask_touches_impl
|
||||
{
|
||||
typedef boost::mpl::vector<
|
||||
static_mask<'F', 'T', '*', '*', '*', '*', '*', '*', '*'>,
|
||||
@ -1142,11 +1142,16 @@ struct static_mask_touches_type
|
||||
// According to OGC, doesn't apply to P/P
|
||||
// Using the above mask the result would be always false
|
||||
template <typename Geometry1, typename Geometry2>
|
||||
struct static_mask_touches_type<Geometry1, Geometry2, 0, 0>
|
||||
struct static_mask_touches_impl<Geometry1, Geometry2, 0, 0>
|
||||
: not_implemented<typename geometry::tag<Geometry1>::type,
|
||||
typename geometry::tag<Geometry2>::type>
|
||||
{};
|
||||
|
||||
template <typename Geometry1, typename Geometry2>
|
||||
struct static_mask_touches_type
|
||||
: static_mask_touches_impl<Geometry1, Geometry2>
|
||||
{};
|
||||
|
||||
// WITHIN
|
||||
typedef static_mask<'T', '*', 'F', '*', '*', 'F', '*', '*', '*'> static_mask_within;
|
||||
|
||||
|
@ -193,22 +193,6 @@ struct use_point_in_geometry
|
||||
}
|
||||
};
|
||||
|
||||
struct use_relate
|
||||
{
|
||||
template <typename Geometry1, typename Geometry2>
|
||||
static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2)
|
||||
{
|
||||
typedef typename
|
||||
detail::relate::static_mask_touches_type
|
||||
<
|
||||
Geometry1,
|
||||
Geometry2
|
||||
>::type static_mask;
|
||||
|
||||
return detail::relate::relate<static_mask>(geometry1, geometry2);
|
||||
}
|
||||
};
|
||||
|
||||
}}
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
@ -226,7 +210,8 @@ template
|
||||
typename CastedTag2 = typename tag_cast<Tag2, pointlike_tag, linear_tag, areal_tag>::type,
|
||||
bool Reverse = reverse_dispatch<Geometry1, Geometry2>::type::value
|
||||
>
|
||||
struct touches : not_implemented<Tag1, Tag2>
|
||||
struct touches
|
||||
: not_implemented<Tag1, Tag2>
|
||||
{};
|
||||
|
||||
// If reversal is needed, perform it
|
||||
@ -269,19 +254,35 @@ struct touches<Point, Geometry, point_tag, Tag2, pointlike_tag, CastedTag2, fals
|
||||
|
||||
template <typename Linear1, typename Linear2, typename Tag1, typename Tag2>
|
||||
struct touches<Linear1, Linear2, Tag1, Tag2, linear_tag, linear_tag, false>
|
||||
: detail::touches::use_relate
|
||||
: detail::relate::relate_base
|
||||
<
|
||||
detail::relate::static_mask_touches_type,
|
||||
Linear1,
|
||||
Linear2
|
||||
>
|
||||
{};
|
||||
|
||||
// L/A
|
||||
|
||||
template <typename Linear1, typename Linear2, typename Tag1, typename Tag2>
|
||||
struct touches<Linear1, Linear2, Tag1, Tag2, linear_tag, areal_tag, true>
|
||||
: detail::touches::use_relate
|
||||
template <typename Linear, typename Areal, typename Tag1, typename Tag2>
|
||||
struct touches<Linear, Areal, Tag1, Tag2, linear_tag, areal_tag, false>
|
||||
: detail::relate::relate_base
|
||||
<
|
||||
detail::relate::static_mask_touches_type,
|
||||
Linear,
|
||||
Areal
|
||||
>
|
||||
{};
|
||||
|
||||
template <typename Linear1, typename Linear2, typename Tag1, typename Tag2>
|
||||
struct touches<Linear1, Linear2, Tag1, Tag2, linear_tag, areal_tag, false>
|
||||
: detail::touches::use_relate
|
||||
// A/L
|
||||
template <typename Linear, typename Areal, typename Tag1, typename Tag2>
|
||||
struct touches<Linear, Areal, Tag1, Tag2, linear_tag, areal_tag, true>
|
||||
: detail::relate::relate_base
|
||||
<
|
||||
detail::relate::static_mask_touches_type,
|
||||
Areal,
|
||||
Linear
|
||||
>
|
||||
{};
|
||||
|
||||
// A/A
|
||||
|
@ -20,6 +20,7 @@
|
||||
template <typename P>
|
||||
void test_all()
|
||||
{
|
||||
typedef bg::model::box<P> box;
|
||||
typedef bg::model::ring<P> ring;
|
||||
typedef bg::model::polygon<P> polygon;
|
||||
typedef bg::model::linestring<P> linestring;
|
||||
@ -199,6 +200,10 @@ void test_all()
|
||||
test_touches<linestring, mpolygon>("LINESTRING(-1 -1,3 3)", "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(0 0,9 1,9 9,1 9,0 0)))", true);
|
||||
|
||||
test_touches<mlinestring, mpolygon>("MULTILINESTRING((0 0,11 11))", "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(0 0,9 1,9 9,1 9,0 0)))", false);
|
||||
|
||||
//test_touches<box, box>("POLYGON((0 0,0 5,5 5,5 0,0 0))", "POLYGON((5 1,5 2,6 2,6 1,5 1))", true);
|
||||
//test_touches<box, box>("POLYGON((0 0,0 5,5 5,5 0,0 0))", "POLYGON((4 1,4 2,5 2,5 1,4 1))", false);
|
||||
//test_touches<box, box>("POLYGON((0 0,0 5,5 5,5 0,0 0))", "POLYGON((4 1,4 2,6 2,6 1,4 1))", false);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user