OB.DAAC Logo
NASA Logo
Ocean Color Science Software

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