File indexing completed on 2025-01-18 09:36:27
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef BOOST_GEOMETRY_PROJECTIONS_FACTORY_HPP
0016 #define BOOST_GEOMETRY_PROJECTIONS_FACTORY_HPP
0017
0018 #include <map>
0019 #include <memory>
0020 #include <string>
0021
0022 #include <boost/geometry/core/static_assert.hpp>
0023
0024 #include <boost/geometry/srs/projections/dpar.hpp>
0025 #include <boost/geometry/srs/projections/proj4.hpp>
0026 #include <boost/geometry/srs/projections/impl/factory_entry.hpp>
0027 #include <boost/geometry/srs/projections/proj/aea.hpp>
0028 #include <boost/geometry/srs/projections/proj/aeqd.hpp>
0029 #include <boost/geometry/srs/projections/proj/airy.hpp>
0030 #include <boost/geometry/srs/projections/proj/aitoff.hpp>
0031 #include <boost/geometry/srs/projections/proj/august.hpp>
0032 #include <boost/geometry/srs/projections/proj/bacon.hpp>
0033 #include <boost/geometry/srs/projections/proj/bipc.hpp>
0034 #include <boost/geometry/srs/projections/proj/boggs.hpp>
0035 #include <boost/geometry/srs/projections/proj/bonne.hpp>
0036 #include <boost/geometry/srs/projections/proj/cass.hpp>
0037 #include <boost/geometry/srs/projections/proj/cc.hpp>
0038 #include <boost/geometry/srs/projections/proj/cea.hpp>
0039 #include <boost/geometry/srs/projections/proj/chamb.hpp>
0040 #include <boost/geometry/srs/projections/proj/col_urban.hpp>
0041 #include <boost/geometry/srs/projections/proj/collg.hpp>
0042 #include <boost/geometry/srs/projections/proj/crast.hpp>
0043 #include <boost/geometry/srs/projections/proj/denoy.hpp>
0044 #include <boost/geometry/srs/projections/proj/eck1.hpp>
0045 #include <boost/geometry/srs/projections/proj/eck2.hpp>
0046 #include <boost/geometry/srs/projections/proj/eck3.hpp>
0047 #include <boost/geometry/srs/projections/proj/eck4.hpp>
0048 #include <boost/geometry/srs/projections/proj/eck5.hpp>
0049 #include <boost/geometry/srs/projections/proj/eqc.hpp>
0050 #include <boost/geometry/srs/projections/proj/eqdc.hpp>
0051 #include <boost/geometry/srs/projections/proj/etmerc.hpp>
0052 #include <boost/geometry/srs/projections/proj/fahey.hpp>
0053 #include <boost/geometry/srs/projections/proj/fouc_s.hpp>
0054 #include <boost/geometry/srs/projections/proj/gall.hpp>
0055 #include <boost/geometry/srs/projections/proj/geocent.hpp>
0056 #include <boost/geometry/srs/projections/proj/geos.hpp>
0057 #include <boost/geometry/srs/projections/proj/gins8.hpp>
0058 #include <boost/geometry/srs/projections/proj/gn_sinu.hpp>
0059 #include <boost/geometry/srs/projections/proj/gnom.hpp>
0060 #include <boost/geometry/srs/projections/proj/goode.hpp>
0061 #include <boost/geometry/srs/projections/proj/gstmerc.hpp>
0062 #include <boost/geometry/srs/projections/proj/hammer.hpp>
0063 #include <boost/geometry/srs/projections/proj/hatano.hpp>
0064 #include <boost/geometry/srs/projections/proj/healpix.hpp>
0065 #include <boost/geometry/srs/projections/proj/krovak.hpp>
0066 #include <boost/geometry/srs/projections/proj/igh.hpp>
0067 #include <boost/geometry/srs/projections/proj/imw_p.hpp>
0068 #include <boost/geometry/srs/projections/proj/isea.hpp>
0069 #include <boost/geometry/srs/projections/proj/laea.hpp>
0070 #include <boost/geometry/srs/projections/proj/labrd.hpp>
0071 #include <boost/geometry/srs/projections/proj/lagrng.hpp>
0072 #include <boost/geometry/srs/projections/proj/larr.hpp>
0073 #include <boost/geometry/srs/projections/proj/lask.hpp>
0074 #include <boost/geometry/srs/projections/proj/latlong.hpp>
0075 #include <boost/geometry/srs/projections/proj/lcc.hpp>
0076 #include <boost/geometry/srs/projections/proj/lcca.hpp>
0077 #include <boost/geometry/srs/projections/proj/loxim.hpp>
0078 #include <boost/geometry/srs/projections/proj/lsat.hpp>
0079 #include <boost/geometry/srs/projections/proj/mbtfpp.hpp>
0080 #include <boost/geometry/srs/projections/proj/mbtfpq.hpp>
0081 #include <boost/geometry/srs/projections/proj/mbt_fps.hpp>
0082 #include <boost/geometry/srs/projections/proj/merc.hpp>
0083 #include <boost/geometry/srs/projections/proj/mill.hpp>
0084 #include <boost/geometry/srs/projections/proj/mod_ster.hpp>
0085 #include <boost/geometry/srs/projections/proj/moll.hpp>
0086 #include <boost/geometry/srs/projections/proj/natearth.hpp>
0087 #include <boost/geometry/srs/projections/proj/nell.hpp>
0088 #include <boost/geometry/srs/projections/proj/nell_h.hpp>
0089 #include <boost/geometry/srs/projections/proj/nocol.hpp>
0090 #include <boost/geometry/srs/projections/proj/nsper.hpp>
0091 #include <boost/geometry/srs/projections/proj/nzmg.hpp>
0092 #include <boost/geometry/srs/projections/proj/ob_tran.hpp>
0093 #include <boost/geometry/srs/projections/proj/ocea.hpp>
0094 #include <boost/geometry/srs/projections/proj/oea.hpp>
0095 #include <boost/geometry/srs/projections/proj/omerc.hpp>
0096 #include <boost/geometry/srs/projections/proj/ortho.hpp>
0097 #include <boost/geometry/srs/projections/proj/qsc.hpp>
0098 #include <boost/geometry/srs/projections/proj/poly.hpp>
0099 #include <boost/geometry/srs/projections/proj/putp2.hpp>
0100 #include <boost/geometry/srs/projections/proj/putp3.hpp>
0101 #include <boost/geometry/srs/projections/proj/putp4p.hpp>
0102 #include <boost/geometry/srs/projections/proj/putp5.hpp>
0103 #include <boost/geometry/srs/projections/proj/putp6.hpp>
0104 #include <boost/geometry/srs/projections/proj/robin.hpp>
0105 #include <boost/geometry/srs/projections/proj/rouss.hpp>
0106 #include <boost/geometry/srs/projections/proj/rpoly.hpp>
0107 #include <boost/geometry/srs/projections/proj/sconics.hpp>
0108 #include <boost/geometry/srs/projections/proj/somerc.hpp>
0109 #include <boost/geometry/srs/projections/proj/stere.hpp>
0110 #include <boost/geometry/srs/projections/proj/sterea.hpp>
0111 #include <boost/geometry/srs/projections/proj/sts.hpp>
0112 #include <boost/geometry/srs/projections/proj/tcc.hpp>
0113 #include <boost/geometry/srs/projections/proj/tcea.hpp>
0114 #include <boost/geometry/srs/projections/proj/tmerc.hpp>
0115 #include <boost/geometry/srs/projections/proj/tpeqd.hpp>
0116 #include <boost/geometry/srs/projections/proj/urm5.hpp>
0117 #include <boost/geometry/srs/projections/proj/urmfps.hpp>
0118 #include <boost/geometry/srs/projections/proj/vandg.hpp>
0119 #include <boost/geometry/srs/projections/proj/vandg2.hpp>
0120 #include <boost/geometry/srs/projections/proj/vandg4.hpp>
0121 #include <boost/geometry/srs/projections/proj/wag2.hpp>
0122 #include <boost/geometry/srs/projections/proj/wag3.hpp>
0123 #include <boost/geometry/srs/projections/proj/wag7.hpp>
0124 #include <boost/geometry/srs/projections/proj/wink1.hpp>
0125 #include <boost/geometry/srs/projections/proj/wink2.hpp>
0126
0127 namespace boost { namespace geometry { namespace projections
0128 {
0129
0130 namespace detail
0131 {
0132
0133 template <typename Params>
0134 struct factory_key
0135 {
0136 BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
0137 "Invalid parameters type.",
0138 Params);
0139 };
0140
0141 template <>
0142 struct factory_key<srs::detail::proj4_parameters>
0143 {
0144 typedef std::string type;
0145 template <typename ProjParams>
0146 static type const& get(ProjParams const& par)
0147 {
0148 return par.id.name;
0149 }
0150 static const char* get(const char* name, srs::dpar::value_proj )
0151 {
0152 return name;
0153 }
0154 };
0155
0156 template <typename T>
0157 struct factory_key<srs::dpar::parameters<T> >
0158 {
0159 typedef srs::dpar::value_proj type;
0160 template <typename ProjParams>
0161 static type const& get(ProjParams const& par)
0162 {
0163 return par.id.id;
0164 }
0165 static srs::dpar::value_proj get(const char* , srs::dpar::value_proj id)
0166 {
0167 return id;
0168 }
0169 };
0170
0171
0172 template <typename Params, typename CT, typename ProjParams>
0173 class factory
0174 {
0175 private:
0176 typedef detail::factory_entry
0177 <
0178 Params,
0179 CT,
0180 ProjParams
0181 > entry_base;
0182
0183 typedef factory_key<Params> key;
0184 typedef typename key::type key_type;
0185 typedef std::shared_ptr<entry_base> entry_ptr;
0186
0187 typedef std::map<key_type, entry_ptr> entries_map;
0188
0189 entries_map m_entries;
0190
0191 public:
0192
0193 factory()
0194 {
0195 detail::aea_init(*this);
0196 detail::aeqd_init(*this);
0197 detail::airy_init(*this);
0198 detail::aitoff_init(*this);
0199 detail::august_init(*this);
0200 detail::bacon_init(*this);
0201 detail::bipc_init(*this);
0202 detail::boggs_init(*this);
0203 detail::bonne_init(*this);
0204 detail::cass_init(*this);
0205 detail::cc_init(*this);
0206 detail::cea_init(*this);
0207 detail::chamb_init(*this);
0208 detail::col_urban_init(*this);
0209 detail::collg_init(*this);
0210 detail::crast_init(*this);
0211 detail::denoy_init(*this);
0212 detail::eck1_init(*this);
0213 detail::eck2_init(*this);
0214 detail::eck3_init(*this);
0215 detail::eck4_init(*this);
0216 detail::eck5_init(*this);
0217 detail::eqc_init(*this);
0218 detail::eqdc_init(*this);
0219 detail::etmerc_init(*this);
0220 detail::fahey_init(*this);
0221 detail::fouc_s_init(*this);
0222 detail::gall_init(*this);
0223 detail::geocent_init(*this);
0224 detail::geos_init(*this);
0225 detail::gins8_init(*this);
0226 detail::gn_sinu_init(*this);
0227 detail::gnom_init(*this);
0228 detail::goode_init(*this);
0229 detail::gstmerc_init(*this);
0230 detail::hammer_init(*this);
0231 detail::hatano_init(*this);
0232 detail::healpix_init(*this);
0233 detail::krovak_init(*this);
0234 detail::igh_init(*this);
0235 detail::imw_p_init(*this);
0236 detail::isea_init(*this);
0237 detail::labrd_init(*this);
0238 detail::laea_init(*this);
0239 detail::lagrng_init(*this);
0240 detail::larr_init(*this);
0241 detail::lask_init(*this);
0242 detail::latlong_init(*this);
0243 detail::lcc_init(*this);
0244 detail::lcca_init(*this);
0245 detail::loxim_init(*this);
0246 detail::lsat_init(*this);
0247 detail::mbtfpp_init(*this);
0248 detail::mbtfpq_init(*this);
0249 detail::mbt_fps_init(*this);
0250 detail::merc_init(*this);
0251 detail::mill_init(*this);
0252 detail::mod_ster_init(*this);
0253 detail::moll_init(*this);
0254 detail::natearth_init(*this);
0255 detail::nell_init(*this);
0256 detail::nell_h_init(*this);
0257 detail::nocol_init(*this);
0258 detail::nsper_init(*this);
0259 detail::nzmg_init(*this);
0260 detail::ob_tran_init(*this);
0261 detail::ocea_init(*this);
0262 detail::oea_init(*this);
0263 detail::omerc_init(*this);
0264 detail::ortho_init(*this);
0265 detail::qsc_init(*this);
0266 detail::poly_init(*this);
0267 detail::putp2_init(*this);
0268 detail::putp3_init(*this);
0269 detail::putp4p_init(*this);
0270 detail::putp5_init(*this);
0271 detail::putp6_init(*this);
0272 detail::robin_init(*this);
0273 detail::rouss_init(*this);
0274 detail::rpoly_init(*this);
0275 detail::sconics_init(*this);
0276 detail::somerc_init(*this);
0277 detail::stere_init(*this);
0278 detail::sterea_init(*this);
0279 detail::sts_init(*this);
0280 detail::tcc_init(*this);
0281 detail::tcea_init(*this);
0282 detail::tmerc_init(*this);
0283 detail::tpeqd_init(*this);
0284 detail::urm5_init(*this);
0285 detail::urmfps_init(*this);
0286 detail::vandg_init(*this);
0287 detail::vandg2_init(*this);
0288 detail::vandg4_init(*this);
0289 detail::wag2_init(*this);
0290 detail::wag3_init(*this);
0291 detail::wag7_init(*this);
0292 detail::wink1_init(*this);
0293 detail::wink2_init(*this);
0294 }
0295
0296 void add_to_factory(const char* name, srs::dpar::value_proj id, entry_base* entry)
0297 {
0298
0299 entry_ptr ptr(entry);
0300 m_entries[key::get(name, id)] = ptr;
0301 }
0302
0303 detail::dynamic_wrapper_b<CT, ProjParams>* create_new(Params const& params, ProjParams const& proj_par) const
0304 {
0305 typedef typename entries_map::const_iterator const_iterator;
0306 const_iterator it = m_entries.find(key::get(proj_par));
0307 if (it != m_entries.end())
0308 {
0309 return it->second->create_new(params, proj_par);
0310 }
0311
0312 return 0;
0313 }
0314 };
0315
0316 template <typename T>
0317 inline detail::dynamic_wrapper_b<T, projections::parameters<T> >*
0318 create_new(srs::detail::proj4_parameters const& params,
0319 projections::parameters<T> const& parameters)
0320 {
0321 static factory<srs::detail::proj4_parameters, T, projections::parameters<T> > const fac;
0322 return fac.create_new(params, parameters);
0323 }
0324
0325 template <typename T>
0326 inline detail::dynamic_wrapper_b<T, projections::parameters<T> >*
0327 create_new(srs::dpar::parameters<T> const& params,
0328 projections::parameters<T> const& parameters)
0329 {
0330 static factory<srs::dpar::parameters<T>, T, projections::parameters<T> > const fac;
0331 return fac.create_new(params, parameters);
0332 }
0333
0334
0335 }
0336
0337 }}}
0338
0339 #endif