OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
molwinv.c
Go to the documentation of this file.
1 /*******************************************************************************
2 NAME MOLLWEIDE
3 
4 PURPOSE: Transforms input Easting and Northing to longitude and
5  latitude for the Mollweide 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. 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., "Map Projections--A Working Manual", U.S. Geological
16  Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
17  State Government Printing Office, Washington D.C., 1987.
18 *******************************************************************************/
19 #include "oli_cproj.h"
20 #include "oli_local.h"
21 
22 /* Variables common to all subroutines in this code file
23  -----------------------------------------------------*/
24 static double lon_center; /* Center longitude (projection center) */
25 static double R; /* Radius of the earth (sphere) */
26 static double false_easting; /* x offset in meters */
27 static double false_northing; /* y offset in meters */
28 
29 /* Initialize the Mollweide projection
30  ------------------------------------*/
31 long molwinvint
32 (
33  double r, /* (I) Radius of the earth (sphere) */
34  double center_long, /* (I) Center longitude */
35  double false_east, /* x offset in meters */
36  double false_north /* y offset in meters */
37 )
38 {
39 /* Place parameters in static storage for common use
40  -------------------------------------------------*/
41 false_easting = false_east;
42 false_northing = false_north;
43 R = r;
44 lon_center = center_long;
45 
46 /* Report parameters to the user
47  -----------------------------*/
48 gctp_print_title("MOLLWEIDE");
50 gctp_print_cenlon(center_long);
52 return(OK);
53 }
54 
55 /* Mollweide inverse equations--mapping x,y to lat,long
56  ----------------------------------------------------*/
57 long molwinv
58 (
59  double x, /* (I) X projection coordinate */
60  double y, /* (I) Y projection coordinate */
61  double *lon, /* (O) Longitude */
62  double *lat /* (O) Latitude */
63 )
64 {
65 double theta;
66 double arg;
67 
68 /* Inverse equations
69  -----------------*/
70 x -= false_easting;
71 y -= false_northing;
72 arg = y / (1.4142135623731 * R);
73 
74 /* Because of division by zero problems, 'arg' can not be 1.0. Therefore
75  a number very close to one is used instead.
76  -------------------------------------------------------------------*/
77 if(fabs(arg) > 0.999999999999) arg=0.999999999999;
78 theta = asin(arg);
79 *lon = adjust_lon(lon_center + (x / (0.900316316158 * R * cos(theta))));
80 if(*lon < (-PI)) *lon= -PI;
81 if(*lon > PI) *lon= PI;
82 arg = (2.0 * theta + sin(2.0 * theta)) / PI;
83 if(fabs(arg) > 1.0)arg=1.0;
84 *lat = asin(arg);
85 return(OK);
86 }
int r
Definition: decode_rs.h:73
void gctp_print_title(const char *proj_name)
Definition: gctp_report.c:14
void gctp_print_cenlon(double A)
Definition: gctp_report.c:40
float * lat
double adjust_lon(double x)
Definition: proj_cproj.c:349
#define PI
Definition: l3_get_org.c:6
long molwinv(double x, double y, double *lon, double *lat)
Definition: molwinv.c:58
void gctp_print_offsetp(double A, double B)
Definition: gctp_report.c:91
#define OK
Definition: ancil.h:30
#define fabs(a)
Definition: misc.h:93
float * lon
void gctp_print_radius(double radius)
Definition: gctp_report.c:22
long molwinvint(double r, double center_long, double false_east, double false_north)
Definition: molwinv.c:32
#define R
Definition: make_L3_v1.1.c:96