aboutsummaryrefslogtreecommitdiff
path: root/src/pj_deriv.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2018-12-18 20:24:11 +0100
committerEven Rouault <even.rouault@spatialys.com>2018-12-26 10:08:53 +0100
commit610957f7035242f15743c399ffd429b92bc36206 (patch)
tree73f0d51147e2f4860c4bfc875f7a4bf9359386d4 /src/pj_deriv.cpp
parent355d681ed88019e97742344bd642c2fd97e700a1 (diff)
downloadPROJ-610957f7035242f15743c399ffd429b92bc36206.tar.gz
PROJ-610957f7035242f15743c399ffd429b92bc36206.zip
cpp conversion: minimal steps to fix compilation errors, not warnings
Diffstat (limited to 'src/pj_deriv.cpp')
-rw-r--r--src/pj_deriv.cpp70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/pj_deriv.cpp b/src/pj_deriv.cpp
new file mode 100644
index 00000000..2c91e0cc
--- /dev/null
+++ b/src/pj_deriv.cpp
@@ -0,0 +1,70 @@
+/* dervative of (*P->fwd) projection */
+#define PJ_LIB__
+
+#include <math.h>
+
+#include "projects.h"
+
+int pj_deriv(LP lp, double h, const PJ *P, struct DERIVS *der) {
+ XY t;
+ /* get rid of constness until we can do it for real */
+ PJ *Q = (PJ *) P;
+ if (0==Q->fwd)
+ return 1;
+
+ lp.lam += h;
+ lp.phi += h;
+ if (fabs(lp.phi) > M_HALFPI)
+ return 1;
+
+ h += h;
+ t = (*Q->fwd)(lp, Q);
+ if (t.x == HUGE_VAL)
+ return 1;
+
+ der->x_l = t.x;
+ der->y_p = t.y;
+ der->x_p = t.x;
+ der->y_l = t.y;
+
+ lp.phi -= h;
+ if (fabs(lp.phi) > M_HALFPI)
+ return 1;
+
+ t = (*Q->fwd)(lp, Q);
+ if (t.x == HUGE_VAL)
+ return 1;
+
+ der->x_l += t.x;
+ der->y_p -= t.y;
+ der->x_p -= t.x;
+ der->y_l += t.y;
+
+ lp.lam -= h;
+ t = (*Q->fwd)(lp, Q);
+ if (t.x == HUGE_VAL)
+ return 1;
+
+ der->x_l -= t.x;
+ der->y_p -= t.y;
+ der->x_p -= t.x;
+ der->y_l -= t.y;
+
+ lp.phi += h;
+ t = (*Q->fwd)(lp, Q);
+ if (t.x == HUGE_VAL)
+ return 1;
+
+ der->x_l -= t.x;
+ der->y_p += t.y;
+ der->x_p += t.x;
+ der->y_l -= t.y;
+
+ h += h;
+ der->x_l /= h;
+ der->y_p /= h;
+ der->x_p /= h;
+ der->y_l /= h;
+
+ return 0;
+}