Imported Upstream version 1.72.0
[platform/upstream/boost.git] / boost / geometry / srs / projections / factory.hpp
index 773d2bb..599c4bf 100644 (file)
@@ -2,8 +2,8 @@
 
 // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
 
-// This file was modified by Oracle on 2017.
-// Modifications copyright (c) 2017, Oracle and/or its affiliates.
+// This file was modified by Oracle on 2017, 2019.
+// Modifications copyright (c) 2017, 2019, Oracle and/or its affiliates.
 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
 
 // Use, modification and distribution is subject to the Boost Software License,
@@ -19,7 +19,6 @@
 #include <boost/shared_ptr.hpp>
 
 #include <boost/geometry/srs/projections/dpar.hpp>
-#include <boost/geometry/srs/projections/factory_key.hpp>
 #include <boost/geometry/srs/projections/proj4.hpp>
 #include <boost/geometry/srs/projections/impl/factory_entry.hpp>
 #include <boost/geometry/srs/projections/proj/aea.hpp>
@@ -127,6 +126,43 @@ namespace boost { namespace geometry { namespace projections
 namespace detail
 {
 
+template <typename Params>
+struct factory_key
+{
+    BOOST_MPL_ASSERT_MSG((false), INVALID_PARAMETERS_TYPE, (Params));
+};
+
+template <>
+struct factory_key<srs::detail::proj4_parameters>
+{
+    typedef std::string type;
+    template <typename ProjParams>
+    static type const& get(ProjParams const& par)
+    {
+        return par.id.name;
+    }
+    static const char* get(const char* name, srs::dpar::value_proj id)
+    {
+        return name;
+    }
+};
+
+template <typename T>
+struct factory_key<srs::dpar::parameters<T> >
+{
+    typedef srs::dpar::value_proj type;
+    template <typename ProjParams>
+    static type const& get(ProjParams const& par)
+    {
+        return par.id.id;
+    }
+    static srs::dpar::value_proj get(const char* name, srs::dpar::value_proj id)
+    {
+        return id;
+    }
+};
+
+
 template <typename Params, typename CT, typename ProjParams>
 class factory
 {
@@ -138,7 +174,8 @@ private:
             ProjParams
         > entry_base;
 
-    typedef typename factory_key_util<Params>::type key_type;
+    typedef factory_key<Params> key;
+    typedef typename key::type key_type;
     typedef boost::shared_ptr<entry_base> entry_ptr;
 
     typedef std::map<key_type, entry_ptr> entries_map;
@@ -249,17 +286,17 @@ public:
         detail::wink2_init(*this);
     }
 
-    void add_to_factory(key_type const& key, entry_base* entry)
+    void add_to_factory(const char* name, srs::dpar::value_proj id, entry_base* entry)
     {
         // The pointer has to be owned before std::map::operator[] in case it thrown an exception.
         entry_ptr ptr(entry);
-        m_entries[key] = ptr;
+        m_entries[key::get(name, id)] = ptr;
     }
 
-    detail::base_v<CT, ProjParams>* create_new(Params const& params, ProjParams const& proj_par) const
+    detail::dynamic_wrapper_b<CT, ProjParams>* create_new(Params const& params, ProjParams const& proj_par) const
     {
-        typename factory_key_util<Params>::type key = factory_key_util<Params>::get(proj_par);
-        typename entries_map::const_iterator it = m_entries.find(key);
+        typedef typename entries_map::const_iterator const_iterator;
+        const_iterator it = m_entries.find(key::get(proj_par));
         if (it != m_entries.end())
         {
             return it->second->create_new(params, proj_par);
@@ -270,7 +307,7 @@ public:
 };
 
 template <typename T>
-inline detail::base_v<T, projections::parameters<T> >*
+inline detail::dynamic_wrapper_b<T, projections::parameters<T> >*
     create_new(srs::detail::proj4_parameters const& params,
                projections::parameters<T> const& parameters)
 {
@@ -279,7 +316,7 @@ inline detail::base_v<T, projections::parameters<T> >*
 }
 
 template <typename T>
-inline detail::base_v<T, projections::parameters<T> >*
+inline detail::dynamic_wrapper_b<T, projections::parameters<T> >*
     create_new(srs::dpar::parameters<T> const& params,
                projections::parameters<T> const& parameters)
 {