File: inv_init.c

package info (click to toggle)
libgctp 2.0.0-13
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 39,776 kB
  • sloc: ansic: 7,922; sh: 4,387; makefile: 88; fortran: 29
file content (582 lines) | stat: -rw-r--r-- 19,022 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
/*******************************************************************************
NAME                           INV_INIT 

PURPOSE:	Initializes inverse projection transformation parameters

PROGRAMMER              DATE		REASON
----------              ----		------
T. Mittan		3-09-93		Initial Development
S. Nelson		11-94		Added Clarke spheroid default to UTM
S. Nelson		 1-98		Changed datum to spheroid.

ALGORITHM REFERENCES

1.  Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
    Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
    State Government Printing Office, Washington D.C., 1987.

2.  Snyder, John P. and Voxland, Philip M., "An Album of Map Projections",
    U.S. Geological Survey Professional Paper 1453 , United State Government
    Printing Office, Washington D.C., 1989.
*******************************************************************************/
#include "cproj.h"

void inv_init(insys,inzone,inparm,inspheroid,fn27,fn83,iflg,inv_trans)

long insys;		/* input system code				*/
long inzone;		/* input zone number				*/
double *inparm;		/* input array of projection parameters		*/
long inspheroid;	/* input spheroid code				*/
char *fn27;		/* NAD 1927 parameter file			*/
char *fn83;		/* NAD 1983 parameter file			*/
long *iflg;		/* status flag					*/
long (*inv_trans[])(double, double, double *, double *);	/* inverse function pointer			*/
{
long zone;		/* zone number					*/
double azimuth;		/* azimuth					*/
double angle;		/* rotation anlge				*/
double alf;		/* SOM angle					*/
double lon;		/* longitude					*/
double lon1;		/* longitude point in utm scene			*/
double lon2;		/* 2nd longitude point 				*/
double lat;		/* latitude					*/
double lat1;		/* 1st standard parallel			*/
double lat2;		/* 2nd standard parallel			*/
double center_long;	/* center longitude				*/
double center_lat;	/* center latitude				*/
double h;		/* height above sphere				*/
double lat_origin;	/* latitude at origin				*/
double lon_origin;	/* longitude at origin				*/
double r_major;		/* major axis in meters				*/
double r_minor;		/* minor axis in meters				*/
double scale_factor;	/* scale factor					*/
double false_easting;	/* false easting in meters			*/
double false_northing;	/* false northing in meters			*/
double radius;		/* radius of sphere				*/
double shape_m;		/* constant used for Oblated Equal Area		*/
double shape_n;		/* constant used for Oblated Equal Area		*/
long   start;		/* start of SOM Beginning or end		*/
double time;		/* SOM time					*/
long path;		/* SOM path number				*/
long satnum;		/* SOM satellite number				*/
long mode;		/* which format is used	A or B			*/
long tmpspheroid;	/* temporary spheroid for UTM			*/

	/* Function declarations for inverse function pointer
	---------------------------------------------------*/
 long utminv(double, double, double *, double *);
 long stplninv(double, double , double *, double *);
long alberinv(double x, double y, double *lon, double *lat);
long lamccinv(double x, double y, double *lon, double *lat);
long merinv(double, double, double *, double *);
long psinv(double, double, double *, double *);
long polyinv(double, double, double *, double *);
long eqconinv(double, double, double *, double *);
long tminv(double, double, double *, double *);
long sterinv(double, double, double *, double *);
long lamazinv(double, double, double *, double *);
long aziminv(double, double, double *, double *);
long gnominv(double, double, double *, double *);
long orthinv(double, double, double *, double *);
long gvnspinv(double, double, double *, double *);
long sininv(double, double, double *, double *);
long equiinv(double, double, double *, double *);
long millinv(double, double, double *, double *);
long vandginv(double, double, double *, double *);
long omerinv(double, double, double *, double *);
long sominv(double, double, double *, double *);
long haminv(double, double, double *, double *);
long robinv(double, double, double *, double *);
long goodinv(double, double, double *, double *);
long molwinv(double, double, double *, double *);
long imolwinv(double, double, double *, double *);
long alconinv(double, double, double *, double *);
long wivinv(double, double, double *, double *);
long wviiinv(double, double, double *, double *);
long obleqinv(double, double, double *, double *);

/* Initialize inverse transformations
-----------------------------------*/
  /* find the correct major and minor axis
  --------------------------------------*/
  sphdz(inspheroid,inparm,&r_major,&r_minor,&radius);
  false_easting  = inparm[6];
  false_northing = inparm[7];

  if (insys == UTM)
     {
     /* this is the call to initialize U T M
     -------------------------------------*/
     /* set Clarke 1866 spheroid if negative spheroid code
        ----------------------------------------------*/
     if (inspheroid < 0)
        {
        tmpspheroid = 0;
        sphdz(tmpspheroid,inparm,&r_major,&r_minor,&radius);
        }
     zone = inzone;
     if (zone == 0)
        {
        lon1 = paksz(inparm[0],iflg) * 3600 * S2R;
        if (*iflg != 0)
           return;
        lat1 = paksz(inparm[1],iflg) * 3600 * S2R;
        if (*iflg != 0)
           return;
        zone = calc_utm_zone(lon1 * R2D);
        if (lat1 < 0)
           zone = -zone;
        }
     scale_factor = .9996;
     *iflg = utminvint(r_major,r_minor,scale_factor,zone);
     inv_trans[insys] = utminv;
     }
  else
  if (insys == SPCS)
     {
     /* this is the call to initialize STATE PLANE 
     --------------------------------------------*/
     *iflg = stplninvint( inzone,inspheroid,fn27,fn83);
        if (*iflg != 0)
           return;
     inv_trans[insys] = stplninv;
     }
  else
  if (insys == ALBERS)
     {
     /* this is the call to initialize ALBERS 
     ---------------------------------------*/
     lat1 = paksz(inparm[2],iflg) * 3600 * S2R;
     if (*iflg != 0)
         return;
     lat2 = paksz(inparm[3],iflg) * 3600 * S2R;
     if (*iflg != 0)
         return;
     center_long = paksz(inparm[4],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     lat_origin  = paksz(inparm[5],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     *iflg = alberinvint(r_major,r_minor,lat1,lat2,center_long,lat_origin,
			false_easting, false_northing);
     inv_trans[insys] = alberinv;
     }
  else
  if (insys == LAMCC)
     {
     /* this is the call to initialize LAMBERT CONFORMAL CONIC 
     --------------------------------------------------------*/
     lat1 = paksz(inparm[2],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     lat2 = paksz(inparm[3],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     center_long = paksz(inparm[4],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     lat_origin  = paksz(inparm[5],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     *iflg = lamccinvint(r_major,r_minor,lat1,lat2,center_long,lat_origin,
			false_easting, false_northing);
     inv_trans[insys] = lamccinv;
     }
  else
  if (insys == MERCAT)
     {
     /* this is the call to initialize MERCATOR
     ----------------------------------------*/
     center_long  = paksz(inparm[4],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     lat1   = paksz(inparm[5],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     *iflg = merinvint(r_major,r_minor,center_long,lat1,false_easting,
                     false_northing);
     inv_trans[insys] = merinv;
     }
  else
  if (insys == PS)
     {
     /* this is the call to initialize POLAR STEREOGRAPHIC 
     ----------------------------------------------------*/
     center_long = paksz(inparm[4],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     lat1  =  paksz(inparm[5],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     *iflg = psinvint(r_major,r_minor,center_long,lat1,false_easting,
	      false_northing);
     inv_trans[insys] = psinv;
     }
  else
  if (insys == POLYC)
     {
     /* this is the call to initialize POLYCONIC
     -----------------------------------------*/
     center_long  = paksz(inparm[4],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     lat_origin   = paksz(inparm[5],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     *iflg = polyinvint(r_major,r_minor,center_long,lat_origin,false_easting,
		       false_northing); 
     inv_trans[insys] = polyinv;
     }
  else
    if (insys == EQUIDC)
    {
     /* this is the call to initialize EQUIDISTANT CONIC
     ---------------------------------------------------*/
    lat1 = paksz(inparm[2],iflg) * 3600 * S2R;
    if (*iflg != 0)
       return;
    lat2 = paksz(inparm[3],iflg) * 3600 * S2R;
    if (*iflg != 0)
       return;
    center_long  = paksz(inparm[4],iflg) * 3600 * S2R;
    if (*iflg != 0)
       return;
    lat_origin   = paksz(inparm[5],iflg) * 3600 * S2R;
    if (*iflg != 0)
       return;
    if (inparm[8] == 0)
       mode = 0;
    else
       mode = 1;
    *iflg = eqconinvint(r_major,r_minor,lat1,lat2,center_long,lat_origin,
		false_easting,false_northing,mode);
    inv_trans[insys] = eqconinv;
    }
  else
  if (insys == TM)
     {
     /* this is the call to initialize TRANSVERSE MERCATOR
     -------------------------------------------------*/
     scale_factor = inparm[2];
     center_long  = paksz(inparm[4],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     lat_origin   = paksz(inparm[5],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     *iflg = tminvint(r_major,r_minor,scale_factor,center_long,lat_origin,
		     false_easting, false_northing);
     inv_trans[insys] = tminv;
     }
  else
  if (insys == STEREO)
     {
     /* this is the call to initialize STEREOGRAPHIC
     ---------------------------------------------*/
     center_long  = paksz(inparm[4],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     center_lat   = paksz(inparm[5],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     *iflg = sterinvint(radius,center_long,center_lat,false_easting, 
		       false_northing); 
     inv_trans[insys] = sterinv;
     }
  else
  if (insys == LAMAZ)
     {
     /* this is the call to initialize LAMBERT AZIMUTHAL EQUAL-AREA 
     -------------------------------------------------------------*/
     center_long = paksz(inparm[4],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     center_lat  = paksz(inparm[5],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     *iflg = lamazinvint(radius, center_long, center_lat,false_easting,
			false_northing);
     inv_trans[insys] = lamazinv;
     }
  else
  if (insys == AZMEQD)
     {
     /* this is the call to initialize AZIMUTHAL EQUIDISTANT
     ------------------------------------------------------*/
     center_long  = paksz(inparm[4],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     center_lat   = paksz(inparm[5],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     *iflg = aziminvint(radius,center_long,center_lat,false_easting,
		       false_northing); 
     inv_trans[insys] = aziminv;
     }
  else
  if (insys == GNOMON)
     {
     /* this is the call to initialize GNOMONIC 
     ----------------------------------------*/
     center_long  = paksz(inparm[4],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     center_lat   = paksz(inparm[5],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     *iflg = gnominvint(radius,center_long,center_lat,false_easting,
                      false_northing);
     inv_trans[insys] = gnominv;
     }
  else
  if (insys == ORTHO)
     {
     /* this is the call to initialize ORTHOGRAPHIC
     --------------------------------------------*/
     center_long  = paksz(inparm[4],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     center_lat   = paksz(inparm[5],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     *iflg = orthinvint(radius,center_long,center_lat,false_easting,
		       false_northing); 
     inv_trans[insys] = orthinv;
     }
  else
  if (insys == GVNSP)
     {
     /* this is the call to initialize GENERAL VERTICAL NEAR SIDED PERSPECTIVE 
     -----------------------------------------------------------------------*/
     center_long  = paksz(inparm[4],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     center_lat   = paksz(inparm[5],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     h = inparm[2];
     *iflg = gvnspinvint(radius,h,center_long,center_lat,false_easting,
			false_northing);
     inv_trans[insys] = gvnspinv;
     }
  else
  if (insys == SNSOID)
     {
     /* this is the call to initialize SINUSOIDAL 
     --------------------------------------------*/
     center_long    = paksz(inparm[4],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     *iflg = sininvint(radius, center_long,false_easting,false_northing);
     inv_trans[insys] = sininv;
     }
  else
  if (insys == EQRECT)
     {
     /* this is the call to initialize EQUIRECTANGULAR
     -----------------------------------------------*/
     center_long  = paksz(inparm[4],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     lat1   = paksz(inparm[5],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     *iflg = equiinvint(radius,center_long,lat1,false_easting,
		       false_northing); 
     inv_trans[insys] = equiinv;
     }
  else
  if (insys == MILLER)
    {
    /* this is the call to initialize MILLER CYLINDRICAL
    --------------------------------------------------*/
    center_long  = paksz(inparm[4],iflg) * 3600 * S2R;
    if (*iflg != 0)
       return;
    *iflg = millinvint(radius, center_long,false_easting,false_northing);
    inv_trans[insys] = millinv;
    }
  else
  if (insys == VGRINT)
    {
    /* this is the call to initialize VAN DER GRINTEN 
    -----------------------------------------------*/
    center_long  = paksz(inparm[4],iflg) * 3600 * S2R;
    if (*iflg != 0)
       return;
    *iflg = vandginvint(radius, center_long,false_easting,false_northing);
    inv_trans[insys] = vandginv;
    }
  else
  if (insys == HOM)
     {
     /* this is the call to initialize HOTLINE OBLIQUE MERCATOR 
     ---------------------------------------------------------*/
     scale_factor = inparm[2];
     lat_origin = paksz(inparm[5],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     if (inparm[12] != 0)
        {
        mode = 1;
        azimuth = paksz(inparm[3],iflg) * 3600 * S2R;
        if (*iflg != 0)
           return;
        lon_origin = paksz(inparm[4],iflg) * 3600 * S2R;
        if (*iflg != 0)
           return;
        }
     else
        {
        mode = 0;
        lon1 = paksz(inparm[8],iflg) * 3600 * S2R;
        if (*iflg != 0)
           return;
        lat1 = paksz(inparm[9],iflg) * 3600 * S2R;
        if (*iflg != 0)
           return;
        lon2 = paksz(inparm[10],iflg) * 3600 * S2R;
        if (*iflg != 0)
           return;
        lat2 = paksz(inparm[11],iflg) * 3600 * S2R;
        if (*iflg != 0)
           return;
        
        }
     *iflg = omerinvint(r_major,r_minor,scale_factor,azimuth,lon_origin,
			lat_origin,false_easting, false_northing,lon1,lat1,
			lon2,lat2,mode);
     inv_trans[insys] = omerinv;
     }
  else
  if (insys == SOM)
     {
     /* this is the call to initialize SOM 
     -----------------------------------*/
     path = inparm[3];
     satnum = inparm[2];
    if (inparm[12] == 0)
       {
       mode = 1;
       alf = paksz(inparm[3],iflg) * 3600 * S2R;
       if (*iflg != 0)
          return;
       lon1 = paksz(inparm[4],iflg) * 3600 * S2R;
       if (*iflg != 0)
          return;
       time = inparm[8];
       start = inparm[10];
       }
    else
       mode = 0;
/*
     *iflg = sominvint(r_major,r_minor,satnum,path,false_easting,
			false_northing);
*/
     *iflg = sominvint(r_major,r_minor,satnum,path,alf,lon1,false_easting,
                      false_northing,time,start,mode);
     inv_trans[insys] = sominv;
     }
  else
  if (insys == HAMMER)
    {
    /* this is the call to initialize HAMMER 
    --------------------------------------*/
    center_long  = paksz(inparm[4],iflg) * 3600 * S2R;
    if (*iflg != 0)
       return;
    *iflg = haminvint(radius, center_long,false_easting,false_northing);
    inv_trans[insys] = haminv;
    }
  else
  if (insys == ROBIN)
    {
    /* this is the call to initialize ROBINSON 
    ----------------------------------------*/
    center_long  = paksz(inparm[4],iflg) * 3600 * S2R;
    if (*iflg != 0)
       return;
    *iflg = robinvint(radius, center_long,false_easting,false_northing);
    inv_trans[insys] = robinv;
    }
  else
  if (insys == GOOD)
     {
     /* this is the call to initialize GOODE'S HOMOLOSINE
     ---------------------------------------------------*/
     *iflg = goodinvint(radius);
     inv_trans[insys] = goodinv;
     }
  else
  if (insys == MOLL)
     {
     /* this is the call to initialize MOLLWEIDE
     -------------------------------------------*/
     center_long = paksz(inparm[4],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     *iflg = molwinvint(radius, center_long,false_easting,false_northing);
     inv_trans[insys] = molwinv;
     }
  else
  if (insys == IMOLL)
     {
     /* this is the call to initialize INTERRUPTED MOLLWEIDE 
     -----------------------------------------------------*/
     *iflg = imolwinvint(radius);
     inv_trans[insys] = imolwinv;
     }
  else
  if (insys == ALASKA)
     {
     /* this is the call to initialize ALASKA CONFORMAL 
     ------------------------------------------------*/
     *iflg = alconinvint(r_major,r_minor,false_easting,false_northing);
     inv_trans[insys] = alconinv;
     }
  else
  if (insys == WAGIV)
     {
     /* this is the call to initialize WAGNER IV 
     -----------------------------------------*/
     center_long = paksz(inparm[4],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     *iflg = wivinvint(radius, center_long,false_easting,false_northing);
     inv_trans[insys] = wivinv;
     }
  else
  if (insys == WAGVII)
     {
     /* this is the call to initialize WAGNER VII 
     ------------------------------------------*/
     center_long = paksz(inparm[4],iflg) * 3600 * S2R;
     if (*iflg != 0)
        return;
     *iflg = wviiinvint(radius, center_long,false_easting,false_northing);
     inv_trans[insys] = wviiinv;
     }
  else
  if (insys == OBEQA)
    {
    /* this is the call to initialize OBLATED EQUAL AREA
    ---------------------------------------------------*/
    center_long = paksz(inparm[4],iflg) * 3600 * S2R;
    if (*iflg != 0)
       return;
    center_lat  = paksz(inparm[5],iflg) * 3600 * S2R;
    if (*iflg != 0)
       return;
    shape_m = inparm[2];
    shape_n = inparm[3];
    angle = paksz(inparm[8],iflg) * 3600 * S2R;
    if (*iflg != 0)
       return;
    *iflg = obleqinvint(radius,center_long,center_lat,shape_m, shape_n,
                angle,false_easting,false_northing);
    inv_trans[insys] = obleqinv;
    }

return;
}