1 // Boost.Geometry - gis-projections (based on PROJ4) 2 3 // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. 4 5 // This file was modified by Oracle on 2017, 2018. 6 // Modifications copyright (c) 2017-2018, 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 // This file is converted from PROJ4, http://trac.osgeo.org/proj 14 // PROJ4 is originally written by Gerald Evenden (then of the USGS) 15 // PROJ4 is maintained by Frank Warmerdam 16 // PROJ4 is converted to Boost.Geometry by Barend Gehrels 17 18 // Last updated version of proj: 5.0.0 19 20 // Original copyright notice: 21 22 // Permission is hereby granted, free of charge, to any person obtaining a 23 // copy of this software and associated documentation files (the "Software"), 24 // to deal in the Software without restriction, including without limitation 25 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 26 // and/or sell copies of the Software, and to permit persons to whom the 27 // Software is furnished to do so, subject to the following conditions: 28 29 // The above copyright notice and this permission notice shall be included 30 // in all copies or substantial portions of the Software. 31 32 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 33 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 34 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 35 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 36 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 37 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 38 // DEALINGS IN THE SOFTWARE. 39 40 #ifndef BOOST_GEOMETRY_PROJECTIONS_CC_HPP 41 #define BOOST_GEOMETRY_PROJECTIONS_CC_HPP 42 43 #include <boost/geometry/util/math.hpp> 44 45 #include <boost/geometry/srs/projections/impl/base_static.hpp> 46 #include <boost/geometry/srs/projections/impl/base_dynamic.hpp> 47 #include <boost/geometry/srs/projections/impl/projects.hpp> 48 #include <boost/geometry/srs/projections/impl/factory_entry.hpp> 49 50 namespace boost { namespace geometry 51 { 52 53 namespace projections 54 { 55 #ifndef DOXYGEN_NO_DETAIL 56 namespace detail { namespace cc 57 { 58 59 static const double epsilon10 = 1.e-10; 60 61 // template class, using CRTP to implement forward/inverse 62 template <typename T, typename Parameters> 63 struct base_cc_spheroid 64 : public base_t_fi<base_cc_spheroid<T, Parameters>, T, Parameters> 65 { base_cc_spheroidboost::geometry::projections::detail::cc::base_cc_spheroid66 inline base_cc_spheroid(const Parameters& par) 67 : base_t_fi<base_cc_spheroid<T, Parameters>, T, Parameters>(*this, par) 68 {} 69 70 // FORWARD(s_forward) spheroid 71 // Project coordinates from geographic (lon, lat) to cartesian (x, y) fwdboost::geometry::projections::detail::cc::base_cc_spheroid72 inline void fwd(T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const 73 { 74 static const T half_pi = detail::half_pi<T>(); 75 76 if (fabs(fabs(lp_lat) - half_pi) <= epsilon10) { 77 BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) ); 78 } 79 xy_x = lp_lon; 80 xy_y = tan(lp_lat); 81 } 82 83 // INVERSE(s_inverse) spheroid 84 // Project coordinates from cartesian (x, y) to geographic (lon, lat) invboost::geometry::projections::detail::cc::base_cc_spheroid85 inline void inv(T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const 86 { 87 lp_lat = atan(xy_y); 88 lp_lon = xy_x; 89 } 90 get_nameboost::geometry::projections::detail::cc::base_cc_spheroid91 static inline std::string get_name() 92 { 93 return "cc_spheroid"; 94 } 95 96 }; 97 98 // Central Cylindrical 99 template <typename Parameters> setup_cc(Parameters & par)100 inline void setup_cc(Parameters& par) 101 { 102 par.es = 0.; 103 } 104 105 }} // namespace detail::cc 106 #endif // doxygen 107 108 /*! 109 \brief Central Cylindrical projection 110 \ingroup projections 111 \tparam Geographic latlong point type 112 \tparam Cartesian xy point type 113 \tparam Parameters parameter type 114 \par Projection characteristics 115 - Cylindrical 116 - Spheroid 117 \par Example 118 \image html ex_cc.gif 119 */ 120 template <typename T, typename Parameters> 121 struct cc_spheroid : public detail::cc::base_cc_spheroid<T, Parameters> 122 { 123 template <typename Params> cc_spheroidboost::geometry::projections::cc_spheroid124 inline cc_spheroid(Params const& , Parameters const& par) 125 : detail::cc::base_cc_spheroid<T, Parameters>(par) 126 { 127 detail::cc::setup_cc(this->m_par); 128 } 129 }; 130 131 #ifndef DOXYGEN_NO_DETAIL 132 namespace detail 133 { 134 135 // Static projection BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::spar::proj_cc,cc_spheroid,cc_spheroid)136 BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::spar::proj_cc, cc_spheroid, cc_spheroid) 137 138 // Factory entry(s) 139 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(cc_entry, cc_spheroid) 140 141 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(cc_init) 142 { 143 BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(cc, cc_entry); 144 } 145 146 } // namespace detail 147 #endif // doxygen 148 149 } // namespace projections 150 151 }} // namespace boost::geometry 152 153 #endif // BOOST_GEOMETRY_PROJECTIONS_CC_HPP 154 155