summaryrefslogtreecommitdiff
path: root/boost/geometry/algorithms/detail/single_geometry.hpp
diff options
context:
space:
mode:
authorChanho Park <chanho61.park@samsung.com>2014-12-11 18:55:56 +0900
committerChanho Park <chanho61.park@samsung.com>2014-12-11 18:55:56 +0900
commit08c1e93fa36a49f49325a07fe91ff92c964c2b6c (patch)
tree7a7053ceb8874b28ec4b868d4c49b500008a102e /boost/geometry/algorithms/detail/single_geometry.hpp
parentbb4dd8289b351fae6b55e303f189127a394a1edd (diff)
downloadboost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.gz
boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.bz2
boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.zip
Imported Upstream version 1.57.0upstream/1.57.0
Diffstat (limited to 'boost/geometry/algorithms/detail/single_geometry.hpp')
-rw-r--r--boost/geometry/algorithms/detail/single_geometry.hpp95
1 files changed, 95 insertions, 0 deletions
diff --git a/boost/geometry/algorithms/detail/single_geometry.hpp b/boost/geometry/algorithms/detail/single_geometry.hpp
new file mode 100644
index 0000000000..c65ff8bf84
--- /dev/null
+++ b/boost/geometry/algorithms/detail/single_geometry.hpp
@@ -0,0 +1,95 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// This file was modified by Oracle on 2013, 2014.
+// Modifications copyright (c) 2013-2014, Oracle and/or its affiliates.
+
+// 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)
+
+// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_SINGLE_GEOMETRY_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_SINGLE_GEOMETRY_HPP
+
+#include <boost/type_traits/is_base_of.hpp>
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/util/range.hpp>
+
+namespace boost { namespace geometry {
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace detail_dispatch {
+
+// Returns single geometry by Id
+// for single geometries returns the geometry itself
+template <typename Geometry,
+ bool IsMulti = boost::is_base_of
+ <
+ multi_tag,
+ typename geometry::tag<Geometry>::type
+ >::value
+>
+struct single_geometry
+{
+ typedef Geometry & return_type;
+
+ template <typename Id>
+ static inline return_type apply(Geometry & g, Id const& ) { return g; }
+};
+
+// for multi geometries returns one of the stored single geometries
+template <typename Geometry>
+struct single_geometry<Geometry, true>
+{
+ typedef typename boost::mpl::if_c
+ <
+ boost::is_const<Geometry>::value,
+ typename boost::range_value<Geometry>::type const&,
+ typename boost::range_value<Geometry>::type
+ >::type return_type;
+
+ template <typename Id>
+ static inline return_type apply(Geometry & g, Id const& id)
+ {
+ BOOST_ASSERT(id.multi_index >= 0);
+ return range::at(g, id.multi_index);
+ }
+};
+
+} // namespace detail_dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail {
+
+template <typename Geometry>
+struct single_geometry_return_type
+{
+ typedef typename detail_dispatch::single_geometry<Geometry>::return_type type;
+};
+
+template <typename Geometry, typename Id>
+inline
+typename single_geometry_return_type<Geometry>::type
+single_geometry(Geometry & geometry, Id const& id)
+{
+ return detail_dispatch::single_geometry<Geometry>::apply(geometry, id);
+}
+
+template <typename Geometry, typename Id>
+inline
+typename single_geometry_return_type<Geometry const>::type
+single_geometry(Geometry const& geometry, Id const& id)
+{
+ return detail_dispatch::single_geometry<Geometry const>::apply(geometry, id);
+}
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_SINGLE_GEOMETRY_HPP