| 1 |
// Boost.Geometry (aka GGL, Generic Geometry Library) |
| 2 |
|
| 3 |
// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands. |
| 4 |
|
| 5 |
// This file was modified by Oracle on 2017-2021. |
| 6 |
// Modifications Copyright (c) 2017, 2026, Oracle and/or its affiliates. |
| 7 |
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle |
| 8 |
|
| 9 |
// Use, modification and distribution is subject to the Boost Software License, |
| 10 |
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
| 11 |
// http://www.boost.org/LICENSE_1_0.txt) |
| 12 |
|
| 13 |
#ifndef BOOST_GEOMETRY_PROJECTIONS_FACTORY_HPP |
| 14 |
#define BOOST_GEOMETRY_PROJECTIONS_FACTORY_HPP |
| 15 |
|
| 16 |
#include <map> |
| 17 |
#include <string> |
| 18 |
|
| 19 |
#include <boost/shared_ptr.hpp> |
| 20 |
|
| 21 |
#include <boost/geometry/core/static_assert.hpp> |
| 22 |
|
| 23 |
#include <boost/geometry/srs/projections/dpar.hpp> |
| 24 |
#include <boost/geometry/srs/projections/proj4.hpp> |
| 25 |
#include <boost/geometry/srs/projections/impl/factory_entry.hpp> |
| 26 |
#include <boost/geometry/srs/projections/proj/aea.hpp> |
| 27 |
#include <boost/geometry/srs/projections/proj/aeqd.hpp> |
| 28 |
#include <boost/geometry/srs/projections/proj/airy.hpp> |
| 29 |
#include <boost/geometry/srs/projections/proj/aitoff.hpp> |
| 30 |
#include <boost/geometry/srs/projections/proj/august.hpp> |
| 31 |
#include <boost/geometry/srs/projections/proj/bacon.hpp> |
| 32 |
#include <boost/geometry/srs/projections/proj/bipc.hpp> |
| 33 |
#include <boost/geometry/srs/projections/proj/boggs.hpp> |
| 34 |
#include <boost/geometry/srs/projections/proj/bonne.hpp> |
| 35 |
#include <boost/geometry/srs/projections/proj/cass.hpp> |
| 36 |
#include <boost/geometry/srs/projections/proj/cc.hpp> |
| 37 |
#include <boost/geometry/srs/projections/proj/cea.hpp> |
| 38 |
#include <boost/geometry/srs/projections/proj/chamb.hpp> |
| 39 |
#include <boost/geometry/srs/projections/proj/col_urban.hpp> |
| 40 |
#include <boost/geometry/srs/projections/proj/collg.hpp> |
| 41 |
#include <boost/geometry/srs/projections/proj/crast.hpp> |
| 42 |
#include <boost/geometry/srs/projections/proj/denoy.hpp> |
| 43 |
#include <boost/geometry/srs/projections/proj/eck1.hpp> |
| 44 |
#include <boost/geometry/srs/projections/proj/eck2.hpp> |
| 45 |
#include <boost/geometry/srs/projections/proj/eck3.hpp> |
| 46 |
#include <boost/geometry/srs/projections/proj/eck4.hpp> |
| 47 |
#include <boost/geometry/srs/projections/proj/eck5.hpp> |
| 48 |
#include <boost/geometry/srs/projections/proj/eqc.hpp> |
| 49 |
#include <boost/geometry/srs/projections/proj/eqdc.hpp> |
| 50 |
#include <boost/geometry/srs/projections/proj/etmerc.hpp> |
| 51 |
#include <boost/geometry/srs/projections/proj/fahey.hpp> |
| 52 |
#include <boost/geometry/srs/projections/proj/fouc_s.hpp> |
| 53 |
#include <boost/geometry/srs/projections/proj/gall.hpp> |
| 54 |
#include <boost/geometry/srs/projections/proj/geocent.hpp> |
| 55 |
#include <boost/geometry/srs/projections/proj/geos.hpp> |
| 56 |
#include <boost/geometry/srs/projections/proj/gins8.hpp> |
| 57 |
#include <boost/geometry/srs/projections/proj/gn_sinu.hpp> |
| 58 |
#include <boost/geometry/srs/projections/proj/gnom.hpp> |
| 59 |
#include <boost/geometry/srs/projections/proj/goode.hpp> |
| 60 |
#include <boost/geometry/srs/projections/proj/gstmerc.hpp> |
| 61 |
#include <boost/geometry/srs/projections/proj/hammer.hpp> |
| 62 |
#include <boost/geometry/srs/projections/proj/hatano.hpp> |
| 63 |
#include <boost/geometry/srs/projections/proj/healpix.hpp> |
| 64 |
#include <boost/geometry/srs/projections/proj/krovak.hpp> |
| 65 |
#include <boost/geometry/srs/projections/proj/igh.hpp> |
| 66 |
#include <boost/geometry/srs/projections/proj/imw_p.hpp> |
| 67 |
#include <boost/geometry/srs/projections/proj/isea.hpp> |
| 68 |
#include <boost/geometry/srs/projections/proj/laea.hpp> |
| 69 |
#include <boost/geometry/srs/projections/proj/labrd.hpp> |
| 70 |
#include <boost/geometry/srs/projections/proj/lagrng.hpp> |
| 71 |
#include <boost/geometry/srs/projections/proj/larr.hpp> |
| 72 |
#include <boost/geometry/srs/projections/proj/lask.hpp> |
| 73 |
#include <boost/geometry/srs/projections/proj/latlong.hpp> |
| 74 |
#include <boost/geometry/srs/projections/proj/lcc.hpp> |
| 75 |
#include <boost/geometry/srs/projections/proj/lcca.hpp> |
| 76 |
#include <boost/geometry/srs/projections/proj/loxim.hpp> |
| 77 |
#include <boost/geometry/srs/projections/proj/lsat.hpp> |
| 78 |
#include <boost/geometry/srs/projections/proj/mbtfpp.hpp> |
| 79 |
#include <boost/geometry/srs/projections/proj/mbtfpq.hpp> |
| 80 |
#include <boost/geometry/srs/projections/proj/mbt_fps.hpp> |
| 81 |
#include <boost/geometry/srs/projections/proj/merc.hpp> |
| 82 |
#include <boost/geometry/srs/projections/proj/mill.hpp> |
| 83 |
#include <boost/geometry/srs/projections/proj/mod_ster.hpp> |
| 84 |
#include <boost/geometry/srs/projections/proj/moll.hpp> |
| 85 |
#include <boost/geometry/srs/projections/proj/natearth.hpp> |
| 86 |
#include <boost/geometry/srs/projections/proj/nell.hpp> |
| 87 |
#include <boost/geometry/srs/projections/proj/nell_h.hpp> |
| 88 |
#include <boost/geometry/srs/projections/proj/nocol.hpp> |
| 89 |
#include <boost/geometry/srs/projections/proj/nsper.hpp> |
| 90 |
#include <boost/geometry/srs/projections/proj/nzmg.hpp> |
| 91 |
#include <boost/geometry/srs/projections/proj/ob_tran.hpp> |
| 92 |
#include <boost/geometry/srs/projections/proj/ocea.hpp> |
| 93 |
#include <boost/geometry/srs/projections/proj/oea.hpp> |
| 94 |
#include <boost/geometry/srs/projections/proj/omerc.hpp> |
| 95 |
#include <boost/geometry/srs/projections/proj/ortho.hpp> |
| 96 |
#include <boost/geometry/srs/projections/proj/qsc.hpp> |
| 97 |
#include <boost/geometry/srs/projections/proj/poly.hpp> |
| 98 |
#include <boost/geometry/srs/projections/proj/putp2.hpp> |
| 99 |
#include <boost/geometry/srs/projections/proj/putp3.hpp> |
| 100 |
#include <boost/geometry/srs/projections/proj/putp4p.hpp> |
| 101 |
#include <boost/geometry/srs/projections/proj/putp5.hpp> |
| 102 |
#include <boost/geometry/srs/projections/proj/putp6.hpp> |
| 103 |
#include <boost/geometry/srs/projections/proj/robin.hpp> |
| 104 |
#include <boost/geometry/srs/projections/proj/rouss.hpp> |
| 105 |
#include <boost/geometry/srs/projections/proj/rpoly.hpp> |
| 106 |
#include <boost/geometry/srs/projections/proj/sconics.hpp> |
| 107 |
#include <boost/geometry/srs/projections/proj/somerc.hpp> |
| 108 |
#include <boost/geometry/srs/projections/proj/stere.hpp> |
| 109 |
#include <boost/geometry/srs/projections/proj/sterea.hpp> |
| 110 |
#include <boost/geometry/srs/projections/proj/sts.hpp> |
| 111 |
#include <boost/geometry/srs/projections/proj/tcc.hpp> |
| 112 |
#include <boost/geometry/srs/projections/proj/tcea.hpp> |
| 113 |
#include <boost/geometry/srs/projections/proj/tmerc.hpp> |
| 114 |
#include <boost/geometry/srs/projections/proj/tpeqd.hpp> |
| 115 |
#include <boost/geometry/srs/projections/proj/urm5.hpp> |
| 116 |
#include <boost/geometry/srs/projections/proj/urmfps.hpp> |
| 117 |
#include <boost/geometry/srs/projections/proj/vandg.hpp> |
| 118 |
#include <boost/geometry/srs/projections/proj/vandg2.hpp> |
| 119 |
#include <boost/geometry/srs/projections/proj/vandg4.hpp> |
| 120 |
#include <boost/geometry/srs/projections/proj/wag2.hpp> |
| 121 |
#include <boost/geometry/srs/projections/proj/wag3.hpp> |
| 122 |
#include <boost/geometry/srs/projections/proj/wag7.hpp> |
| 123 |
#include <boost/geometry/srs/projections/proj/wink1.hpp> |
| 124 |
#include <boost/geometry/srs/projections/proj/wink2.hpp> |
| 125 |
|
| 126 |
namespace boost { namespace geometry { namespace projections |
| 127 |
{ |
| 128 |
|
| 129 |
namespace detail |
| 130 |
{ |
| 131 |
|
| 132 |
template <typename Params> |
| 133 |
struct factory_key |
| 134 |
{ |
| 135 |
BOOST_GEOMETRY_STATIC_ASSERT_FALSE( |
| 136 |
"Invalid parameters type.", |
| 137 |
Params); |
| 138 |
}; |
| 139 |
|
| 140 |
template <> |
| 141 |
struct factory_key<srs::detail::proj4_parameters> |
| 142 |
{ |
| 143 |
typedef std::string type; |
| 144 |
template <typename ProjParams> |
| 145 |
static type const& get(ProjParams const& par) |
| 146 |
{ |
| 147 |
return par.id.name; |
| 148 |
} |
| 149 |
static const char* get(const char* name, srs::dpar::value_proj ) |
| 150 |
{ |
| 151 |
return name; |
| 152 |
} |
| 153 |
}; |
| 154 |
|
| 155 |
template <typename T> |
| 156 |
struct factory_key<srs::dpar::parameters<T> > |
| 157 |
{ |
| 158 |
typedef srs::dpar::value_proj type; |
| 159 |
template <typename ProjParams> |
| 160 |
static type const& get(ProjParams const& par) |
| 161 |
{ |
| 162 |
return par.id.id; |
| 163 |
} |
| 164 |
static srs::dpar::value_proj get(const char* , srs::dpar::value_proj id) |
| 165 |
{ |
| 166 |
return id; |
| 167 |
} |
| 168 |
}; |
| 169 |
|
| 170 |
|
| 171 |
template <typename Params, typename CT, typename ProjParams> |
| 172 |
class factory |
| 173 |
{ |
| 174 |
private: |
| 175 |
typedef detail::factory_entry |
| 176 |
< |
| 177 |
Params, |
| 178 |
CT, |
| 179 |
ProjParams |
| 180 |
> entry_base; |
| 181 |
|
| 182 |
typedef factory_key<Params> key; |
| 183 |
typedef typename key::type key_type; |
| 184 |
typedef boost::shared_ptr<entry_base> entry_ptr; |
| 185 |
|
| 186 |
typedef std::map<key_type, entry_ptr> entries_map; |
| 187 |
|
| 188 |
entries_map m_entries; |
| 189 |
|
| 190 |
public: |
| 191 |
|
| 192 |
factory() |
| 193 |
{ |
| 194 |
detail::aea_init(*this); |
| 195 |
detail::aeqd_init(*this); |
| 196 |
detail::airy_init(*this); |
| 197 |
detail::aitoff_init(*this); |
| 198 |
detail::august_init(*this); |
| 199 |
detail::bacon_init(*this); |
| 200 |
detail::bipc_init(*this); |
| 201 |
detail::boggs_init(*this); |
| 202 |
detail::bonne_init(*this); |
| 203 |
detail::cass_init(*this); |
| 204 |
detail::cc_init(*this); |
| 205 |
detail::cea_init(*this); |
| 206 |
detail::chamb_init(*this); |
| 207 |
detail::col_urban_init(*this); |
| 208 |
detail::collg_init(*this); |
| 209 |
detail::crast_init(*this); |
| 210 |
detail::denoy_init(*this); |
| 211 |
detail::eck1_init(*this); |
| 212 |
detail::eck2_init(*this); |
| 213 |
detail::eck3_init(*this); |
| 214 |
detail::eck4_init(*this); |
| 215 |
detail::eck5_init(*this); |
| 216 |
detail::eqc_init(*this); |
| 217 |
detail::eqdc_init(*this); |
| 218 |
detail::etmerc_init(*this); |
| 219 |
detail::fahey_init(*this); |
| 220 |
detail::fouc_s_init(*this); |
| 221 |
detail::gall_init(*this); |
| 222 |
detail::geocent_init(*this); |
| 223 |
detail::geos_init(*this); |
| 224 |
detail::gins8_init(*this); |
| 225 |
detail::gn_sinu_init(*this); |
| 226 |
detail::gnom_init(*this); |
| 227 |
detail::goode_init(*this); |
| 228 |
detail::gstmerc_init(*this); |
| 229 |
detail::hammer_init(*this); |
| 230 |
detail::hatano_init(*this); |
| 231 |
detail::healpix_init(*this); |
| 232 |
detail::krovak_init(*this); |
| 233 |
detail::igh_init(*this); |
| 234 |
detail::imw_p_init(*this); |
| 235 |
detail::isea_init(*this); |
| 236 |
detail::labrd_init(*this); |
| 237 |
detail::laea_init(*this); |
| 238 |
detail::lagrng_init(*this); |
| 239 |
detail::larr_init(*this); |
| 240 |
detail::lask_init(*this); |
| 241 |
detail::latlong_init(*this); |
| 242 |
detail::lcc_init(*this); |
| 243 |
detail::lcca_init(*this); |
| 244 |
detail::loxim_init(*this); |
| 245 |
detail::lsat_init(*this); |
| 246 |
detail::mbtfpp_init(*this); |
| 247 |
detail::mbtfpq_init(*this); |
| 248 |
detail::mbt_fps_init(*this); |
| 249 |
detail::merc_init(*this); |
| 250 |
detail::mill_init(*this); |
| 251 |
detail::mod_ster_init(*this); |
| 252 |
detail::moll_init(*this); |
| 253 |
detail::natearth_init(*this); |
| 254 |
detail::nell_init(*this); |
| 255 |
detail::nell_h_init(*this); |
| 256 |
detail::nocol_init(*this); |
| 257 |
detail::nsper_init(*this); |
| 258 |
detail::nzmg_init(*this); |
| 259 |
detail::ob_tran_init(*this); |
| 260 |
detail::ocea_init(*this); |
| 261 |
detail::oea_init(*this); |
| 262 |
detail::omerc_init(*this); |
| 263 |
detail::ortho_init(*this); |
| 264 |
detail::qsc_init(*this); |
| 265 |
detail::poly_init(*this); |
| 266 |
detail::putp2_init(*this); |
| 267 |
detail::putp3_init(*this); |
| 268 |
detail::putp4p_init(*this); |
| 269 |
detail::putp5_init(*this); |
| 270 |
detail::putp6_init(*this); |
| 271 |
detail::robin_init(*this); |
| 272 |
detail::rouss_init(*this); |
| 273 |
detail::rpoly_init(*this); |
| 274 |
detail::sconics_init(*this); |
| 275 |
detail::somerc_init(*this); |
| 276 |
detail::stere_init(*this); |
| 277 |
detail::sterea_init(*this); |
| 278 |
detail::sts_init(*this); |
| 279 |
detail::tcc_init(*this); |
| 280 |
detail::tcea_init(*this); |
| 281 |
detail::tmerc_init(*this); |
| 282 |
detail::tpeqd_init(*this); |
| 283 |
detail::urm5_init(*this); |
| 284 |
detail::urmfps_init(*this); |
| 285 |
detail::vandg_init(*this); |
| 286 |
detail::vandg2_init(*this); |
| 287 |
detail::vandg4_init(*this); |
| 288 |
detail::wag2_init(*this); |
| 289 |
detail::wag3_init(*this); |
| 290 |
detail::wag7_init(*this); |
| 291 |
detail::wink1_init(*this); |
| 292 |
detail::wink2_init(*this); |
| 293 |
} |
| 294 |
|
| 295 |
void add_to_factory(const char* name, srs::dpar::value_proj id, entry_base* entry) |
| 296 |
{ |
| 297 |
// The pointer has to be owned before std::map::operator[] in case it thrown an exception. |
| 298 |
entry_ptr ptr(entry); |
| 299 |
m_entries[key::get(name, id)] = ptr; |
| 300 |
} |
| 301 |
|
| 302 |
detail::dynamic_wrapper_b<CT, ProjParams>* create_new(Params const& params, ProjParams const& proj_par) const |
| 303 |
{ |
| 304 |
typedef typename entries_map::const_iterator const_iterator; |
| 305 |
const_iterator it = m_entries.find(key::get(proj_par)); |
| 306 |
if (it != m_entries.end()) |
| 307 |
{ |
| 308 |
return it->second->create_new(params, proj_par); |
| 309 |
} |
| 310 |
|
| 311 |
return 0; |
| 312 |
} |
| 313 |
}; |
| 314 |
|
| 315 |
template <typename T> |
| 316 |
inline detail::dynamic_wrapper_b<T, projections::parameters<T> >* |
| 317 |
create_new(srs::detail::proj4_parameters const& params, |
| 318 |
projections::parameters<T> const& parameters) |
| 319 |
{ |
| 320 |
static factory<srs::detail::proj4_parameters, T, projections::parameters<T> > const fac; |
| 321 |
return fac.create_new(params, parameters); |
| 322 |
} |
| 323 |
|
| 324 |
template <typename T> |
| 325 |
inline detail::dynamic_wrapper_b<T, projections::parameters<T> >* |
| 326 |
create_new(srs::dpar::parameters<T> const& params, |
| 327 |
projections::parameters<T> const& parameters) |
| 328 |
{ |
| 329 |
static factory<srs::dpar::parameters<T>, T, projections::parameters<T> > const fac; |
| 330 |
return fac.create_new(params, parameters); |
| 331 |
} |
| 332 |
|
| 333 |
|
| 334 |
} // namespace detail |
| 335 |
|
| 336 |
}}} // namespace boost::geometry::projections |
| 337 |
|
| 338 |
#endif // BOOST_GEOMETRY_PROJECTIONS_FACTORY_HPP |