OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
eqconfor.c
Go to the documentation of this file.
1 /*******************************************************************************
2 NAME EQUIDISTANT CONIC
3 
4 PURPOSE: Transforms input longitude and latitude to Easting and Northing
5  for the Equidistant Conic projection. The longitude and
6  latitude must be in radians. The Easting and Northing values
7  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 lon_center; /* Center longitude (projection center) */
27 static double e0,e1,e2,e3; /* eccentricity constants */
28 static double e,es; /* eccentricity constants */
29 static double ml0; /* small value m */
30 static double false_northing; /* y offset in meters */
31 static double false_easting; /* x offset in meters */
32 static double ns;
33 static double g;
34 static double rh;
35 
36 
37 /* Initialize the Equidistant Conic projection
38  ------------------------------------------*/
39 long eqconforint
40 (
41  double r_maj, /* major axis */
42  double r_min, /* minor axis */
43  double lat1, /* latitude of standard parallel*/
44  double lat2, /* latitude of standard parallel*/
45  double center_lon, /* center longitude */
46  double center_lat, /* center latitude */
47  double false_east, /* x offset in meters */
48  double false_north, /* y offset in meters */
49  long mode /* which format is present A B */
50 )
51 {
52 double temp; /* temporary variable */
53 double sinphi,cosphi; /* sin and cos values */
54 double ms1,ms2;
55 double ml1,ml2;
56 
57 /* Place parameters in static storage for common use
58  -------------------------------------------------*/
59 r_major = r_maj;
60 r_minor = r_min;
61 lon_center = center_lon;
62 false_northing = false_north;
63 false_easting = false_east;
64 
65 temp = r_minor / r_major;
66 es = 1.0 - SQUARE(temp);
67 e = sqrt(es);
68 e0 = gctp_calc_e0(es);
69 e1 = gctp_calc_e1(es);
70 e2 = gctp_calc_e2(es);
71 e3 = gctp_calc_e3(es);
72 
73 sincos(lat1,&sinphi,&cosphi);
74 ms1 = gctp_calc_small_radius(e,sinphi,cosphi);
75 ml1 = gctp_calc_dist_from_equator(e0, e1, e2, e3, lat1);
76 
77 /* format B
78 ---------*/
79 if (mode != 0)
80  {
81  if (fabs(lat1 + lat2) < EPSLN)
82  {
83  GCTP_PRINT_ERROR("Standard Parallels on opposite sides of equator");
84  return(81);
85  }
86  sincos(lat2,&sinphi,&cosphi);
87  ms2 = gctp_calc_small_radius(e,sinphi,cosphi);
88  ml2 = gctp_calc_dist_from_equator(e0, e1, e2, e3, lat2);
89  if (fabs(lat1 - lat2) >= EPSLN)
90  ns = (ms1 - ms2) / (ml2 - ml1);
91  else
92  ns = sinphi;
93  }
94 else
95  ns = sinphi;
96 g = ml1 + ms1/ns;
97 ml0 = gctp_calc_dist_from_equator(e0, e1, e2, e3, center_lat);
98 rh = r_major * (g - ml0);
99 
100 
101 /* Report parameters to the user
102  -----------------------------*/
103 if (mode != 0)
104  {
105  gctp_print_title("EQUIDISTANT CONIC");
106  gctp_print_radius2(r_major, r_minor);
107  gctp_print_stanparl(lat1,lat2);
108  gctp_print_cenlonmer(lon_center);
109  gctp_print_origin(center_lat);
110  gctp_print_offsetp(false_easting,false_northing);
111  }
112 else
113  {
114  gctp_print_title("EQUIDISTANT CONIC");
115  gctp_print_radius2(r_major, r_minor);
116  gctp_print_stparl1(lat1);
117  gctp_print_cenlonmer(lon_center);
118  gctp_print_origin(center_lat);
119  gctp_print_offsetp(false_easting,false_northing);
120  }
121 
122 return(OK);
123 }
124 
125 
126 /* Equidistant Conic forward equations--mapping lat,long to x,y
127  -----------------------------------------------------------*/
128 long eqconfor
129 (
130  double lon, /* (I) Longitude */
131  double lat, /* (I) Latitude */
132  double *x, /* (O) X projection coordinate */
133  double *y /* (O) Y projection coordinate */
134 )
135 {
136 double ml;
137 double theta;
138 double rh1;
139 
140 /* Forward equations
141  -----------------*/
142 ml = gctp_calc_dist_from_equator(e0, e1, e2, e3, lat);
143 rh1 = r_major * (g - ml);
144 theta = ns * adjust_lon(lon - lon_center);
145 *x = false_easting + rh1 * sin(theta);
146 *y = false_northing + rh - rh1 * cos(theta);
147 
148 return(OK);
149 }
#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
double gctp_calc_e2(double x)
Definition: gctp_utility.c:139
long eqconfor(double lon, double lat, double *x, double *y)
Definition: eqconfor.c:129
README for MOD_PR02AQUA(AQUA) Version to set to For disabling creating and output data sets when in night mode
Definition: README.txt:96
#define GCTP_PRINT_ERROR(format,...)
Definition: oli_local.h:81
float * lat
void gctp_print_stparl1(double A)
Definition: gctp_report.c:83
double adjust_lon(double x)
Definition: proj_cproj.c:349
void gctp_print_stanparl(double A, double B)
Definition: gctp_report.c:73
double gctp_calc_e0(double x)
Definition: gctp_utility.c:125
void gctp_print_offsetp(double A, double B)
Definition: gctp_report.c:91
#define OK
Definition: ancil.h:30
double gctp_calc_e3(double x)
Definition: gctp_utility.c:146
double gctp_calc_e1(double x)
Definition: gctp_utility.c:132
#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
long eqconforint(double r_maj, double r_min, double lat1, double lat2, double center_lon, double center_lat, double false_east, double false_north, long mode)
Definition: eqconfor.c:40
double gctp_calc_dist_from_equator(double e0, double e1, double e2, double e3, double phi)
Definition: gctp_utility.c:187
#define EPSLN
Definition: proj_define.h:86