/* **************************************************************** */ long utmConversionInit(PointLla point) { long zone = 0; double r_maj = 6378137; // Magic Number: These are the values double r_min = 6356752.3142; // needed for the UTM ellipsoid double scale_fact = .9996; // long val; if(point->longitudeRadians > PI || point->longitudeRadians < -PI) { p_error("Invalid Seed Point for UTM Init. Check Radians??",""); return(-1); } zone = calc_utm_zone(point->longitudeRadians*R2D); // Check if the zone is different than what was done before if(zone != utmLibZone) { if(utmforint(r_maj, r_min, scale_fact, zone) != OK) return -1; if(utminvint(r_maj, r_min, scale_fact, zone) != OK) return -1; utmLibInitFlag = 1; utmLibZone = zone; return OK; } else { // Zone is the same, no need to re-init return OK; } }
/* Assigns values to the semimajor axis, semiminor axis, and radius of sphere. Initializes the forward and/or inverse mapping function. */ int LSsphdz ( char *projection, /* I: projection name string */ float coordinates[8], /* I: general coordinate info */ double *parm, /* I: Projection parameters */ double *radius, /* O: Radius of the sphere */ double corner[2] /* I: UL x,y for UL corner */ ) { double r_major; /* major axis */ double r_minor; /* minor axis */ double orient; /* orientation */ int ret = 0; /* return code */ long isph; /* spheroid code number also known as datum */ long zone; /* zone code */ /* Initialize global variables for the mapping */ zone = (long) coordinates[4]; isph = (long) coordinates[5]; orient = coordinates[6]; pixel_size = coordinates[7]; sin_orien = sin (orient); cos_orien = cos (orient); ul_corner[0] = corner[0]; ul_corner[1] = corner[1]; /* Initialize the variables using GCTP */ ret = sphdz (isph, parm, &r_major, &r_minor, radius); if (ret != 0) return (ret); if (zone == 0) zone = 31L; /* Do the forward or inverse transformation setup, depending on whether inverse is specified */ #ifdef INV if (!strcmp (projection, "GCTP_UTM")) ret = utminvint(r_major, r_minor, scale_factor, zone); else if (!strcmp (projection, "GCTP_PS")) ret = psinvint(r_major, r_minor, parm[4], parm[5], parm[6], parm[7]); else if (!strcmp (projection, "GCTP_ALBERS")) ret = alberinvint(r_major, r_minor, parm[2], parm[3], parm[4], parm[5], parm[6], parm[7]); #else if (!strcmp (projection, "GCTP_UTM")) ret = utmforint(r_major, r_minor, scale_factor, zone); else if (!strcmp (projection, "GCTP_PS")) ret = psforint(r_major, r_minor, parm[4], parm[5], parm[6], parm[7]); else if (!strcmp (projection, "GCTP_ALBERS")) ret = alberforint(r_major, r_minor, parm[2], parm[3], parm[4], parm[5], parm[6], parm[7]); #endif return (ret); }