OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
haminv.c
Go to the documentation of this file.
1 /*******************************************************************************
2 NAME HAMMER
3 
4 PURPOSE: Transforms input Easting and Northing to longitude and
5  latitude for the Hammer 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 Hammer projection code (FORTRAN) in
10 the General Cartographic Transformation Package software which is
11 available from the U.S. Geological Survey National Mapping Division.
12 
13 ALGORITHM REFERENCES
14 
15 1. "New Equal-Area Map Projections for Noncircular Regions", John P. Snyder,
16  The American Cartographer, Vol 15, No. 4, October 1988, pp. 341-355.
17 
18 2. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
19  Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
20  State Government Printing Office, Washington D.C., 1987.
21 
22 3. "Software Documentation for GCTP General Cartographic Transformation
23  Package", U.S. Geological Survey National Mapping Division, May 1982.
24 *******************************************************************************/
25 #include "oli_cproj.h"
26 #include "oli_local.h"
27 
28 /* Variables common to all subroutines in this code file
29  -----------------------------------------------------*/
30 static double lon_center; /* Center longitude (projection center) */
31 static double R; /* Radius of the earth (sphere) */
32 static double false_easting; /* x offset in meters */
33 static double false_northing; /* y offset in meters */
34 
35 /* Initialize the HAMMER projection
36  -------------------------------*/
37 long haminvint
38 (
39  double r, /* (I) Radius of the earth (sphere) */
40  double center_long, /* (I) Center longitude */
41  double false_east, /* x offset in meters */
42  double false_north /* y offset in meters */
43 )
44 {
45 /* Place parameters in static storage for common use
46  -------------------------------------------------*/
47 R = r;
48 lon_center = center_long;
49 false_easting = false_east;
50 false_northing = false_north;
51 
52 /* Report parameters to the user
53  -----------------------------*/
54 gctp_print_title("HAMMER");
56 gctp_print_cenlon(center_long);
57 gctp_print_offsetp(false_easting,false_northing);
58 return(OK);
59 }
60 
61 /* HAMMER inverse equations--mapping x,y to lat/long
62  ------------------------------------------------*/
63 long haminv
64 (
65  double x, /* (O) X projection coordinate */
66  double y, /* (O) Y projection coordinate */
67  double *lon, /* (I) Longitude */
68  double *lat /* (I) Latitude */
69 )
70 
71 {
72 double fac;
73 
74 /* Inverse equations
75  -----------------*/
76 x -= false_easting;
77 y -= false_northing;
78 fac = sqrt(4.0 * R * R - (x * x)/ 4.0 - y * y) / 2.0;
79 *lon = adjust_lon(lon_center + 2.0 *
80  atan2((x * fac), (2.0 * R * R - x * x/4 - y * y)));
81 *lat = asinz(y * fac / R / R);
82 return(OK);
83 }
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
long haminvint(double r, double center_long, double false_east, double false_north)
Definition: haminv.c:38
double adjust_lon(double x)
Definition: proj_cproj.c:349
#define fac
void gctp_print_offsetp(double A, double B)
Definition: gctp_report.c:91
#define OK
Definition: ancil.h:30
long haminv(double x, double y, double *lon, double *lat)
Definition: haminv.c:64
float * lon
void gctp_print_radius(double radius)
Definition: gctp_report.c:22
#define R
Definition: make_L3_v1.1.c:96
double asinz(double con)
Definition: proj_cproj.c:67