OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
alberfor.c
Go to the documentation of this file.
1 /*******************************************************************************
2 NAME ALBERS CONICAL EQUAL AREA
3 
4 PURPOSE: Transforms input longitude and latitude to Easting and Northing
5  for the Albers Conical Equal Area projection. The longitude
6  and latitude must be in radians. The Easting and Northing
7  values will be returned in meters.
8 
9 ALGORITHM REFERENCES
10 
11 1. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
12  Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
13  State Government Printing Office, Washington D.C., 1987.
14 
15 2. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections",
16  U.S. Geological Survey Professional Paper 1453 , United State Government
17  Printing Office, Washington D.C., 1989.
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 r_major; /* major axis */
25  static double r_minor; /* minor axis */
26  static double c; /* constant c */
27  static double e3; /* eccentricity */
28  static double rh; /* heigth above elipsoid */
29  static double ns0; /* ratio between meridians */
30  static double lon_center; /* center longitude */
31  static double false_easting; /* x offset in meters */
32  static double false_northing; /* y offset in meters */
33 
34 /* Initialize the Albers projection
35  -------------------------------*/
37 double r_maj, /* major axis */
38 double r_min, /* minor axis */
39 double lat1, /* first standard parallel */
40 double lat2, /* second standard parallel */
41 double lon0, /* center longitude */
42 double lat0, /* center lattitude */
43 double false_east, /* x offset in meters */
44 double false_north) /* y offset in meters */
45 {
46 double sin_po,cos_po; /* sin and cos values */
47 double con; /* temporary variable */
48 double es,temp; /* eccentricity squared and temp var */
49 double ms1; /* small m 1 */
50 double ms2; /* small m 2 */
51 double qs0; /* small q 0 */
52 double qs1; /* small q 1 */
53 double qs2; /* small q 2 */
54 
55 false_easting = false_east;
56 false_northing = false_north;
57 lon_center = lon0;
58 if (fabs(lat1 + lat2) < EPSLN)
59  {
61  "Equal latitudes for St. Parallels on opposite sides of equator");
62  return(31);
63  }
64 r_major = r_maj;
65 r_minor = r_min;
66 temp = r_minor / r_major;
67 es = 1.0 - SQUARE(temp);
68 e3 = sqrt(es);
69 
70 sincos(lat1, &sin_po, &cos_po);
71 con = sin_po;
72 
73 ms1 = gctp_calc_small_radius(e3,sin_po,cos_po);
74 qs1 = qsfnz(e3,sin_po);
75 
76 sincos(lat2,&sin_po,&cos_po);
77 
78 ms2 = gctp_calc_small_radius(e3,sin_po,cos_po);
79 qs2 = qsfnz(e3,sin_po);
80 
81 sincos(lat0,&sin_po,&cos_po);
82 
83 qs0 = qsfnz(e3,sin_po);
84 
85 if (fabs(lat1 - lat2) > EPSLN)
86  ns0 = (ms1 * ms1 - ms2 *ms2)/ (qs2 - qs1);
87 else
88  ns0 = con;
89 c = ms1 * ms1 + ns0 * qs1;
90 rh = r_major * sqrt(c - ns0 * qs0)/ns0;
91 
92 /* Report parameters to the user
93  -----------------------------*/
94 gctp_print_title("ALBERS CONICAL EQUAL-AREA");
95 gctp_print_radius2(r_major, r_minor);
96 gctp_print_stanparl(lat1,lat2);
97 gctp_print_cenlonmer(lon_center);
98 gctp_print_origin(lat0);
99 gctp_print_offsetp(false_easting,false_northing);
100 
101 return(OK);
102 }
103 
104 /* Albers Conical Equal Area forward equations--mapping lat,long to x,y
105  -------------------------------------------------------------------*/
106 long alberfor
107 (
108  double lon, /* (I) Longitude */
109  double lat, /* (I) Latitude */
110  double *x, /* (O) X projection coordinate */
111  double *y /* (O) Y projection coordinate */
112 )
113 {
114 double sin_phi,cos_phi; /* sine and cos values */
115 double qs; /* small q */
116 double theta; /* angle */
117 double rh1; /* height above ellipsoid */
118 
119 sincos(lat,&sin_phi,&cos_phi);
120 qs = qsfnz(e3,sin_phi);
121 rh1 = r_major * sqrt(c - ns0 * qs)/ns0;
122 theta = ns0 * adjust_lon(lon - lon_center);
123 *x = rh1 * sin(theta) + false_easting;
124 *y = rh - rh1 * cos(theta) + false_northing;
125 
126 return(OK);
127 }
#define SQUARE(x)
Definition: proj_define.h:99
void gctp_print_origin(double A)
Definition: gctp_report.c:65
void gctp_print_title(const char *proj_name)
Definition: gctp_report.c:14
long alberforint(double r_maj, double r_min, double lat1, double lat2, double lon0, double lat0, double false_east, double false_north)
Definition: alberfor.c:36
#define GCTP_PRINT_ERROR(format,...)
Definition: oli_local.h:81
float * lat
long alberfor(double lon, double lat, double *x, double *y)
Definition: alberfor.c:107
double adjust_lon(double x)
Definition: proj_cproj.c:349
double qsfnz(double eccent, double sinphi, double cosphi)
Definition: proj_cproj.c:97
void gctp_print_stanparl(double A, double B)
Definition: gctp_report.c:73
void gctp_print_offsetp(double A, double B)
Definition: gctp_report.c:91
#define OK
Definition: ancil.h:30
#define sincos
Definition: proj_define.h:108
void gctp_print_radius2(double radius1, double radius2)
Definition: gctp_report.c:30
void gctp_print_cenlonmer(double A)
Definition: gctp_report.c:48
double gctp_calc_small_radius(double eccent, double sinphi, double cosphi)
Definition: gctp_utility.c:253
#define fabs(a)
Definition: misc.h:93
float * lon
no change in intended resolving MODur00064 Corrected handling of bad ephemeris attitude resolving resolving GSFcd00179 Corrected handling of fill values for[Sensor|Solar][Zenith|Azimuth] resolving MODxl01751 Changed to validate LUT version against a value retrieved from the resolving MODxl02056 Changed to calculate Solar Diffuser angles without adjustment for estimated post launch changes in the MODIS orientation relative to incidentally resolving defects MODxl01766 Also resolves MODxl01947 Changed to ignore fill values in SCI_ABNORM and SCI_STATE rather than treating them as resolving MODxl01780 Changed to use spacecraft ancillary data to recognise when the mirror encoder data is being set by side A or side B and to change calculations accordingly This removes the need for seperate LUTs for Side A and Side B data it makes the new LUTs incompatible with older versions of the and vice versa Also resolves MODxl01685 A more robust GRing algorithm is being which will create a non default GRing anytime there s even a single geolocated pixel in a granule Removed obsolete messages from seed as required for compatibility with version of the SDP toolkit Corrected test output file names to end in per delivery and then split off a new MYD_PR03 pcf file for Aqua Added AssociatedPlatformInstrumentSensor to the inventory metadata in MOD01 mcf and MOD03 mcf Created new versions named MYD01 mcf and MYD03 where AssociatedPlatformShortName is rather than Terra The program itself has been changed to read the Satellite Instrument validate it against the input L1A and LUT and to use it determine the correct files to retrieve the ephemeris and attitude data from Changed to produce a LocalGranuleID starting with MYD03 if run on Aqua data Added the Scan Type file attribute to the Geolocation copied from the L1A and attitude_angels to radians rather than degrees The accumulation of Cumulated gflags was moved from GEO_validate_earth_location c to GEO_locate_one_scan c
Definition: HISTORY.txt:464
#define EPSLN
Definition: proj_define.h:86