From 73dc6dbed54cf9284da047a1407a55029d4c3c4e Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 10 Oct 2019 18:27:23 +0200 Subject: [PATCH] [algorithms] Implement relops for arguments always resulting in false. --- .../detail/equals/implementation.hpp | 88 +++++++++++++++---- .../algorithms/detail/equals/interface.hpp | 12 ++- .../algorithms/detail/relate/de9im.hpp | 29 +++--- .../algorithms/detail/relate/relate_impl.hpp | 70 ++++++++++----- .../algorithms/detail/relate/result.hpp | 8 +- .../detail/touches/implementation.hpp | 26 ++++-- 6 files changed, 167 insertions(+), 66 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/equals/implementation.hpp b/include/boost/geometry/algorithms/detail/equals/implementation.hpp index f39ae0b8b..4088478d5 100644 --- a/include/boost/geometry/algorithms/detail/equals/implementation.hpp +++ b/include/boost/geometry/algorithms/detail/equals/implementation.hpp @@ -5,8 +5,8 @@ // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. // Copyright (c) 2014-2015 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2014, 2015, 2016, 2017, 2018. -// Modifications copyright (c) 2014-2018 Oracle and/or its affiliates. +// This file was modified by Oracle on 2014, 2015, 2016, 2017, 2018, 2019. +// Modifications copyright (c) 2014-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 @@ -275,6 +275,15 @@ private: } }; +struct equals_always_false +{ + template + static inline bool apply(Geometry1 const& , Geometry2 const& , Strategy const& ) + { + return false; + } +}; + }} // namespace detail::equals #endif // DOXYGEN_NO_DETAIL @@ -285,81 +294,92 @@ namespace dispatch { template -struct equals +struct equals : detail::equals::point_point<0, DimensionCount> {}; template -struct equals +struct equals : detail::equals::equals_by_relate {}; template -struct equals +struct equals : detail::equals::equals_by_relate {}; template -struct equals +struct equals : detail::equals::box_box<0, DimensionCount> {}; template -struct equals +struct equals : detail::equals::equals_by_collection_or_relate {}; template -struct equals +struct equals : detail::equals::equals_by_collection_or_relate {}; template -struct equals +struct equals : detail::equals::equals_by_collection_or_relate {}; template -struct equals +struct equals : detail::equals::equals_by_collection {}; template -struct equals +struct equals : detail::equals::equals_by_collection {}; template -struct equals +struct equals : detail::equals::segment_segment {}; template -struct equals +struct equals : detail::equals::equals_by_relate {}; template -struct equals +struct equals : detail::equals::equals_by_relate {}; template -struct equals +struct equals : detail::equals::equals_by_relate {}; +template +struct equals + : detail::equals::equals_by_relate +{}; + +template +struct equals + : detail::equals::equals_by_relate +{}; + template struct equals < MultiPolygon1, MultiPolygon2, multi_polygon_tag, multi_polygon_tag, + areal_tag, areal_tag, 2, Reverse > @@ -372,6 +392,7 @@ struct equals < Polygon, MultiPolygon, polygon_tag, multi_polygon_tag, + areal_tag, areal_tag, 2, Reverse > @@ -383,6 +404,7 @@ struct equals < MultiPolygon, Ring, multi_polygon_tag, ring_tag, + areal_tag, areal_tag, 2, Reverse > @@ -390,6 +412,42 @@ struct equals {}; +// NOTE: degenerated linear geometries, e.g. segment or linestring containing +// 2 equal points, are considered to be invalid. Though theoretically +// degenerated segments and linestrings could be treated as points and +// multi-linestrings as multi-points. +// This reasoning could also be applied to boxes. + +template +struct equals + : detail::equals::equals_always_false +{}; + +template +struct equals + : detail::equals::equals_always_false +{}; + +template +struct equals + : detail::equals::equals_always_false +{}; + +template +struct equals + : detail::equals::equals_always_false +{}; + +template +struct equals + : detail::equals::equals_always_false +{}; + +template +struct equals + : detail::equals::equals_always_false +{}; + } // namespace dispatch #endif // DOXYGEN_NO_DISPATCH diff --git a/include/boost/geometry/algorithms/detail/equals/interface.hpp b/include/boost/geometry/algorithms/detail/equals/interface.hpp index eacf95e9f..1e4918836 100644 --- a/include/boost/geometry/algorithms/detail/equals/interface.hpp +++ b/include/boost/geometry/algorithms/detail/equals/interface.hpp @@ -5,8 +5,8 @@ // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. // Copyright (c) 2014-2015 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2014, 2015, 2016, 2017. -// Modifications copyright (c) 2014-2017 Oracle and/or its affiliates. +// This file was modified by Oracle on 2014, 2015, 2016, 2017, 2019. +// Modifications copyright (c) 2014-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 @@ -52,6 +52,8 @@ template typename Geometry2, typename Tag1 = typename tag::type, typename Tag2 = typename tag::type, + typename CastedTag1 = typename tag_cast::type, + typename CastedTag2 = typename tag_cast::type, std::size_t DimensionCount = dimension::type::value, bool Reverse = reverse_dispatch::type::value > @@ -64,10 +66,11 @@ template < typename Geometry1, typename Geometry2, typename Tag1, typename Tag2, + typename CastedTag1, typename CastedTag2, std::size_t DimensionCount > -struct equals - : equals +struct equals + : equals { template static inline bool apply(Geometry1 const& g1, Geometry2 const& g2, Strategy const& strategy) @@ -76,6 +79,7 @@ struct equals < Geometry2, Geometry1, Tag2, Tag1, + CastedTag2, CastedTag1, DimensionCount, false >::apply(g2, g1, strategy); diff --git a/include/boost/geometry/algorithms/detail/relate/de9im.hpp b/include/boost/geometry/algorithms/detail/relate/de9im.hpp index 713a3fc8f..be745bfda 100644 --- a/include/boost/geometry/algorithms/detail/relate/de9im.hpp +++ b/include/boost/geometry/algorithms/detail/relate/de9im.hpp @@ -2,8 +2,8 @@ // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2013, 2014, 2015. -// Modifications copyright (c) 2013-2015 Oracle and/or its affiliates. +// This file was modified by Oracle on 2013, 2014, 2015, 2019. +// Modifications copyright (c) 2013-2019 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -22,7 +22,6 @@ #include #include -#include #include #include @@ -318,9 +317,9 @@ struct static_mask_touches_impl // Using the above mask the result would be always false template struct static_mask_touches_impl - : not_implemented::type, - typename geometry::tag::type> -{}; +{ + typedef geometry::detail::relate::false_mask type; +}; template struct static_mask_touches_type @@ -377,12 +376,9 @@ template typename Geometry1, typename Geometry2, std::size_t Dim > struct static_mask_crosses_impl - : not_implemented - < - typename geometry::tag::type, - typename geometry::tag::type - > -{}; +{ + typedef geometry::detail::relate::false_mask type; +}; // dim(G1) == 1 && dim(G2) == 1 - L/L template struct static_mask_crosses_impl @@ -406,12 +402,9 @@ template std::size_t Dim2 = geometry::topological_dimension::value > struct static_mask_overlaps_impl - : not_implemented - < - typename geometry::tag::type, - typename geometry::tag::type - > -{}; +{ + typedef geometry::detail::relate::false_mask type; +}; // dim(G1) == D && dim(G2) == D - P/P A/A template struct static_mask_overlaps_impl diff --git a/include/boost/geometry/algorithms/detail/relate/relate_impl.hpp b/include/boost/geometry/algorithms/detail/relate/relate_impl.hpp index 2ec2361c0..ae963c4b0 100644 --- a/include/boost/geometry/algorithms/detail/relate/relate_impl.hpp +++ b/include/boost/geometry/algorithms/detail/relate/relate_impl.hpp @@ -2,8 +2,8 @@ // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2013, 2014, 2015. -// Modifications copyright (c) 2013-2015 Oracle and/or its affiliates. +// This file was modified by Oracle on 2013, 2014, 2015, 2019. +// Modifications copyright (c) 2013-2019 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -30,25 +30,19 @@ namespace detail { namespace relate { struct implemented_tag {}; -template