1 // Boost.Geometry (aka GGL, Generic Geometry Library) 2 // This file is manually converted from PROJ4 (projects.h) 3 4 // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands. 5 6 // This file was modified by Oracle on 2017, 2018. 7 // Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. 8 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle 9 10 // Use, modification and distribution is subject to the Boost Software License, 11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 12 // http://www.boost.org/LICENSE_1_0.txt) 13 14 // This file is converted from PROJ4, http://trac.osgeo.org/proj 15 // PROJ4 is originally written by Gerald Evenden (then of the USGS) 16 // PROJ4 is maintained by Frank Warmerdam 17 // PROJ4 is converted to Geometry Library by Barend Gehrels (Geodan, Amsterdam) 18 19 // Original copyright notice: 20 21 // Permission is hereby granted, free of charge, to any person obtaining a 22 // copy of this software and associated documentation files (the "Software"), 23 // to deal in the Software without restriction, including without limitation 24 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 25 // and/or sell copies of the Software, and to permit persons to whom the 26 // Software is furnished to do so, subject to the following conditions: 27 28 // The above copyright notice and this permission notice shall be included 29 // in all copies or substantial portions of the Software. 30 31 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 32 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 33 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 34 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 35 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 36 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 37 // DEALINGS IN THE SOFTWARE. 38 39 #ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_PROJECTS_HPP 40 #define BOOST_GEOMETRY_PROJECTIONS_IMPL_PROJECTS_HPP 41 42 43 #include <cstring> 44 #include <string> 45 #include <vector> 46 47 #include <boost/config.hpp> 48 #include <boost/geometry/srs/projections/constants.hpp> 49 #include <boost/geometry/srs/projections/dpar.hpp> 50 #include <boost/geometry/srs/projections/spar.hpp> 51 #include <boost/mpl/if.hpp> 52 #include <boost/type_traits/is_pod.hpp> 53 54 55 namespace boost { namespace geometry { namespace projections 56 { 57 58 #ifndef DOXYGEN_NO_DETAIL 59 namespace detail 60 { 61 62 /* datum_type values */ 63 enum datum_type 64 { 65 datum_unknown = 0, 66 datum_3param = 1, 67 datum_7param = 2, 68 datum_gridshift = 3, 69 datum_wgs84 = 4 /* WGS84 (or anything considered equivelent) */ 70 }; 71 72 // Originally defined in proj_internal.h 73 //enum pj_io_units { 74 // pj_io_units_whatever = 0, /* Doesn't matter (or depends on pipeline neighbours) */ 75 // pj_io_units_classic = 1, /* Scaled meters (right), projected system */ 76 // pj_io_units_projected = 2, /* Meters, projected system */ 77 // pj_io_units_cartesian = 3, /* Meters, 3D cartesian system */ 78 // pj_io_units_angular = 4 /* Radians */ 79 //}; 80 81 // Originally defined in proj_internal.h 82 /* Maximum latitudinal overshoot accepted */ 83 //static const double pj_epsilon_lat = 1e-12; 84 85 template <typename T> 86 struct pj_consts 87 { 88 // E L L I P S O I D P A R A M E T E R S 89 90 T a; /* semimajor axis (radius if eccentricity==0) */ 91 T ra; /* 1/a */ 92 93 T e; /* first eccentricity */ 94 T es; /* first eccentricity squared */ 95 T one_es; /* 1 - e^2 */ 96 T rone_es; /* 1/one_es */ 97 98 T es_orig, a_orig; /* es and a before any +proj related adjustment */ 99 100 // C O O R D I N A T E H A N D L I N G 101 102 int over; /* over-range flag */ 103 int geoc; /* geocentric latitude flag */ 104 int is_latlong; /* proj=latlong ... not really a projection at all */ 105 int is_geocent; /* proj=geocent ... not really a projection at all */ 106 //int need_ellps; /* 0 for operations that are purely cartesian */ 107 108 //enum pj_io_units left; /* Flags for input/output coordinate types */ 109 //enum pj_io_units right; 110 111 // C A R T O G R A P H I C O F F S E T S 112 113 T lam0, phi0; /* central longitude, latitude */ 114 T x0, y0/*, z0, t0*/; /* false easting and northing (and height and time) */ 115 116 // S C A L I N G 117 118 T k0; /* general scaling factor */ 119 T to_meter, fr_meter; /* cartesian scaling */ 120 T vto_meter, vfr_meter; /* Vertical scaling. Internal unit [m] */ 121 122 // D A T U M S A N D H E I G H T S Y S T E M S 123 124 detail::datum_type datum_type; /* PJD_UNKNOWN/3PARAM/7PARAM/GRIDSHIFT/WGS84 */ 125 srs::detail::towgs84<T> datum_params; /* Parameters for 3PARAM and 7PARAM */ 126 srs::detail::nadgrids nadgrids; /* Names of horozontal grid files. */ 127 128 T from_greenwich; /* prime meridian offset (in radians) */ 129 T long_wrap_center; /* 0.0 for -180 to 180, actually in radians*/ 130 bool is_long_wrap_set; 131 132 // Initialize all variables pj_constsboost::geometry::projections::detail::pj_consts133 pj_consts() 134 : a(0), ra(0) 135 , e(0), es(0), one_es(0), rone_es(0) 136 , es_orig(0), a_orig(0) 137 , over(0), geoc(0), is_latlong(0), is_geocent(0) 138 //, need_ellps(1) 139 //, left(PJ_IO_UNITS_ANGULAR), right(PJ_IO_UNITS_CLASSIC) 140 , lam0(0), phi0(0) 141 , x0(0), y0(0)/*, z0(0), t0(0)*/ 142 , k0(0) , to_meter(0), fr_meter(0), vto_meter(0), vfr_meter(0) 143 , datum_type(datum_unknown) 144 , from_greenwich(0), long_wrap_center(0), is_long_wrap_set(false) 145 {} 146 }; 147 148 // PROJ4 complex. Might be replaced with std::complex 149 template <typename T> 150 struct pj_complex { T r, i; }; 151 152 } // namespace detail 153 #endif // DOXYGEN_NO_DETAIL 154 155 /*! 156 \brief parameters, projection parameters 157 \details This structure initializes all projections 158 \ingroup projection 159 */ 160 template <typename T> 161 struct parameters : public detail::pj_consts<T> 162 { 163 typedef T type; 164 165 struct proj_id 166 { proj_idboost::geometry::projections::parameters::proj_id167 proj_id() 168 : id(srs::dpar::proj_unknown) 169 {} 170 proj_idboost::geometry::projections::parameters::proj_id171 proj_id(srs::dpar::value_proj i) 172 : id(i) 173 {} 174 proj_idboost::geometry::projections::parameters::proj_id175 proj_id(std::string const& s) 176 : id(srs::dpar::proj_unknown) 177 , name(s) 178 {} 179 is_unknownboost::geometry::projections::parameters::proj_id180 bool is_unknown() const 181 { 182 return id == srs::dpar::proj_unknown && name.empty(); 183 } 184 185 // Either one of these is set: 186 srs::dpar::value_proj id; // id of projection 187 std::string name; // name of projection 188 }; 189 190 proj_id id; 191 }; 192 193 }}} // namespace boost::geometry::projections 194 #endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PROJECTS_HPP 195