OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
wivfor.c
Go to the documentation of this file.
1 /*******************************************************************************
2 NAME WAGNER IV
3 
4 PURPOSE: Transforms input longitude and latitude to Easting and
5  Northing for the Wagner IV projection. The
6  longitude and latitude must be in radians. The Easting
7  and Northing values will be returned in meters.
8 
9 ALGORITHM REFERENCES
10 
11 1. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections",
12  U.S. Geological Survey Professional Paper 1453 , United State Government
13  Printing Office, Washington D.C., 1989.
14 
15 2. Snyder, John P., Personal correspondence, January 1991.
16 *******************************************************************************/
17 #include "oli_cproj.h"
18 #include "oli_local.h"
19 
20 /* Variables common to all subroutines in this code file
21  -----------------------------------------------------*/
22 static double lon_center; /* Center longitude (projection center) */
23 static double R; /* Radius of the earth (sphere) */
24 static double false_easting; /* x offset */
25 static double false_northing; /* y offset */
26 
27 /* Initialize the Wagner IV projection
28  ------------------------------------*/
29 long wivforint
30 (
31  double r, /* (I) Radius of the earth (sphere) */
32  double center_long, /* (I) Center longitude */
33  double false_east, /* x offset */
34  double false_north /* y offset */
35 )
36 {
37 /* Place parameters in static storage for common use
38  -------------------------------------------------*/
39 R = r;
40 lon_center = center_long;
41 false_easting = false_east;
42 false_northing = false_north;
43 
44 /* Report parameters to the user
45  -----------------------------*/
46 gctp_print_title("WAGNER IV");
48 gctp_print_cenlon(center_long);
49 gctp_print_offsetp(false_east,false_north);
50 return(OK);
51 }
52 
53 /* Wagner IV forward equations--mapping lat,long to x,y
54  ----------------------------------------------------*/
55 long wivfor
56 (
57  double lon, /* (I) Longitude */
58  double lat, /* (I) Latitude */
59  double *x, /* (O) X projection coordinate */
60  double *y /* (O) Y projection coordinate */
61 )
62 {
63 double delta_lon; /* Delta longitude (Given longitude - center */
64 double theta;
65 double delta_theta;
66 double con;
67 long i;
68 
69 /* Forward equations
70  -----------------*/
71 delta_lon = adjust_lon(lon - lon_center);
72 theta = lat;
73 con = 2.9604205062 * sin(lat);
74 
75 /* Iterate using the Newton-Raphson method to find theta
76  -----------------------------------------------------*/
77 for (i=0;;i++)
78  {
79  delta_theta = -(theta + sin(theta) - con) / (1.0 + cos(theta));
80  theta += delta_theta;
81  if (fabs(delta_theta) < EPSLN) break;
82  if (i >= 30)
83  GCTP_PRINT_ERROR("Iteration failed to converge");
84  }
85 theta /= 2.0;
86 *x = 0.86310 * R * delta_lon * cos(theta) + false_easting;
87 *y = 1.56548 * R * sin(theta) + false_northing;
88 return(OK);
89 }
int r
Definition: decode_rs.h:73
void gctp_print_title(const char *proj_name)
Definition: gctp_report.c:14
long wivfor(double lon, double lat, double *x, double *y)
Definition: wivfor.c:56
void gctp_print_cenlon(double A)
Definition: gctp_report.c:40
#define GCTP_PRINT_ERROR(format,...)
Definition: oli_local.h:81
float * lat
double adjust_lon(double x)
Definition: proj_cproj.c:349
double false_easting
Definition: tm.c:54
void gctp_print_offsetp(double A, double B)
Definition: gctp_report.c:91
double false_northing
Definition: tm.c:53
#define OK
Definition: ancil.h:30
#define fabs(a)
Definition: misc.h:93
double lon_center
Definition: tm.c:51
float * lon
void gctp_print_radius(double radius)
Definition: gctp_report.c:22
long wivforint(double r, double center_long, double false_east, double false_north)
Definition: wivfor.c:30
#define R
Definition: make_L3_v1.1.c:96
int i
Definition: decode_rs.h:71
#define EPSLN
Definition: proj_define.h:86