diff options
| author | Kristian Evers <kristianevers@gmail.com> | 2019-02-14 19:22:18 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-02-14 19:22:18 +0100 |
| commit | a813ad65cfb819bfa295dfbacdf577b258377c93 (patch) | |
| tree | c7855676df4213a6b5a39e1ab6c0f09b2ec2527a /src | |
| parent | 63c7ba2e229bfd94389d17bdedc002489232027f (diff) | |
| parent | 12689e3d858d66e5e00e8d99f9326ef91cc0a384 (diff) | |
| download | PROJ-a813ad65cfb819bfa295dfbacdf577b258377c93.tar.gz PROJ-a813ad65cfb819bfa295dfbacdf577b258377c93.zip | |
Merge pull request #1264 from kbevers/remove-t_obs
Clean up time handling in helmert and deformation
Diffstat (limited to 'src')
| -rw-r--r-- | src/apps/gie.cpp | 1 | ||||
| -rw-r--r-- | src/proj_internal.h | 1 | ||||
| -rw-r--r-- | src/strerrno.cpp | 1 | ||||
| -rw-r--r-- | src/transform.cpp | 5 | ||||
| -rw-r--r-- | src/transformations/deformation.cpp | 63 | ||||
| -rw-r--r-- | src/transformations/helmert.cpp | 5 |
6 files changed, 42 insertions, 34 deletions
diff --git a/src/apps/gie.cpp b/src/apps/gie.cpp index c3622d52..abed11c0 100644 --- a/src/apps/gie.cpp +++ b/src/apps/gie.cpp @@ -1082,6 +1082,7 @@ static const struct errno_vs_err_const lookup[] = { {"pjd_err_too_many_inits" , -57}, {"pjd_err_invalid_arg" , -58}, {"pjd_err_inconsistent_unit" , -59}, + {"pjd_err_mutually_exclusive_args" , -60}, {"pjd_err_dont_skip" , 5555}, {"pjd_err_unknown" , 9999}, {"pjd_err_enomem" , ENOMEM}, diff --git a/src/proj_internal.h b/src/proj_internal.h index 1f86f93e..14b69492 100644 --- a/src/proj_internal.h +++ b/src/proj_internal.h @@ -678,6 +678,7 @@ struct FACTORS { #define PJD_ERR_TOO_MANY_INITS -57 #define PJD_ERR_INVALID_ARG -58 #define PJD_ERR_INCONSISTENT_UNIT -59 +#define PJD_ERR_MUTUALLY_EXCLUSIVE_ARGS -60 /* NOTE: Remember to update src/strerrno.cpp, src/apps/gie.cpp and transient_error in */ /* src/transform.cpp when adding new value */ diff --git a/src/strerrno.cpp b/src/strerrno.cpp index 13e9c757..01097a42 100644 --- a/src/strerrno.cpp +++ b/src/strerrno.cpp @@ -68,6 +68,7 @@ pj_err_list[] = { "only one +init allowed for non-pipeline operations", /* -57 */ "argument not numerical or out of range", /* -58 */ "inconsistent unit type between input and output", /* -59 */ + "arguments are mutually exclusive", /* -60 */ /* When adding error messages, remember to update ID defines in projects.h, and transient_error array in pj_transform */ diff --git a/src/transform.cpp b/src/transform.cpp index 486178d0..d111d835 100644 --- a/src/transform.cpp +++ b/src/transform.cpp @@ -75,14 +75,15 @@ static int adjust_axis( projCtx ctx, const char *axis, int denormalize_flag, ** */ -static const int transient_error[60] = { +static const int transient_error[70] = { /* 0 1 2 3 4 5 6 7 8 9 */ /* 0 to 9 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 10 to 19 */ 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, /* 20 to 29 */ 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, /* 30 to 39 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 40 to 49 */ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - /* 50 to 59 */ 1, 0, 1, 0, 1, 1, 1, 1, 0, 0 }; + /* 50 to 59 */ 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, + /* 60 to 69 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,}; /* -------------------------------------------------------------------- */ diff --git a/src/transformations/deformation.cpp b/src/transformations/deformation.cpp index 9221d39e..c28e1489 100644 --- a/src/transformations/deformation.cpp +++ b/src/transformations/deformation.cpp @@ -65,7 +65,7 @@ PROJ_HEAD(deformation, "Kinematic grid shift"); namespace { // anonymous namespace struct pj_opaque { - double t_obs; + double dt; double t_epoch; PJ *cart; }; @@ -167,23 +167,20 @@ static PJ_XYZ forward_3d(PJ_LPZ lpz, PJ *P) { struct pj_opaque *Q = (struct pj_opaque *) P->opaque; PJ_COORD out, in; PJ_XYZ shift; - double dt = 0.0; in.lpz = lpz; out = in; - if (Q->t_obs != HUGE_VAL) { - dt = Q->t_epoch - Q->t_obs; - } else { + if (Q->dt == HUGE_VAL) { out = proj_coord_error(); /* in the 3D case +t_obs must be specified */ - proj_log_debug(P, "deformation: +t_obs must be specified"); + proj_log_debug(P, "deformation: +dt must be specified"); return out.xyz; } shift = get_grid_shift(P, in.xyz); - out.xyz.x += dt * shift.x; - out.xyz.y += dt * shift.y; - out.xyz.z += dt * shift.z; + out.xyz.x += Q->dt * shift.x; + out.xyz.y += Q->dt * shift.y; + out.xyz.z += Q->dt * shift.z; return out.xyz; } @@ -195,10 +192,10 @@ static PJ_COORD forward_4d(PJ_COORD in, PJ *P) { PJ_XYZ shift; PJ_COORD out = in; - if (Q->t_obs != HUGE_VAL) { - dt = Q->t_epoch - Q->t_obs; - } else { - dt = Q->t_epoch - in.xyzt.t; + if (Q->dt != HUGE_VAL) { + dt = Q->dt; + } else { + dt = in.xyzt.t - Q->t_epoch ; } shift = get_grid_shift(P, in.xyz); @@ -215,18 +212,15 @@ static PJ_COORD forward_4d(PJ_COORD in, PJ *P) { static PJ_LPZ reverse_3d(PJ_XYZ in, PJ *P) { struct pj_opaque *Q = (struct pj_opaque *) P->opaque; PJ_COORD out; - double dt = 0.0; out.xyz = in; - if (Q->t_obs != HUGE_VAL) { - dt = Q->t_epoch - Q->t_obs; - } else { + if (Q->dt == HUGE_VAL) { out = proj_coord_error(); /* in the 3D case +t_obs must be specified */ - proj_log_debug(P, "deformation: +t_obs must be specified"); + proj_log_debug(P, "deformation: +dt must be specified"); return out.lpz; } - out.xyz = reverse_shift(P, in, dt); + out.xyz = reverse_shift(P, in, Q->dt); return out.lpz; } @@ -237,10 +231,10 @@ static PJ_COORD reverse_4d(PJ_COORD in, PJ *P) { double dt; - if (Q->t_obs != HUGE_VAL) { - dt = Q->t_epoch - Q->t_obs; + if (Q->dt != HUGE_VAL) { + dt = Q->dt; } else { - dt = Q->t_epoch - in.xyzt.t; + dt = in.xyzt.t - Q->t_epoch; } out.xyz = reverse_shift(P, in.xyz, dt); @@ -298,16 +292,29 @@ PJ *TRANSFORMATION(deformation,1) { return destructor(P, PJD_ERR_FAILED_TO_LOAD_GRID); } - Q->t_obs = HUGE_VAL; - if (pj_param(P->ctx, P->params, "tt_obs").i) { - Q->t_obs = pj_param(P->ctx, P->params, "dt_obs").f; + Q->dt = HUGE_VAL; + if (pj_param(P->ctx, P->params, "tdt").i) { + Q->dt = pj_param(P->ctx, P->params, "ddt").f; + } + + 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); } + Q->t_epoch = HUGE_VAL; if (pj_param(P->ctx, P->params, "tt_epoch").i) { Q->t_epoch = pj_param(P->ctx, P->params, "dt_epoch").f; - } else { - proj_log_error(P, "deformation: +t_epoch parameter missing."); - return destructor(P, PJD_ERR_MISSING_ARGS); + } + + 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); + } + + 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); } P->fwd4d = forward_4d; diff --git a/src/transformations/helmert.cpp b/src/transformations/helmert.cpp index 085bbbf9..034f76f4 100644 --- a/src/transformations/helmert.cpp +++ b/src/transformations/helmert.cpp @@ -649,9 +649,6 @@ PJ *TRANSFORMATION(helmert, 0) { if (pj_param(P->ctx, P->params, "tt_epoch").i) Q->t_epoch = pj_param (P->ctx, P->params, "dt_epoch").f; - if (pj_param(P->ctx, P->params, "tt_obs").i) - Q->t_obs = pj_param (P->ctx, P->params, "dt_obs").f; - Q->xyz = Q->xyz_0; Q->opk = Q->opk_0; Q->scale = Q->scale_0; @@ -678,7 +675,7 @@ PJ *TRANSFORMATION(helmert, 0) { " convention=coordinate_frame"); proj_log_debug(P, "dx= %8.5f dy= %8.5f dz= %8.5f", Q->dxyz.x, Q->dxyz.y, Q->dxyz.z); proj_log_debug(P, "drx=%8.5f dry=%8.5f drz=%8.5f", Q->dopk.o, Q->dopk.p, Q->dopk.k); - proj_log_debug(P, "ds= %8.5f t_epoch=%8.5f t_obs=%8.5f", Q->dscale, Q->t_epoch, Q->t_obs); + proj_log_debug(P, "ds= %8.5f t_epoch=%8.5f", Q->dscale, Q->t_epoch); } if (Q->no_rotation) { |
