/* Initialize the Lambert Azimuthal Equal Area projection ------------------------------------------------------*/ long lamazforint ( double r, /* (I) Radius of the earth (sphere) */ double center_long, /* (I) Center longitude */ double center_lat, /* (I) Center latitude */ double false_east, /* x offset in meters */ double false_north /* y offset in meters */ ) { /* Place parameters in static storage for common use -------------------------------------------------*/ R = r; lon_center = center_long; false_easting = false_east; false_northing = false_north; gctp_sincos(center_lat, &sin_lat_o, &cos_lat_o); /* Report parameters to the user -----------------------------*/ ptitle("LAMBERT AZIMUTHAL EQUAL-AREA"); radius(r); cenlon(center_long); cenlat(center_lat); offsetp(false_easting,false_northing); return(GCTP_OK); }
/* Initialize the General Vertical Near-Side Perspective projection ---------------------------------------------------------------*/ long gvnspforint ( double r, /* (I) Radius of the earth (sphere) */ double h, /* height above sphere */ double center_long, /* (I) Center longitude */ double center_lat, /* (I) Center latitude */ double false_east, /* x offset in meters */ double false_north /* y offset in meters */ ) { /* Place parameters in static storage for common use -------------------------------------------------*/ R = r; p = 1.0 + h / R; lon_center = center_long; false_easting = false_east; false_northing = false_north; gctp_sincos(center_lat, &sin_p15, &cos_p15); /* Report parameters to the user -----------------------------*/ ptitle("GENERAL VERTICAL NEAR-SIDE PERSPECTIVE"); radius(r); genrpt(h,"Height of Point Above Surface of Sphere: "); cenlon(center_long); cenlat(center_lat); offsetp(false_easting,false_northing); return(GCTP_OK); }
/* Initialize the Sinusoidal projection ------------------------------------*/ int sininvint( double r_maj, /* major axis */ double r_min, /* minor axis */ double center_long, /* (I) Center longitude */ double false_east, /* x offset in meters */ double false_north) /* y offset in meters */ { /* Place parameters in static storage for common use -------------------------------------------------*/ R = r_maj; if(fabs(r_min) < EPSLN ) /* sphere */ { r_major = r_maj; r_minor = r_maj; } else /* sphere or ellipsoide */ { r_major = r_maj; r_minor = r_min; } lon_center = center_long; false_easting = false_east; false_northing = false_north; es = 1.0 - SQUARE(r_minor / r_major); e = sqrt(es); if(e < 0.00001) { ind = 1; /* sphere */ } else { double e12, e13, e14; ind = 0; /* ellipsoid */ e1 = (1.0 - sqrt(1.0 - es))/(1.0 + sqrt(1.0 - es)); e12 = e1 * e1; e13 = e12 * e1; e14 = e13 * e1; imu = (1.0 - (es/4.0) - (3.0 * es * es / 64.0) - (5.0 * es * es * es /256.0)); e2 = ((3.0 * e1 /2.0) - (27.0 * e13 / 32.0)); e3 = ((21.0 * e12 / 16.0) - (55.0 * e14 / 32.0)); e4 = (151.0 * e13 / 96.0); e5 = (1097.0 * e14 / 512.0); } /* Report parameters to the user -----------------------------*/ ptitle("SINUSOIDAL"); radius2(r_major, r_minor); cenlon(center_long); offsetp(false_easting,false_northing); return(OK); }
/* Initialize the ALASKA CONFORMAL projection -----------------------------------------*/ long alconinvint ( double r_maj, /* Major axis */ double r_min, /* Minor axis */ double false_east, /* x offset in meters */ double false_north /* y offset in meters */ ) { double es; double chi; double esphi; /* Place parameters in static storage for common use -------------------------------------------------*/ r_major = r_maj; r_minor = r_min; false_easting = false_east; false_northing = false_north; lon_center = -152.0 * D2R; lat_center = 64.0 * D2R; n = 6; es = .006768657997291094; e = sqrt(es); acoef[1]= 0.9945303; acoef[2]= 0.0052083; acoef[3]= 0.0072721; acoef[4]= -0.0151089; acoef[5]= 0.0642675; acoef[6]= 0.3582802; bcoef[1]= 0.0; bcoef[2]= -.0027404; bcoef[3]= 0.0048181; bcoef[4]= -0.1932526; bcoef[5]= -0.1381226; bcoef[6]= -0.2884586; esphi = e * sin(lat_center); chi = 2.0 * atan(tan((HALF_PI + lat_center)/2.0) * pow(((1.0 - esphi)/(1.0 + esphi)),(e/2.0))) - HALF_PI; gctp_sincos(chi,&sin_p26,&cos_p26); /* Report parameters to the user -----------------------------*/ ptitle("ALASKA CONFORMAL"); radius2(r_major,r_minor); cenlon(lon_center); cenlat(lat_center); offsetp(false_easting,false_northing); return(GCTP_OK); }
/* Initialize the Polar Stereographic projection --------------------------------------------*/ long psinvint ( double r_maj, /* major axis */ double r_min, /* minor axis */ double c_lon, /* center longitude */ double c_lat, /* center latitude */ double false_east, /* x offset in meters */ double false_north /* y offset in meters */ ) { double temp; /* temporary variable */ double con1; /* temporary angle */ double sinphi; /* sin value */ double cosphi; /* cos value */ double es; /* eccentricity squared */ r_major = r_maj; r_minor = r_min; false_easting = false_east; false_northing = false_north; temp = r_minor / r_major; es = 1.0 - SQUARE(temp); e = sqrt(es); e4 = e4fn(e); center_lon = c_lon; center_lat = c_lat; if (c_lat < 0) fac = -1.0; else fac = 1.0; ind = 0; if (fabs(fabs(c_lat) - HALF_PI) > EPSLN) { ind = 1; con1 = fac * center_lat; gctp_sincos(con1,&sinphi,&cosphi); mcs = msfnz(e,sinphi,cosphi); tcs = tsfnz(e,con1,sinphi); } /* Report parameters to the user -----------------------------*/ ptitle("POLAR STEREOGRAPHIC"); radius2(r_major, r_minor); cenlon(center_lon); offsetp(false_east,false_north); return(GCTP_OK); }
// Initialize the Polar Stereographic projection long Projectoid::psinvint( double r_maj, // major axis double r_min, // minor axis double c_lon, // center longitude double c_lat, // center latitude double false_east, // x offset in meters double false_north) // y offset in meters { double temp; // temporary variable double con1; // temporary angle double sinphi; // sin value double cosphi; // cos value double es; // eccentricity squared r_major = r_maj; r_minor = r_min; false_easting = false_east; false_northing = false_north; temp = r_minor / r_major; es = 1.0 - SQUARE(temp); e = sqrt(es); e4 = e4fn(e); center_lon = c_lon; center_lat = c_lat; if (c_lat < 0) fac = -1.0; else fac = 1.0; ind = 0; if (fabs(fabs(c_lat) - HALF_PI) > EPSLN) { ind = 1; con1 = fac * center_lat; sincos(con1, &sinphi, &cosphi); mcs = msfnz(e, sinphi, cosphi); tcs = tsfnz(e, con1, sinphi); } // Report parameters to the user ptitle("POLAR STEREOGRAPHIC"); radius2(r_major, r_minor); cenlon(center_lon); offsetp(false_east, false_north); InverseOK[WCS_PROJECTIONCODE_PS] = 1; InverseTransform = &Projectoid::psinv; return(OK); }
/* Initialize the Miller Cylindrical projection -------------------------------------------*/ int millforint( double r, /* (I) Radius of the earth (sphere) */ double center_long, /* (I) Center longitude */ double false_east, /* x offset in meters */ double false_north) /* y offset in meters */ { /* Place parameters in static storage for common use -------------------------------------------------*/ R = r; lon_center = center_long; false_easting = false_east; false_northing = false_north; /* Report parameters to the user -----------------------------*/ ptitle("MILLER CYLINDRICAL"); radius(r); cenlon(center_long); offsetp(false_easting,false_northing); return(OK); }
long obleqforint ( double r, double center_long, double center_lat, double shape_m, double shape_n, double angle, double false_east, double false_north ) { /* Place parameters in static storage for common use -------------------------------------------------*/ R = r; lon_center = center_long; lat_o = center_lat; m = shape_m; n = shape_n; theta = angle; false_easting = false_east; false_northing = false_north; /* Report parameters to the user (to device set up prior to this call) -------------------------------------------------------------------*/ ptitle("OBLATED EQUAL-AREA"); radius(R); cenlon(lon_center); cenlat(lat_o); genrpt(m,"Parameter m: "); genrpt(n,"Parameter n: "); genrpt(theta,"Theta: "); offsetp(false_easting,false_northing); /* Calculate the sine and cosine of the latitude of the center of the map and store in static storage for common use. -------------------------------------------*/ gctp_sincos(lat_o, &sin_lat_o, &cos_lat_o); return(GCTP_OK); }
/* Initialize the Van Der Grinten projection ----------------------------------------*/ long vandgforint ( double r, /* (I) Radius of the earth (sphere) */ double center_long, /* (I) Center longitude */ double false_east, /* x offset in meters */ double false_north /* y offset in meters */ ) { /* Place parameters in static storage for common use -------------------------------------------------*/ R = r; lon_center = center_long; false_easting = false_east; false_northing = false_north; /* Report parameters to the user -----------------------------*/ ptitle("VAN DER GRINTEN"); radius(r); cenlon(center_long); offsetp(false_easting,false_northing); return(GCTP_OK); }
// Initialize the Wagner VII projection long Projectoid::wviiinvint( double r, // (I) Radius of the earth (sphere) double center_long, // (I) Center longitude double false_east, // x offset double false_north) // y offset { // Place parameters in static storage for common use R = r; lon_center = center_long; false_easting = false_east; false_northing = false_north; // Report parameters to the user ptitle("WAGNER VII"); radius(r); cenlon(center_long); offsetp(false_easting, false_northing); InverseOK[WCS_PROJECTIONCODE_WAGVII] = 1; InverseTransform = &Projectoid::wviiinv; return(OK); }
// Initialize the ROBINSON projection long Projectoid::robinvint( double r, // (I) Radius of the earth (sphere) double center_long, // (I) Center longitude double false_east, // x offset in meters double false_north) // y offset in meters { long i; // Place parameters in static storage for common use R = r; lon_center = center_long; false_easting = false_east; false_northing = false_north; pr[1]= -0.062; xlr[1]=0.9986; pr[2]=0.0; xlr[2]=1.0; pr[3]=0.062; xlr[3]=0.9986; pr[4]=0.124; xlr[4]=0.9954; pr[5]=0.186; xlr[5]=0.99; pr[6]=0.248; xlr[6]=0.9822; pr[7]=0.31; xlr[7]=0.973; pr[8]=0.372; xlr[8]=0.96; pr[9]=0.434; xlr[9]=0.9427; pr[10]=0.4958; xlr[10]=0.9216; pr[11]=0.5571; xlr[11]=0.8962; pr[12]=0.6176; xlr[12]=0.8679; pr[13]=0.6769; xlr[13]=0.835; pr[14]=0.7346; xlr[14]=0.7986; pr[15]=0.7903; xlr[15]=0.7597; pr[16]=0.8435; xlr[16]=0.7186; pr[17]=0.8936; xlr[17]=0.6732; pr[18]=0.9394; xlr[18]=0.6213; pr[19]=0.9761; xlr[19]=0.5722; pr[20]=1.0; xlr[20]=0.5322; for (i = 0; i < 21; i++) xlr[i] *= 0.9858; // Report parameters to the user ptitle("ROBINSON"); radius(r); cenlon(center_long); offsetp(false_easting, false_northing); InverseOK[WCS_PROJECTIONCODE_ROBIN] = 1; InverseTransform = &Projectoid::robinv; return(OK); }
/* Initialize the General Lambert Azimuthal Equal Area projection --------------------------------------------------------------*/ int lamazforint( double r_maj, /* major axis */ double r_min, /* minor axis */ double center_long, /* (I) Center longitude */ double center_lat, /* (I) Center latitude */ double false_east, /* x offset in meters */ double false_north) /* y offset in meters */ { /* Place parameters in static storage for common use -------------------------------------------------*/ R = r_maj; if(fabs(r_min) < EPSLN ) /* sphere */ { r_major = r_maj; r_minor = r_maj; } else /* sphere or ellipsoide */ { r_major = r_maj; r_minor = r_min; } lon_center = center_long; lat_center = center_lat; false_easting = false_east; false_northing = false_north; tsincos(center_lat, &sin_lat_o, &cos_lat_o); sinphi1 = sin_lat_o; cosphi1 = cos_lat_o; es = 1.0 - SQUARE(r_minor / r_major); e = sqrt(es); if(es < 0.00001) { ind = 1; /* sphere */ qp = 2.0; q1 = 2.0; } else { ind = 0; /* ellipsoid */ qp = (1.0 - es)* (((1.0/(1.0 - es))-(1.0/(2.0*e))*log((1.0 - e)/(1.0 + e)))); if((fabs (lat_center - HALF_PI) <= EPSLN ) || (fabs (lat_center + HALF_PI) <= EPSLN )) { /* no other constants needed for LA with North and South polar Aspects lat_center = 90 or -90*/ } else { tsincos(lat_center, &sinphi1, &cosphi1); q1 = (1.0 - es) * ((sinphi1 / (1.0 - es * sinphi1 * sinphi1)) - (1.0 / (2.0 * e)) * log((1.0 - e * sinphi1)/(1.0 + e * sinphi1))); Rq = r_major * sqrt(qp/2.0); if(fabs(q1) >= fabs(qp)) { beta1 = HALF_PI * (fabs(q1/qp)/(q1/qp)); } else { beta1 = asinz(q1/qp); } tsincos(beta1, &sin_beta1, &cos_beta1); m1 = cosphi1 / sqrt(1.0 - es * sinphi1 * sinphi1); D = (r_major * m1)/ (Rq * cos_beta1); } } /* Report parameters to the user -----------------------------*/ ptitle("LAMBERT AZIMUTHAL EQUAL-AREA"); radius2(r_major, r_minor); cenlon(center_long); cenlat(center_lat); offsetp(false_easting,false_northing); return(OK); }
/* !C****************************************************************************** !Description: Isin_for_init (initialize mapping) initializes the integerized sinusoidal transformations by calculating constants and a short-cut lookup table. !Input Parameters: sphere sphere radius (user's units) lon_cen_mer longitude of central meridian (radians) false_east easting at projection origin (user's units) false_north northing at projection origin (user's units) nrow number of rows (longitudinal zones) ijustify justify flag; flag to indicate what to do with rows with an odd number of columns; 0 = indicates the extra column is on the right of the projection y axis; 1 = indicates the extra column is on the left of the projection y axis; 2 = calculate an even number of columns !Output Parameters: (returns) a handle for this instance of the integerized sinusoidal projection or NULL for error !Team Unique Header: ! Usage Notes: 1. The sphere radius must not be smaller than 'EPS_SPHERE'. 2. The longitude must be in the range [-'TWO_PI' to 'TWO_PI']. 3. The number of rows must be a multiple of two and no more than 'NROW_MAX'. !END**************************************************************************** */ Isin_t *Isin_for_init ( double sphere, double lon_cen_mer, double false_east, double false_north, long nrow, int ijustify ) { Isin_t *this; /* 'isin' data structure */ Isin_row_t *row; /* current row data structure */ long irow; /* row (zone) index */ double clat; /* central latitude of the row */ long ncol_cen; /* number of columns in the central row of the grid (at the equator) */ #ifdef CHECK_EDGE double dcol; /* delta column (normalized by number of columns) */ double dcol_min, /* minimum delta column */ double log2_dcol_min; /* log base 2 of minimum delta column */ dcol_min = 1.0; #endif /* Check input parameters */ if ( sphere < EPS_SPHERE ) { Isin_error( &ISIN_BADPARAM, "Isin_for_init" ); return NULL; } if ( lon_cen_mer < -TWO_PI || lon_cen_mer > TWO_PI ) { Isin_error( &ISIN_BADPARAM, "Isin_for_init" ); return NULL; } if ( lon_cen_mer < PI ) lon_cen_mer += TWO_PI; if ( lon_cen_mer >= PI ) lon_cen_mer -= TWO_PI; if ( nrow < 2 || nrow > NROW_MAX ) { Isin_error( &ISIN_BADPARAM, "Isin_for_init" ); return NULL; } if ( ( nrow % 2 ) != 0 ) { Isin_error( &ISIN_BADPARAM, "Isin_for_init" ); return NULL; } if ( ijustify < 0 || ijustify > 2 ) { Isin_error( &ISIN_BADPARAM, "Isin_for_init" ); return NULL; } /* Allocate 'isin' data structure */ this = ( Isin_t * ) malloc( sizeof( Isin_t ) ); if ( this == NULL ) { Isin_error( &ISIN_BADALLOC, "Isin_for_init" ); return NULL; } /* Place parameters in static storage for common use ------------------------------------------------- R = sphere; lon_center = lon_cen_mer; false_easting = false_east; false_northing = false_north; zone = nrow; justify = ijustify; */ /* Report parameters to the user -----------------------------*/ ptitle("INTEGERIZED SINUSOIDAL"); radius(sphere); cenlon(lon_cen_mer); offsetp(false_east,false_north); genrpt_long(nrow, "Number of Latitudinal Zones: "); genrpt(ijustify, "Right Justify Columns Flag: "); /* Initialize data structure */ this->key = 0; this->false_east = false_east; this->false_north = false_north; this->sphere = sphere; this->sphere_inv = 1.0 / sphere; this->ang_size_inv = ( ( double ) nrow ) / PI; this->nrow = nrow; this->nrow_half = nrow / 2; this->lon_cen_mer = lon_cen_mer; this->ref_lon = lon_cen_mer - PI; if ( this->ref_lon < -PI ) this->ref_lon += TWO_PI; this->ijustify = ijustify; /* Allocate space for information about each row */ this->row = (Isin_row_t *)malloc(this->nrow_half * sizeof(Isin_row_t)); if ( this->row == NULL ) { free( this ); Isin_error( &ISIN_BADALLOC, "Isin_for_init" ); return NULL; } /* Do calculations for each row; calculations are only done for half * the rows because of the symmetry between the rows above the * equator and the ones below */ row = this->row; for ( irow = 0; irow < this->nrow_half; irow++, row++ ) { /* Calculate latitude at center of row */ clat = HALF_PI * ( 1.0 - ( ( double ) irow + 0.5 ) / this->nrow_half ); /* Calculate number of columns per row */ if ( ijustify < 2 ) row->ncol = (long)((2.0 * cos(clat) * nrow) + 0.5); else { /* make the number of columns even */ row->ncol = (long)((cos(clat) * nrow) + 0.5); row->ncol *= 2; } #ifdef CHECK_EDGE /* Check to be sure the are no less then three columns per row and that * there are exactly three columns at the poles */ if ( ijustify < 2 ) { if ( row->ncol < 3 || ( irow == 0 && row->ncol != 3 ) ) printf( " irow = %d ncol = %d\n", irow, row->ncol ); } else { if ( row->ncol < 6 || ( irow == 0 && row->ncol != 6 ) ) printf( " irow = %d ncol = %d\n", irow, row->ncol ); } #endif /* Must have at least one column */ if ( row->ncol < 1 ) row->ncol = 1; #ifdef CHECK_EDGE /* Calculate the minimum delta column (normalized by the number of * columns in the row) */ if ( ijustify < 2 ) dcol = fabs( ( 2.0 * cos( clat ) * nrow ) + 0.5 - row->ncol ); else dcol = 2.0 * fabs((cos(clat) * nrow) + 0.5 - (row->ncol/2)); dcol = dcol / row->ncol; if ( dcol < dcol_min ) dcol_min = dcol; if ( ijustify < 2 ) { dcol = fabs((2.0 * cos(clat) * nrow) + 0.5 - (row->ncol + 1)); dcol = dcol / ( row->ncol + 1 ); } else { dcol = 2.0 * fabs((cos(clat) * nrow) + 0.5 - ((row->ncol/2) + 1)); dcol = dcol / ( row->ncol + 2 ); } if ( dcol < dcol_min ) dcol_min = dcol; #endif /* Save the inverse of the number of columns */ row->ncol_inv = 1.0 / ( ( double ) row->ncol ); /* Calculate the column number of the column whose left edge touches the central meridian */ if ( ijustify == 1 ) row->icol_cen = ( row->ncol + 1 ) / 2; else row->icol_cen = row->ncol / 2; } /* for (irow... */ /* Get the number of columns at the equator */ ncol_cen = this->row[this->nrow_half - 1].ncol; #ifdef CHECK_EDGE /* Print the minimum delta column and its base 2 log */ log2_dcol_min = log( dcol_min ) / log( 2.0 ); printf( " dcol_min = %g log2_dcol_min = %g\n", dcol_min, log2_dcol_min ); /* Check to be sure the number of columns at the equator is twice the * number of rows */ if ( ncol_cen != nrow * 2 ) printf( " ncol_cen = %d nrow = %d\n", ncol_cen, nrow ); #endif /* Calculate the distance at the equator between * the centers of two columns (and the inverse) */ this->col_dist = ( TWO_PI * sphere ) / ncol_cen; this->col_dist_inv = ncol_cen / ( TWO_PI * sphere ); /* Give the data structure a valid key */ this->key = ISIN_KEY; /* All done */ return this; }