/* Lambert Conformal conic forward equations--mapping lat,long to x,y
  -----------------------------------------------------------------*/
bool LambertConformalConic::lamccfor(double lon, double lat, double *x, double *y)
{

    double con;                     /* temporary angle variable             */
    double rh1;                     /* height above ellipsoid               */
    double sinphi;                  /* sin value                            */
    double theta;                   /* angle                                */
    double ts;                      /* small value t                        */

    con  = fabs( fabs(lat) - PIO2);
    if (con > EPSLN)
    {
        sinphi = sin(lat);
        ts = tsfnz(e,lat,sinphi);
        rh1 = r_major * f0 * pow(ts,ns);
    }
    else
    {
        con = lat * ns;
        if (con <= 0)
        {
            return(false);
        }
        rh1 = 0;
    }

    theta = ns * adjust_lon_rad(lon - center_lon);
    *x = rh1 * sin(theta) + false_easting;
    *y = rh - rh1 * cos(theta) + false_northing;

    return(true);
}
Beispiel #2
0
/* Polar Stereographic forward equations--mapping lat,long to x,y
  --------------------------------------------------------------*/
int psfor(
double lon,			/* (I) Longitude 		*/
double lat,			/* (I) Latitude 		*/
double *x,			/* (O) X projection coordinate 	*/
double *y)			/* (O) Y projection coordinate 	*/

{
double con1;			/* adjusted longitude		*/
double con2;			/* adjusted latitude		*/
double rh;			/* height above ellipsoid	*/
double sinphi;			/* sin value			*/
double ts;			/* value of small t		*/

con1 = fac * adjust_lon(lon - center_lon);
con2 = fac * lat;
sinphi = sin(con2);
ts = tsfnz(e,con2,sinphi);
if (ind != 0)
   rh = r_major * mcs * ts / tcs;
else
   rh = 2.0 * r_major * ts / e4;
*x = fac * rh * sin(con1) + false_easting;
*y = -fac * rh * cos(con1) + false_northing;;

return(OK);
}
Beispiel #3
0
/* 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);
}
Beispiel #4
0
// 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);

}
Beispiel #5
0
/* Lambert Conformal conic forward equations--mapping lat,long to x,y
  -----------------------------------------------------------------*/
int lamccfor(
double lon,                     /* (I) Longitude                */
double lat,                     /* (I) Latitude                 */
double *x,                      /* (O) X projection coordinate  */
double *y)                      /* (O) Y projection coordinate  */

{
double con;                     /* temporary angle variable             */
double rh1;                     /* height above ellipsoid               */
double sinphi;                  /* sin value                            */
double theta;                   /* angle                                */
double ts;                      /* small value t                        */

con  = fabs( fabs(lat) - HALF_PI);
if (con > EPSLN)
  {
  sinphi = sin(lat);
  ts = tsfnz(e,lat,sinphi);
  rh1 = r_major * f0 * pow(ts,ns);
  }
else
  {
  con = lat * ns;
  if (con <= 0)
    {
    p_error("Point can not be projected","lamcc-for");
    return(44);
    }
  rh1 = 0;
  }
theta = ns * adjust_lon(lon - center_lon);
*x = rh1 * sin(theta) + false_easting;
*y = rh - rh1 * cos(theta) + false_northing;

return(OK);
}
void LambertConformalConic::Initialize(double r_maj, double r_min, double stdlat1, double stdlat2, double c_lon, double c_lat, int imagewidth, int imageheight, int corrX, int corrY)
{
    /* double r_maj;                   major axis                           */
    /* double r_min;                   minor axis                           */
    /* double lat1;                    first standard parallel              */
    /* double lat2;                    second standard parallel             */
    /* double c_lon;                   center longitude                     */
    /* double c_lat;                   center latitude                      */
    /* double false_east;              x offset in meters                   */
    /* double false_north;             y offset in meters                   */

    qDebug()<< QString("paralel1 = %1").arg(stdlat1);
    qDebug()<< QString("paralel2 = %1").arg(stdlat2);
    qDebug()<< QString("c_lon    = %1").arg(c_lon);
    qDebug()<< QString("c_lat    = %1").arg(c_lat);
    qDebug()<< QString("imagewidth  = %1").arg(imagewidth);
    qDebug()<< QString("imageheight = %1").arg(imageheight);
    qDebug()<< QString("corr X      = %1").arg(corrX);
    qDebug()<< QString("corr Y      = %1").arg(corrY);





    image_width = imagewidth;
    image_height = imageheight;

    double lat1 = stdlat1*PI/180.0;
    double lat2 = stdlat2*PI/180.0;

    center_lon = c_lon * PI/180.0;
    center_lat = c_lat * PI/180.0;
    r_major = r_maj;
    r_minor = r_min;
    f0 = F;

    if (imagewidth != imageptrs->ptrimageProjection->width() || imageheight != imageptrs->ptrimageProjection->height())
    {
        delete imageptrs->ptrimageProjection;
        imageptrs->ptrimageProjection = new QImage(imagewidth, imageheight, QImage::Format_ARGB32);
        imageptrs->ptrimageProjection->fill(qRgba(0, 0, 0, 250));
    }


    int mapwh;

    if (imagewidth > imageheight)
    {
        mapwh = imageheight;
        mapdeltax = (imagewidth - imageheight)/2;
        mapdeltay = 0;
    }
    else if(imageheight > imagewidth)
    {

        mapwh = imagewidth;
        mapdeltay = (imageheight - imagewidth)/2;
        mapdeltax = 0;
    }
    else
    {
        mapwh = imageheight;
        mapdeltax = 0;
        mapdeltay = 0;
    }

    map_width = mapwh;
    map_height = mapwh;


    double sin_po;                  /* sin value                            */
    double cos_po;                  /* cos value                            */
    double con;                     /* temporary variable                   */
    double ms1;                     /* small m 1                            */
    double ms2;                     /* small m 2                            */
    double temp;                    /* temporary variable                   */
    double ts0;                     /* small t 0                            */
    double ts1;                     /* small t 1                            */
    double ts2;                     /* small t 2                            */

    r_major = r_maj;
    r_minor = r_min;
    false_northing = corrX * 10000.0;
    false_easting = corrY * 10000.0;

    /* Standard Parallels cannot be equal and on opposite sides of the equator
    ------------------------------------------------------------------------*/
    if (fabs(lat1+lat2) < EPSLN)
       {
           qDebug() << "Equal latitudes for St. Parallels on opposite sides of equator";
           return;
       }

    temp = r_minor / r_major;
    es = 1.0 - temp*temp;
    e = sqrt(es);

#ifdef WIN32 && __GNUC__
    sin_po = sin(lat1);
    cos_po = cos(lat1);
#else
    sincos(lat1,&sin_po,&cos_po);
#endif

    con = sin_po;
    ms1 = msfnz(e,sin_po,cos_po);
    ts1 = tsfnz(e,lat1,sin_po);

#ifdef WIN32 && __GNUC__
    sin_po = sin(lat2);
    cos_po = cos(lat2);
#else
    sincos(lat2,&sin_po,&cos_po);
#endif

    ms2 = msfnz(e,sin_po,cos_po);
    ts2 = tsfnz(e,lat2,sin_po);
    sin_po = sin(center_lat);
    ts0 = tsfnz(e,center_lat,sin_po);

    if (fabs(lat1 - lat2) > EPSLN)
        ns = log (ms1/ms2)/ log (ts1/ts2);
    else
        ns = con;
    f0 = ms1 / (ns * pow(ts1,ns));
    rh = r_major * f0 * pow(ts0,ns);
    calc_map_extents();

    qDebug() << QString("LambertConformalConic::Initialize %1 x %2 ").arg(imagewidth).arg(imageheight);
}
Beispiel #7
0
// Initialize the Lambert Conformal Conic projection
long Projectoid::lamccinvint(
double r_maj,                           // major axis
double r_min,                           // minor axis
double lat1,                            // first standard parallel
double lat2,                            // second standard parallel
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 sin_po;                          // sin value
double cos_po;                          // cos value
double con;                             // temporary sin value
double ms1;                             // small m 1
double ms2;                             // small m 2
double temp;                            // temporary variable
double ts0;                             // small t 0
double ts1;                             // small t 1
double ts2;                             // small t 2

r_major = r_maj;
r_minor = r_min;
false_easting = false_east;
false_northing = false_north;

// Standard Parallels cannot be equal and on opposite sides of the equator
if (fabs(lat1 + lat2) < EPSLN)
	{
	p_error("Equal Latitiudes for St. Parallels on opposite sides of equator", "lamcc-inv");
	return(41);
	}

temp = r_minor / r_major;
es = 1.0 - SQUARE(temp);
e = sqrt(es);

center_lon = c_lon;
center_lat = c_lat;
sincos(lat1, &sin_po, &cos_po);
con = sin_po;
ms1 = msfnz(e, sin_po, cos_po);
ts1 = tsfnz(e, lat1, sin_po);
sincos(lat2, &sin_po, &cos_po);
ms2 = msfnz(e, sin_po, cos_po);
ts2 = tsfnz(e, lat2, sin_po);
sin_po = sin(center_lat);
ts0 = tsfnz(e, center_lat, sin_po);

if (fabs(lat1 - lat2) > EPSLN)
	ns = log(ms1 / ms2) / log(ts1 / ts2);
else
	ns = con;
f0 = ms1 / (ns * pow(ts1, ns));
rh = r_major * f0 * pow(ts0, ns);

// Report parameters to the user
ptitle("LAMBERT CONFORMAL CONIC"); 
radius2(r_major, r_minor);
stanparl(lat1, lat2);
cenlonmer(center_lon);
origin(c_lat);
offsetp(false_easting, false_northing);
InverseOK[WCS_PROJECTIONCODE_LAMCC] = 1;
InverseTransform = &Projectoid::lamccinv;

return(OK);

}
Beispiel #8
0
/* Initialize the Lambert Conformal conic projection
  ------------------------------------------------*/
int lamccforint(
double r_maj,                   /* major axis                           */
double r_min,                   /* minor axis                           */
double lat1,                    /* first standard parallel              */
double lat2,                    /* second standard parallel             */
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 sin_po;                  /* sin value                            */
double cos_po;                  /* cos value                            */
double con;                     /* temporary variable                   */
double ms1;                     /* small m 1                            */
double ms2;                     /* small m 2                            */
double temp;                    /* temporary variable                   */
double ts0;                     /* small t 0                            */
double ts1;                     /* small t 1                            */
double ts2;                     /* small t 2                            */
r_major = r_maj;
r_minor = r_min;
false_northing = false_north;
false_easting = false_east;

/* Standard Parallels cannot be equal and on opposite sides of the equator
------------------------------------------------------------------------*/
if (fabs(lat1+lat2) < EPSLN)
   {
   p_error("Equal Latitiudes for St. Parallels on opposite sides of equator",
	   "lamcc-for");
   return(41);
   }
   
temp = r_minor / r_major;
es = 1.0 - SQUARE(temp);
e = sqrt(es);

center_lon = c_lon;
center_lat = c_lat;
tsincos(lat1,&sin_po,&cos_po);
con = sin_po;
ms1 = msfnz(e,sin_po,cos_po);
ts1 = tsfnz(e,lat1,sin_po);
tsincos(lat2,&sin_po,&cos_po);
ms2 = msfnz(e,sin_po,cos_po);
ts2 = tsfnz(e,lat2,sin_po);
sin_po = sin(center_lat);
ts0 = tsfnz(e,center_lat,sin_po);

if (fabs(lat1 - lat2) > EPSLN)
    ns = log (ms1/ms2)/ log (ts1/ts2);
else
    ns = con;
f0 = ms1 / (ns * pow(ts1,ns));
rh = r_major * f0 * pow(ts0,ns);


/* Report parameters to the user
  -----------------------------*/
ptitle("LAMBERT CONFORMAL CONIC");
radius2(r_major, r_minor);
stanparl(lat1,lat2);
cenlonmer(center_lon);
origin(c_lat);
offsetp(false_easting,false_northing);

return(OK);
}