From 15a225b0d80281b80c536e7b5dde334d12c406c6 Mon Sep 17 00:00:00 2001 From: Kristian Evers Date: Fri, 1 Feb 2019 12:59:44 +0100 Subject: Remove +t_obs parameter from helmert operation --- src/transformations/helmert.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/transformations') 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) { -- cgit v1.2.3 From 29a59cadb9d1371479477af517f3431784e880f9 Mon Sep 17 00:00:00 2001 From: Kristian Evers Date: Thu, 14 Feb 2019 12:00:45 +0100 Subject: Reverse direction of deformation operations/transformations/deformation Changed the direction of dt-calculation to follow the same convention as helmert. Changed from dt = t_c - t_obs to dt = t_obs - t_c, which effectively reverses the direction of the operation. Existing projstrings using deformation can simply reverse the direction of the operation to achieve the same results as before this commit. --- src/transformations/deformation.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/transformations') diff --git a/src/transformations/deformation.cpp b/src/transformations/deformation.cpp index 9221d39e..14f34e4e 100644 --- a/src/transformations/deformation.cpp +++ b/src/transformations/deformation.cpp @@ -172,7 +172,7 @@ static PJ_XYZ forward_3d(PJ_LPZ lpz, PJ *P) { out = in; if (Q->t_obs != HUGE_VAL) { - dt = Q->t_epoch - Q->t_obs; + dt = Q->t_obs - Q->t_epoch; } else { out = proj_coord_error(); /* in the 3D case +t_obs must be specified */ proj_log_debug(P, "deformation: +t_obs must be specified"); @@ -196,9 +196,9 @@ static PJ_COORD forward_4d(PJ_COORD in, PJ *P) { PJ_COORD out = in; if (Q->t_obs != HUGE_VAL) { - dt = Q->t_epoch - Q->t_obs; + dt = Q->t_obs - Q->t_epoch; } else { - dt = Q->t_epoch - in.xyzt.t; + dt = in.xyzt.t - Q->t_epoch ; } shift = get_grid_shift(P, in.xyz); @@ -219,7 +219,7 @@ static PJ_LPZ reverse_3d(PJ_XYZ in, PJ *P) { out.xyz = in; if (Q->t_obs != HUGE_VAL) { - dt = Q->t_epoch - Q->t_obs; + dt = Q->t_obs - Q->t_epoch; } else { out = proj_coord_error(); /* in the 3D case +t_obs must be specified */ proj_log_debug(P, "deformation: +t_obs must be specified"); @@ -238,9 +238,9 @@ static PJ_COORD reverse_4d(PJ_COORD in, PJ *P) { if (Q->t_obs != HUGE_VAL) { - dt = Q->t_epoch - Q->t_obs; + dt = Q->t_obs - Q->t_epoch; } else { - dt = Q->t_epoch - in.xyzt.t; + dt = in.xyzt.t - Q->t_epoch; } out.xyz = reverse_shift(P, in.xyz, dt); -- cgit v1.2.3 From 12689e3d858d66e5e00e8d99f9326ef91cc0a384 Mon Sep 17 00:00:00 2001 From: Kristian Evers Date: Thu, 14 Feb 2019 14:51:39 +0100 Subject: deformation: Replace +t_obs with +dt The +t_obs parameter was confusing for users since it effectively overwrote the observation time in input coordinates. To make it more clear what is the operation is doing, users are now required to directly specify the time span for which they wish to apply a given deformation. The parameter +dt has been added for that purpose. The new parameter is mutually exclusive with +t_epoch. +dt is used when deformation for a set amount of time is needed and +t_epoch is used (in conjunction with the observation time of the input coordinate) when deformation from a specific epoch to the observation time is needed. --- src/transformations/deformation.cpp | 61 +++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 27 deletions(-) (limited to 'src/transformations') diff --git a/src/transformations/deformation.cpp b/src/transformations/deformation.cpp index 14f34e4e..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_obs - Q->t_epoch; - } 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_obs - Q->t_epoch; - } else { - dt = in.xyzt.t - Q->t_epoch ; + 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_obs - Q->t_epoch; - } 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,8 +231,8 @@ static PJ_COORD reverse_4d(PJ_COORD in, PJ *P) { double dt; - if (Q->t_obs != HUGE_VAL) { - dt = Q->t_obs - Q->t_epoch; + if (Q->dt != HUGE_VAL) { + dt = Q->dt; } else { dt = in.xyzt.t - Q->t_epoch; } @@ -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; -- cgit v1.2.3