/usr/include/boost/geometry/algorithms/detail/equals
Edit: /usr/include/boost/geometry/algorithms/detail/equals/implementation.hpp (16244B)
// 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) 2014-2015 Adam Wulkiewicz, Lodz, Poland.
// 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
// 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_EQUALS_IMPLEMENTATION_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_EQUALS_IMPLEMENTATION_HPP
#include
#include
#include
#include
#include
#include
#include
// For trivial checks
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace equals
{
template
<
std::size_t Dimension,
std::size_t DimensionCount
>
struct point_point
{
template
static inline bool apply(Point1 const& point1, Point2 const& point2, Strategy const& )
{
return Strategy::apply(point1, point2);
}
};
template
<
std::size_t Dimension,
std::size_t DimensionCount
>
struct box_box
{
template
static inline bool apply(Box1 const& box1, Box2 const& box2, Strategy const& strategy)
{
if (!geometry::math::equals(get(box1), get(box2))
|| !geometry::math::equals(get(box1), get(box2)))
{
return false;
}
return box_box::apply(box1, box2, strategy);
}
};
template
struct box_box
{
template
static inline bool apply(Box1 const& , Box2 const& , Strategy const& )
{
return true;
}
};
struct segment_segment
{
template
static inline bool apply(Segment1 const& segment1, Segment2 const& segment2,
Strategy const& strategy)
{
typename Strategy::point_in_point_strategy_type const&
pt_pt_strategy = strategy.get_point_in_point_strategy();
return equals::equals_point_point(
indexed_point_view(segment1),
indexed_point_view(segment2),
pt_pt_strategy)
? equals::equals_point_point(
indexed_point_view(segment1),
indexed_point_view(segment2),
pt_pt_strategy)
: ( equals::equals_point_point(
indexed_point_view(segment1),
indexed_point_view(segment2),
pt_pt_strategy)
&& equals::equals_point_point(
indexed_point_view(segment1),
indexed_point_view(segment2),
pt_pt_strategy)
);
}
};
struct area_check
{
template
static inline bool apply(Geometry1 const& geometry1,
Geometry2 const& geometry2,
Strategy const& strategy)
{
return geometry::math::equals(
geometry::area(geometry1,
strategy.template get_area_strategy()),
geometry::area(geometry2,
strategy.template get_area_strategy()));
}
};
struct length_check
{
template
static inline bool apply(Geometry1 const& geometry1,
Geometry2 const& geometry2,
Strategy const& strategy)
{
return geometry::math::equals(
geometry::length(geometry1,
strategy.template get_distance_strategy()),
geometry::length(geometry2,
strategy.template get_distance_strategy()));
}
};
template
struct collected_vector
{
typedef typename geometry::select_most_precise
<
typename select_coordinate_type
<
Geometry1, Geometry2
>::type,
double
>::type calculation_type;
typedef geometry::collected_vector
<
calculation_type,
Geometry1,
typename IntersectionStrategy::side_strategy_type
> type;
};
template
struct equals_by_collection
{
template
static inline bool apply(Geometry1 const& geometry1,
Geometry2 const& geometry2,
Strategy const& strategy)
{
if (! TrivialCheck::apply(geometry1, geometry2, strategy))
{
return false;
}
typedef typename collected_vector
<
Geometry1, Geometry2, Strategy
>::type collected_vector_type;
std::vector c1, c2;
geometry::collect_vectors(c1, geometry1);
geometry::collect_vectors(c2, geometry2);
if (boost::size(c1) != boost::size(c2))
{
return false;
}
std::sort(c1.begin(), c1.end());
std::sort(c2.begin(), c2.end());
// Just check if these vectors are equal.
return std::equal(c1.begin(), c1.end(), c2.begin());
}
};
template
struct equals_by_relate
: detail::relate::relate_impl
<
detail::de9im::static_mask_equals_type,
Geometry1,
Geometry2
>
{};
// If collect_vectors which is a SideStrategy-dispatched optimization
// is implemented in a way consistent with the Intersection/Side Strategy
// then collect_vectors is used, otherwise relate is used.
// NOTE: the result could be conceptually different for invalid
// geometries in different coordinate systems because collect_vectors
// and relate treat invalid geometries differently.
template
struct equals_by_collection_or_relate
{
template
static inline bool apply(Geometry1 const& geometry1,
Geometry2 const& geometry2,
Strategy const& strategy)
{
typedef typename boost::is_base_of
<
nyi::not_implemented_tag,
typename collected_vector
<
Geometry1, Geometry2, Strategy
>::type
>::type enable_relate_type;
return apply(geometry1, geometry2, strategy, enable_relate_type());
}
private:
template
static inline bool apply(Geometry1 const& geometry1,
Geometry2 const& geometry2,
Strategy const& strategy,
boost::false_type /*enable_relate*/)
{
return equals_by_collection::apply(geometry1, geometry2, strategy);
}
template
static inline bool apply(Geometry1 const& geometry1,
Geometry2 const& geometry2,
Strategy const& strategy,
boost::true_type /*enable_relate*/)
{
return equals_by_relate::apply(geometry1, geometry2, strategy);
}
};
struct equals_always_false
{
template
static inline bool apply(Geometry1 const& , Geometry2 const& , Strategy const& )
{
return false;
}
};
}} // namespace detail::equals
#endif // DOXYGEN_NO_DETAIL
#ifndef DOXYGEN_NO_DISPATCH
namespace dispatch
{
template
struct equals
: detail::equals::point_point<0, DimensionCount>
{};
template
struct equals
: detail::equals::equals_by_relate
{};
template
struct equals
: detail::equals::equals_by_relate
{};
template
struct equals
: detail::equals::box_box<0, DimensionCount>
{};
template
struct equals
: detail::equals::equals_by_collection_or_relate
{};
template
struct equals
: detail::equals::equals_by_collection_or_relate
{};
template
struct equals
: detail::equals::equals_by_collection_or_relate
{};
template
struct equals
: detail::equals::equals_by_collection
{};
template
struct equals
: detail::equals::equals_by_collection
{};
template
struct equals
: detail::equals::segment_segment
{};
template
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
: 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
>
: detail::equals::equals_by_collection_or_relate
{};
template
struct equals
<
Polygon, MultiPolygon,
polygon_tag, multi_polygon_tag,
areal_tag, areal_tag,
2,
Reverse
>
: detail::equals::equals_by_collection_or_relate
{};
template
struct equals
<
MultiPolygon, Ring,
multi_polygon_tag, ring_tag,
areal_tag, areal_tag,
2,
Reverse
>
: detail::equals::equals_by_collection_or_relate
{};
// 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
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_EQUALS_IMPLEMENTATION_HPP