From 244a24104ded3a4573aeffa32160af21f76cbce6 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 15 Dec 2020 00:51:46 +0100 Subject: Revise error codes to have a reduced set exposed in the public API. Fixes #2482 And also add proj_context_errno_string() Revise gie 'expect failure errno XXXX' strings --- src/transformations/deformation.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src/transformations/deformation.cpp') diff --git a/src/transformations/deformation.cpp b/src/transformations/deformation.cpp index 8ce02bee..307de85f 100644 --- a/src/transformations/deformation.cpp +++ b/src/transformations/deformation.cpp @@ -179,7 +179,7 @@ static PJ_XYZ get_grid_shift(PJ* P, const PJ_XYZ& cartesian) { shift.lp = pj_hgrid_value(P, Q->hgrids, geodetic.lp); shift.enu.u = pj_vgrid_value(P, Q->vgrids, geodetic.lp, 1.0); - if (proj_errno(P) == PJD_ERR_GRID_AREA) + if (proj_errno(P) == PROJ_ERR_COORD_TRANSFM_OUTSIDE_GRID) proj_log_debug(P, "deformation: coordinate (%.3f, %.3f) outside deformation model", proj_todeg(geodetic.lpz.lam), proj_todeg(geodetic.lpz.phi)); @@ -358,7 +358,7 @@ PJ *TRANSFORMATION(deformation,1) { // Pass a dummy ellipsoid definition that will be overridden just afterwards Q->cart = proj_create(P->ctx, "+proj=cart +a=1"); if (Q->cart == nullptr) - return destructor(P, ENOMEM); + return destructor(P, PROJ_ERR_INVALID_OP /*ENOMEM*/); /* inherit ellipsoid definition from P to Q->cart */ pj_inherit_ellipsoid_def (P, Q->cart); @@ -369,8 +369,8 @@ PJ *TRANSFORMATION(deformation,1) { /* Build gridlists. Both horizontal and vertical grids are mandatory. */ if ( !has_grids && (!has_xy_grids || !has_z_grids)) { - proj_log_error(P, "deformation: Either +grids or (+xy_grids and +z_grids) should be specified."); - return destructor(P, PJD_ERR_NO_ARGS ); + proj_log_error(P, _("deformation: Either +grids or (+xy_grids and +z_grids) should be specified.")); + return destructor(P, PROJ_ERR_INVALID_OP_MISSING_ARG ); } if( has_grids ) @@ -378,22 +378,22 @@ PJ *TRANSFORMATION(deformation,1) { Q->grids = pj_generic_grid_init(P, "grids"); /* Was gridlist compiled properly? */ if ( proj_errno(P) ) { - proj_log_error(P, "deformation: could not find required grid(s)."); - return destructor(P, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_log_error(P, _("deformation: could not find required grid(s).)")); + return destructor(P, PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID); } } else { Q->hgrids = pj_hgrid_init(P, "xy_grids"); if (proj_errno(P)) { - proj_log_error(P, "deformation: could not find requested xy_grid(s)."); - return destructor(P, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_log_error(P, _("deformation: could not find requested xy_grid(s).")); + return destructor(P, PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID); } Q->vgrids = pj_vgrid_init(P, "z_grids"); if (proj_errno(P)) { - proj_log_error(P, "deformation: could not find requested z_grid(s)."); - return destructor(P, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_log_error(P, _("deformation: could not find requested z_grid(s).")); + return destructor(P, PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID); } } @@ -403,8 +403,8 @@ PJ *TRANSFORMATION(deformation,1) { } if (pj_param_exists(P->params, "t_obs")) { - proj_log_error(P, "deformation: +t_obs parameter is deprecated. Use +dt instead."); - return destructor(P, PJD_ERR_MISSING_ARGS); + proj_log_error(P, _("deformation: +t_obs parameter is deprecated. Use +dt instead.")); + return destructor(P, PROJ_ERR_INVALID_OP_MISSING_ARG); } Q->t_epoch = HUGE_VAL; @@ -413,13 +413,13 @@ PJ *TRANSFORMATION(deformation,1) { } if (Q->dt == HUGE_VAL && Q->t_epoch == HUGE_VAL) { - proj_log_error(P, "deformation: either +dt or +t_epoch needs to be set."); - return destructor(P, PJD_ERR_MISSING_ARGS); + proj_log_error(P, _("deformation: either +dt or +t_epoch needs to be set.")); + return destructor(P, PROJ_ERR_INVALID_OP_MISSING_ARG); } if (Q->dt != HUGE_VALL && Q->t_epoch != HUGE_VALL) { - proj_log_error(P, "deformation: +dt or +t_epoch are mutually exclusive."); - return destructor(P, PJD_ERR_MUTUALLY_EXCLUSIVE_ARGS); + proj_log_error(P, _("deformation: +dt or +t_epoch are mutually exclusive.")); + return destructor(P, PROJ_ERR_INVALID_OP_MUTUALLY_EXCLUSIVE_ARGS); } P->fwd4d = forward_4d; -- cgit v1.2.3 From df96a13d2c9b70bc18cec1b08eea5b2b068127d7 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 15 Dec 2020 15:32:40 +0100 Subject: Various operations: remove explicit short name prefixing in log messages now that it is automatically added --- src/transformations/deformation.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/transformations/deformation.cpp') diff --git a/src/transformations/deformation.cpp b/src/transformations/deformation.cpp index 307de85f..56909eb2 100644 --- a/src/transformations/deformation.cpp +++ b/src/transformations/deformation.cpp @@ -100,7 +100,7 @@ static bool get_grid_values(PJ* P, } const auto samplesPerPixel = grid->samplesPerPixel(); if( samplesPerPixel < 3 ) { - proj_log_error(P, "deformation: grid has not enough samples"); + proj_log_error(P, "grid has not enough samples"); return false; } int sampleE = 0; @@ -119,7 +119,7 @@ static bool get_grid_values(PJ* P, } const auto unit = grid->unit(sampleE); if( !unit.empty() && unit != "millimetres per year" ) { - proj_log_error(P, "deformation: Only unit=millimetres per year currently handled"); + proj_log_error(P, "Only unit=millimetres per year currently handled"); return false; } @@ -180,7 +180,7 @@ static PJ_XYZ get_grid_shift(PJ* P, const PJ_XYZ& cartesian) { shift.enu.u = pj_vgrid_value(P, Q->vgrids, geodetic.lp, 1.0); if (proj_errno(P) == PROJ_ERR_COORD_TRANSFM_OUTSIDE_GRID) - proj_log_debug(P, "deformation: coordinate (%.3f, %.3f) outside deformation model", + proj_log_debug(P, "coordinate (%.3f, %.3f) outside deformation model", proj_todeg(geodetic.lpz.lam), proj_todeg(geodetic.lpz.phi)); /* grid values are stored as mm/yr, we need m/yr */ @@ -261,7 +261,7 @@ static PJ_XYZ forward_3d(PJ_LPZ lpz, PJ *P) { if (Q->dt == HUGE_VAL) { out = proj_coord_error(); /* in the 3D case +t_obs must be specified */ - proj_log_debug(P, "deformation: +dt must be specified"); + proj_log_debug(P, "+dt must be specified"); return out.xyz; } @@ -308,7 +308,7 @@ static PJ_LPZ reverse_3d(PJ_XYZ in, PJ *P) { if (Q->dt == HUGE_VAL) { out = proj_coord_error(); /* in the 3D case +t_obs must be specified */ - proj_log_debug(P, "deformation: +dt must be specified"); + proj_log_debug(P, "+dt must be specified"); return out.lpz; } @@ -369,7 +369,7 @@ PJ *TRANSFORMATION(deformation,1) { /* Build gridlists. Both horizontal and vertical grids are mandatory. */ if ( !has_grids && (!has_xy_grids || !has_z_grids)) { - proj_log_error(P, _("deformation: Either +grids or (+xy_grids and +z_grids) should be specified.")); + proj_log_error(P, _("Either +grids or (+xy_grids and +z_grids) should be specified.")); return destructor(P, PROJ_ERR_INVALID_OP_MISSING_ARG ); } @@ -378,7 +378,7 @@ PJ *TRANSFORMATION(deformation,1) { Q->grids = pj_generic_grid_init(P, "grids"); /* Was gridlist compiled properly? */ if ( proj_errno(P) ) { - proj_log_error(P, _("deformation: could not find required grid(s).)")); + proj_log_error(P, _("could not find required grid(s).)")); return destructor(P, PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID); } } @@ -386,13 +386,13 @@ PJ *TRANSFORMATION(deformation,1) { { Q->hgrids = pj_hgrid_init(P, "xy_grids"); if (proj_errno(P)) { - proj_log_error(P, _("deformation: could not find requested xy_grid(s).")); + proj_log_error(P, _("could not find requested xy_grid(s).")); return destructor(P, PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID); } Q->vgrids = pj_vgrid_init(P, "z_grids"); if (proj_errno(P)) { - proj_log_error(P, _("deformation: could not find requested z_grid(s).")); + proj_log_error(P, _("could not find requested z_grid(s).")); return destructor(P, PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID); } } @@ -403,7 +403,7 @@ PJ *TRANSFORMATION(deformation,1) { } if (pj_param_exists(P->params, "t_obs")) { - proj_log_error(P, _("deformation: +t_obs parameter is deprecated. Use +dt instead.")); + proj_log_error(P, _("+t_obs parameter is deprecated. Use +dt instead.")); return destructor(P, PROJ_ERR_INVALID_OP_MISSING_ARG); } @@ -413,12 +413,12 @@ PJ *TRANSFORMATION(deformation,1) { } if (Q->dt == HUGE_VAL && Q->t_epoch == HUGE_VAL) { - proj_log_error(P, _("deformation: either +dt or +t_epoch needs to be set.")); + proj_log_error(P, _("either +dt or +t_epoch needs to be set.")); return destructor(P, PROJ_ERR_INVALID_OP_MISSING_ARG); } if (Q->dt != HUGE_VALL && Q->t_epoch != HUGE_VALL) { - proj_log_error(P, _("deformation: +dt or +t_epoch are mutually exclusive.")); + proj_log_error(P, _("+dt or +t_epoch are mutually exclusive.")); return destructor(P, PROJ_ERR_INVALID_OP_MUTUALLY_EXCLUSIVE_ARGS); } -- cgit v1.2.3 From a27c0255e7b8e6aab1b91e49fd7870d1ee4e1a80 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 15 Dec 2020 17:53:29 +0100 Subject: Remap ENOMEM from PROJ_ERR_INVALID_OP to PROJ_ERR_OTHER --- src/transformations/deformation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/transformations/deformation.cpp') diff --git a/src/transformations/deformation.cpp b/src/transformations/deformation.cpp index 56909eb2..1a04d0f5 100644 --- a/src/transformations/deformation.cpp +++ b/src/transformations/deformation.cpp @@ -358,7 +358,7 @@ PJ *TRANSFORMATION(deformation,1) { // Pass a dummy ellipsoid definition that will be overridden just afterwards Q->cart = proj_create(P->ctx, "+proj=cart +a=1"); if (Q->cart == nullptr) - return destructor(P, PROJ_ERR_INVALID_OP /*ENOMEM*/); + return destructor(P, PROJ_ERR_OTHER /*ENOMEM*/); /* inherit ellipsoid definition from P to Q->cart */ pj_inherit_ellipsoid_def (P, Q->cart); -- cgit v1.2.3