ossimDpt ossimEquDistCylProjection::forward(const ossimGpt &latLon)const { double easting = 0.0; double northing = 0.0; ossimGpt gpt = latLon; if (theDatum) { if (theDatum->code() != latLon.datum()->code()) { gpt.changeDatum(theDatum); // Shift to our datum. } } Convert_Geodetic_To_Equidistant_Cyl(gpt.latr(), gpt.lonr(), &easting, &northing); return ossimDpt(easting, northing); }
long Set_Equidistant_Cyl_Parameters(double a, double f, double Std_Parallel, double Central_Meridian, double False_Easting, double False_Northing) { /* Begin Set_Equidistant_Cyl_Parameters */ /* * The function Set_Equidistant_Cyl_Parameters receives the ellipsoid parameters and * projection parameters as inputs, and sets the corresponding state * variables. It also calculates the spherical radius of the sphere having * the same area as the ellipsoid. If any errors occur, the error code(s) * are returned by the function, otherwise EQCY_NO_ERROR is returned. * * a : Semi-major axis of ellipsoid, in meters (input) * f : Flattening of ellipsoid (input) * Std_Parallel : Latitude in radians at which the (input) * point scale factor is 1.0 * Central_Meridian : Longitude in radians at the center of (input) * the projection * False_Easting : A coordinate value in meters assigned to the * central meridian of the projection. (input) * False_Northing : A coordinate value in meters assigned to the * standard parallel of the projection (input) */ double temp; double inv_f = 1 / f; long Error_Code = EQCY_NO_ERROR; if (a <= 0.0) { /* Semi-major axis must be greater than zero */ Error_Code |= EQCY_A_ERROR; } if ((inv_f < 250) || (inv_f > 350)) { /* Inverse flattening must be between 250 and 350 */ Error_Code |= EQCY_INV_F_ERROR; } if ((Std_Parallel < -PI_OVER_2) || (Std_Parallel > PI_OVER_2)) { /* standard parallel out of range */ Error_Code |= EQCY_STDP_ERROR; } if ((Central_Meridian < -PI) || (Central_Meridian > TWO_PI)) { /* origin longitude out of range */ Error_Code |= EQCY_CENT_MER_ERROR; } if (!Error_Code) { /* no errors */ Eqcy_a = a; Eqcy_f = f; es2 = 2 * Eqcy_f - Eqcy_f * Eqcy_f; es4 = es2 * es2; es6 = es4 * es2; /* spherical radius */ Ra = Eqcy_a * (1.0 - es2 / 6.0 - 17.0 * es4 / 360.0 - 67.0 * es6 /3024.0); Eqcy_Std_Parallel = Std_Parallel; Cos_Eqcy_Std_Parallel = cos(Eqcy_Std_Parallel); Ra_Cos_Eqcy_Std_Parallel = Ra * Cos_Eqcy_Std_Parallel; if (Central_Meridian > PI) Central_Meridian -= TWO_PI; Eqcy_Origin_Long = Central_Meridian; Eqcy_False_Easting = False_Easting; Eqcy_False_Northing = False_Northing; if (Eqcy_Origin_Long > 0) { Convert_Geodetic_To_Equidistant_Cyl(PI_OVER_2, Eqcy_Origin_Long - PI - ONE, &Eqcy_Max_Easting, &temp); Convert_Geodetic_To_Equidistant_Cyl(PI_OVER_2, Eqcy_Origin_Long - PI, &Eqcy_Min_Easting, &temp); } else if (Eqcy_Origin_Long < 0) { Convert_Geodetic_To_Equidistant_Cyl(PI_OVER_2, Eqcy_Origin_Long + PI, &Eqcy_Max_Easting, &temp); Convert_Geodetic_To_Equidistant_Cyl(PI_OVER_2, Eqcy_Origin_Long + PI + ONE, &Eqcy_Min_Easting, &temp); } else { Convert_Geodetic_To_Equidistant_Cyl(PI_OVER_2, PI, &Eqcy_Max_Easting, &temp); Eqcy_Min_Easting = -Eqcy_Max_Easting; } Eqcy_Delta_Northing = Ra * PI_OVER_2; } /* End if(!Error_Code) */ return (Error_Code); } /* End Set_Equidistant_Cyl_Parameters */