aboutsummaryrefslogtreecommitdiff
path: root/src/PJ_vgridshift.c
diff options
context:
space:
mode:
authorKristian Evers <kristianevers@gmail.com>2017-11-15 21:00:49 +0100
committerKristian Evers <kristianevers@gmail.com>2017-11-15 21:00:49 +0100
commit94771c16596d75c989657447f65d52e8115d3426 (patch)
tree0f7e4206ca3b724e9ebc24c065a137490bf0adfb /src/PJ_vgridshift.c
parent91b641e627a028786e56276d18501dd518d6b112 (diff)
parentf08a7c0cf9dc3ed017a224e196e9d251da8dc97c (diff)
downloadPROJ-94771c16596d75c989657447f65d52e8115d3426.tar.gz
PROJ-94771c16596d75c989657447f65d52e8115d3426.zip
Merge remote-tracking branch 'osgeo/master' into docs-release-4.10.0
Diffstat (limited to 'src/PJ_vgridshift.c')
-rw-r--r--src/PJ_vgridshift.c101
1 files changed, 17 insertions, 84 deletions
diff --git a/src/PJ_vgridshift.c b/src/PJ_vgridshift.c
index ededd544..97faa240 100644
--- a/src/PJ_vgridshift.c
+++ b/src/PJ_vgridshift.c
@@ -9,14 +9,10 @@ static XYZ forward_3d(LPZ lpz, PJ *P) {
PJ_TRIPLET point;
point.lpz = lpz;
- if (P->gridlist != NULL) {
+ if (P->vgridlist_geoid != NULL) {
/* Only try the gridshift if at least one grid is loaded,
* otherwise just pass the coordinate through unchanged. */
- pj_apply_vgridshift( P, "sgrids",
- &(P->gridlist),
- &(P->gridlist_count),
- 1, 1, 0,
- &point.xyz.x, &point.xyz.y, &point.xyz.z );
+ point.xyz.z -= proj_vgrid_value(P, point.lp);
}
return point.xyz;
@@ -27,52 +23,47 @@ static LPZ reverse_3d(XYZ xyz, PJ *P) {
PJ_TRIPLET point;
point.xyz = xyz;
- if (P->gridlist != NULL) {
+ if (P->vgridlist_geoid != NULL) {
/* Only try the gridshift if at least one grid is loaded,
* otherwise just pass the coordinate through unchanged. */
- pj_apply_vgridshift( P, "sgrids",
- &(P->gridlist),
- &(P->gridlist_count),
- 0, 1, 0,
- &point.xyz.x, &point.xyz.y, &point.xyz.z );
+ point.xyz.z += proj_vgrid_value(P, point.lp);
}
return point.lpz;
}
-static PJ_OBS forward_obs(PJ_OBS obs, PJ *P) {
- PJ_OBS point;
- point.coo.xyz = forward_3d (obs.coo.lpz, P);
+static PJ_COORD forward_4d(PJ_COORD obs, PJ *P) {
+ PJ_COORD point;
+ point.xyz = forward_3d (obs.lpz, P);
return point;
}
-static PJ_OBS reverse_obs(PJ_OBS obs, PJ *P) {
- PJ_OBS point;
- point.coo.lpz = reverse_3d (obs.coo.xyz, P);
+static PJ_COORD reverse_4d(PJ_COORD obs, PJ *P) {
+ PJ_COORD point;
+ point.lpz = reverse_3d (obs.xyz, P);
return point;
}
-PJ *PROJECTION(vgridshift) {
+PJ *TRANSFORMATION(vgridshift,0) {
if (!pj_param(P->ctx, P->params, "tgrids").i) {
proj_log_error(P, "vgridshift: +grids parameter missing.");
return pj_default_destructor(P, PJD_ERR_NO_ARGS);
}
- /* Build gridlist. P->gridlist can be empty if +grids only ask for optional grids. */
- P->gridlist = pj_gridlist_from_nadgrids( P->ctx, pj_param(P->ctx, P->params, "sgrids").s,
- &(P->gridlist_count) );
+ /* Build gridlist. P->vgridlist_geoid can be empty if +grids only ask for optional grids. */
+ proj_vgrid_init(P, "grids");
/* Was gridlist compiled properly? */
- if ( pj_ctx_get_errno(P->ctx) ) {
+ if ( proj_errno(P) ) {
proj_log_error(P, "vgridshift: could not find required grid(s).");
- return pj_default_destructor(P, -38);
+ return pj_default_destructor(P, PJD_ERR_FAILED_TO_LOAD_GRID);
}
- P->fwdobs = forward_obs;
- P->invobs = reverse_obs;
+ P->fwd4d = forward_4d;
+ P->inv4d = reverse_4d;
P->fwd3d = forward_3d;
P->inv3d = reverse_3d;
P->fwd = 0;
@@ -84,61 +75,3 @@ PJ *PROJECTION(vgridshift) {
return P;
}
-
-#ifndef PJ_SELFTEST
-/* selftest stub */
-int pj_vgridshift_selftest (void) {return 0;}
-#else
-int pj_vgridshift_selftest (void) {
- PJ *P;
- PJ_OBS expect, a, b;
- double dist;
- int failures = 0;
-
- /* fail on purpose: +grids parameter is mandatory*/
- P = proj_create(PJ_DEFAULT_CTX, "+proj=vgridshift");
- if (0!=P) {
- proj_destroy (P);
- return 99;
- }
-
- /* fail on purpose: open non-existing grid */
- P = proj_create(PJ_DEFAULT_CTX, "+proj=vgridshift +grids=nonexistinggrid.gtx");
- if (0!=P) {
- proj_destroy (P);
- return 999;
- }
-
- /* Failure most likely means the grid is missing */
- P = proj_create(PJ_DEFAULT_CTX, "+proj=vgridshift +grids=egm96_15.gtx +ellps=GRS80");
- if (0==P)
- return 10;
-
- a = proj_obs_null;
- a.coo.lpz.lam = PJ_TORAD(12.5);
- a.coo.lpz.phi = PJ_TORAD(55.5);
-
- dist = proj_roundtrip (P, PJ_FWD, 1, a.coo);
- if (dist > 0.00000001)
- return 1;
-
- expect = a;
- /* Appears there is a difference between the egm96_15.gtx distributed by OSGeo4W, */
- /* and the one from http://download.osgeo.org/proj/vdatum/egm96_15/egm96_15.gtx */
- /* Was: expect.coo.lpz.z = -36.021305084228515625; (download.osgeo.org) */
- /* Was: expect.coo.lpz.z = -35.880001068115234000; (OSGeo4W) */
- /* This is annoying, but must be handled elsewhere. So for now, we check for both. */
- expect.coo.lpz.z = -36.021305084228516;
- failures = 0;
- b = proj_trans_obs(P, PJ_FWD, a);
- if (proj_xyz_dist(expect.coo.xyz, b.coo.xyz) > 1e-4) failures++;
- expect.coo.lpz.z = -35.880001068115234000;
- if (proj_xyz_dist(expect.coo.xyz, b.coo.xyz) > 1e-4) failures++;
- if (failures > 1)
- return 2;
-
- proj_destroy (P);
-
- return 0;
-}
-#endif