OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
for_init.c
Go to the documentation of this file.
1 /*******************************************************************************
2 NAME FOR_INIT
3 
4 PURPOSE: Initializes forward projection transformation parameters
5 
6 ALGORITHM REFERENCES
7 
8 1. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
9  Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
10  State Government Printing Office, Washington D.C., 1987.
11 
12 2. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections",
13  U.S. Geological Survey Professional Paper 1453 , United State Government
14  Printing Office, Washington D.C., 1989.
15 *******************************************************************************/
16 #include "oli_cproj.h"
17 #include "gctp.h"
18 
19 void for_init
20 (
21  long outsys, /* output system code */
22  long outzone, /* output zone number */
23  const double *outparm, /* output array of projection parameters */
24  long outspheroid, /* output spheroid */
25  long *iflg, /* status flag */
26  long (*for_trans[])(double, double, double*, double*)
27  /* forward function pointer */
28 )
29 {
30 double angle; /* rotation anlge */
31 double lat1 = 0.0; /* 1st standard parallel */
32 double lat2 = 0.0; /* 2nd standard parallel */
33 double center_long; /* center longitude */
34 double center_lat; /* center latitude */
35 double h; /* height above sphere */
36 double lat_origin; /* latitude at origin */
37 double r_major; /* major axis in meters */
38 double r_minor; /* minor axis in meters */
39 double false_easting; /* false easting in meters */
40 double false_northing; /* false northing in meters */
41 double shape_m; /* constant used for Oblated Equal Area */
42 double shape_n; /* constant used for Oblated Equal Area */
43 double radius; /* radius of sphere */
44 long mode; /* which initialization method to use A or B */
45 double dzone; /* number of longitudinal zones in ISG */
46 double djustify; /* justify flag in ISG projection */
47 
48  /* Function declarations for function pointer use
49  -----------------------------------------------*/
50 long alberfor();
51 long merfor();
52 long eqconfor();
53 long sterfor();
54 long lamazfor();
55 long azimfor();
56 long gnomfor();
57 long orthfor();
58 long gvnspfor();
59 long sinfor();
60 long equifor();
61 long millfor();
62 long vandgfor();
63 long hamfor();
64 long robfor();
65 long goodfor();
66 long molwfor();
67 long imolwfor();
68 long alconfor();
69 long wivfor();
70 long wviifor();
71 long obleqfor();
72 long isinusfor();
73 
74 /* Initialize forward transformations
75 -----------------------------------*/
76  /* find the correct major and minor axis
77  --------------------------------------*/
78  sphdz(outspheroid,outparm,&r_major,&r_minor,&radius);
79  false_easting = outparm[6];
80  false_northing = outparm[7];
81 
82  if ((outsys == HOM)
83  || (outsys == LAMCC)
84  || (outsys == UTM)
85  || (outsys == TM)
86  || (outsys == POLYC)
87  || (outsys == PS)
88  || (outsys == SOM)
89  || (outsys == SPCS))
90  {
91  /* For projections no longer supported via the old interface, consider it
92  an error */
93  *iflg = ERROR;
94  return;
95  }
96  else
97  if (outsys == ALBERS)
98  {
99  /* this is the call to initialize ALBERS CONICAL EQUAL AREA
100  ----------------------------------------------------------*/
101  lat1 = paksz(outparm[2],iflg)* 3600 * S2R;
102  if (*iflg != 0)
103  return;
104  lat2 = paksz(outparm[3],iflg)* 3600 * S2R;
105  if (*iflg != 0)
106  return;
107  lat_origin = paksz(outparm[5],iflg)* 3600 * S2R;
108  if (*iflg != 0)
109  return;
110  center_long = paksz(outparm[4],iflg)* 3600 * S2R;
111  if (*iflg != 0)
112  return;
113  *iflg = alberforint(r_major,r_minor,lat1,lat2,center_long,lat_origin,
114  false_easting, false_northing);
115  for_trans[outsys] = alberfor;
116  }
117  else
118  if (outsys == MERCAT)
119  {
120  /* this is the call to initialize MERCATOR
121  ----------------------------------------*/
122  center_long = paksz(outparm[4],iflg)* 3600 * S2R;
123  if (*iflg != 0)
124  return;
125  lat1 = paksz(outparm[5],iflg)* 3600 * S2R;
126  if (*iflg != 0)
127  return;
128  *iflg = merforint(r_major,r_minor,center_long,lat1,false_easting,
129  false_northing);
130  for_trans[outsys] = merfor;
131  }
132  else
133  if (outsys == EQUIDC)
134  {
135  /* this is the call to initialize EQUIDISTANT CONIC
136  -------------------------------------------------*/
137  lat1 = paksz(outparm[2],iflg)* 3600 * S2R;
138  if (*iflg != 0)
139  return;
140  lat2 = paksz(outparm[3],iflg)* 3600 * S2R;
141  if (*iflg != 0)
142  return;
143  center_long = paksz(outparm[4],iflg)* 3600 * S2R;
144  if (*iflg != 0)
145  return;
146  lat_origin = paksz(outparm[5],iflg)* 3600 * S2R;
147  if (*iflg != 0)
148  return;
149  if (outparm[8] == 0)
150  mode = 0;
151  else
152  mode = 1;
153  *iflg = eqconforint(r_major,r_minor,lat1,lat2,center_long,lat_origin,
154  false_easting,false_northing,mode);
155  for_trans[outsys] = eqconfor;
156  }
157  else
158  if (outsys == STEREO)
159  {
160  /* this is the call to initialize STEREOGRAPHIC
161  ---------------------------------------------*/
162  center_long = paksz(outparm[4],iflg)* 3600 * S2R;
163  if (*iflg != 0)
164  return;
165  center_lat = paksz(outparm[5],iflg)* 3600 * S2R;
166  if (*iflg != 0)
167  return;
168  *iflg = sterforint(radius,center_long,center_lat,false_easting,
169  false_northing);
170  for_trans[outsys] = sterfor;
171  }
172  else
173  if (outsys == LAMAZ)
174  {
175  /* this is the call to initialize LAMBERT AZIMUTHAL
176  -------------------------------------------------*/
177  center_long = paksz(outparm[4],iflg)* 3600 * S2R;
178  if (*iflg != 0)
179  return;
180  center_lat = paksz(outparm[5],iflg)* 3600 * S2R;
181  if (*iflg != 0)
182  return;
183  *iflg = lamazforint(radius,center_long, center_lat,false_easting,
184  false_northing);
185  for_trans[outsys] = lamazfor;
186  }
187  else
188  if (outsys == AZMEQD)
189  {
190  /* this is the call to initialize AZIMUTHAL EQUIDISTANT
191  -----------------------------------------------------*/
192  center_long = paksz(outparm[4],iflg)* 3600 * S2R;
193  if (*iflg != 0)
194  return;
195  center_lat = paksz(outparm[5],iflg)* 3600 * S2R;
196  if (*iflg != 0)
197  return;
198  *iflg = azimforint(radius,center_long,center_lat,false_easting,
199  false_northing);
200  for_trans[outsys] = azimfor;
201  }
202  else
203  if (outsys == GNOMON)
204  {
205  /* this is the call to initialize GNOMONIC
206  ----------------------------------------*/
207  center_long = paksz(outparm[4],iflg)* 3600 * S2R;
208  if (*iflg != 0)
209  return;
210  center_lat = paksz(outparm[5],iflg)* 3600 * S2R;
211  if (*iflg != 0)
212  return;
213  *iflg = gnomforint(radius,center_long,center_lat,false_easting,
214  false_northing);
215  for_trans[outsys] = gnomfor;
216  }
217  else
218  if (outsys == ORTHO)
219  {
220  /* this is the call to initalize ORTHOGRAPHIC
221  -------------------------------------------*/
222  center_long = paksz(outparm[4],iflg)* 3600 * S2R;
223  if (*iflg != 0)
224  return;
225  center_lat = paksz(outparm[5],iflg)* 3600 * S2R;
226  if (*iflg != 0)
227  return;
228  *iflg = orthforint(radius,center_long,center_lat,false_easting,
229  false_northing);
230  for_trans[outsys] = orthfor;
231  }
232  else
233  if (outsys == GVNSP)
234  {
235  /* this is the call to initalize GENERAL VERTICAL NEAR-SIDE PERSPECTIVE
236  ----------------------------------------------------------------------*/
237  center_long = paksz(outparm[4],iflg)* 3600 * S2R;
238  if (*iflg != 0)
239  return;
240  center_lat = paksz(outparm[5],iflg)* 3600 * S2R;
241  if (*iflg != 0)
242  return;
243  h = outparm[2];
244  *iflg = gvnspforint(radius,h,center_long,center_lat,false_easting,
245  false_northing);
246  for_trans[outsys] = gvnspfor;
247  }
248  else
249  if (outsys == SNSOID)
250  {
251  /* this is the call to initialize SINUSOIDAL
252  -------------------------------------------*/
253  center_long = paksz(outparm[4],iflg)* 3600 * S2R;
254  if (*iflg != 0)
255  return;
256  *iflg = sinforint(radius, center_long,false_easting,false_northing);
257  for_trans[outsys] = sinfor;
258  }
259  else
260  if (outsys == EQRECT)
261  {
262  /* this is the call to initialize EQUIRECTANGULAR
263  -----------------------------------------------*/
264  center_long = paksz(outparm[4],iflg)* 3600 * S2R;
265  if (*iflg != 0)
266  return;
267  lat1 = paksz(outparm[5],iflg)* 3600 * S2R;
268  if (*iflg != 0)
269  return;
270  *iflg = equiforint(radius,center_long,lat1,false_easting,false_northing);
271  for_trans[outsys] = equifor;
272  }
273  else
274  if (outsys == MILLER)
275  {
276  /* this is the call to initialize MILLER CYLINDRICAL
277  --------------------------------------------------*/
278  center_long = paksz(outparm[4],iflg) * 3600 * S2R;
279  if (*iflg != 0)
280  return;
281  *iflg = millforint(radius, center_long,false_easting,false_northing);
282  for_trans[outsys] = millfor;
283  }
284  else
285  if (outsys == VGRINT)
286  {
287  /* this is the call to initialize VAN DER GRINTEN
288  -----------------------------------------------*/
289  center_long = paksz(outparm[4],iflg)* 3600 * S2R;
290  if (*iflg != 0)
291  return;
292  *iflg = vandgforint(radius, center_long,false_easting,false_northing);
293  for_trans[outsys] = vandgfor;
294  }
295  else
296  if (outsys == HAMMER)
297  {
298  /* this is the call to initialize HAMMER
299  --------------------------------------*/
300  center_long = paksz(outparm[4],iflg)* 3600 * S2R;
301  if (*iflg != 0)
302  return;
303  *iflg = hamforint(radius,center_long,false_easting,false_northing);
304  for_trans[outsys] = hamfor;
305  }
306  else
307  if (outsys == ROBIN)
308  {
309  /* this is the call to initialize ROBINSON
310  ----------------------------------------*/
311  center_long = paksz(outparm[4],iflg)* 3600 * S2R;
312  if (*iflg != 0)
313  return;
314  *iflg = robforint(radius,center_long,false_easting,false_northing);
315  for_trans[outsys] = robfor;
316  }
317  else
318  if (outsys == GOOD)
319  {
320  /* this is the call to initialize GOODE'S HOMOLOSINE
321  ---------------------------------------------------*/
322  *iflg = goodforint(radius);
323  for_trans[outsys] = goodfor;
324  }
325  else
326  if (outsys == MOLL)
327  {
328  /* this is the call to initialize MOLLWEIDE
329  ------------------------------------------*/
330  center_long = paksz(outparm[4],iflg)* 3600 * S2R;
331  if (*iflg != 0)
332  return;
333  *iflg = molwforint(radius, center_long,false_easting,false_northing);
334  for_trans[outsys] = molwfor;
335  }
336  else
337  if (outsys == IMOLL)
338  {
339  /* this is the call to initialize INTERRUPTED MOLLWEIDE
340  -----------------------------------------------------*/
341  *iflg = imolwforint(radius);
342  for_trans[outsys] = imolwfor;
343  }
344  else
345  if (outsys == ALASKA)
346  {
347  /* this is the call to initialize ALASKA CONFORMAL
348  ------------------------------------------------*/
349  *iflg = alconforint(r_major,r_minor,false_easting,false_northing);
350  for_trans[outsys] = alconfor;
351  }
352  else
353  if (outsys == WAGIV)
354  {
355  /* this is the call to initialize WAGNER IV
356  -----------------------------------------*/
357  center_long = paksz(outparm[4],iflg)* 3600 * S2R;
358  if (*iflg != 0)
359  return;
360  *iflg = wivforint(radius, center_long,false_easting,false_northing);
361  for_trans[outsys] = wivfor;
362  }
363  else
364  if (outsys == WAGVII)
365  {
366  /* this is the call to initialize WAGNER VII
367  ------------------------------------------*/
368  center_long = paksz(outparm[4],iflg)* 3600 * S2R;
369  if (*iflg != 0)
370  return;
371  *iflg = wviiforint(radius, center_long,false_easting,false_northing);
372  for_trans[outsys] = wviifor;
373  }
374  else
375  if (outsys == OBEQA)
376  {
377  /* this is the call to initialize OBLATED EQUAL AREA
378  ---------------------------------------------------*/
379  center_long = paksz(outparm[4],iflg)* 3600 * S2R;
380  if (*iflg != 0)
381  return;
382  center_lat = paksz(outparm[5],iflg)* 3600 * S2R;
383  if (*iflg != 0)
384  return;
385  shape_m = outparm[2];
386  shape_n = outparm[3];
387  angle = paksz(outparm[8],iflg)* 3600 * S2R;
388  if (*iflg != 0)
389  return;
390  *iflg = obleqforint(radius,center_long,center_lat,shape_m, shape_n,
391  angle,false_easting,false_northing);
392  for_trans[outsys] = obleqfor;
393  }
394 
395  else if ( outsys == ISIN )
396  {
397  /* this is the call to initialize INTEGERIZED SINUSOIDAL GRID
398  ------------------------------------------------------------ */
399  center_long = paksz( outparm[4], iflg ) * 3600 * S2R;
400  if ( *iflg != 0 )
401  return;
402 
403  dzone = outparm[8];
404  djustify = outparm[10];
405 
406  *iflg = isinusforinit( radius, center_long, false_easting, false_northing,
407  dzone, djustify );
408  for_trans[outsys] = isinusfor;
409  }
410 }
int hamfor(double lon, double lat, double *x, double *y)
Definition: proj_hamfor.c:60
int robfor(double lon, double lat, double *x, double *y)
Definition: proj_robfor.c:108
long alconfor(double lon, double lat, double *x, double *y)
Definition: alconfor.c:102
#define ALASKA
Definition: proj_define.h:59
#define STEREO
Definition: proj_define.h:46
#define EQRECT
Definition: proj_define.h:53
long millforint(double r, double center_long, double false_east, double false_north)
Definition: millfor.c:38
long vandgfor(double lon, double lat, double *x, double *y)
Definition: vandgfor.c:64
long merfor(double lon, double lat, double *x, double *y)
Definition: merfor.c:76
#define SNSOID
Definition: proj_define.h:52
long eqconfor(double lon, double lat, double *x, double *y)
Definition: eqconfor.c:129
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
long wviiforint(double r, double center_long, double false_east, double false_north)
Definition: wviifor.c:30
long lamazfor(double lon, double lat, double *x, double *y)
Definition: lamazfor.c:70
#define POLYC
Definition: proj_define.h:43
long goodfor(double lon, double lat, double *x, double *y)
Definition: goodfor.c:83
int molwforint(double r, double center_long, double false_east, double false_north)
Definition: proj_molwfor.c:37
#define VGRINT
Definition: proj_define.h:55
#define GNOMON
Definition: proj_define.h:49
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 SPCS
Definition: proj_define.h:38
long sterfor(double lon, double lat, double *x, double *y)
Definition: sterfor.c:67
float h[MODELMAX]
Definition: atrem_corl1.h:131
#define SOM
Definition: proj_define.h:58
long isinusforinit(double sphere, double lon_cen_mer, double false_east, double false_north, double dzone, double djustify)
Definition: isinfor.c:115
long azimforint(double r_maj, double center_lon, double center_lat, double false_east, double false_north)
Definition: azimfor.c:36
long alconforint(double r_maj, double r_min, double false_east, double false_north)
Definition: alconfor.c:46
long gnomforint(double r, double center_long, double center_lat, double false_east, double false_north)
Definition: gnomfor.c:40
long orthfor(double lon, double lat, double *x, double *y)
Definition: orthfor.c:67
long alberfor(double lon, double lat, double *x, double *y)
Definition: alberfor.c:107
long millfor(double lon, double lat, double *x, double *y)
Definition: millfor.c:64
long sinfor(double lon, double lat, double *x, double *y)
Definition: sinfor.c:61
long obleqforint(double r, double center_long, double center_lat, double shape_m, double shape_n, double angle, double false_east, double false_north)
Definition: obleqfor.c:36
long equiforint(double r_maj, double center_lon, double lat1, double false_east, double false_north)
Definition: equifor.c:33
#define UTM
Definition: proj_define.h:37
#define LAMCC
Definition: proj_define.h:40
long goodforint(double r)
Definition: goodfor.c:35
long sinforint(double r, double center_long, double false_east, double false_north)
Definition: sinfor.c:35
int robforint(double r, double center_long, double false_east, double false_north)
Definition: proj_robfor.c:43
#define EQUIDC
Definition: proj_define.h:44
#define MERCAT
Definition: proj_define.h:41
long obleqfor(double lon, double lat, double *x, double *y)
Definition: obleqfor.c:77
#define MILLER
Definition: proj_define.h:54
#define GVNSP
Definition: proj_define.h:51
long gnomfor(double lon, double lat, double *x, double *y)
Definition: gnomfor.c:69
#define IMOLL
Definition: proj_define.h:62
long gvnspforint(double r, double h, double center_long, double center_lat, double false_east, double false_north)
Definition: gvnspfor.c:43
#define ROBIN
Definition: proj_define.h:57
#define WAGVII
Definition: proj_define.h:65
#define OBEQA
Definition: proj_define.h:66
long equifor(double lon, double lat, double *x, double *y)
Definition: equifor.c:64
#define PS
Definition: proj_define.h:42
#define TM
Definition: proj_define.h:45
long sterforint(double r_maj, double center_lon, double center_lat, double false_east, double false_north)
Definition: sterfor.c:35
long wivfor(double lon, double lat, double *x, double *y)
Definition: wivfor.c:56
long wivforint(double r, double center_long, double false_east, double false_north)
Definition: wivfor.c:30
#define MOLL
Definition: proj_define.h:61
double paksz(double ang, long *iflg)
Definition: paksz.c:50
#define ISIN
Definition: gctp.h:72
long gvnspfor(double lon, double lat, double *x, double *y)
Definition: gvnspfor.c:76
#define GOOD
Definition: proj_define.h:60
long isinusfor(double lon, double lat, double *x, double *y)
Definition: isinfor.c:460
#define HOM
Definition: proj_define.h:56
long vandgforint(double r, double center_long, double false_east, double false_north)
Definition: vandgfor.c:38
#define S2R
Definition: proj_define.h:92
long azimfor(double lon, double lat, double *x, double *y)
Definition: azimfor.c:69
long merforint(double r_maj, double r_min, double center_lon, double center_lat, double false_east, double false_north)
Definition: merfor.c:37
long lamazforint(double r, double center_long, double center_lat, double false_east, double false_north)
Definition: lamazfor.c:41
void sphdz(long isph, const double *parm, double *r_major, double *r_minor, double *radius)
Definition: sphdz.c:141
@ HAMMER
Definition: make_L3_v1.1.c:41
#define AZMEQD
Definition: proj_define.h:48
int molwfor(double lon, double lat, double *x, double *y)
Definition: proj_molwfor.c:53
long imolwfor(double lon, double lat, double *x, double *y)
Definition: imolwfor.c:67
long orthforint(double r_maj, double center_lon, double center_lat, double false_east, double false_north)
Definition: orthfor.c:35
long imolwforint(double r)
Definition: imolwfor.c:31
void radius(double A)
Definition: proj_report.c:132
#define WAGIV
Definition: proj_define.h:64
#define LAMAZ
Definition: proj_define.h:47
#define ALBERS
Definition: proj_define.h:39
long wviifor(double lon, double lat, double *x, double *y)
Definition: wviifor.c:56
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
void for_init(long outsys, long outzone, const double *outparm, long outspheroid, long *iflg, long(*for_trans[])(double, double, double *, double *))
Definition: for_init.c:20
int hamforint(double r, double center_long, double false_east, double false_north)
Definition: proj_hamfor.c:41
#define ORTHO
Definition: proj_define.h:50
#define ERROR
Definition: ancil.h:24