OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
obleqinv.c
Go to the documentation of this file.
1 /*******************************************************************************
2 NAME OBLATED EQUAL-AREA
3 
4 PURPOSE: Transforms input Easting and Northing to longitude and
5  latitude for the Oblated Equal Area projection. The
6  Easting and Northing must be in meters. The longitude
7  and latitude values will be returned in radians.
8 
9 ALGORITHM REFERENCES
10 
11 1. "New Equal-Area Map Projections for Noncircular Regions", John P. Snyder,
12  The American Cartographer, Vol 15, No. 4, October 1988, pp. 341-355.
13 
14 2. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
15  Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
16  State Government Printing Office, Washington D.C., 1987.
17 
18 3. "Software Documentation for GCTP General Cartographic Transformation
19  Package", U.S. Geological Survey National Mapping Division, May 1982.
20 *******************************************************************************/
21 #include "oli_cproj.h"
22 #include "oli_local.h"
23 
24 static double lon_center;
25 static double lat_o;
26 static double theta;
27 static double m;
28 static double n;
29 static double R;
30 static double sin_lat_o;
31 static double cos_lat_o;
32 static double false_easting;
33 static double false_northing;
34 
35 long obleqinvint
36 (
37  double r,
38  double center_long,
39  double center_lat,
40  double shape_m,
41  double shape_n,
42  double angle,
43  double false_east,
44  double false_north
45 )
46 {
47 /* Place parameters in static storage for common use
48  -------------------------------------------------*/
49 R = r;
50 lon_center = center_long;
51 lat_o = center_lat;
52 m = shape_m;
53 n = shape_n;
54 theta = angle;
55 false_easting = false_east;
56 false_northing = false_north;
57 
58 /* Report parameters to the user (to device set up prior to this call)
59  -------------------------------------------------------------------*/
60 gctp_print_title("OBLATED EQUAL-AREA");
62 gctp_print_cenlon(lon_center);
63 gctp_print_cenlat(lat_o);
64 gctp_print_genrpt(m,"Parameter m: ");
65 gctp_print_genrpt(n,"Parameter n: ");
66 gctp_print_genrpt(theta,"Theta: ");
67 gctp_print_offsetp(false_easting,false_northing);
68 
69 /* Calculate the sine and cosine of the latitude of the center of the map
70  and store in static storage for common use.
71  -------------------------------------------*/
72 sincos(lat_o, &sin_lat_o, &cos_lat_o);
73 return(OK);
74 }
75 
76 long obleqinv
77 (
78  double x, /* (I) X projection coordinate */
79  double y, /* (I) Y projection coordinate */
80  double *lon, /* (O) Longitude */
81  double *lat /* (O) Latitude */
82 )
83 {
84 double z;
85 double sin_z;
86 double cos_z;
87 double Az;
88 double temp; /* Re-used temporary variable */
89 double x_prime;
90 double y_prime;
91 double M;
92 double N;
93 double diff_angle;
94 double sin_diff_angle;
95 double cos_diff_angle;
96 
97 /* Inverse equations
98  -----------------*/
99 x -= false_easting;
100 y -= false_northing;
101 N = (n / 2.0) * asin(y / (n * R));
102 temp = x / (m * R) * cos(2.0 * N / n) / cos(N);
103 M = (m / 2.0) * asin(temp);
104 x_prime = 2.0 * sin(M);
105 y_prime = 2.0 * sin(N) * cos(2.0 * M / m) / cos(M);
106 temp = sqrt(x_prime * x_prime + y_prime * y_prime) / 2.0;
107 z = 2.0 * asin(temp);
108 Az = atan2(x_prime, y_prime);
109 diff_angle = Az - theta;
110 sincos(diff_angle, &sin_diff_angle, &cos_diff_angle);
111 sincos(z, &sin_z, &cos_z);
112 *lat = asin(sin_lat_o * cos_z + cos_lat_o * sin_z * cos_diff_angle);
113 *lon = adjust_lon(lon_center + atan2((sin_z * sin_diff_angle), (cos_lat_o *
114  cos_z - sin_lat_o * sin_z * cos_diff_angle)));
115 return(OK);
116 }
117 
int r
Definition: decode_rs.h:73
void gctp_print_title(const char *proj_name)
Definition: gctp_report.c:14
int N
Definition: Usds.c:60
void gctp_print_cenlon(double A)
Definition: gctp_report.c:40
long obleqinvint(double r, double center_long, double center_lat, double shape_m, double shape_n, double angle, double false_east, double false_north)
Definition: obleqinv.c:36
float * lat
double adjust_lon(double x)
Definition: proj_cproj.c:349
long obleqinv(double x, double y, double *lon, double *lat)
Definition: obleqinv.c:77
void gctp_print_offsetp(double A, double B)
Definition: gctp_report.c:91
#define OK
Definition: ancil.h:30
int M[]
Definition: Usds.c:107
void gctp_print_genrpt(double A, const char *S)
Definition: gctp_report.c:117
#define sincos
Definition: proj_define.h:108
float * lon
void gctp_print_radius(double radius)
Definition: gctp_report.c:22
#define R
Definition: make_L3_v1.1.c:96
void gctp_print_cenlat(double A)
Definition: gctp_report.c:57