OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
proj_hamfor.c
Go to the documentation of this file.
1 /*******************************************************************************
2 NAME HAMMER
3 
4 PURPOSE: Transforms input longitude and latitude to Easting and
5  Northing for the Hammer projection. The longitude
6  and latitude must be in radians. The Easting and
7  Northing values will be returned in meters.
8 
9 PROGRAMMER DATE
10 ---------- ----
11 T. Mittan March, 1993
12 
13 This function was adapted from the Lambert Azimuthal Equal Area projection
14 code (FORTRAN) in the General Cartographic Transformation Package software
15 which is 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 #include <stdint.h>
31 
32 /* Variables common to all subroutines in this code file
33  -----------------------------------------------------*/
34 static double lon_center; /* Center longitude (projection center) */
35 static double R; /* Radius of the earth (sphere) */
36 static double false_easting; /* x offset in meters */
37 static double false_northing; /* y offset in meters */
38 
39 /* Initialize the HAMMER projection
40  -------------------------------*/
41 int hamforint(r, center_long, false_east, false_north)
42 
43 double r; /* (I) Radius of the earth (sphere) */
44 double center_long; /* (I) Center longitude */
45 double false_east; /* x offset in meters */
46 double false_north; /* y offset in meters */
47 {
48 
49  /* Place parameters in static storage for common use
50  -------------------------------------------------*/
51  R = r;
52  lon_center = center_long;
53  false_easting = false_east;
54  false_northing = false_north;
55  return (OK);
56 }
57 
58 /* HAMMER forward equations--mapping lat,long to x,y
59  ------------------------------------------------------------*/
60 int hamfor(lon, lat, x, y)
61 double lon; /* (I) Longitude */
62 double lat; /* (I) Latitude */
63 double *x; /* (O) X projection coordinate */
64 double *y; /* (O) Y projection coordinate */
65 
66 {
67  double dlon;
68  double adjust_lon();
69  double fac;
70 
71  /* Forward equations
72  -----------------*/
73  dlon = adjust_lon(lon - lon_center);
74 
75  fac = R * 1.414213562 / sqrt(1.0 + cos(lat) * cos(dlon / 2.0));
76  *x = false_easting + fac * 2.0 * cos(lat) * sin(dlon / 2.0);
77  *y = false_northing + fac * sin(lat);
78 
79  return (OK);
80 }
int hamfor(double lon, double lat, double *x, double *y)
Definition: proj_hamfor.c:60
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
float * lon
#define R
Definition: make_L3_v1.1.c:96
int hamforint(double r, double center_long, double false_east, double false_north)
Definition: proj_hamfor.c:41