1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
10 // Use, modification and distribution is subject to the Boost Software License,
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12 // http://www.boost.org/LICENSE_1_0.txt)
15 #ifndef BOOST_GEOMETRY_CORE_TOPOLOGICAL_DIMENSION_HPP
16 #define BOOST_GEOMETRY_CORE_TOPOLOGICAL_DIMENSION_HPP
19 #include <boost/mpl/int.hpp>
22 #include <boost/geometry/core/tag.hpp>
23 #include <boost/geometry/core/tags.hpp>
26 namespace boost { namespace geometry
30 #ifndef DOXYGEN_NO_DISPATCH
31 namespace core_dispatch
35 template <typename GeometryTag>
40 struct top_dim<point_tag> : boost::mpl::int_<0> {};
44 struct top_dim<linestring_tag> : boost::mpl::int_<1> {};
48 struct top_dim<segment_tag> : boost::mpl::int_<1> {};
51 // ring: topological dimension of two, but some people say: 1 !!
52 // NOTE: This is not OGC LinearRing!
54 struct top_dim<ring_tag> : boost::mpl::int_<2> {};
57 // TODO: This is wrong! Boxes may have various topological dimensions
59 struct top_dim<box_tag> : boost::mpl::int_<2> {};
63 struct top_dim<polygon_tag> : boost::mpl::int_<2> {};
67 struct top_dim<multi_point_tag> : boost::mpl::int_<0> {};
71 struct top_dim<multi_linestring_tag> : boost::mpl::int_<1> {};
75 struct top_dim<multi_polygon_tag> : boost::mpl::int_<2> {};
78 } // namespace core_dispatch
86 \brief Meta-function returning the topological dimension of a geometry
87 \details The topological dimension defines a point as 0-dimensional,
88 a linestring as 1-dimensional,
89 and a ring or polygon as 2-dimensional.
90 \see http://www.math.okstate.edu/mathdept/dynamics/lecnotes/node36.html
93 template <typename Geometry>
94 struct topological_dimension
95 : core_dispatch::top_dim<typename tag<Geometry>::type> {};
98 }} // namespace boost::geometry
101 #endif // BOOST_GEOMETRY_CORE_TOPOLOGICAL_DIMENSION_HPP