Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:39

0001 // Boost.Geometry
0002 // This file is manually converted from PROJ4
0003 
0004 // This file was modified by Oracle on 2017, 2018.
0005 // Modifications copyright (c) 2017-2018, Oracle and/or its affiliates.
0006 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0007 
0008 // Use, modification and distribution is subject to the Boost Software License,
0009 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0010 // http://www.boost.org/LICENSE_1_0.txt)
0011 
0012 // This file is converted from PROJ4, http://trac.osgeo.org/proj
0013 // PROJ4 is originally written by Gerald Evenden (then of the USGS)
0014 // PROJ4 is maintained by Frank Warmerdam
0015 // This file was converted to Geometry Library by Adam Wulkiewicz
0016 
0017 // Original copyright notice:
0018 
0019 // None
0020 
0021 /* list of projection system pj_errno values */
0022 
0023 #ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_STRERRNO_HPP
0024 #define BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_STRERRNO_HPP
0025 
0026 #include <cerrno>
0027 #include <cstring>
0028 #include <sstream>
0029 #include <string>
0030 
0031 namespace boost { namespace geometry { namespace projections
0032 {
0033 
0034 namespace detail
0035 {
0036 
0037 // Originally defined in projects.hpp
0038 /* library errors */
0039 enum error_type
0040 {
0041     error_no_args                 =  -1,
0042     error_no_option_in_init_file  =  -2,
0043     error_no_colon_in_init_string =  -3,
0044     error_proj_not_named          =  -4,
0045     error_unknown_projection_id   =  -5,
0046     error_eccentricity_is_one     =  -6,
0047     error_unknow_unit_id          =  -7,
0048     error_invalid_boolean_param   =  -8,
0049     error_unknown_ellp_param      =  -9,
0050     error_rev_flattening_is_zero  = -10,
0051     error_ref_rad_larger_than_90  = -11,
0052     error_es_less_than_zero       = -12,
0053     error_major_axis_not_given    = -13,
0054     error_lat_or_lon_exceed_limit = -14,
0055     error_invalid_x_or_y          = -15,
0056     error_wrong_format_dms_value  = -16,
0057     error_non_conv_inv_meri_dist  = -17,
0058     error_non_con_inv_phi2        = -18,
0059     error_acos_asin_arg_too_large = -19,
0060     error_tolerance_condition     = -20,
0061     error_conic_lat_equal         = -21,
0062     error_lat_larger_than_90      = -22,
0063     error_lat1_is_zero            = -23,
0064     error_lat_ts_larger_than_90   = -24,
0065     error_control_point_no_dist   = -25,
0066     error_no_rotation_proj        = -26,
0067     error_w_or_m_zero_or_less     = -27,
0068     error_lsat_not_in_range       = -28,
0069     error_path_not_in_range       = -29,
0070     error_h_less_than_zero        = -30,
0071     error_k_less_than_zero        = -31,
0072     error_lat_1_or_2_zero_or_90   = -32,
0073     error_lat_0_or_alpha_eq_90    = -33,
0074     error_ellipsoid_use_required  = -34,
0075     error_invalid_utm_zone        = -35,
0076     error_tcheby_val_out_of_range = -36,
0077     error_failed_to_find_proj     = -37,
0078     error_failed_to_load_grid     = -38,
0079     error_invalid_m_or_n          = -39,
0080     error_n_out_of_range          = -40,
0081     error_lat_1_2_unspecified     = -41,
0082     error_abs_lat1_eq_abs_lat2    = -42,
0083     error_lat_0_half_pi_from_mean = -43,
0084     error_unparseable_cs_def      = -44,
0085     error_geocentric              = -45,
0086     error_unknown_prime_meridian  = -46,
0087     error_axis                    = -47,
0088     error_grid_area               = -48,
0089     error_invalid_sweep_axis      = -49,
0090     error_malformed_pipeline      = -50,
0091     error_unit_factor_less_than_0 = -51,
0092     error_invalid_scale           = -52,
0093     error_non_convergent          = -53,
0094     error_missing_args            = -54,
0095     error_lat_0_is_zero           = -55,
0096     error_ellipsoidal_unsupported = -56,
0097     error_too_many_inits          = -57,
0098     error_invalid_arg             = -58
0099 };
0100 
0101     static const char *
0102 pj_err_list[] = {
0103     "no arguments in initialization list",                             /*  -1 */
0104     "no options found in 'init' file",                                 /*  -2 */
0105     "no colon in init= string",                                        /*  -3 */
0106     "projection not named",                                            /*  -4 */
0107     "unknown projection id",                                           /*  -5 */
0108     "effective eccentricity = 1.",                                     /*  -6 */
0109     "unknown unit conversion id",                                      /*  -7 */
0110     "invalid boolean param argument",                                  /*  -8 */
0111     "unknown elliptical parameter name",                               /*  -9 */
0112     "reciprocal flattening (1/f) = 0",                                 /* -10 */
0113     "|radius reference latitude| > 90",                                /* -11 */
0114     "squared eccentricity < 0",                                        /* -12 */
0115     "major axis or radius = 0 or not given",                           /* -13 */
0116     "latitude or longitude exceeded limits",                           /* -14 */
0117     "invalid x or y",                                                  /* -15 */
0118     "improperly formed DMS value",                                     /* -16 */
0119     "non-convergent inverse meridional dist",                          /* -17 */
0120     "non-convergent inverse phi2",                                     /* -18 */
0121     "acos/asin: |arg| >1.+1e-14",                                      /* -19 */
0122     "tolerance condition error",                                       /* -20 */
0123     "conic lat_1 = -lat_2",                                            /* -21 */
0124     "lat_1 >= 90",                                                     /* -22 */
0125     "lat_1 = 0",                                                       /* -23 */
0126     "lat_ts >= 90",                                                    /* -24 */
0127     "no distance between control points",                              /* -25 */
0128     "projection not selected to be rotated",                           /* -26 */
0129     "W <= 0 or M <= 0",                                                /* -27 */
0130     "lsat not in 1-5 range",                                           /* -28 */
0131     "path not in range",                                               /* -29 */
0132     "h <= 0",                                                          /* -30 */
0133     "k <= 0",                                                          /* -31 */
0134     "lat_0 = 0 or 90 or alpha = 90",                                   /* -32 */
0135     "lat_1=lat_2 or lat_1=0 or lat_2=90",                              /* -33 */
0136     "elliptical usage required",                                       /* -34 */
0137     "invalid UTM zone number",                                         /* -35 */
0138     "arg(s) out of range for Tcheby eval",                             /* -36 */
0139     "failed to find projection to be rotated",                         /* -37 */
0140     "failed to load datum shift file",                                 /* -38 */
0141     "both n & m must be spec'd and > 0",                               /* -39 */
0142     "n <= 0, n > 1 or not specified",                                  /* -40 */
0143     "lat_1 or lat_2 not specified",                                    /* -41 */
0144     "|lat_1| == |lat_2|",                                              /* -42 */
0145     "lat_0 is pi/2 from mean lat",                                     /* -43 */
0146     "unparseable coordinate system definition",                        /* -44 */
0147     "geocentric transformation missing z or ellps",                    /* -45 */
0148     "unknown prime meridian conversion id",                            /* -46 */
0149     "illegal axis orientation combination",                            /* -47 */
0150     "point not within available datum shift grids",                    /* -48 */
0151     "invalid sweep axis, choose x or y",                               /* -49 */
0152     "malformed pipeline",                                              /* -50 */
0153     "unit conversion factor must be > 0",                              /* -51 */
0154     "invalid scale",                                                   /* -52 */
0155     "non-convergent computation",                                      /* -53 */
0156     "missing required arguments",                                      /* -54 */
0157     "lat_0 = 0",                                                       /* -55 */
0158     "ellipsoidal usage unsupported",                                   /* -56 */
0159     "only one +init allowed for non-pipeline operations",              /* -57 */
0160     "argument not numerical or out of range",                          /* -58 */
0161 
0162     /* When adding error messages, remember to update ID defines in
0163     projects.h, and transient_error array in pj_transform                  */
0164 };
0165 
0166 inline std::string pj_generic_strerrno(std::string const& msg, int err)
0167 {
0168     std::stringstream ss;
0169     ss << msg << " (" << err << ")";
0170     return ss.str();
0171 }
0172 
0173 inline std::string pj_strerrno(int err) {
0174     if (0==err)
0175     {
0176         return "";
0177     }
0178     else if (err > 0)
0179     {
0180         // std::strerror function may be not thread-safe
0181         //return std::strerror(err);
0182 
0183         switch(err)
0184         {
0185 #ifdef EINVAL
0186             case EINVAL:
0187                 return "Invalid argument";
0188 #endif
0189 #ifdef EDOM
0190             case EDOM:
0191                 return "Math argument out of domain of func";
0192 #endif
0193 #ifdef ERANGE
0194             case ERANGE:
0195                 return "Math result not representable";
0196 #endif
0197             default:
0198                 return pj_generic_strerrno("system error", err);
0199         }
0200     }
0201     else /*if (err < 0)*/
0202     {
0203         size_t adjusted_err = - err - 1;
0204         if (adjusted_err < (sizeof(pj_err_list) / sizeof(char *)))
0205         {
0206             return(pj_err_list[adjusted_err]);
0207         }
0208         else
0209         {
0210             return pj_generic_strerrno("invalid projection system error", err);
0211         }
0212     }
0213 }
0214 
0215 } // namespace detail
0216 
0217 }}} // namespace boost::geometry::projections
0218 
0219 #endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_STRERRNO_HPP