OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
inv_init.c
Go to the documentation of this file.
1 /*******************************************************************************
2 NAME INV_INIT
3 
4 PURPOSE: Initializes inverse 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 inv_init
20 (
21  long insys, /* input system code */
22  long inzone, /* input zone number */
23  const double *inparm, /* input array of projection parameters */
24  long inspheroid, /* input spheroid code */
25  long *iflg, /* status flag */
26  long (*inv_trans[])(double,double,double*,double*)
27  /* inverse 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 radius; /* radius of sphere */
42 double shape_m; /* constant used for Oblated Equal Area */
43 double shape_n; /* constant used for Oblated Equal Area */
44 long mode; /* which format is used 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 inverse function pointer
49  ---------------------------------------------------*/
50 long alberinv();
51 long merinv();
52 long eqconinv();
53 long sterinv();
54 long lamazinv();
55 long aziminv();
56 long gnominv();
57 long orthinv();
58 long gvnspinv();
59 long sininv();
60 long equiinv();
61 long millinv();
62 long vandginv();
63 long haminv();
64 long robinv();
65 long goodinv();
66 long molwinv();
67 long imolwinv();
68 long alconinv();
69 long wivinv();
70 long wviiinv();
71 long obleqinv();
72 long isinusinv();
73 
74 /* Initialize inverse transformations
75 -----------------------------------*/
76  /* find the correct major and minor axis
77  --------------------------------------*/
78  sphdz(inspheroid,inparm,&r_major,&r_minor,&radius);
79  false_easting = inparm[6];
80  false_northing = inparm[7];
81 
82  if ((insys == HOM)
83  || (insys == LAMCC)
84  || (insys == UTM)
85  || (insys == TM)
86  || (insys == POLYC)
87  || (insys == PS)
88  || (insys == SOM)
89  || (insys == 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 (insys == ALBERS)
98  {
99  /* this is the call to initialize ALBERS
100  ---------------------------------------*/
101  lat1 = paksz(inparm[2],iflg) * 3600 * S2R;
102  if (*iflg != 0)
103  return;
104  lat2 = paksz(inparm[3],iflg) * 3600 * S2R;
105  if (*iflg != 0)
106  return;
107  center_long = paksz(inparm[4],iflg) * 3600 * S2R;
108  if (*iflg != 0)
109  return;
110  lat_origin = paksz(inparm[5],iflg) * 3600 * S2R;
111  if (*iflg != 0)
112  return;
113  *iflg = alberinvint(r_major,r_minor,lat1,lat2,center_long,lat_origin,
114  false_easting, false_northing);
115  inv_trans[insys] = alberinv;
116  }
117  else
118  if (insys == MERCAT)
119  {
120  /* this is the call to initialize MERCATOR
121  ----------------------------------------*/
122  center_long = paksz(inparm[4],iflg) * 3600 * S2R;
123  if (*iflg != 0)
124  return;
125  lat1 = paksz(inparm[5],iflg) * 3600 * S2R;
126  if (*iflg != 0)
127  return;
128  *iflg = merinvint(r_major,r_minor,center_long,lat1,false_easting,
129  false_northing);
130  inv_trans[insys] = merinv;
131  }
132  else
133  if (insys == EQUIDC)
134  {
135  /* this is the call to initialize EQUIDISTANT CONIC
136  ---------------------------------------------------*/
137  lat1 = paksz(inparm[2],iflg) * 3600 * S2R;
138  if (*iflg != 0)
139  return;
140  lat2 = paksz(inparm[3],iflg) * 3600 * S2R;
141  if (*iflg != 0)
142  return;
143  center_long = paksz(inparm[4],iflg) * 3600 * S2R;
144  if (*iflg != 0)
145  return;
146  lat_origin = paksz(inparm[5],iflg) * 3600 * S2R;
147  if (*iflg != 0)
148  return;
149  if (inparm[8] == 0)
150  mode = 0;
151  else
152  mode = 1;
153  *iflg = eqconinvint(r_major,r_minor,lat1,lat2,center_long,lat_origin,
154  false_easting,false_northing,mode);
155  inv_trans[insys] = eqconinv;
156  }
157  else
158  if (insys == STEREO)
159  {
160  /* this is the call to initialize STEREOGRAPHIC
161  ---------------------------------------------*/
162  center_long = paksz(inparm[4],iflg) * 3600 * S2R;
163  if (*iflg != 0)
164  return;
165  center_lat = paksz(inparm[5],iflg) * 3600 * S2R;
166  if (*iflg != 0)
167  return;
168  *iflg = sterinvint(radius,center_long,center_lat,false_easting,
169  false_northing);
170  inv_trans[insys] = sterinv;
171  }
172  else
173  if (insys == LAMAZ)
174  {
175  /* this is the call to initialize LAMBERT AZIMUTHAL EQUAL-AREA
176  -------------------------------------------------------------*/
177  center_long = paksz(inparm[4],iflg) * 3600 * S2R;
178  if (*iflg != 0)
179  return;
180  center_lat = paksz(inparm[5],iflg) * 3600 * S2R;
181  if (*iflg != 0)
182  return;
183  *iflg = lamazinvint(radius, center_long, center_lat,false_easting,
184  false_northing);
185  inv_trans[insys] = lamazinv;
186  }
187  else
188  if (insys == AZMEQD)
189  {
190  /* this is the call to initialize AZIMUTHAL EQUIDISTANT
191  ------------------------------------------------------*/
192  center_long = paksz(inparm[4],iflg) * 3600 * S2R;
193  if (*iflg != 0)
194  return;
195  center_lat = paksz(inparm[5],iflg) * 3600 * S2R;
196  if (*iflg != 0)
197  return;
198  *iflg = aziminvint(radius,center_long,center_lat,false_easting,
199  false_northing);
200  inv_trans[insys] = aziminv;
201  }
202  else
203  if (insys == GNOMON)
204  {
205  /* this is the call to initialize GNOMONIC
206  ----------------------------------------*/
207  center_long = paksz(inparm[4],iflg) * 3600 * S2R;
208  if (*iflg != 0)
209  return;
210  center_lat = paksz(inparm[5],iflg) * 3600 * S2R;
211  if (*iflg != 0)
212  return;
213  *iflg = gnominvint(radius,center_long,center_lat,false_easting,
214  false_northing);
215  inv_trans[insys] = gnominv;
216  }
217  else
218  if (insys == ORTHO)
219  {
220  /* this is the call to initialize ORTHOGRAPHIC
221  --------------------------------------------*/
222  center_long = paksz(inparm[4],iflg) * 3600 * S2R;
223  if (*iflg != 0)
224  return;
225  center_lat = paksz(inparm[5],iflg) * 3600 * S2R;
226  if (*iflg != 0)
227  return;
228  *iflg = orthinvint(radius,center_long,center_lat,false_easting,
229  false_northing);
230  inv_trans[insys] = orthinv;
231  }
232  else
233  if (insys == GVNSP)
234  {
235  /* this is the call to initialize GENERAL VERTICAL NEAR SIDED PERSPECTIVE
236  -----------------------------------------------------------------------*/
237  center_long = paksz(inparm[4],iflg) * 3600 * S2R;
238  if (*iflg != 0)
239  return;
240  center_lat = paksz(inparm[5],iflg) * 3600 * S2R;
241  if (*iflg != 0)
242  return;
243  h = inparm[2];
244  *iflg = gvnspinvint(radius,h,center_long,center_lat,false_easting,
245  false_northing);
246  inv_trans[insys] = gvnspinv;
247  }
248  else
249  if (insys == SNSOID)
250  {
251  /* this is the call to initialize SINUSOIDAL
252  --------------------------------------------*/
253  center_long = paksz(inparm[4],iflg) * 3600 * S2R;
254  if (*iflg != 0)
255  return;
256  *iflg = sininvint(radius, center_long,false_easting,false_northing);
257  inv_trans[insys] = sininv;
258  }
259  else
260  if (insys == EQRECT)
261  {
262  /* this is the call to initialize EQUIRECTANGULAR
263  -----------------------------------------------*/
264  center_long = paksz(inparm[4],iflg) * 3600 * S2R;
265  if (*iflg != 0)
266  return;
267  lat1 = paksz(inparm[5],iflg) * 3600 * S2R;
268  if (*iflg != 0)
269  return;
270  *iflg = equiinvint(radius,center_long,lat1,false_easting,
271  false_northing);
272  inv_trans[insys] = equiinv;
273  }
274  else
275  if (insys == MILLER)
276  {
277  /* this is the call to initialize MILLER CYLINDRICAL
278  --------------------------------------------------*/
279  center_long = paksz(inparm[4],iflg) * 3600 * S2R;
280  if (*iflg != 0)
281  return;
282  *iflg = millinvint(radius, center_long,false_easting,false_northing);
283  inv_trans[insys] = millinv;
284  }
285  else
286  if (insys == VGRINT)
287  {
288  /* this is the call to initialize VAN DER GRINTEN
289  -----------------------------------------------*/
290  center_long = paksz(inparm[4],iflg) * 3600 * S2R;
291  if (*iflg != 0)
292  return;
293  *iflg = vandginvint(radius, center_long,false_easting,false_northing);
294  inv_trans[insys] = vandginv;
295  }
296  else
297  if (insys == HAMMER)
298  {
299  /* this is the call to initialize HAMMER
300  --------------------------------------*/
301  center_long = paksz(inparm[4],iflg) * 3600 * S2R;
302  if (*iflg != 0)
303  return;
304  *iflg = haminvint(radius, center_long,false_easting,false_northing);
305  inv_trans[insys] = haminv;
306  }
307  else
308  if (insys == ROBIN)
309  {
310  /* this is the call to initialize ROBINSON
311  ----------------------------------------*/
312  center_long = paksz(inparm[4],iflg) * 3600 * S2R;
313  if (*iflg != 0)
314  return;
315  *iflg = robinvint(radius, center_long,false_easting,false_northing);
316  inv_trans[insys] = robinv;
317  }
318  else
319  if (insys == GOOD)
320  {
321  /* this is the call to initialize GOODE'S HOMOLOSINE
322  ---------------------------------------------------*/
323  *iflg = goodinvint(radius);
324  inv_trans[insys] = goodinv;
325  }
326  else
327  if (insys == MOLL)
328  {
329  /* this is the call to initialize MOLLWEIDE
330  -------------------------------------------*/
331  center_long = paksz(inparm[4],iflg) * 3600 * S2R;
332  if (*iflg != 0)
333  return;
334  *iflg = molwinvint(radius, center_long,false_easting,false_northing);
335  inv_trans[insys] = molwinv;
336  }
337  else
338  if (insys == IMOLL)
339  {
340  /* this is the call to initialize INTERRUPTED MOLLWEIDE
341  -----------------------------------------------------*/
342  *iflg = imolwinvint(radius);
343  inv_trans[insys] = imolwinv;
344  }
345  else
346  if (insys == ALASKA)
347  {
348  /* this is the call to initialize ALASKA CONFORMAL
349  ------------------------------------------------*/
350  *iflg = alconinvint(r_major,r_minor,false_easting,false_northing);
351  inv_trans[insys] = alconinv;
352  }
353  else
354  if (insys == WAGIV)
355  {
356  /* this is the call to initialize WAGNER IV
357  -----------------------------------------*/
358  center_long = paksz(inparm[4],iflg) * 3600 * S2R;
359  if (*iflg != 0)
360  return;
361  *iflg = wivinvint(radius, center_long,false_easting,false_northing);
362  inv_trans[insys] = wivinv;
363  }
364  else
365  if (insys == WAGVII)
366  {
367  /* this is the call to initialize WAGNER VII
368  ------------------------------------------*/
369  center_long = paksz(inparm[4],iflg) * 3600 * S2R;
370  if (*iflg != 0)
371  return;
372  *iflg = wviiinvint(radius, center_long,false_easting,false_northing);
373  inv_trans[insys] = wviiinv;
374  }
375  else
376  if (insys == OBEQA)
377  {
378  /* this is the call to initialize OBLATED EQUAL AREA
379  ---------------------------------------------------*/
380  center_long = paksz(inparm[4],iflg) * 3600 * S2R;
381  if (*iflg != 0)
382  return;
383  center_lat = paksz(inparm[5],iflg) * 3600 * S2R;
384  if (*iflg != 0)
385  return;
386  shape_m = inparm[2];
387  shape_n = inparm[3];
388  angle = paksz(inparm[8],iflg) * 3600 * S2R;
389  if (*iflg != 0)
390  return;
391  *iflg = obleqinvint(radius,center_long,center_lat,shape_m, shape_n,
392  angle,false_easting,false_northing);
393  inv_trans[insys] = obleqinv;
394  }
395  else if (insys == ISIN)
396  {
397  /* this is the call to initialize INTEGERIZED SINUSOIDAL GRID
398  ------------------------------------------------------------ */
399  center_long = paksz( inparm[4], iflg ) * 3600 * S2R;
400  if ( *iflg != 0 )
401  return;
402  dzone = inparm[8];
403  djustify = inparm[10];
404 
405  *iflg = isinusinvinit( radius, center_long, false_easting, false_northing,
406  dzone, djustify );
407  inv_trans[insys] = isinusinv;
408  }
409 }
#define ALASKA
Definition: proj_define.h:59
#define STEREO
Definition: proj_define.h:46
long isinusinv(double, double, double *, double *)
Definition: isininv.c:472
long merinvint(double r_maj, double r_min, double center_lon, double center_lat, double false_east, double false_north)
Definition: merinv.c:37
int robinv(double x, double y, double *lon, double *lat)
Definition: proj_robinv.c:111
#define EQRECT
Definition: proj_define.h:53
long orthinvint(double r_maj, double center_lon, double center_lat, double false_east, double false_north)
Definition: orthinv.c:35
long equiinv(double x, double y, double *lon, double *lat)
Definition: equiinv.c:64
#define SNSOID
Definition: proj_define.h:52
long equiinvint(double r_maj, double center_lon, double lat1, double false_east, double false_north)
Definition: equiinv.c:33
long alconinvint(double r_maj, double r_min, double false_east, double false_north)
Definition: alconinv.c:46
long aziminv(double x, double y, double *lon, double *lat)
Definition: aziminv.c:68
#define POLYC
Definition: proj_define.h:43
long alberinv(double x, double y, double *lon, double *lat)
Definition: alberinv.c:110
long gnominv(double x, double y, double *lon, double *lat)
Definition: gnominv.c:71
int robinvint(double r, double center_long, double false_east, double false_north)
Definition: proj_robinv.c:46
long sterinvint(double r_maj, double center_lon, double center_lat, double false_east, double false_north)
Definition: sterinv.c:35
#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 gvnspinvint(double r, double h, double center_long, double center_lat, double false_east, double false_north)
Definition: gvnspinv.c:42
long obleqinvint(double r, double center_long, double center_lat, double shape_m, double shape_n, double angle, double false_east, double false_north)
Definition: obleqinv.c:36
float h[MODELMAX]
Definition: atrem_corl1.h:131
#define SOM
Definition: proj_define.h:58
long wivinvint(double r, double center_long, double false_east, double false_north)
Definition: wivinv.c:30
long goodinv(double x, double y, double *lon, double *lat)
Definition: goodinv.c:83
long wivinv(double x, double y, double *lon, double *lat)
Definition: wivinv.c:56
long eqconinv(double x, double y, double *lon, double *lat)
Definition: eqconinv.c:129
long vandginvint(double r, double center_long, double false_east, double false_north)
Definition: vandginv.c:38
long wviiinv(double x, double y, double *lon, double *lat)
Definition: wviiinv.c:56
#define UTM
Definition: proj_define.h:37
long wviiinvint(double r, double center_long, double false_east, double false_north)
Definition: wviiinv.c:30
#define LAMCC
Definition: proj_define.h:40
long millinv(double x, double y, double *lon, double *lat)
Definition: millinv.c:64
#define EQUIDC
Definition: proj_define.h:44
#define MERCAT
Definition: proj_define.h:41
#define MILLER
Definition: proj_define.h:54
#define GVNSP
Definition: proj_define.h:51
#define IMOLL
Definition: proj_define.h:62
long sininvint(double r, double center_long, double false_east, double false_north)
Definition: sininv.c:35
long obleqinv(double x, double y, double *lon, double *lat)
Definition: obleqinv.c:77
long alconinv(double x, double y, double *lon, double *lat)
Definition: alconinv.c:101
void inv_init(long insys, long inzone, const double *inparm, long inspheroid, long *iflg, long(*inv_trans[])(double, double, double *, double *))
Definition: inv_init.c:20
long vandginv(double x, double y, double *lon, double *lat)
Definition: vandginv.c:64
long orthinv(double x, double y, double *lon, double *lat)
Definition: orthinv.c:68
#define ROBIN
Definition: proj_define.h:57
#define WAGVII
Definition: proj_define.h:65
long gnominvint(double r, double center_long, double center_lat, double false_east, double false_north)
Definition: gnominv.c:41
long imolwinv(double x, double y, double *lon, double *lat)
Definition: imolwinv.c:65
#define OBEQA
Definition: proj_define.h:66
#define PS
Definition: proj_define.h:42
#define TM
Definition: proj_define.h:45
long aziminvint(double r_maj, double center_lon, double center_lat, double false_east, double false_north)
Definition: aziminv.c:35
int haminv(double x, double y, double *lon, double *lat)
Definition: proj_haminv.c:59
long merinv(double x, double y, double *lon, double *lat)
Definition: merinv.c:76
long lamazinv(double x, double y, double *lon, double *lat)
Definition: lamazinv.c:71
#define MOLL
Definition: proj_define.h:61
double paksz(double ang, long *iflg)
Definition: paksz.c:50
#define ISIN
Definition: gctp.h:72
int molwinvint(double r, double center_long, double false_east, double false_north)
Definition: proj_molwinv.c:35
#define GOOD
Definition: proj_define.h:60
#define HOM
Definition: proj_define.h:56
#define S2R
Definition: proj_define.h:92
void sphdz(long isph, const double *parm, double *r_major, double *r_minor, double *radius)
Definition: sphdz.c:141
long goodinvint(double r)
Definition: goodinv.c:35
@ HAMMER
Definition: make_L3_v1.1.c:41
#define AZMEQD
Definition: proj_define.h:48
long sterinv(double x, double y, double *lon, double *lat)
Definition: sterinv.c:67
long millinvint(double r, double center_long, double false_east, double false_north)
Definition: millinv.c:38
long gvnspinv(double x, double y, double *lon, double *lat)
Definition: gvnspinv.c:76
long eqconinvint(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: eqconinv.c:40
long alberinvint(double r_maj, double r_min, double lat1, double lat2, double lon0, double lat0, double false_east, double false_north)
Definition: alberinv.c:38
long sininv(double x, double y, double *lon, double *lat)
Definition: sininv.c:61
void radius(double A)
Definition: proj_report.c:132
int molwinv(double x, double y, double *lon, double *lat)
Definition: proj_molwinv.c:52
long lamazinvint(double r, double center_long, double center_lat, double false_east, double false_north)
Definition: lamazinv.c:41
#define WAGIV
Definition: proj_define.h:64
#define LAMAZ
Definition: proj_define.h:47
#define ALBERS
Definition: proj_define.h:39
long imolwinvint(double r)
Definition: imolwinv.c:31
int haminvint(double r, double center_long, double false_east, double false_north)
Definition: proj_haminv.c:40
long isinusinvinit(double sphere, double lon_cen_mer, double false_east, double false_north, double dzone, double djustify)
Definition: isininv.c:128
#define ORTHO
Definition: proj_define.h:50
#define ERROR
Definition: ancil.h:24