Debian Codegraph @

gctp/src/wviiinv.c

raw
1 /*******************************************************************************
2 NAME WAGNER VII
3
4 PURPOSE: Transforms input Easting and Northing to longitude and
5 latitude for the Wagner VII projection. The
6 Easting and Northing must be in meters. The longitude
7 and latitude values will be returned in radians.
8
9 PROGRAMMER DATE
10 ---------- ----
11 D. Steinwand, EROS May, 1991
12 S. Nelson, EROS Dec, 1993 Added function call to "asinz" to
13 fix errors at 90 and -90 deg lat.
14 This replaced calls to "asin".
15
16 This function was implemented with formulas supplied by John P. Snyder.
17
18 ALGORITHM REFERENCES
19
20 1. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections",
21 U.S. Geological Survey Professional Paper 1453 , United State Government
22 Printing Office, Washington D.C., 1989.
23
24 2. Snyder, John P., Personal correspondence, January 1991.
25 *******************************************************************************/
26 #include <stdio.h>
27 #include "cproj.h"
28
29 /* Variables common to all subroutines in this code file
30 -----------------------------------------------------*/
31 static double lon_center; /* Center longitude (projection center) */
32 static double R; /* Radius of the earth (sphere) */
33 static double false_easting; /* x offset */
34 static double false_northing; /* y offset */
35
36 /* Initialize the Wagner VII projection
37 ------------------------------------*/
38 int wviiinvint(
39 double r, /* (I) Radius of the earth (sphere) */
40 double center_long, /* (I) Center longitude */
41 double false_east, /* x offset */
42 double false_north) /* y offset */
43 {
44 /* Place parameters in static storage for common use
45 -------------------------------------------------*/
46 R = r;
47 lon_center = center_long;
48 false_easting = false_east;
49 false_northing = false_north;
50
51 /* Report parameters to the user
52 -----------------------------*/
53 ptitle("WAGNER VII");
54 radius(r);
55 cenlon(center_long);
56 offsetp(false_easting,false_northing);
57 return(OK);
58 }
59
60 /* Wagner VII inverse equations--mapping x,y to lat,long
61 -----------------------------------------------------*/
62 int wviiinv(
63 double x, /* (I) X projection coordinate */
64 double y, /* (I) Y projection coordinate */
65 double *lon, /* (O) Longitude */
66 double *lat) /* (O) Latitude */
67 {
68 double t1, t2, p, c;
69
70 /* Inverse equations
71 -----------------*/
72 x -= false_easting;
73 y -= false_northing;
74 t1 = x / 2.66723;
75 t2 = y / 1.24104;
76 t1 *= t1;
77 t2 *= t2;
78 p = sqrt(t1 + t2);
79 c = 2.0 * asinz(p / (2.0 * R));
80 *lat = asinz(y * sin(c) / (1.24104 * 0.90631 * p));
81 *lon = adjust_lon(lon_center + 3.0 * atan2(x * tan(c), 2.66723 * p));
82 return(OK);
83 }
84