summaryrefslogtreecommitdiff
path: root/boost/geometry/srs/projections/impl/projects.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/geometry/srs/projections/impl/projects.hpp')
-rw-r--r--boost/geometry/srs/projections/impl/projects.hpp321
1 files changed, 147 insertions, 174 deletions
diff --git a/boost/geometry/srs/projections/impl/projects.hpp b/boost/geometry/srs/projections/impl/projects.hpp
index 232ae67ae9..2f94ffd021 100644
--- a/boost/geometry/srs/projections/impl/projects.hpp
+++ b/boost/geometry/srs/projections/impl/projects.hpp
@@ -3,8 +3,8 @@
// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
-// This file was modified by Oracle on 2017.
-// Modifications copyright (c) 2017, Oracle and/or its affiliates.
+// This file was modified by Oracle on 2017, 2018.
+// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
@@ -44,8 +44,8 @@
#include <string>
#include <vector>
-#include <boost/geometry/srs/projections/exception.hpp>
-#include <boost/math/constants/constants.hpp>
+#include <boost/config.hpp>
+#include <boost/geometry/srs/projections/constants.hpp>
#include <boost/mpl/if.hpp>
#include <boost/type_traits/is_pod.hpp>
@@ -57,199 +57,172 @@ namespace boost { namespace geometry { namespace projections
namespace detail
{
-/* some useful constants */
-template <typename T>
-inline T ONEPI() { return boost::math::constants::pi<T>(); }
-template <typename T>
-inline T HALFPI() { return boost::math::constants::half_pi<T>(); }
-template <typename T>
-inline T FORTPI() { return boost::math::constants::pi<T>() / T(4); }
-template <typename T>
-inline T TWOPI() { return boost::math::constants::two_pi<T>(); }
-template <typename T>
-inline T TWO_D_PI() { return boost::math::constants::two_div_pi<T>(); }
-template <typename T>
-inline T HALFPI_SQR() { return 2.4674011002723396547086227499689; }
-template <typename T>
-inline T PI_SQR() { return boost::math::constants::pi_sqr<T>(); }
-template <typename T>
-inline T THIRD() { return 0.3333333333333333333333333333333; }
-template <typename T>
-inline T TWOTHIRD() { return 0.6666666666666666666666666666666; }
-template <typename T>
-inline T PI_HALFPI() { return 4.7123889803846898576939650749193; }
-template <typename T>
-inline T TWOPI_HALFPI() { return 7.8539816339744830961566084581988; }
-template <typename T>
-inline T PI_DIV_3() { return 1.0471975511965977461542144610932; }
-
/* datum_type values */
-static const int PJD_UNKNOWN = 0;
-static const int PJD_3PARAM = 1;
-static const int PJD_7PARAM = 2;
-static const int PJD_GRIDSHIFT = 3;
-static const int PJD_WGS84 = 4; /* WGS84 (or anything considered equivelent) */
+enum datum_type
+{
+ datum_unknown = 0,
+ datum_3param = 1,
+ datum_7param = 2,
+ datum_gridshift = 3,
+ datum_wgs84 = 4 /* WGS84 (or anything considered equivelent) */
+};
/* library errors */
-static const int PJD_ERR_GEOCENTRIC = -45;
-static const int PJD_ERR_AXIS = -47;
-static const int PJD_ERR_GRID_AREA = -48;
-static const int PJD_ERR_CATALOG = -49;
+enum error_type
+{
+ error_no_args = -1,
+ error_no_option_in_init_file = -2,
+ error_no_colon_in_init_string = -3,
+ error_proj_not_named = -4,
+ error_unknown_projection_id = -5,
+ error_eccentricity_is_one = -6,
+ error_unknow_unit_id = -7,
+ error_invalid_boolean_param = -8,
+ error_unknown_ellp_param = -9,
+ error_rev_flattening_is_zero = -10,
+ error_ref_rad_larger_than_90 = -11,
+ error_es_less_than_zero = -12,
+ error_major_axis_not_given = -13,
+ error_lat_or_lon_exceed_limit = -14,
+ error_invalid_x_or_y = -15,
+ error_wrong_format_dms_value = -16,
+ error_non_conv_inv_meri_dist = -17,
+ error_non_con_inv_phi2 = -18,
+ error_acos_asin_arg_too_large = -19,
+ error_tolerance_condition = -20,
+ error_conic_lat_equal = -21,
+ error_lat_larger_than_90 = -22,
+ error_lat1_is_zero = -23,
+ error_lat_ts_larger_than_90 = -24,
+ error_control_point_no_dist = -25,
+ error_no_rotation_proj = -26,
+ error_w_or_m_zero_or_less = -27,
+ error_lsat_not_in_range = -28,
+ error_path_not_in_range = -29,
+ error_h_less_than_zero = -30,
+ error_k_less_than_zero = -31,
+ error_lat_1_or_2_zero_or_90 = -32,
+ error_lat_0_or_alpha_eq_90 = -33,
+ error_ellipsoid_use_required = -34,
+ error_invalid_utm_zone = -35,
+ error_tcheby_val_out_of_range = -36,
+ error_failed_to_find_proj = -37,
+ error_failed_to_load_grid = -38,
+ error_invalid_m_or_n = -39,
+ error_n_out_of_range = -40,
+ error_lat_1_2_unspecified = -41,
+ error_abs_lat1_eq_abs_lat2 = -42,
+ error_lat_0_half_pi_from_mean = -43,
+ error_unparseable_cs_def = -44,
+ error_geocentric = -45,
+ error_unknown_prime_meridian = -46,
+ error_axis = -47,
+ error_grid_area = -48,
+ error_invalid_sweep_axis = -49,
+ error_malformed_pipeline = -50,
+ error_unit_factor_less_than_0 = -51,
+ error_invalid_scale = -52,
+ error_non_convergent = -53,
+ error_missing_args = -54,
+ error_lat_0_is_zero = -55,
+ error_ellipsoidal_unsupported = -56,
+ error_too_many_inits = -57,
+ error_invalid_arg = -58
+};
template <typename T>
struct pvalue
{
std::string param;
- int used;
-
- int i;
- T f;
std::string s;
+ //int used;
};
-template <typename T>
-struct pj_const_pod
-{
- int over; /* over-range flag */
- int geoc; /* geocentric latitude flag */
- int is_latlong; /* proj=latlong ... not really a projection at all */
- int is_geocent; /* proj=geocent ... not really a projection at all */
- T
- a, /* major axis or radius if es==0 */
- a_orig, /* major axis before any +proj related adjustment */
- es, /* e ^ 2 */
- es_orig, /* es before any +proj related adjustment */
- e, /* eccentricity */
- ra, /* 1/A */
- one_es, /* 1 - e^2 */
- rone_es, /* 1/one_es */
- lam0, phi0, /* central longitude, latitude */
- x0, y0, /* easting and northing */
- k0, /* general scaling factor */
- to_meter, fr_meter, /* cartesian scaling */
- vto_meter, vfr_meter; /* Vertical scaling. Internal unit [m] */
-
- int datum_type; /* PJD_UNKNOWN/3PARAM/7PARAM/GRIDSHIFT/WGS84 */
- T datum_params[7];
- T from_greenwich; /* prime meridian offset (in radians) */
- T long_wrap_center; /* 0.0 for -180 to 180, actually in radians*/
- bool is_long_wrap_set;
-
- // Initialize all variables to zero
- pj_const_pod()
- {
- std::memset(this, 0, sizeof(pj_const_pod));
- }
-};
+// Originally defined in proj_internal.h
+//enum pj_io_units {
+// pj_io_units_whatever = 0, /* Doesn't matter (or depends on pipeline neighbours) */
+// pj_io_units_classic = 1, /* Scaled meters (right), projected system */
+// pj_io_units_projected = 2, /* Meters, projected system */
+// pj_io_units_cartesian = 3, /* Meters, 3D cartesian system */
+// pj_io_units_angular = 4 /* Radians */
+//};
+
+// Originally defined in proj_internal.h
+/* Maximum latitudinal overshoot accepted */
+//static const double pj_epsilon_lat = 1e-12;
template <typename T>
-struct pj_const_non_pod
+struct pj_consts
{
- int over; /* over-range flag */
- int geoc; /* geocentric latitude flag */
- int is_latlong; /* proj=latlong ... not really a projection at all */
- int is_geocent; /* proj=geocent ... not really a projection at all */
- T
- a, /* major axis or radius if es==0 */
- a_orig, /* major axis before any +proj related adjustment */
- es, /* e ^ 2 */
- es_orig, /* es before any +proj related adjustment */
- e, /* eccentricity */
- ra, /* 1/A */
- one_es, /* 1 - e^2 */
- rone_es, /* 1/one_es */
- lam0, phi0, /* central longitude, latitude */
- x0, y0, /* easting and northing */
- k0, /* general scaling factor */
- to_meter, fr_meter, /* cartesian scaling */
- vto_meter, vfr_meter; /* Vertical scaling. Internal unit [m] */
-
- int datum_type; /* PJD_UNKNOWN/3PARAM/7PARAM/GRIDSHIFT/WGS84 */
- T datum_params[7];
- T from_greenwich; /* prime meridian offset (in radians) */
- T long_wrap_center; /* 0.0 for -180 to 180, actually in radians*/
- bool is_long_wrap_set;
-
- // Initialize all variables to zero
- pj_const_non_pod()
- : over(0), geoc(0), is_latlong(0), is_geocent(0)
- , a(0), a_orig(0), es(0), es_orig(0), e(0), ra(0)
- , one_es(0), rone_es(0), lam0(0), phi0(0), x0(0), y0(0), k0(0)
- , to_meter(0), fr_meter(0), vto_meter(0), vfr_meter(0)
- , datum_type(PJD_UNKNOWN)
- , from_greenwich(0), long_wrap_center(0), is_long_wrap_set(false)
- {
- datum_params[0] = 0;
- datum_params[1] = 0;
- datum_params[2] = 0;
- datum_params[3] = 0;
- datum_params[4] = 0;
- datum_params[5] = 0;
- datum_params[6] = 0;
- }
-};
+ // E L L I P S O I D P A R A M E T E R S
-template <typename T>
-struct pj_const
- : boost::mpl::if_c
- <
- boost::is_pod<T>::value,
- pj_const_pod<T>,
- pj_const_non_pod<T>
- >::type
-{};
+ T a; /* semimajor axis (radius if eccentricity==0) */
+ T ra; /* 1/a */
-// PROJ4 complex. Might be replaced with std::complex
-template <typename T>
-struct COMPLEX { T r, i; };
+ T e; /* first eccentricity */
+ T es; /* first eccentricity squared */
+ T one_es; /* 1 - e^2 */
+ T rone_es; /* 1/one_es */
-struct PJ_ELLPS
-{
- std::string id; /* ellipse keyword name */
- std::string major; /* a= value */
- std::string ell; /* elliptical parameter */
- std::string name; /* comments */
-};
+ T es_orig, a_orig; /* es and a before any +proj related adjustment */
-struct PJ_DATUMS
-{
- std::string id; /* datum keyword */
- std::string defn; /* ie. "to_wgs84=..." */
- std::string ellipse_id; /* ie from ellipse table */
- std::string comments; /* EPSG code, etc */
-};
+ // C O O R D I N A T E H A N D L I N G
-struct PJ_PRIME_MERIDIANS
-{
- std::string id; /* prime meridian keyword */
- std::string defn; /* offset from greenwich in DMS format. */
-};
+ int over; /* over-range flag */
+ int geoc; /* geocentric latitude flag */
+ int is_latlong; /* proj=latlong ... not really a projection at all */
+ int is_geocent; /* proj=geocent ... not really a projection at all */
+ //int need_ellps; /* 0 for operations that are purely cartesian */
-struct PJ_UNITS
-{
- std::string id; /* units keyword */
- std::string to_meter; /* multiply by value to get meters */
- std::string name; /* comments */
-};
+ //enum pj_io_units left; /* Flags for input/output coordinate types */
+ //enum pj_io_units right;
-template <typename T>
-struct DERIVS
-{
- T x_l, x_p; /* derivatives of x for lambda-phi */
- T y_l, y_p; /* derivatives of y for lambda-phi */
+ // C A R T O G R A P H I C O F F S E T S
+
+ T lam0, phi0; /* central longitude, latitude */
+ T x0, y0/*, z0, t0*/; /* false easting and northing (and height and time) */
+
+ // S C A L I N G
+
+ T k0; /* general scaling factor */
+ T to_meter, fr_meter; /* cartesian scaling */
+ T vto_meter, vfr_meter; /* Vertical scaling. Internal unit [m] */
+
+ // D A T U M S A N D H E I G H T S Y S T E M S
+
+ detail::datum_type datum_type; /* PJD_UNKNOWN/3PARAM/7PARAM/GRIDSHIFT/WGS84 */
+ T datum_params[7]; /* Parameters for 3PARAM and 7PARAM */
+
+ T from_greenwich; /* prime meridian offset (in radians) */
+ T long_wrap_center; /* 0.0 for -180 to 180, actually in radians*/
+ bool is_long_wrap_set;
+
+ // Initialize all variables
+ pj_consts()
+ : a(0), ra(0)
+ , e(0), es(0), one_es(0), rone_es(0)
+ , es_orig(0), a_orig(0)
+ , over(0), geoc(0), is_latlong(0), is_geocent(0)
+ //, need_ellps(1)
+ //, left(PJ_IO_UNITS_ANGULAR), right(PJ_IO_UNITS_CLASSIC)
+ , lam0(0), phi0(0)
+ , x0(0), y0(0)/*, z0(0), t0(0)*/
+ , k0(0) , to_meter(0), fr_meter(0), vto_meter(0), vfr_meter(0)
+ , datum_type(datum_unknown)
+#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) && (!defined(_MSC_VER) || (_MSC_VER >= 1900)) // workaround for VC++ 12 (aka 2013)
+ , datum_params{0, 0, 0, 0, 0, 0, 0}
+#endif
+ , from_greenwich(0), long_wrap_center(0), is_long_wrap_set(false)
+ {
+#if defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) || (defined(_MSC_VER) && (_MSC_VER < 1900)) // workaround for VC++ 12 (aka 2013)
+ std::fill(datum_params, datum_params + 7, T(0));
+#endif
+ }
};
+// PROJ4 complex. Might be replaced with std::complex
template <typename T>
-struct FACTORS
-{
- DERIVS<T> der;
- T h, k; /* meridinal, parallel scales */
- T omega, thetap; /* angular distortion, theta prime */
- T conv; /* convergence */
- T s; /* areal scale factor */
- T a, b; /* max-min scale error */
- int code; /* info as to analytics, see following */
-};
+struct pj_complex { T r, i; };
} // namespace detail
#endif // DOXYGEN_NO_DETAIL
@@ -260,7 +233,7 @@ struct FACTORS
\ingroup projection
*/
template <typename T>
-struct parameters : public detail::pj_const<T>
+struct parameters : public detail::pj_consts<T>
{
typedef T type;