aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKristian Evers <kristianevers@gmail.com>2016-05-03 21:10:02 +0200
committerKristian Evers <kristianevers@gmail.com>2016-05-03 21:10:02 +0200
commit0fa0bd162e299b540f626e926c4beefdf01ba9a8 (patch)
tree7bc1e00980cbd9d588c4fae7a6a6ea42877d03ef /src
parent65f0502425fdd3f5d0a67b94f1ad12c98cbf5694 (diff)
downloadPROJ-0fa0bd162e299b540f626e926c4beefdf01ba9a8.tar.gz
PROJ-0fa0bd162e299b540f626e926c4beefdf01ba9a8.zip
Converted putp4p and weren
Diffstat (limited to 'src')
-rw-r--r--src/PJ_aea.c2
-rw-r--r--src/PJ_putp4p.c200
2 files changed, 174 insertions, 28 deletions
diff --git a/src/PJ_aea.c b/src/PJ_aea.c
index d5c76ff1..df653cde 100644
--- a/src/PJ_aea.c
+++ b/src/PJ_aea.c
@@ -365,7 +365,6 @@ int pj_lonlat_selftest (void) {return 10000;}
int pj_longlat_selftest (void) {return 10000;}
int pj_ob_tran_selftest (void) {return 10000;}
-int pj_putp4p_selftest (void) {return 10000;}
int pj_putp5_selftest (void) {return 10000;}
int pj_putp5p_selftest (void) {return 10000;}
int pj_putp6_selftest (void) {return 10000;}
@@ -382,5 +381,4 @@ int pj_vandg_selftest (void) {return 10000;}
int pj_vandg2_selftest (void) {return 10000;}
int pj_vandg3_selftest (void) {return 10000;}
int pj_vandg4_selftest (void) {return 10000;}
-int pj_weren_selftest (void) {return 10000;}
#endif
diff --git a/src/PJ_putp4p.c b/src/PJ_putp4p.c
index 32036bbe..9264d896 100644
--- a/src/PJ_putp4p.c
+++ b/src/PJ_putp4p.c
@@ -1,29 +1,177 @@
-#define PROJ_PARMS__ \
- double C_x, C_y;
#define PJ_LIB__
-# include <projects.h>
+#include <projects.h>
+
+struct pj_opaque {
+ double C_x, C_y;
+};
+
PROJ_HEAD(putp4p, "Putnins P4'") "\n\tPCyl., Sph.";
PROJ_HEAD(weren, "Werenskiold I") "\n\tPCyl., Sph.";
-FORWARD(s_forward); /* spheroid */
- lp.phi = aasin(P->ctx,0.883883476 * sin(lp.phi));
- xy.x = P->C_x * lp.lam * cos(lp.phi);
- xy.x /= cos(lp.phi *= 0.333333333333333);
- xy.y = P->C_y * sin(lp.phi);
- return (xy);
-}
-INVERSE(s_inverse); /* spheroid */
- lp.phi = aasin(P->ctx,xy.y / P->C_y);
- lp.lam = xy.x * cos(lp.phi) / P->C_x;
- lp.phi *= 3.;
- lp.lam /= cos(lp.phi);
- lp.phi = aasin(P->ctx,1.13137085 * sin(lp.phi));
- return (lp);
-}
-FREEUP; if (P) pj_dalloc(P); }
- static PJ *
-setup(PJ *P) {
- P->es = 0.; P->inv = s_inverse; P->fwd = s_forward;
- return P;
-}
-ENTRY0(putp4p) P->C_x = 0.874038744; P->C_y = 3.883251825; ENDENTRY(setup(P))
-ENTRY0(weren) P->C_x = 1.; P->C_y = 4.442882938; ENDENTRY(setup(P))
+
+
+static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
+ XY xy = {0.0,0.0};
+ struct pj_opaque *Q = P->opaque;
+
+ lp.phi = aasin(P->ctx,0.883883476 * sin(lp.phi));
+ xy.x = Q->C_x * lp.lam * cos(lp.phi);
+ xy.x /= cos(lp.phi *= 0.333333333333333);
+ xy.y = Q->C_y * sin(lp.phi);
+
+ return xy;
+}
+
+
+static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
+ LP lp = {0.0,0.0};
+ struct pj_opaque *Q = P->opaque;
+
+ lp.phi = aasin(P->ctx,xy.y / Q->C_y);
+ lp.lam = xy.x * cos(lp.phi) / Q->C_x;
+ lp.phi *= 3.;
+ lp.lam /= cos(lp.phi);
+ lp.phi = aasin(P->ctx,1.13137085 * sin(lp.phi));
+
+ return lp;
+}
+
+
+static void *freeup_new (PJ *P) { /* Destructor */
+ if (0==P)
+ return 0;
+ if (0==P->opaque)
+ return pj_dealloc (P);
+
+ pj_dealloc (P->opaque);
+ return pj_dealloc(P);
+}
+
+
+static void freeup (PJ *P) {
+ freeup_new (P);
+ return;
+}
+
+
+PJ *PROJECTION(putp4p) {
+ struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+ if (0==Q)
+ return freeup_new (P);
+ P->opaque = Q;
+
+ Q->C_x = 0.874038744;
+ Q->C_y = 3.883251825;
+
+ P->es = 0.;
+ P->inv = s_inverse;
+ P->fwd = s_forward;
+
+ return P;
+}
+
+
+PJ *PROJECTION(weren) {
+ struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
+ if (0==Q)
+ return freeup_new (P);
+ P->opaque = Q;
+
+ Q->C_x = 1.;
+ Q->C_y = 4.442882938;
+
+ P->es = 0.;
+ P->inv = s_inverse;
+ P->fwd = s_forward;
+
+ return P;
+}
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_putp4p_selftest (void) {return 0;}
+#else
+
+int pj_putp4p_selftest (void) {
+ double tolerance_lp = 1e-10;
+ double tolerance_xy = 1e-7;
+
+ char s_args[] = {"+proj=putp4p +a=6400000 +lat_1=0.5 +lat_2=2"};
+
+ LP fwd_in[] = {
+ { 2, 1},
+ { 2,-1},
+ {-2, 1},
+ {-2,-1}
+ };
+
+ XY s_fwd_expect[] = {
+ { 195241.47734938623, 127796.782307926231},
+ { 195241.47734938623, -127796.782307926231},
+ {-195241.47734938623, 127796.782307926231},
+ {-195241.47734938623, -127796.782307926231},
+ };
+
+ XY inv_in[] = {
+ { 200, 100},
+ { 200,-100},
+ {-200, 100},
+ {-200,-100}
+ };
+
+ LP s_inv_expect[] = {
+ { 0.00204852830860296001, 0.000782480174932193733},
+ { 0.00204852830860296001, -0.000782480174932193733},
+ {-0.00204852830860296001, 0.000782480174932193733},
+ {-0.00204852830860296001, -0.000782480174932193733},
+ };
+
+ 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
+
+
+#ifdef PJ_OMIT_SELFTEST
+int pj_weren_selftest (void) {return 0;}
+#else
+
+int pj_weren_selftest (void) {
+ double tolerance_lp = 1e-10;
+ double tolerance_xy = 1e-7;
+
+ char s_args[] = {"+proj=weren +a=6400000 +lat_1=0.5 +lat_2=2"};
+
+ LP fwd_in[] = {
+ { 2, 1},
+ { 2,-1},
+ {-2, 1},
+ {-2,-1}
+ };
+
+ XY s_fwd_expect[] = {
+ { 223378.515757633519, 146214.093042288267},
+ { 223378.515757633519, -146214.093042288267},
+ {-223378.515757633519, 146214.093042288267},
+ {-223378.515757633519, -146214.093042288267},
+ };
+
+ XY inv_in[] = {
+ { 200, 100},
+ { 200,-100},
+ {-200, 100},
+ {-200,-100}
+ };
+
+ LP s_inv_expect[] = {
+ { 0.00179049310987240413, 0.000683917989676492265},
+ { 0.00179049310987240413, -0.000683917989676492265},
+ {-0.00179049310987240413, 0.000683917989676492265},
+ {-0.00179049310987240413, -0.000683917989676492265},
+ };
+
+ 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