aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKristian Evers <kristianevers@gmail.com>2016-04-13 22:54:36 +0200
committerKristian Evers <kristianevers@gmail.com>2016-04-13 22:54:36 +0200
commit613baf982c3d14ab4ebce2e754043f193f0c56fa (patch)
treee55b01dcb1ad0bad2b0f8c46531a6baaa1a69e45 /src
parenta98e366f1e91202d576cecb2015dfa8db6a42bc3 (diff)
downloadPROJ-613baf982c3d14ab4ebce2e754043f193f0c56fa.tar.gz
PROJ-613baf982c3d14ab4ebce2e754043f193f0c56fa.zip
Converted Compact Miller projection
Diffstat (limited to 'src')
-rw-r--r--src/PJ_aea.c1
-rw-r--r--src/PJ_comill.c133
2 files changed, 102 insertions, 32 deletions
diff --git a/src/PJ_aea.c b/src/PJ_aea.c
index 52510360..65b001b4 100644
--- a/src/PJ_aea.c
+++ b/src/PJ_aea.c
@@ -357,7 +357,6 @@ int pj_aeqd_selftest (void) {return 10000;}
int pj_alsk_selftest (void) {return 10000;}
int pj_chamb_selftest (void) {return 10000;}
-int pj_comill_selftest (void) {return 10000;}
int pj_crast_selftest (void) {return 10000;}
int pj_denoy_selftest (void) {return 10000;}
int pj_eck1_selftest (void) {return 10000;}
diff --git a/src/PJ_comill.c b/src/PJ_comill.c
index ad9914d4..f84f4eb0 100644
--- a/src/PJ_comill.c
+++ b/src/PJ_comill.c
@@ -1,13 +1,14 @@
/*
-The Compact Miller projection was designed by Tom Patterson, US National
-Park Service, in 2014. The polynomial equation was developed by Bojan
-Savric and Bernhard Jenny, College of Earth, Ocean, and Atmospheric
+The Compact Miller projection was designed by Tom Patterson, US National
+Park Service, in 2014. The polynomial equation was developed by Bojan
+Savric and Bernhard Jenny, College of Earth, Ocean, and Atmospheric
Sciences, Oregon State University.
Port to PROJ.4 by Bojan Savric, 4 April 2016
*/
#define PJ_LIB__
-#include <projects.h>
+#include <projects.h>
+
PROJ_HEAD(comill, "Compact Miller") "\n\tCyl., Sph.";
#define K1 0.9902
@@ -19,41 +20,111 @@ PROJ_HEAD(comill, "Compact Miller") "\n\tCyl., Sph.";
#define EPS 1e-11
#define MAX_Y (0.6000207669862655 * PI)
-FORWARD(s_forward); /* spheroid */
- double lat_sq;
- lat_sq = lp.phi * lp.phi;
- xy.x = lp.lam;
- xy.y = lp.phi * (K1 + lat_sq * (K2 + K3 * lat_sq));
- return (xy);
+static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
+ XY xy = {0.0,0.0};
+ double lat_sq;
+
+ lat_sq = lp.phi * lp.phi;
+ xy.x = lp.lam;
+ xy.y = lp.phi * (K1 + lat_sq * (K2 + K3 * lat_sq));
+ return xy;
}
-INVERSE(s_inverse); /* spheroid */
- double yc, tol, y2, y4, f, fder;
+
+
+static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
+ LP lp = {0.0,0.0};
+ double yc, tol, y2, y4, f, fder;
/* make sure y is inside valid range */
- if (xy.y > MAX_Y) {
- xy.y = MAX_Y;
- } else if (xy.y < -MAX_Y) {
- xy.y = -MAX_Y;
- }
+ if (xy.y > MAX_Y) {
+ xy.y = MAX_Y;
+ } else if (xy.y < -MAX_Y) {
+ xy.y = -MAX_Y;
+ }
/* latitude */
- yc = xy.y;
+ yc = xy.y;
for (;;) { /* Newton-Raphson */
- y2 = yc * yc;
- f = (yc * (K1 + y2 * (K2 + K3 * y2))) - xy.y;
- fder = C1 + y2 * (C2 + C3 * y2);
- yc -= tol = f / fder;
- if (fabs(tol) < EPS) {
- break;
- }
- }
- lp.phi = yc;
+ y2 = yc * yc;
+ f = (yc * (K1 + y2 * (K2 + K3 * y2))) - xy.y;
+ fder = C1 + y2 * (C2 + C3 * y2);
+ yc -= tol = f / fder;
+ if (fabs(tol) < EPS) {
+ break;
+ }
+ }
+ lp.phi = yc;
/* longitude */
- lp.lam = xy.x;
+ lp.lam = xy.x;
+
+ return lp;
+}
+
+static void *freeup_new (PJ *P) { /* Destructor */
+ return pj_dealloc(P);
+}
+
+static void freeup (PJ *P) {
+ freeup_new (P);
+ return;
+}
+
+
+PJ *PROJECTION(comill) {
+ P->es = 0;
+
+ P->inv = s_inverse;
+ P->fwd = s_forward;
- return (lp);
+ P->pfree = freeup;
+ P->descr = des_comill;
+
+ return P;
}
-FREEUP; if (P) pj_dalloc(P); }
-ENTRY0(comill) P->es = 0; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P)
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_comill_selftest (void) {return 0;}
+#else
+
+int pj_comill_selftest (void) {
+ double tolerance_lp = 1e-10;
+ double tolerance_xy = 1e-7;
+
+ char s_args[] = {"+proj=comill +a=6400000 +lat_1=0.5 +lat_2=2"};
+
+ LP fwd_in[] = {
+ { 2, 1},
+ { 2,-1},
+ {-2, 1},
+ {-2,-1}
+ };
+
+ XY s_fwd_expect[] = {
+ {223402.144255274179, 110611.859089458536},
+ {223402.144255274179, -110611.859089458536},
+ {-223402.144255274179, 110611.859089458536},
+ {-223402.144255274179, -110611.859089458536},
+ };
+
+ XY inv_in[] = {
+ { 200, 100},
+ { 200,-100},
+ {-200, 100},
+ {-200,-100}
+ };
+
+ LP s_inv_expect[] = {
+ {0.00179049310978382265, 0.000904106801510605831},
+ {0.00179049310978382265, -0.000904106801510605831},
+ {-0.00179049310978382265, 0.000904106801510605831},
+ {-0.00179049310978382265, -0.000904106801510605831},
+ };
+
+ 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