summaryrefslogtreecommitdiff
path: root/boost/geometry/srs/projections/proj/lcc.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/geometry/srs/projections/proj/lcc.hpp')
-rw-r--r--boost/geometry/srs/projections/proj/lcc.hpp66
1 files changed, 35 insertions, 31 deletions
diff --git a/boost/geometry/srs/projections/proj/lcc.hpp b/boost/geometry/srs/projections/proj/lcc.hpp
index f8fdd015ea..1b261cb70b 100644
--- a/boost/geometry/srs/projections/proj/lcc.hpp
+++ b/boost/geometry/srs/projections/proj/lcc.hpp
@@ -55,12 +55,6 @@
namespace boost { namespace geometry
{
-namespace srs { namespace par4
-{
- struct lcc {}; // Lambert Conformal Conic
-
-}} //namespace srs::par4
-
namespace projections
{
#ifndef DOXYGEN_NO_DETAIL
@@ -92,7 +86,7 @@ namespace projections
// FORWARD(e_forward) ellipsoid & spheroid
// Project coordinates from geographic (lon, lat) to cartesian (x, y)
- inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const
+ inline void fwd(T lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
{
static const T fourth_pi = detail::fourth_pi<T>();
static const T half_pi = detail::half_pi<T>();
@@ -116,7 +110,7 @@ namespace projections
// INVERSE(e_inverse) ellipsoid & spheroid
// Project coordinates from cartesian (x, y) to geographic (lon, lat)
- inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const
+ inline void inv(T xy_x, T xy_y, T& lp_lon, T& lp_lat) const
{
static const T half_pi = detail::half_pi<T>();
@@ -155,8 +149,8 @@ namespace projections
};
// Lambert Conformal Conic
- template <typename Parameters, typename T>
- inline void setup_lcc(Parameters& par, par_lcc<T>& proj_parm)
+ template <typename Params, typename Parameters, typename T>
+ inline void setup_lcc(Params const& params, Parameters& par, par_lcc<T>& proj_parm)
{
static const T fourth_pi = detail::fourth_pi<T>();
static const T half_pi = detail::half_pi<T>();
@@ -164,12 +158,29 @@ namespace projections
T cosphi, sinphi;
int secant;
- proj_parm.phi1 = pj_get_param_r(par.params, "lat_1");
- if (pj_param_r(par.params, "lat_2", proj_parm.phi2)) {
- /* empty */
- } else {
+ proj_parm.phi1 = 0.0;
+ proj_parm.phi2 = 0.0;
+ bool is_phi1_set = pj_param_r<srs::spar::lat_1>(params, "lat_1", srs::dpar::lat_1, proj_parm.phi1);
+ bool is_phi2_set = pj_param_r<srs::spar::lat_2>(params, "lat_2", srs::dpar::lat_2, proj_parm.phi2);
+
+ // Boost.Geometry specific, set default parameters manually
+ if (! is_phi1_set || ! is_phi2_set) {
+ bool const use_defaults = ! pj_get_param_b<srs::spar::no_defs>(params, "no_defs", srs::dpar::no_defs);
+ if (use_defaults) {
+ if (!is_phi1_set) {
+ proj_parm.phi1 = 33;
+ is_phi1_set = true;
+ }
+ if (!is_phi2_set) {
+ proj_parm.phi2 = 45;
+ is_phi2_set = true;
+ }
+ }
+ }
+
+ if (! is_phi2_set) {
proj_parm.phi2 = proj_parm.phi1;
- if (!pj_param_exists(par.params, "lat_0"))
+ if (! pj_param_exists<srs::spar::lat_0>(params, "lat_0", srs::dpar::lat_0))
par.phi0 = proj_parm.phi1;
}
if (fabs(proj_parm.phi1 + proj_parm.phi2) < epsilon10)
@@ -226,9 +237,11 @@ namespace projections
template <typename T, typename Parameters>
struct lcc_ellipsoid : public detail::lcc::base_lcc_ellipsoid<T, Parameters>
{
- inline lcc_ellipsoid(const Parameters& par) : detail::lcc::base_lcc_ellipsoid<T, Parameters>(par)
+ template <typename Params>
+ inline lcc_ellipsoid(Params const& params, Parameters const& par)
+ : detail::lcc::base_lcc_ellipsoid<T, Parameters>(par)
{
- detail::lcc::setup_lcc(this->m_par, this->m_proj_parm);
+ detail::lcc::setup_lcc(params, this->m_par, this->m_proj_parm);
}
};
@@ -237,23 +250,14 @@ namespace projections
{
// Static projection
- BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::lcc, lcc_ellipsoid, lcc_ellipsoid)
+ BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::spar::proj_lcc, lcc_ellipsoid, lcc_ellipsoid)
// Factory entry(s)
- template <typename T, typename Parameters>
- class lcc_entry : public detail::factory_entry<T, Parameters>
- {
- public :
- virtual base_v<T, Parameters>* create_new(const Parameters& par) const
- {
- return new base_v_fi<lcc_ellipsoid<T, Parameters>, T, Parameters>(par);
- }
- };
-
- template <typename T, typename Parameters>
- inline void lcc_init(detail::base_factory<T, Parameters>& factory)
+ BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(lcc_entry, lcc_ellipsoid)
+
+ BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(lcc_init)
{
- factory.add_to_factory("lcc", new lcc_entry<T, Parameters>);
+ BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(lcc, lcc_entry);
}
} // namespace detail