bool LambertConformalConic::lamccinv(double x, double y, double *lon, double *lat)
{

    double rh1;			/* height above ellipsoid	*/
    double con;			/* sign variable		    */
    double ts;			/* small t			        */
    double theta;		/* angle			        */

    x -= false_easting;
    y = rh - y + false_northing;
    if (ns > 0)
    {
        rh1 = sqrt (x * x + y * y);
        con = 1.0;
    }
    else
    {
        rh1 = -sqrt (x * x + y * y);
        con = -1.0;
    }
    theta = 0.0;
    if (rh1 != 0)
        theta = atan2((con * x),(con * y));
    if ((rh1 != 0) || (ns > 0.0))
    {
        con = 1.0/ns;
        ts = pow((rh1/(r_major * f0)),con);
        *lat = phi2z(e,ts);
    }
    else
        *lat = -HALF_PI;
    *lon = adjust_lon_rad(theta/ns + center_lon);
    return(true);
}
Exemple #2
0
// Polar Stereographic inverse equations--mapping x,y to lat/long
long Projectoid::psinv(
double x,                       // (O) X projection coordinate
double y,                       // (O) Y projection coordinate
double *lon,                    // (I) Longitude
double *lat)                    // (I) Latitude
{
double rh;				// height above ellipsiod
double ts;				// small value t
double temp;			// temporary variable
long   flag;			// error flag

flag = 0;
x = (x - false_easting) * fac;
y = (y - false_northing) * fac;
rh = sqrt(x * x + y * y);
if (ind != 0)
	ts = rh * tcs / (r_major * mcs);
else
	ts = rh * e4 / (r_major * 2.0);
*lat = fac * phi2z(e, ts, &flag);
if (flag != 0)
	return(flag);
if (rh == 0)
	*lon = fac * center_lon;
else
	{
	temp = atan2(x, -y);
	*lon = adjust_lon(fac * temp + center_lon);
	}

return(OK);

}
Exemple #3
0
/* Polar Stereographic inverse equations--mapping x,y to lat/long
  --------------------------------------------------------------*/
long psinv
(
    double x,			/* (O) X projection coordinate 	*/
    double y,			/* (O) Y projection coordinate 	*/
    double *lon,			/* (I) Longitude 		*/
    double *lat			/* (I) Latitude 		*/
)

{
double rh;			/* height above ellipsiod	*/
double ts;			/* small value t		*/
double temp;			/* temporary variable		*/
long   flag;			/* error flag			*/

flag = 0;
x = (x - false_easting) * fac;
y = (y - false_northing) *fac;
rh = sqrt(x * x + y * y);
if (ind != 0)
  ts = rh * tcs/(r_major * mcs);
else
  ts = rh * e4 / (r_major * 2.0);
*lat = fac * phi2z(e,ts,&flag);
if (flag != 0)
   return(flag);
if (rh == 0)
   *lon = fac * center_lon;
else
   {
   temp = atan2(x, -y);
   *lon = adjust_lon(fac *temp + center_lon);
   }

return(GCTP_OK);
}
Exemple #4
0
// Lambert Conformal Conic inverse equations--mapping x,y to lat/long
long Projectoid::lamccinv(
double x,                       // (O) X projection coordinate
double y,                       // (O) Y projection coordinate
double *lon,                    // (I) Longitude
double *lat)                    // (I) Latitude
{
double rh1;                     // height above ellipsoid
double con;                     // sign variable
double ts;                      // small t
double theta;                   // angle
long   flag;                    // error flag

flag = 0;
x -= false_easting;
y = rh - y + false_northing;
if (ns > 0)
	{
	rh1 = sqrt(x * x + y * y);
	con = 1.0;
	}
else
	{
	rh1 = -sqrt(x * x + y * y);
	con = -1.0;
	}

theta = 0.0;
if (rh1 != 0)
	theta = atan2((con * x), (con * y));
if ((rh1 != 0) || (ns > 0.0))
	{
	con = 1.0 / ns;
	ts = pow((rh1 / (r_major * f0)), con);
	*lat = phi2z(e, ts, &flag);
	if (flag != 0)
		return(flag);
	}
else
	*lat = -HALF_PI;
*lon = adjust_lon(theta / ns + center_lon);

return(OK);

}
Exemple #5
0
/* Mercator inverse equations--mapping x,y to lat/long
  --------------------------------------------------*/
int merinv(
double x,			/* (O) X projection coordinate 	*/
double y,			/* (O) Y projection coordinate 	*/
double *lon,			/* (I) Longitude 		*/
double *lat)			/* (I) Latitude 		*/
{
double ts;		/* small t value				*/
long flag;		/* error flag 					*/


/* Inverse equations
  -----------------*/
flag = 0;
x -= false_easting;
y -= false_northing;
ts = exp(-y/(r_major * m1));
*lat = phi2z(e,ts,&flag);
if (flag != 0)
   return(flag);
*lon = adjust_lon(lon_center + x/(r_major * m1));

return(OK);
}