OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
sininv.c
Go to the documentation of this file.
1 /*******************************************************************************
2 NAME SINUSOIDAL
3 
4 PURPOSE: Transforms input Easting and Northing to longitude and
5  latitude for the Sinusoidal projection. The
6  Easting and Northing must be in meters. The longitude
7  and latitude values will be returned in radians.
8 
9 This function was adapted from the Sinusoidal projection code (FORTRAN) in the
10 General Cartographic Transformation Package software which is available from
11 the U.S. Geological Survey National Mapping Division.
12 
13 ALGORITHM REFERENCES
14 
15 1. 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 2. "Software Documentation for GCTP General Cartographic Transformation
20  Package", U.S. Geological Survey National Mapping Division, May 1982.
21 *******************************************************************************/
22 #include "oli_cproj.h"
23 #include "oli_local.h"
24 
25 /* Variables common to all subroutines in this code file
26  -----------------------------------------------------*/
27 static double lon_center; /* Center longitude (projection center) */
28 static double R; /* Radius of the earth (sphere) */
29 static double false_easting; /* x offset in meters */
30 static double false_northing; /* y offset in meters */
31 
32 /* Initialize the Sinusoidal projection
33  ------------------------------------*/
34 long sininvint
35 (
36  double r, /* (I) Radius of the earth (sphere) */
37  double center_long, /* (I) Center longitude */
38  double false_east, /* x offset in meters */
39  double false_north /* y offset in meters */
40 )
41 {
42 /* Place parameters in static storage for common use
43  -------------------------------------------------*/
44 R = r;
45 lon_center = center_long;
46 false_easting = false_east;
47 false_northing = false_north;
48 
49 /* Report parameters to the user
50  -----------------------------*/
51 gctp_print_title("SINUSOIDAL");
53 gctp_print_cenlon(center_long);
55 return(OK);
56 }
57 
58 /* Sinusoidal inverse equations--mapping x,y to lat,long
59  -----------------------------------------------------*/
60 long sininv
61 (
62  double x, /* (I) X projection coordinate */
63  double y, /* (I) Y projection coordinate */
64  double *lon, /* (O) Longitude */
65  double *lat /* (O) Latitude */
66 )
67 {
68 double temp; /* Re-used temporary variable */
69 
70 /* Inverse equations
71  -----------------*/
72 x -= false_easting;
73 y -= false_northing;
74 *lat = y / R;
75 if (fabs(*lat) > HALF_PI)
76  {
77  GCTP_PRINT_ERROR("Input data error");
78  return(164);
79  }
80 temp = fabs(*lat) - HALF_PI;
81 if (fabs(temp) > EPSLN)
82  {
83  temp = lon_center + x / (R * cos(*lat));
84  *lon = adjust_lon(temp);
85  }
86 else *lon = lon_center;
87 return(OK);
88 }
89 
int r
Definition: decode_rs.h:73
void gctp_print_title(const char *proj_name)
Definition: gctp_report.c:14
double false_northing
Definition: polyconic.c:53
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
#define HALF_PI
Definition: proj_define.h:84
double false_easting
Definition: polyconic.c:54
void gctp_print_offsetp(double A, double B)
Definition: gctp_report.c:91
#define OK
Definition: ancil.h:30
long sininv(double x, double y, double *lon, double *lat)
Definition: sininv.c:61
#define fabs(a)
Definition: misc.h:93
float * lon
void gctp_print_radius(double radius)
Definition: gctp_report.c:22
#define R
Definition: make_L3_v1.1.c:96
long sininvint(double r, double center_long, double false_east, double false_north)
Definition: sininv.c:35
#define EPSLN
Definition: proj_define.h:86