geometry_id.hpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. // This file was modified by Oracle on 2020.
  6. // Modifications copyright (c) 2020 Oracle and/or its affiliates.
  7. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  8. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  9. // (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)
  13. #ifndef BOOST_GEOMETRY_CORE_GEOMETRY_ID_HPP
  14. #define BOOST_GEOMETRY_CORE_GEOMETRY_ID_HPP
  15. #include <type_traits>
  16. #include <boost/geometry/core/static_assert.hpp>
  17. #include <boost/geometry/core/tag.hpp>
  18. #include <boost/geometry/core/tags.hpp>
  19. namespace boost { namespace geometry
  20. {
  21. #ifndef DOXYGEN_NO_DISPATCH
  22. namespace core_dispatch
  23. {
  24. template <typename GeometryTag>
  25. struct geometry_id
  26. {
  27. BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
  28. "Not implemented for this Geometry type.",
  29. GeometryTag);
  30. };
  31. template <>
  32. struct geometry_id<point_tag> : std::integral_constant<int, 1> {};
  33. template <>
  34. struct geometry_id<linestring_tag> : std::integral_constant<int, 2> {};
  35. template <>
  36. struct geometry_id<polygon_tag> : std::integral_constant<int, 3> {};
  37. template <>
  38. struct geometry_id<multi_point_tag> : std::integral_constant<int, 4> {};
  39. template <>
  40. struct geometry_id<multi_linestring_tag> : std::integral_constant<int, 5> {};
  41. template <>
  42. struct geometry_id<multi_polygon_tag> : std::integral_constant<int, 6> {};
  43. template <>
  44. struct geometry_id<geometry_collection_tag> : std::integral_constant<int, 7> {};
  45. template <>
  46. struct geometry_id<segment_tag> : std::integral_constant<int, 92> {};
  47. template <>
  48. struct geometry_id<ring_tag> : std::integral_constant<int, 93> {};
  49. template <>
  50. struct geometry_id<box_tag> : std::integral_constant<int, 94> {};
  51. } // namespace core_dispatch
  52. #endif
  53. /*!
  54. \brief Meta-function returning the id of a geometry type
  55. \details The meta-function geometry_id defines a numerical ID (based on
  56. std::integral_constant<int, ...> ) for each geometry concept. A numerical ID is
  57. sometimes useful, and within Boost.Geometry it is used for the
  58. reverse_dispatch metafuntion.
  59. \note Used for e.g. reverse meta-function
  60. \ingroup core
  61. */
  62. template <typename Geometry>
  63. struct geometry_id : core_dispatch::geometry_id<typename tag<Geometry>::type>
  64. {};
  65. }} // namespace boost::geometry
  66. #endif // BOOST_GEOMETRY_CORE_GEOMETRY_ID_HPP