| 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-2020. |
| 7 |
// Modifications Copyright (c) 2017, 2026, 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 |
|
| 52 |
|
| 53 |
namespace boost { namespace geometry { namespace projections |
| 54 |
{ |
| 55 |
|
| 56 |
#ifndef DOXYGEN_NO_DETAIL |
| 57 |
namespace detail |
| 58 |
{ |
| 59 |
|
| 60 |
/* datum_type values */ |
| 61 |
enum datum_type |
| 62 |
{ |
| 63 |
datum_unknown = 0, |
| 64 |
datum_3param = 1, |
| 65 |
datum_7param = 2, |
| 66 |
datum_gridshift = 3, |
| 67 |
datum_wgs84 = 4 /* WGS84 (or anything considered equivelent) */ |
| 68 |
}; |
| 69 |
|
| 70 |
// Originally defined in proj_internal.h |
| 71 |
//enum pj_io_units { |
| 72 |
// pj_io_units_whatever = 0, /* Doesn't matter (or depends on pipeline neighbours) */ |
| 73 |
// pj_io_units_classic = 1, /* Scaled meters (right), projected system */ |
| 74 |
// pj_io_units_projected = 2, /* Meters, projected system */ |
| 75 |
// pj_io_units_cartesian = 3, /* Meters, 3D cartesian system */ |
| 76 |
// pj_io_units_angular = 4 /* Radians */ |
| 77 |
//}; |
| 78 |
|
| 79 |
// Originally defined in proj_internal.h |
| 80 |
/* Maximum latitudinal overshoot accepted */ |
| 81 |
//static const double pj_epsilon_lat = 1e-12; |
| 82 |
|
| 83 |
template <typename T> |
| 84 |
struct pj_consts |
| 85 |
{ |
| 86 |
// E L L I P S O I D P A R A M E T E R S |
| 87 |
|
| 88 |
T a; /* semimajor axis (radius if eccentricity==0) */ |
| 89 |
T ra; /* 1/a */ |
| 90 |
|
| 91 |
T e; /* first eccentricity */ |
| 92 |
T es; /* first eccentricity squared */ |
| 93 |
T one_es; /* 1 - e^2 */ |
| 94 |
T rone_es; /* 1/one_es */ |
| 95 |
|
| 96 |
T es_orig, a_orig; /* es and a before any +proj related adjustment */ |
| 97 |
|
| 98 |
// C A R T O G R A P H I C O F F S E T S |
| 99 |
|
| 100 |
T lam0, phi0; /* central longitude, latitude */ |
| 101 |
T x0, y0/*, z0, t0*/; /* false easting and northing (and height and time) */ |
| 102 |
|
| 103 |
// S C A L I N G |
| 104 |
|
| 105 |
T k0; /* general scaling factor */ |
| 106 |
T to_meter, fr_meter; /* cartesian scaling */ |
| 107 |
T vto_meter, vfr_meter; /* Vertical scaling. Internal unit [m] */ |
| 108 |
|
| 109 |
// D A T U M S A N D H E I G H T S Y S T E M S |
| 110 |
|
| 111 |
T from_greenwich; /* prime meridian offset (in radians) */ |
| 112 |
T long_wrap_center; /* 0.0 for -180 to 180, actually in radians*/ |
| 113 |
|
| 114 |
srs::detail::towgs84<T> datum_params; /* Parameters for 3PARAM and 7PARAM */ |
| 115 |
srs::detail::nadgrids nadgrids; /* Names of horozontal grid files. */ |
| 116 |
detail::datum_type datum_type; /* PJD_UNKNOWN/3PARAM/7PARAM/GRIDSHIFT/WGS84 */ |
| 117 |
|
| 118 |
bool is_long_wrap_set; |
| 119 |
|
| 120 |
// C O O R D I N A T E H A N D L I N G |
| 121 |
|
| 122 |
bool over; /* over-range flag */ |
| 123 |
bool geoc; /* geocentric latitude flag */ |
| 124 |
bool is_latlong; /* proj=latlong ... not really a projection at all */ |
| 125 |
bool is_geocent; /* proj=geocent ... not really a projection at all */ |
| 126 |
//bool need_ellps; /* 0 for operations that are purely cartesian */ |
| 127 |
|
| 128 |
//enum pj_io_units left; /* Flags for input/output coordinate types */ |
| 129 |
//enum pj_io_units right; |
| 130 |
|
| 131 |
srs::detail::axis axis; |
| 132 |
srs::detail::axis sign; |
| 133 |
|
| 134 |
// Initialize all variables |
| 135 |
pj_consts() |
| 136 |
: a(0), ra(0) |
| 137 |
, e(0), es(0), one_es(0), rone_es(0) |
| 138 |
, es_orig(0), a_orig(0) |
| 139 |
, lam0(0), phi0(0) |
| 140 |
, x0(0), y0(0)/*, z0(0), t0(0)*/ |
| 141 |
, k0(0) , to_meter(0), fr_meter(0), vto_meter(0), vfr_meter(0) |
| 142 |
, from_greenwich(0), long_wrap_center(0) |
| 143 |
, datum_type(datum_unknown) |
| 144 |
, is_long_wrap_set(false) |
| 145 |
, over(false), geoc(false), is_latlong(false), is_geocent(false) |
| 146 |
, axis(0,1,2), sign(1,1,1) //the default east, northing, elevation |
| 147 |
//, need_ellps(true) |
| 148 |
//, left(PJ_IO_UNITS_ANGULAR), right(PJ_IO_UNITS_CLASSIC) |
| 149 |
{} |
| 150 |
}; |
| 151 |
|
| 152 |
// PROJ4 complex. Might be replaced with std::complex |
| 153 |
template <typename T> |
| 154 |
struct pj_complex { T r, i; }; |
| 155 |
|
| 156 |
} // namespace detail |
| 157 |
#endif // DOXYGEN_NO_DETAIL |
| 158 |
|
| 159 |
/*! |
| 160 |
\brief parameters, projection parameters |
| 161 |
\details This structure initializes all projections |
| 162 |
\ingroup projection |
| 163 |
*/ |
| 164 |
template <typename T> |
| 165 |
struct parameters : public detail::pj_consts<T> |
| 166 |
{ |
| 167 |
typedef T type; |
| 168 |
|
| 169 |
struct proj_id |
| 170 |
{ |
| 171 |
proj_id() |
| 172 |
: id(srs::dpar::proj_unknown) |
| 173 |
{} |
| 174 |
|
| 175 |
proj_id(srs::dpar::value_proj i) |
| 176 |
: id(i) |
| 177 |
{} |
| 178 |
|
| 179 |
proj_id(std::string const& s) |
| 180 |
: id(srs::dpar::proj_unknown) |
| 181 |
, name(s) |
| 182 |
{} |
| 183 |
|
| 184 |
bool is_unknown() const |
| 185 |
{ |
| 186 |
return id == srs::dpar::proj_unknown && name.empty(); |
| 187 |
} |
| 188 |
|
| 189 |
// Either one of these is set: |
| 190 |
srs::dpar::value_proj id; // id of projection |
| 191 |
std::string name; // name of projection |
| 192 |
}; |
| 193 |
|
| 194 |
proj_id id; |
| 195 |
}; |
| 196 |
|
| 197 |
}}} // namespace boost::geometry::projections |
| 198 |
#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PROJECTS_HPP |