aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKristian Evers <kristianevers@gmail.com>2016-04-28 21:04:35 +0200
committerKristian Evers <kristianevers@gmail.com>2016-04-28 21:04:35 +0200
commit66b9152c5339cdc699c93d8954078e1a81f84e38 (patch)
tree2153c654776d9a253cb76eef1f171555fde53f4f /src
parentc9f12e0033474518fa460444b9948f36ce47d51f (diff)
downloadPROJ-66b9152c5339cdc699c93d8954078e1a81f84e38.tar.gz
PROJ-66b9152c5339cdc699c93d8954078e1a81f84e38.zip
Converted mbt_fps
Diffstat (limited to 'src')
-rw-r--r--src/PJ_aea.c1
-rw-r--r--src/PJ_mbt_fps.c129
2 files changed, 101 insertions, 29 deletions
diff --git a/src/PJ_aea.c b/src/PJ_aea.c
index 84ad5c4c..4198d2b3 100644
--- a/src/PJ_aea.c
+++ b/src/PJ_aea.c
@@ -369,7 +369,6 @@ int pj_longlat_selftest (void) {return 10000;}
int pj_lee_os_selftest (void) {return 10000;}
-int pj_mbt_fps_selftest (void) {return 10000;}
int pj_mbtfpp_selftest (void) {return 10000;}
int pj_mbtfpq_selftest (void) {return 10000;}
int pj_merc_selftest (void) {return 10000;}
diff --git a/src/PJ_mbt_fps.c b/src/PJ_mbt_fps.c
index 3cd5e674..daa1555c 100644
--- a/src/PJ_mbt_fps.c
+++ b/src/PJ_mbt_fps.c
@@ -1,39 +1,112 @@
#define PJ_LIB__
-#include <projects.h>
+#include <projects.h>
+
PROJ_HEAD(mbt_fps, "McBryde-Thomas Flat-Pole Sine (No. 2)") "\n\tCyl., Sph.";
-#define MAX_ITER 10
-#define LOOP_TOL 1e-7
+
+#define MAX_ITER 10
+#define LOOP_TOL 1e-7
#define C1 0.45503
#define C2 1.36509
#define C3 1.41546
#define C_x 0.22248
#define C_y 1.44492
#define C1_2 0.33333333333333333333333333
-FORWARD(s_forward); /* spheroid */
- double k, V, t;
- int i;
- (void) P;
-
- k = C3 * sin(lp.phi);
- for (i = MAX_ITER; i ; --i) {
- t = lp.phi / C2;
- lp.phi -= V = (C1 * sin(t) + sin(lp.phi) - k) /
- (C1_2 * cos(t) + cos(lp.phi));
- if (fabs(V) < LOOP_TOL)
- break;
- }
- t = lp.phi / C2;
- xy.x = C_x * lp.lam * (1. + 3. * cos(lp.phi)/cos(t) );
- xy.y = C_y * sin(t);
- return (xy);
+
+static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
+ XY xy = {0.0,0.0};
+ double k, V, t;
+ int i;
+ (void) P;
+
+ k = C3 * sin(lp.phi);
+ for (i = MAX_ITER; i ; --i) {
+ t = lp.phi / C2;
+ lp.phi -= V = (C1 * sin(t) + sin(lp.phi) - k) /
+ (C1_2 * cos(t) + cos(lp.phi));
+ if (fabs(V) < LOOP_TOL)
+ break;
+ }
+ t = lp.phi / C2;
+ xy.x = C_x * lp.lam * (1. + 3. * cos(lp.phi)/cos(t) );
+ xy.y = C_y * sin(t);
+ return xy;
}
-INVERSE(s_inverse); /* spheroid */
- double t;
- lp.phi = C2 * (t = aasin(P->ctx,xy.y / C_y));
- lp.lam = xy.x / (C_x * (1. + 3. * cos(lp.phi)/cos(t)));
- lp.phi = aasin(P->ctx,(C1 * sin(t) + sin(lp.phi)) / C3);
- return (lp);
+
+static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
+ LP lp = {0.0,0.0};
+ double t;
+
+ lp.phi = C2 * (t = aasin(P->ctx,xy.y / C_y));
+ lp.lam = xy.x / (C_x * (1. + 3. * cos(lp.phi)/cos(t)));
+ lp.phi = aasin(P->ctx,(C1 * sin(t) + sin(lp.phi)) / C3);
+ return (lp);
}
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(mbt_fps) P->es = 0; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P)
+
+
+static void *freeup_new (PJ *P) { /* Destructor */
+ if (0==P)
+ return 0;
+
+ return pj_dealloc(P);
+}
+
+
+static void freeup (PJ *P) {
+ freeup_new (P);
+ return;
+}
+
+
+PJ *PROJECTION(mbt_fps) {
+
+ P->es = 0;
+ P->inv = s_inverse;
+ P->fwd = s_forward;
+
+ return P;
+}
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_mbt_fps_selftest (void) {return 0;}
+#else
+
+int pj_mbt_fps_selftest (void) {
+ double tolerance_lp = 1e-10;
+ double tolerance_xy = 1e-7;
+
+ char s_args[] = {"+proj=mbt_fps +a=6400000 +lat_1=0.5 +lat_2=2"};
+
+ LP fwd_in[] = {
+ { 2, 1},
+ { 2,-1},
+ {-2, 1},
+ {-2,-1}
+ };
+
+ XY s_fwd_expect[] = {
+ { 198798.176129849948, 125512.017254530627},
+ { 198798.176129849948, -125512.017254530627},
+ {-198798.176129849948, 125512.017254530627},
+ {-198798.176129849948, -125512.017254530627},
+ };
+
+ XY inv_in[] = {
+ { 200, 100},
+ { 200,-100},
+ {-200, 100},
+ {-200,-100}
+ };
+
+ LP s_inv_expect[] = {
+ { 0.00201197086238270742, 0.000796711850174446003},
+ { 0.00201197086238270742, -0.000796711850174446003},
+ {-0.00201197086238270742, 0.000796711850174446003},
+ {-0.00201197086238270742, -0.000796711850174446003},
+ };
+
+ return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
+}
+
+
+#endif