| 1 |
/******************************************************************************* |
| 2 |
NAME FOR_INIT |
| 3 |
|
| 4 |
PURPOSE: Initializes forward projection transformation parameters |
| 5 |
|
| 6 |
PROGRAMMER DATE REASON |
| 7 |
---------- ---- ------ |
| 8 |
T. Mittan 3-09-93 Initial Development |
| 9 |
S. Nelson 11-94 Added Clarke spheroid default to UTM |
| 10 |
Raj Gejjagaraguppe(ARC) 8-30-96 Landsat Ratio is removed as hard |
| 11 |
coded value. Now this ratio can be |
| 12 |
an input from the user through the |
| 13 |
projection parameter array element |
| 14 |
number 9. |
| 15 |
Raj Gejjagaraguppe(ARC) 1-07-97 Added a new projection type called |
| 16 |
Integerized Sinusoidal Grid to |
| 17 |
support MODIS level 3 datasets. |
| 18 |
D. Wynne(ARC) 3-24-97 Added Support for Power Challenge |
| 19 |
(R10000 Processor Chip Revision: 2.5) |
| 20 |
Long is 8 bytes, on all other currently |
| 21 |
supported platforms Long is 4 bytes. |
| 22 |
Abe Taaheri 06-27-00 Added a new projection type called |
| 23 |
Behrmann Cylinderical Equal Area to |
| 24 |
support EASE grid. |
| 25 |
Abe Taaheri 10-23-00 Updated for ISINUS projection, so |
| 26 |
that both codes 31 and 99 (i.e. |
| 27 |
ISINUS and ISINUS1) can be used |
| 28 |
for this projection. |
| 29 |
Abe Taaheri 1-15-03 Modified to support both |
| 30 |
spherical and ellipsoid |
| 31 |
models of earth for |
| 32 |
Normal Cylinderical Equal Area |
| 33 |
projection. |
| 34 |
Abe Taaheri 8-15-03 Added CEA projection. This is used |
| 35 |
by generalized EASE grid, when the |
| 36 |
EASE grid corners are specified in |
| 37 |
meters (Note that BCEA is similar |
| 38 |
projection and used when EASE grid |
| 39 |
corners are set in packed DMS degrees. |
| 40 |
Abe Taaheri 11-15-03 Modified the call for LA projection |
| 41 |
to support ellipsoid earth for this |
| 42 |
projection |
| 43 |
|
| 44 |
ALGORITHM REFERENCES |
| 45 |
|
| 46 |
1. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological |
| 47 |
Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United |
| 48 |
State Government Printing Office, Washington D.C., 1987. |
| 49 |
|
| 50 |
2. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections", |
| 51 |
U.S. Geological Survey Professional Paper 1453 , United State Government |
| 52 |
Printing Office, Washington D.C., 1989. |
| 53 |
*******************************************************************************/ |
| 54 |
#include <stdio.h> |
| 55 |
#include "cproj.h" |
| 56 |
#include "proj.h" |
| 57 |
|
| 58 |
int for_init( |
| 59 |
int outsys, /* output system code */ |
| 60 |
int outzone, /* output zone number */ |
| 61 |
double *outparm, /* output array of projection parameters */ |
| 62 |
int outdatum, /* output datum */ |
| 63 |
char *fn27, /* NAD 1927 parameter file */ |
| 64 |
char *fn83, /* NAD 1983 parameter file */ |
| 65 |
int *iflg, /* status flag */ |
| 66 |
int (*for_trans[])(double, double, double *, double *)) /* forward function pointer */ |
| 67 |
{ |
| 68 |
long zone; /* zone number */ |
| 69 |
double azimuth; /* azimuth */ |
| 70 |
double alf; /* SOM angle */ |
| 71 |
double angle; /* rotation anlge */ |
| 72 |
double lon1; /* longitude point in utm scene */ |
| 73 |
double lon2; /* 2nd longitude */ |
| 74 |
double lat1; /* 1st standard parallel */ |
| 75 |
double lat2; /* 2nd standard parallel */ |
| 76 |
double center_long; /* center longitude */ |
| 77 |
double center_lat; /* center latitude */ |
| 78 |
double h; /* height above sphere */ |
| 79 |
double lon_origin; /* longitude at origin */ |
| 80 |
double lat_origin; /* latitude at origin */ |
| 81 |
double r_major; /* major axis in meters */ |
| 82 |
double r_minor; /* minor axis in meters */ |
| 83 |
double scale_factor; /* scale factor */ |
| 84 |
double false_easting; /* false easting in meters */ |
| 85 |
double false_northing; /* false northing in meters */ |
| 86 |
double shape_m; /* constant used for Oblated Equal Area */ |
| 87 |
double shape_n; /* constant used for Oblated Equal Area */ |
| 88 |
long start; /* where SOM starts beginning or end */ |
| 89 |
double time; /* SOM time */ |
| 90 |
double radius; /* radius of sphere */ |
| 91 |
long tmpdatum; /* temporary datum for UTM */ |
| 92 |
long path; /* SOM path number */ |
| 93 |
long satnum; /* SOM satellite number */ |
| 94 |
long mode; /* which initialization method to use A or B */ |
| 95 |
double sat_ratio; /* satellite ratio which specify the start point*/ |
| 96 |
double dzone; /* number of longitudinal zones in ISG */ |
| 97 |
double djustify; /* justify flag in ISG projection */ |
| 98 |
|
| 99 |
long thing; /* used to initialize 8 byte pointer, added */ |
| 100 |
/* for Power Challenge */ |
| 101 |
long *iflg64; /* 8 byte status flag, for Power Challenge */ |
| 102 |
|
| 103 |
thing = 0; /* These lines are to initialize the */ |
| 104 |
iflg64 = &thing; /* the 8-byte pointer address */ |
| 105 |
|
| 106 |
/* Initialize forward transformations |
| 107 |
-----------------------------------*/ |
| 108 |
/* find the correct major and minor axis |
| 109 |
--------------------------------------*/ |
| 110 |
if(outsys == CEA) |
| 111 |
{ |
| 112 |
if(outparm[0] > 0.0 || outparm[0] < 0.0 || |
| 113 |
outparm[1] > 0.0 || outparm[1] < 0.0) |
| 114 |
{ |
| 115 |
outdatum = -20; |
| 116 |
} |
| 117 |
|
| 118 |
sphdz(outdatum,outparm,&r_major,&r_minor,&radius); |
| 119 |
} |
| 120 |
else if(outsys == BCEA) |
| 121 |
{ |
| 122 |
if(outparm[0] > 0.0 || outparm[0] < 0.0 || |
| 123 |
outparm[1] > 0.0 || outparm[1] < 0.0) |
| 124 |
{ |
| 125 |
outdatum = -20; |
| 126 |
} |
| 127 |
else /* for BCEA use 6371228.0 m as default for r_maj and r_min, i.e. |
| 128 |
use spherical earth model with radius 6371228.0 m instead of |
| 129 |
Clarke 1866 spheroid */ |
| 130 |
{ |
| 131 |
outdatum = 20; |
| 132 |
} |
| 133 |
|
| 134 |
sphdz(outdatum,outparm,&r_major,&r_minor,&radius); |
| 135 |
} |
| 136 |
else |
| 137 |
{ |
| 138 |
sphdz(outdatum,outparm,&r_major,&r_minor,&radius); |
| 139 |
} |
| 140 |
|
| 141 |
false_easting = outparm[6]; |
| 142 |
false_northing = outparm[7]; |
| 143 |
|
| 144 |
if (outsys == CEA)/* Cylindrical Equal-Area, used for EASE grid wghen |
| 145 |
grid corners are specified in meters */ |
| 146 |
{ |
| 147 |
/* this is the call to initialize CEA |
| 148 |
----------------------------------------*/ |
| 149 |
center_long = paksz(outparm[4],iflg64)* 3600 * S2R; |
| 150 |
*iflg = (int)*iflg64; |
| 151 |
if ((int)*iflg64 != 0) |
| 152 |
return ERROR; |
| 153 |
|
| 154 |
lat1 = paksz(outparm[5],iflg64)* 3600 * S2R; |
| 155 |
*iflg = (int)*iflg64; |
| 156 |
if ((int)*iflg64 != 0) |
| 157 |
return ERROR;; |
| 158 |
|
| 159 |
*iflg64 = ceaforint(r_major,r_minor,center_long,lat1,false_easting, |
| 160 |
false_northing); |
| 161 |
*iflg = (int)*iflg64; |
| 162 |
for_trans[outsys] = ceafor; |
| 163 |
} |
| 164 |
else |
| 165 |
if (outsys == BCEA)/* Cylindrical Equal-Area, used for EASE grid wghen |
| 166 |
grid corners are specified in DMS degrees */ |
| 167 |
{ |
| 168 |
/* this is the call to initialize BCEA |
| 169 |
----------------------------------------*/ |
| 170 |
center_long = paksz(outparm[4],iflg64)* 3600 * S2R; |
| 171 |
*iflg = (int)*iflg64; |
| 172 |
if ((int)*iflg64 != 0) |
| 173 |
return ERROR; |
| 174 |
|
| 175 |
lat1 = paksz(outparm[5],iflg64)* 3600 * S2R; |
| 176 |
*iflg = (int)*iflg64; |
| 177 |
if ((int)*iflg64 != 0) |
| 178 |
return ERROR;; |
| 179 |
|
| 180 |
*iflg64 = bceaforint(r_major,r_minor,center_long,lat1,false_easting, |
| 181 |
false_northing); |
| 182 |
*iflg = (int)*iflg64; |
| 183 |
for_trans[outsys] = bceafor; |
| 184 |
} |
| 185 |
else |
| 186 |
if (outsys == UTM) |
| 187 |
{ |
| 188 |
/* this is the call to initialize U T M |
| 189 |
-------------------------------------*/ |
| 190 |
/* set Clarke 1866 spheroid if negative datum code |
| 191 |
----------------------------------------------*/ |
| 192 |
if (outdatum < 0) |
| 193 |
{ |
| 194 |
tmpdatum = 0; |
| 195 |
sphdz(tmpdatum,outparm,&r_major,&r_minor,&radius); |
| 196 |
} |
| 197 |
zone = outzone; |
| 198 |
if (zone == 0) |
| 199 |
{ |
| 200 |
lon1 = paksz(outparm[0],iflg64)* 3600 * S2R; |
| 201 |
*iflg = (int)*iflg64; |
| 202 |
if ((int)*iflg64 != 0) |
| 203 |
return ERROR; |
| 204 |
lat1 = paksz(outparm[1],iflg64)* 3600 * S2R; |
| 205 |
*iflg = (int)*iflg64; |
| 206 |
if ((int)*iflg64 != 0) |
| 207 |
return ERROR; |
| 208 |
zone = calc_utm_zone(lon1 * R2D); |
| 209 |
if (lat1 < 0) |
| 210 |
zone = -zone; |
| 211 |
} |
| 212 |
scale_factor = .9996; |
| 213 |
*iflg64 = utmforint(r_major,r_minor,scale_factor,zone); |
| 214 |
*iflg = (int)*iflg64; |
| 215 |
for_trans[outsys] = utmfor; |
| 216 |
} |
| 217 |
else |
| 218 |
if (outsys == SPCS) |
| 219 |
{ |
| 220 |
/* this is the call to initialize STATE PLANE |
| 221 |
-------------------------------------------*/ |
| 222 |
*iflg64 = stplnforint(outzone,outdatum,fn27,fn83); |
| 223 |
*iflg = (int)*iflg64; |
| 224 |
if ((int)*iflg64 != 0) |
| 225 |
return ERROR; |
| 226 |
for_trans[outsys] = stplnfor; |
| 227 |
} |
| 228 |
else |
| 229 |
if (outsys == ALBERS) |
| 230 |
{ |
| 231 |
/* this is the call to initialize ALBERS CONICAL EQUAL AREA |
| 232 |
----------------------------------------------------------*/ |
| 233 |
lat1 = paksz(outparm[2],iflg64)* 3600 * S2R; |
| 234 |
*iflg = (int)*iflg64; |
| 235 |
if ((int)*iflg64 != 0) |
| 236 |
return ERROR; |
| 237 |
lat2 = paksz(outparm[3],iflg64)* 3600 * S2R; |
| 238 |
*iflg = (int)*iflg64; |
| 239 |
if ((int)*iflg64 != 0) |
| 240 |
return ERROR; |
| 241 |
lat_origin = paksz(outparm[5],iflg64)* 3600 * S2R; |
| 242 |
*iflg = (int)*iflg64; |
| 243 |
if ((int)*iflg64 != 0) |
| 244 |
return ERROR; |
| 245 |
center_long = paksz(outparm[4],iflg64)* 3600 * S2R; |
| 246 |
*iflg = (int)*iflg64; |
| 247 |
if ((int)*iflg64 != 0) |
| 248 |
return ERROR; |
| 249 |
*iflg64 = alberforint(r_major,r_minor,lat1,lat2,center_long,lat_origin, |
| 250 |
false_easting, false_northing); |
| 251 |
*iflg = (int)*iflg64; |
| 252 |
for_trans[outsys] = alberfor; |
| 253 |
} |
| 254 |
else |
| 255 |
if (outsys == LAMCC) |
| 256 |
{ |
| 257 |
/* this is the call to initialize LAMBERT CONFORMAL CONIC |
| 258 |
--------------------------------------------------------*/ |
| 259 |
lat1 = paksz(outparm[2],iflg64)* 3600 * S2R; |
| 260 |
*iflg = (int)*iflg64; |
| 261 |
if ((int)*iflg64 != 0) |
| 262 |
return ERROR; |
| 263 |
lat2 = paksz(outparm[3],iflg64)* 3600 * S2R; |
| 264 |
*iflg = (int)*iflg64; |
| 265 |
if ((int)*iflg64 != 0) |
| 266 |
return ERROR; |
| 267 |
center_long = paksz(outparm[4],iflg64)* 3600 * S2R; |
| 268 |
*iflg = (int)*iflg64; |
| 269 |
if ((int)*iflg64 != 0) |
| 270 |
return ERROR; |
| 271 |
lat_origin = paksz(outparm[5],iflg64)* 3600 * S2R; |
| 272 |
*iflg = (int)*iflg64; |
| 273 |
if ((int)*iflg64 != 0) |
| 274 |
return ERROR; |
| 275 |
*iflg64 = lamccforint(r_major,r_minor,lat1,lat2,center_long,lat_origin, |
| 276 |
false_easting, false_northing); |
| 277 |
*iflg = (int)*iflg64; |
| 278 |
for_trans[outsys] = lamccfor; |
| 279 |
} |
| 280 |
else |
| 281 |
if (outsys == MERCAT) |
| 282 |
{ |
| 283 |
/* this is the call to initialize MERCATOR |
| 284 |
----------------------------------------*/ |
| 285 |
center_long = paksz(outparm[4],iflg64)* 3600 * S2R; |
| 286 |
*iflg = (int)*iflg64; |
| 287 |
if ((int)*iflg64 != 0) |
| 288 |
return ERROR; |
| 289 |
lat1 = paksz(outparm[5],iflg64)* 3600 * S2R; |
| 290 |
*iflg = (int)*iflg64; |
| 291 |
if ((int)*iflg64 != 0) |
| 292 |
return ERROR; |
| 293 |
*iflg64 = merforint(r_major,r_minor,center_long,lat1,false_easting, |
| 294 |
false_northing); |
| 295 |
*iflg = (int)*iflg64; |
| 296 |
for_trans[outsys] = merfor; |
| 297 |
} |
| 298 |
else |
| 299 |
if (outsys == PS) |
| 300 |
{ |
| 301 |
/* this is the call to initialize POLAR STEREOGRAPHIC |
| 302 |
----------------------------------------------------*/ |
| 303 |
center_long = paksz(outparm[4],iflg64)* 3600 * S2R; |
| 304 |
*iflg = (int) *iflg64; |
| 305 |
if ((int)*iflg64 != 0) |
| 306 |
return ERROR; |
| 307 |
lat1 = paksz(outparm[5],iflg64)* 3600 * S2R; |
| 308 |
*iflg = (int)*iflg64; |
| 309 |
if ((int)*iflg64 != 0) |
| 310 |
return ERROR; |
| 311 |
|
| 312 |
*iflg64 = psforint(r_major,r_minor,center_long,lat1,false_easting, |
| 313 |
false_northing); |
| 314 |
*iflg = (int)*iflg64; |
| 315 |
|
| 316 |
for_trans[outsys] = psfor; |
| 317 |
} |
| 318 |
else |
| 319 |
if (outsys == POLYC) |
| 320 |
{ |
| 321 |
/* this is the call to initialize POLYCONIC |
| 322 |
-----------------------------------------*/ |
| 323 |
center_long = paksz(outparm[4],iflg64)* 3600 * S2R; |
| 324 |
*iflg = (int)*iflg64; |
| 325 |
if ((int)*iflg64 != 0) |
| 326 |
return ERROR; |
| 327 |
lat_origin = paksz(outparm[5],iflg64)* 3600 * S2R; |
| 328 |
*iflg = (int)*iflg64; |
| 329 |
if ((int)*iflg64 != 0) |
| 330 |
return ERROR; |
| 331 |
*iflg64 = polyforint(r_major,r_minor,center_long,lat_origin,false_easting, |
| 332 |
false_northing); |
| 333 |
*iflg = (int)*iflg64; |
| 334 |
for_trans[outsys] = polyfor; |
| 335 |
} |
| 336 |
else |
| 337 |
if (outsys == EQUIDC) |
| 338 |
{ |
| 339 |
/* this is the call to initialize EQUIDISTANT CONIC |
| 340 |
-------------------------------------------------*/ |
| 341 |
lat1 = paksz(outparm[2],iflg64)* 3600 * S2R; |
| 342 |
*iflg = (int)*iflg64; |
| 343 |
if ((int)*iflg64 != 0) |
| 344 |
return ERROR; |
| 345 |
lat2 = paksz(outparm[3],iflg64)* 3600 * S2R; |
| 346 |
*iflg = (int)*iflg64; |
| 347 |
if ((int)*iflg64 != 0) |
| 348 |
return ERROR; |
| 349 |
center_long = paksz(outparm[4],iflg64)* 3600 * S2R; |
| 350 |
*iflg = (int)*iflg64; |
| 351 |
if ((int)*iflg64 != 0) |
| 352 |
return ERROR; |
| 353 |
lat_origin = paksz(outparm[5],iflg64)* 3600 * S2R; |
| 354 |
*iflg = (int)*iflg64; |
| 355 |
if ((int)*iflg64 != 0) |
| 356 |
return ERROR; |
| 357 |
if (outparm[8] == 0) |
| 358 |
mode = 0; |
| 359 |
else |
| 360 |
mode = 1; |
| 361 |
*iflg64 = eqconforint(r_major,r_minor,lat1,lat2,center_long,lat_origin, |
| 362 |
false_easting,false_northing,mode); |
| 363 |
*iflg = (int)*iflg64; |
| 364 |
for_trans[outsys] = eqconfor; |
| 365 |
} |
| 366 |
else |
| 367 |
if (outsys == TM) |
| 368 |
{ |
| 369 |
/* this is the call to initialize TRANSVERSE MECTAR |
| 370 |
-------------------------------------------------*/ |
| 371 |
scale_factor = outparm[2]; |
| 372 |
center_long = paksz(outparm[4],iflg64)* 3600 * S2R; |
| 373 |
*iflg = (int)*iflg64; |
| 374 |
if ((int)*iflg64 != 0) |
| 375 |
return ERROR; |
| 376 |
lat_origin = paksz(outparm[5],iflg64)* 3600 * S2R; |
| 377 |
*iflg = (int)*iflg64; |
| 378 |
if ((int)*iflg64 != 0) |
| 379 |
return ERROR; |
| 380 |
*iflg64 = tmforint(r_major,r_minor,scale_factor,center_long,lat_origin, |
| 381 |
false_easting,false_northing); |
| 382 |
*iflg = (int)*iflg64; |
| 383 |
for_trans[outsys] = tmfor; |
| 384 |
} |
| 385 |
else |
| 386 |
if (outsys == STEREO) |
| 387 |
{ |
| 388 |
/* this is the call to initialize STEREOGRAPHIC |
| 389 |
---------------------------------------------*/ |
| 390 |
center_long = paksz(outparm[4],iflg64)* 3600 * S2R; |
| 391 |
*iflg = (int)*iflg64; |
| 392 |
if ((int)*iflg64 != 0) |
| 393 |
return ERROR; |
| 394 |
center_lat = paksz(outparm[5],iflg64)* 3600 * S2R; |
| 395 |
*iflg = (int)*iflg64; |
| 396 |
if ((int)*iflg64 != 0) |
| 397 |
return ERROR; |
| 398 |
*iflg64 = sterforint(radius,center_long,center_lat,false_easting, |
| 399 |
false_northing); |
| 400 |
*iflg = (int)*iflg64; |
| 401 |
for_trans[outsys] = sterfor; |
| 402 |
} |
| 403 |
else |
| 404 |
if (outsys == LAMAZ) |
| 405 |
{ |
| 406 |
/* this is the call to initialize LAMBERT AZIMUTHAL |
| 407 |
-------------------------------------------------*/ |
| 408 |
center_long = paksz(outparm[4],iflg64)* 3600 * S2R; |
| 409 |
*iflg = (int)*iflg64; |
| 410 |
if ((int)*iflg64 != 0) |
| 411 |
return ERROR; |
| 412 |
center_lat = paksz(outparm[5],iflg64)* 3600 * S2R; |
| 413 |
*iflg = (int)*iflg64; |
| 414 |
if ((int)*iflg64 != 0) |
| 415 |
return ERROR; |
| 416 |
*iflg64 = lamazforint(r_major, r_minor, center_long, center_lat,false_easting, |
| 417 |
false_northing); |
| 418 |
*iflg = (int)*iflg64; |
| 419 |
for_trans[outsys] = lamazfor; |
| 420 |
} |
| 421 |
else |
| 422 |
if (outsys == AZMEQD) |
| 423 |
{ |
| 424 |
/* this is the call to initialize AZIMUTHAL EQUIDISTANT |
| 425 |
-----------------------------------------------------*/ |
| 426 |
center_long = paksz(outparm[4],iflg64)* 3600 * S2R; |
| 427 |
*iflg = (int)*iflg64; |
| 428 |
if ((int)*iflg64 != 0) |
| 429 |
return ERROR; |
| 430 |
center_lat = paksz(outparm[5],iflg64)* 3600 * S2R; |
| 431 |
*iflg = (int)*iflg64; |
| 432 |
if ((int)*iflg64 != 0) |
| 433 |
return ERROR; |
| 434 |
*iflg64 = azimforint(radius,center_long,center_lat,false_easting, |
| 435 |
false_northing); |
| 436 |
*iflg = (int)*iflg64; |
| 437 |
for_trans[outsys] = azimfor; |
| 438 |
} |
| 439 |
else |
| 440 |
if (outsys == GNOMON) |
| 441 |
{ |
| 442 |
/* this is the call to initialize GNOMONIC |
| 443 |
----------------------------------------*/ |
| 444 |
center_long = paksz(outparm[4],iflg64)* 3600 * S2R; |
| 445 |
*iflg = (int)*iflg64; |
| 446 |
if ((int)*iflg64 != 0) |
| 447 |
return ERROR; |
| 448 |
center_lat = paksz(outparm[5],iflg64)* 3600 * S2R; |
| 449 |
*iflg = (int)*iflg64; |
| 450 |
if ((int)*iflg64 != 0) |
| 451 |
return ERROR; |
| 452 |
*iflg64 = gnomforint(radius,center_long,center_lat,false_easting, |
| 453 |
false_northing); |
| 454 |
*iflg = (int)*iflg64; |
| 455 |
for_trans[outsys] = gnomfor; |
| 456 |
} |
| 457 |
else |
| 458 |
if (outsys == ORTHO) |
| 459 |
{ |
| 460 |
/* this is the call to initalize ORTHOGRAPHIC |
| 461 |
-------------------------------------------*/ |
| 462 |
center_long = paksz(outparm[4],iflg64)* 3600 * S2R; |
| 463 |
*iflg = (int)*iflg64; |
| 464 |
if ((int)*iflg64 != 0) |
| 465 |
return ERROR; |
| 466 |
center_lat = paksz(outparm[5],iflg64)* 3600 * S2R; |
| 467 |
*iflg = (int)*iflg64; |
| 468 |
if ((int)*iflg64 != 0) |
| 469 |
return ERROR; |
| 470 |
*iflg64 = orthforint(radius,center_long,center_lat,false_easting, |
| 471 |
false_northing); |
| 472 |
*iflg = (int)*iflg64; |
| 473 |
for_trans[outsys] = orthfor; |
| 474 |
} |
| 475 |
else |
| 476 |
if (outsys == GVNSP) |
| 477 |
{ |
| 478 |
/* this is the call to initalize GENERAL VERTICAL NEAR-SIDE PERSPECTIVE |
| 479 |
----------------------------------------------------------------------*/ |
| 480 |
center_long = paksz(outparm[4],iflg64)* 3600 * S2R; |
| 481 |
*iflg = (int)*iflg64; |
| 482 |
if ((int)*iflg64 != 0) |
| 483 |
return ERROR; |
| 484 |
center_lat = paksz(outparm[5],iflg64)* 3600 * S2R; |
| 485 |
*iflg = (int)*iflg64; |
| 486 |
if ((int)*iflg64 != 0) |
| 487 |
return ERROR; |
| 488 |
h = outparm[2]; |
| 489 |
*iflg64 = gvnspforint(radius,h,center_long,center_lat,false_easting, |
| 490 |
false_northing); |
| 491 |
*iflg = (int)*iflg64; |
| 492 |
for_trans[outsys] = gvnspfor; |
| 493 |
} |
| 494 |
else |
| 495 |
if (outsys == SNSOID) |
| 496 |
{ |
| 497 |
/* this is the call to initialize SINUSOIDAL |
| 498 |
-------------------------------------------*/ |
| 499 |
center_long = paksz(outparm[4],iflg64)* 3600 * S2R; |
| 500 |
*iflg = (int)*iflg64; |
| 501 |
if ((int)*iflg64 != 0) |
| 502 |
return ERROR; |
| 503 |
*iflg64 = sinforint(r_major,r_minor, center_long,false_easting,false_northing); |
| 504 |
*iflg = (int)*iflg64; |
| 505 |
for_trans[outsys] = sinfor; |
| 506 |
} |
| 507 |
else |
| 508 |
if (outsys == EQRECT) |
| 509 |
{ |
| 510 |
/* this is the call to initialize EQUIRECTANGULAR |
| 511 |
-----------------------------------------------*/ |
| 512 |
center_long = paksz(outparm[4],iflg64)* 3600 * S2R; |
| 513 |
*iflg = (int)*iflg64; |
| 514 |
if ((int)*iflg64 != 0) |
| 515 |
return ERROR; |
| 516 |
lat1 = paksz(outparm[5],iflg64)* 3600 * S2R; |
| 517 |
*iflg = (int)*iflg64; |
| 518 |
if ((int)*iflg64 != 0) |
| 519 |
return ERROR; |
| 520 |
*iflg64 = equiforint(radius,center_long,lat1,false_easting,false_northing); |
| 521 |
*iflg = (int)*iflg64; |
| 522 |
for_trans[outsys] = equifor; |
| 523 |
} |
| 524 |
else |
| 525 |
if (outsys == MILLER) |
| 526 |
{ |
| 527 |
/* this is the call to initialize MILLER CYLINDRICAL |
| 528 |
--------------------------------------------------*/ |
| 529 |
center_long = paksz(outparm[4],iflg64) * 3600 * S2R; |
| 530 |
*iflg = (int)*iflg64; |
| 531 |
if ((int)*iflg64 != 0) |
| 532 |
return ERROR; |
| 533 |
*iflg64 = millforint(radius, center_long,false_easting,false_northing); |
| 534 |
*iflg = (int)*iflg64; |
| 535 |
for_trans[outsys] = millfor; |
| 536 |
} |
| 537 |
else |
| 538 |
if (outsys == VGRINT) |
| 539 |
{ |
| 540 |
/* this is the call to initialize VAN DER GRINTEN |
| 541 |
-----------------------------------------------*/ |
| 542 |
center_long = paksz(outparm[4],iflg64)* 3600 * S2R; |
| 543 |
*iflg = (int)*iflg64; |
| 544 |
if ((int)*iflg64 != 0) |
| 545 |
return ERROR; |
| 546 |
*iflg64 = vandgforint(radius, center_long,false_easting,false_northing); |
| 547 |
*iflg = (int)*iflg64; |
| 548 |
for_trans[outsys] = vandgfor; |
| 549 |
} |
| 550 |
else |
| 551 |
if (outsys == HOM) |
| 552 |
{ |
| 553 |
/* this is the call to initialize HOTLINE OBLIQUE MERCATOR |
| 554 |
---------------------------------------------------------*/ |
| 555 |
scale_factor = outparm[2]; |
| 556 |
lat_origin = paksz(outparm[5],iflg64)* 3600 * S2R; |
| 557 |
*iflg = (int)*iflg64; |
| 558 |
if ((int)*iflg64 != 0) |
| 559 |
return ERROR; |
| 560 |
if (outparm[12] != 0) |
| 561 |
{ |
| 562 |
mode = 1; |
| 563 |
azimuth = paksz(outparm[3],iflg64)* 3600 * S2R; |
| 564 |
*iflg = (int)*iflg64; |
| 565 |
if ((int)*iflg64 != 0) |
| 566 |
return ERROR; |
| 567 |
lon_origin = paksz(outparm[4],iflg64)* 3600 * S2R; |
| 568 |
*iflg = (int)*iflg64; |
| 569 |
if ((int)*iflg64 != 0) |
| 570 |
return ERROR; |
| 571 |
} |
| 572 |
else |
| 573 |
{ |
| 574 |
mode = 0; |
| 575 |
lon1 = paksz(outparm[8],iflg64)* 3600 * S2R; |
| 576 |
*iflg = (int)*iflg64; |
| 577 |
if ((int)*iflg64 != 0) |
| 578 |
return ERROR; |
| 579 |
lat1 = paksz(outparm[9],iflg64)* 3600 * S2R; |
| 580 |
*iflg = (int)*iflg64; |
| 581 |
if ((int)*iflg64 != 0) |
| 582 |
return ERROR; |
| 583 |
lon2 = paksz(outparm[10],iflg64)* 3600 * S2R; |
| 584 |
*iflg = (int)*iflg64; |
| 585 |
if ((int)*iflg64 != 0) |
| 586 |
return ERROR; |
| 587 |
lat2 = paksz(outparm[11],iflg64)* 3600 * S2R; |
| 588 |
*iflg = (int)*iflg64; |
| 589 |
if ((int)*iflg64 != 0) |
| 590 |
return ERROR; |
| 591 |
} |
| 592 |
*iflg64 = omerforint(r_major,r_minor,scale_factor,azimuth,lon_origin, |
| 593 |
lat_origin,false_easting, false_northing,lon1,lat1, |
| 594 |
lon2,lat2,mode); |
| 595 |
*iflg = (int)*iflg64; |
| 596 |
for_trans[outsys] = omerfor; |
| 597 |
} |
| 598 |
else |
| 599 |
if (outsys == SOM) |
| 600 |
{ |
| 601 |
/* this is the call to initialize SOM |
| 602 |
-----------------------------------*/ |
| 603 |
path = (long) outparm[3]; |
| 604 |
satnum = (long) outparm[2]; |
| 605 |
if (outparm[12] == 0) |
| 606 |
{ |
| 607 |
mode = 1; |
| 608 |
alf = paksz(outparm[3],iflg64)* 3600 * S2R; |
| 609 |
*iflg = (int)*iflg64; |
| 610 |
if ((int)*iflg64 != 0) |
| 611 |
return ERROR; |
| 612 |
lon1 = paksz(outparm[4],iflg64)* 3600 * S2R; |
| 613 |
*iflg = (int)*iflg64; |
| 614 |
if ((int)*iflg64 != 0) |
| 615 |
return ERROR; |
| 616 |
time = outparm[8]; |
| 617 |
sat_ratio = outparm[9]; |
| 618 |
start = (long) outparm[10]; |
| 619 |
} |
| 620 |
else |
| 621 |
mode = 0; |
| 622 |
/* |
| 623 |
*iflg64 = somforint(r_major,r_minor,satnum,path,false_easting,false_northing); |
| 624 |
*iflg = (int)*iflg64; |
| 625 |
*/ |
| 626 |
*iflg64 = somforint(r_major,r_minor,satnum,path,alf,lon1,false_easting, |
| 627 |
false_northing,time,start,mode,sat_ratio); |
| 628 |
*iflg = (int)*iflg64; |
| 629 |
for_trans[outsys] = somfor; |
| 630 |
} |
| 631 |
else |
| 632 |
if (outsys == HAMMER) |
| 633 |
{ |
| 634 |
/* this is the call to initialize HAMMER |
| 635 |
--------------------------------------*/ |
| 636 |
center_long = paksz(outparm[4],iflg64)* 3600 * S2R; |
| 637 |
*iflg = (int)*iflg64; |
| 638 |
if ((int)*iflg64 != 0) |
| 639 |
return ERROR; |
| 640 |
*iflg64 = hamforint(radius,center_long,false_easting,false_northing); |
| 641 |
*iflg = (int)*iflg64; |
| 642 |
for_trans[outsys] = hamfor; |
| 643 |
} |
| 644 |
else |
| 645 |
if (outsys == ROBIN) |
| 646 |
{ |
| 647 |
/* this is the call to initialize ROBINSON |
| 648 |
----------------------------------------*/ |
| 649 |
center_long = paksz(outparm[4],iflg64)* 3600 * S2R; |
| 650 |
*iflg = (int)*iflg64; |
| 651 |
if ((int)*iflg64 != 0) |
| 652 |
return ERROR; |
| 653 |
*iflg64 = robforint(radius,center_long,false_easting,false_northing); |
| 654 |
*iflg = (int)*iflg64; |
| 655 |
for_trans[outsys] = robfor; |
| 656 |
} |
| 657 |
else |
| 658 |
if (outsys == GOODE) |
| 659 |
{ |
| 660 |
/* this is the call to initialize GOODE'S HOMOLOSINE |
| 661 |
---------------------------------------------------*/ |
| 662 |
*iflg64 = goodforint(radius); |
| 663 |
*iflg = (int)*iflg64; |
| 664 |
for_trans[outsys] = goodfor; |
| 665 |
} |
| 666 |
else |
| 667 |
if (outsys == MOLL) |
| 668 |
{ |
| 669 |
/* this is the call to initialize MOLLWEIDE |
| 670 |
------------------------------------------*/ |
| 671 |
center_long = paksz(outparm[4],iflg64)* 3600 * S2R; |
| 672 |
*iflg = (int)*iflg64; |
| 673 |
if ((int)*iflg64 != 0) |
| 674 |
return ERROR; |
| 675 |
*iflg64 = molwforint(radius, center_long,false_easting,false_northing); |
| 676 |
*iflg = (int)*iflg64; |
| 677 |
for_trans[outsys] = molwfor; |
| 678 |
} |
| 679 |
else |
| 680 |
if (outsys == IMOLL) |
| 681 |
{ |
| 682 |
/* this is the call to initialize INTERRUPTED MOLLWEIDE |
| 683 |
-----------------------------------------------------*/ |
| 684 |
*iflg64 = imolwforint(radius); |
| 685 |
*iflg = (int)*iflg64; |
| 686 |
for_trans[outsys] = imolwfor; |
| 687 |
} |
| 688 |
else |
| 689 |
if (outsys == ALASKA) |
| 690 |
{ |
| 691 |
/* this is the call to initialize ALASKA CONFORMAL |
| 692 |
------------------------------------------------*/ |
| 693 |
*iflg64 = alconforint(r_major,r_minor,false_easting,false_northing); |
| 694 |
*iflg = (int)*iflg64; |
| 695 |
for_trans[outsys] = alconfor; |
| 696 |
} |
| 697 |
else |
| 698 |
if (outsys == WAGIV) |
| 699 |
{ |
| 700 |
/* this is the call to initialize WAGNER IV |
| 701 |
-----------------------------------------*/ |
| 702 |
center_long = paksz(outparm[4],iflg64)* 3600 * S2R; |
| 703 |
*iflg = (int)*iflg64; |
| 704 |
if ((int)*iflg64 != 0) |
| 705 |
return ERROR; |
| 706 |
*iflg64 = wivforint(radius, center_long,false_easting,false_northing); |
| 707 |
*iflg = (int)*iflg64; |
| 708 |
for_trans[outsys] = wivfor; |
| 709 |
} |
| 710 |
else |
| 711 |
if (outsys == WAGVII) |
| 712 |
{ |
| 713 |
/* this is the call to initialize WAGNER VII |
| 714 |
------------------------------------------*/ |
| 715 |
center_long = paksz(outparm[4],iflg64)* 3600 * S2R; |
| 716 |
*iflg = (int)*iflg64; |
| 717 |
if ((int)*iflg64 != 0) |
| 718 |
return ERROR; |
| 719 |
*iflg64 = wviiforint(radius, center_long,false_easting,false_northing); |
| 720 |
*iflg = (int)*iflg64; |
| 721 |
for_trans[outsys] = wviifor; |
| 722 |
} |
| 723 |
else |
| 724 |
if (outsys == OBEQA) |
| 725 |
{ |
| 726 |
/* this is the call to initialize OBLATED EQUAL AREA |
| 727 |
---------------------------------------------------*/ |
| 728 |
center_long = paksz(outparm[4],iflg64)* 3600 * S2R; |
| 729 |
*iflg = (int)*iflg64; |
| 730 |
if ((int)*iflg64 != 0) |
| 731 |
return ERROR; |
| 732 |
center_lat = paksz(outparm[5],iflg64)* 3600 * S2R; |
| 733 |
*iflg = (int)*iflg64; |
| 734 |
if ((int)*iflg64 != 0) |
| 735 |
return ERROR; |
| 736 |
shape_m = outparm[2]; |
| 737 |
shape_n = outparm[3]; |
| 738 |
angle = paksz(outparm[8],iflg64)* 3600 * S2R; |
| 739 |
*iflg = (int)*iflg64; |
| 740 |
if ((int)*iflg64 != 0) |
| 741 |
return ERROR; |
| 742 |
*iflg64 = obleqforint(radius,center_long,center_lat,shape_m, shape_n, |
| 743 |
angle,false_easting,false_northing); |
| 744 |
*iflg = (int)*iflg64; |
| 745 |
for_trans[outsys] = obleqfor; |
| 746 |
} |
| 747 |
else |
| 748 |
if ((outsys == ISINUS) || (outsys == ISINUS1)) |
| 749 |
{ |
| 750 |
/* this is the call to initialize INTEGERIZED SINUSOIDAL GRID |
| 751 |
------------------------------------------------------------*/ |
| 752 |
|
| 753 |
center_long = paksz(outparm[4],iflg64)* 3600 * S2R; |
| 754 |
*iflg = (int)*iflg64; |
| 755 |
if ((int)*iflg64 != 0) |
| 756 |
return ERROR; |
| 757 |
dzone = outparm[8]; |
| 758 |
djustify = outparm[10]; |
| 759 |
|
| 760 |
*iflg64 = isinusforinit(radius, center_long, false_easting, false_northing, |
| 761 |
dzone, djustify); |
| 762 |
*iflg = (int)*iflg64; |
| 763 |
|
| 764 |
for_trans[outsys] = isinusfor; |
| 765 |
} |
| 766 |
|
| 767 |
return OK; |
| 768 |
} |