factory_key.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Boost.Geometry
  2. // Copyright (c) 2018, Oracle and/or its affiliates.
  3. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  4. // Use, modification and distribution is subject to the Boost Software License,
  5. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. #ifndef BOOST_GEOMETRY_PROJECTIONS_FACTORY_KEY_HPP
  8. #define BOOST_GEOMETRY_PROJECTIONS_FACTORY_KEY_HPP
  9. #include <string>
  10. #include <boost/geometry/srs/projections/dpar.hpp>
  11. #include <boost/geometry/srs/projections/proj4.hpp>
  12. namespace boost { namespace geometry { namespace projections
  13. {
  14. namespace detail
  15. {
  16. template <typename Params>
  17. struct factory_key_util
  18. {
  19. BOOST_MPL_ASSERT_MSG((false), INVALID_PARAMETERS_TYPE, (Params));
  20. };
  21. template <>
  22. struct factory_key_util<srs::detail::proj4_parameters>
  23. {
  24. typedef std::string type;
  25. template <typename ProjParams>
  26. static type const& get(ProjParams const& par)
  27. {
  28. return par.id.name;
  29. }
  30. };
  31. template <typename T>
  32. struct factory_key_util<srs::dpar::parameters<T> >
  33. {
  34. typedef srs::dpar::value_proj type;
  35. template <typename ProjParams>
  36. static type const& get(ProjParams const& par)
  37. {
  38. return par.id.id;
  39. }
  40. };
  41. struct factory_key
  42. {
  43. factory_key(const char* name, srs::dpar::value_proj id)
  44. : m_name(name), m_id(id)
  45. {}
  46. operator const char*() const
  47. {
  48. return m_name;
  49. }
  50. operator std::string() const
  51. {
  52. return std::string(m_name);
  53. }
  54. operator srs::dpar::value_proj() const
  55. {
  56. return m_id;
  57. }
  58. private:
  59. const char* m_name;
  60. srs::dpar::value_proj m_id;
  61. };
  62. } // namespace detail
  63. }}} // namespace boost::geometry::projections
  64. #endif // BOOST_GEOMETRY_PROJECTIONS_FACTORY_KEY_HPP