Debian Codegraph @

gctp/src/wivinv.c

raw
1 /*******************************************************************************
2 NAME WAGNER IV
3
4 PURPOSE: Transforms input Easting and Northing to longitude and
5 latitude for the Wagner IV 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
13 This function was implemented with formulas supplied by John P. Snyder.
14
15 ALGORITHM REFERENCES
16
17 1. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections",
18 U.S. Geological Survey Professional Paper 1453 , United State Government
19 Printing Office, Washington D.C., 1989.
20
21 2. Snyder, John P., Personal correspondence, January 1991.
22 *******************************************************************************/
23 #include <stdio.h>
24 #include "cproj.h"
25
26 /* Variables common to all subroutines in this code file
27 -----------------------------------------------------*/
28 static double lon_center; /* Center longitude (projection center) */
29 static double R; /* Radius of the earth (sphere) */
30 static double false_easting; /* x offset */
31 static double false_northing; /* y offset */
32
33 /* Initialize the Wagner IV projection
34 ------------------------------------*/
35 int wivinvint(
36 double r, /* (I) Radius of the earth (sphere) */
37 double center_long, /* (I) Center longitude */
38 double false_east, /* x offset */
39 double false_north) /* y offset */
40 {
41 /* Place parameters in static storage for common use
42 -------------------------------------------------*/
43 R = r;
44 lon_center = center_long;
45 false_easting = false_east;
46 false_northing = false_north;
47
48 /* Report parameters to the user
49 -----------------------------*/
50 ptitle("WAGNER IV");
51 radius(r);
52 cenlon(center_long);
53 offsetp(false_east,false_north);
54 return(OK);
55 }
56
57 /* Wagner IV inverse equations--mapping x,y to lat,long
58 ----------------------------------------------------*/
59 int wivinv(
60 double x, /* (I) X projection coordinate */
61 double y, /* (I) Y projection coordinate */
62 double *lon, /* (O) Longitude */
63 double *lat) /* (O) Latitude */
64 {
65 double theta;
66
67 /* Inverse equations
68 -----------------*/
69 x -= false_easting;
70 y -= false_northing;
71 theta = asin(y / (1.56548 * R));
72 *lon = adjust_lon(lon_center + (x / (0.86310 * R * cos(theta))));
73 *lat = asin((2.0 * theta + sin(2.0 * theta)) / 2.9604205062);
74 return(OK);
75 }
76