topological_dimension.hpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
  5. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  6. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  7. // Use, modification and distribution is subject to the Boost Software License,
  8. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. #ifndef BOOST_GEOMETRY_CORE_TOPOLOGICAL_DIMENSION_HPP
  11. #define BOOST_GEOMETRY_CORE_TOPOLOGICAL_DIMENSION_HPP
  12. #include <boost/mpl/int.hpp>
  13. #include <boost/geometry/core/tag.hpp>
  14. #include <boost/geometry/core/tags.hpp>
  15. namespace boost { namespace geometry
  16. {
  17. #ifndef DOXYGEN_NO_DISPATCH
  18. namespace core_dispatch
  19. {
  20. template <typename GeometryTag>
  21. struct top_dim {};
  22. template <>
  23. struct top_dim<point_tag> : boost::mpl::int_<0> {};
  24. template <>
  25. struct top_dim<linestring_tag> : boost::mpl::int_<1> {};
  26. template <>
  27. struct top_dim<segment_tag> : boost::mpl::int_<1> {};
  28. // ring: topological dimension of two, but some people say: 1 !!
  29. // NOTE: This is not OGC LinearRing!
  30. template <>
  31. struct top_dim<ring_tag> : boost::mpl::int_<2> {};
  32. // TODO: This is wrong! Boxes may have various topological dimensions
  33. template <>
  34. struct top_dim<box_tag> : boost::mpl::int_<2> {};
  35. template <>
  36. struct top_dim<polygon_tag> : boost::mpl::int_<2> {};
  37. template <>
  38. struct top_dim<multi_point_tag> : boost::mpl::int_<0> {};
  39. template <>
  40. struct top_dim<multi_linestring_tag> : boost::mpl::int_<1> {};
  41. template <>
  42. struct top_dim<multi_polygon_tag> : boost::mpl::int_<2> {};
  43. } // namespace core_dispatch
  44. #endif
  45. /*!
  46. \brief Meta-function returning the topological dimension of a geometry
  47. \details The topological dimension defines a point as 0-dimensional,
  48. a linestring as 1-dimensional,
  49. and a ring or polygon as 2-dimensional.
  50. \see http://www.math.okstate.edu/mathdept/dynamics/lecnotes/node36.html
  51. \ingroup core
  52. */
  53. template <typename Geometry>
  54. struct topological_dimension
  55. : core_dispatch::top_dim<typename tag<Geometry>::type> {};
  56. }} // namespace boost::geometry
  57. #endif // BOOST_GEOMETRY_CORE_TOPOLOGICAL_DIMENSION_HPP