OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
obleqfor.c
Go to the documentation of this file.
1 /*******************************************************************************
2 NAME OBLATED EQUAL-AREA
3 
4 PURPOSE: Transforms input longitude and latitude to Easting and
5  Northing for the Oblated Equal Area 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. "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 obleqforint
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 obleqfor
77 (
78  double lon, /* (I) Longitude */
79  double lat, /* (I) Latitude */
80  double *x, /* (O) X projection coordinate */
81  double *y /* (O) Y projection coordinate */
82 )
83 {
84 double delta_lon;
85 double sin_delta_lon;
86 double cos_delta_lon;
87 double sin_lat;
88 double cos_lat;
89 double z;
90 double Az;
91 double sin_Az;
92 double cos_Az;
93 double temp; /* Re-used temporary variable */
94 double x_prime;
95 double y_prime;
96 double M;
97 double N;
98 
99 /* Forward equations
100  -----------------*/
101 delta_lon = lon - lon_center;
102 sincos(lat, &sin_lat, &cos_lat);
103 sincos(delta_lon, &sin_delta_lon, &cos_delta_lon);
104 z = acos(sin_lat_o * sin_lat + cos_lat_o * cos_lat * cos_delta_lon);
105 Az = atan2(cos_lat * sin_delta_lon , cos_lat_o * sin_lat - sin_lat_o *
106  cos_lat * cos_delta_lon) + theta;
107 sincos(Az, &sin_Az, &cos_Az);
108 temp = 2.0 * sin(z / 2.0);
109 x_prime = temp * sin_Az;
110 y_prime = temp * cos_Az;
111 M = asin(x_prime / 2.0);
112 temp = y_prime / 2.0 * cos(M) / cos(2.0 * M / m);
113 N = asin(temp);
114 *y = n * R * sin(2.0 * N / n) + false_easting;
115 *x = m * R * sin(2.0 * M / m) * cos(N) / cos(2.0 * N / n) + false_northing;
116 return(OK);
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
float * lat
long obleqforint(double r, double center_long, double center_lat, double shape_m, double shape_n, double angle, double false_east, double false_north)
Definition: obleqfor.c:36
long obleqfor(double lon, double lat, double *x, double *y)
Definition: obleqfor.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