Exemple #1
0
/* Polyconic forward equations--mapping lat,long to x,y
  ---------------------------------------------------*/
long polyfor
(
    double lon,			/* (I) Longitude 		*/
    double lat,			/* (I) Latitude 		*/
    double *x,			/* (O) X projection coordinate 	*/
    double *y			/* (O) Y projection coordinate 	*/
)
{
double sinphi, cosphi;	/* sin and cos value				*/
double con, ml;		/* cone constant, small m			*/
double ms;		/* small m					*/

/* Forward equations
  -----------------*/
con = adjust_lon(lon - lon_center);
if (fabs(lat) <= .0000001)
   {
   *x = false_easting + r_major * con;
   *y = false_northing - r_major * ml0;
   }
else
   {
   gctp_sincos(lat,&sinphi,&cosphi);
   ml = mlfn(e0, e1, e2, e3, lat);
   ms = msfnz(e,sinphi,cosphi);
   con *= sinphi;
   *x = false_easting + r_major * ms * sin(con)/sinphi;
   *y = false_northing + r_major * (ml - ml0 + ms * (1.0 - cos(con))/sinphi);
   }

return(GCTP_OK);
}
Exemple #2
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);
}
Exemple #3
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);

}
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);
}
Exemple #5
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);

}
Exemple #6
0
/* Initialize the Albers projection
  -------------------------------*/
int alberinvint(
double r_maj,                   /* major axis                           */
double r_min,                   /* minor axis                           */
double lat1,                    /* first standard parallel              */
double lat2,                    /* second standard parallel             */
double lon0,                    /* center longitude                     */
double lat0,                    /* center lattitude                     */
double false_east,              /* x offset in meters                   */
double false_north)             /* y offset in meters                   */
{
double sin_po,cos_po;		/* sine and cos values			*/
double con;			/* temporary variable			*/
double temp;			/* temporary variable			*/
double ms1;   		        /* small m 1                            */
double ms2;            		/* small m 2                            */
double qs0;            		/* small q 0                            */
double qs1;            		/* small q 1                            */
double qs2;            		/* small q 2                            */

false_easting = false_east;
false_northing = false_north;
lon_center = lon0;
if (fabs(lat1 + lat2) < EPSLN)
   {
  p_error("Equal latitudes for Standard Parallels on opposite sides of equator"
	  ,"alber-invinit");
   return(31);
   }
r_major = r_maj;
r_minor = r_min;
temp = r_minor / r_major;
es = 1.0 - SQUARE(temp);
e3 = sqrt(es);

tsincos(lat1, &sin_po, &cos_po);
con = sin_po;

ms1 = msfnz(e3,sin_po,cos_po);
qs1 = qsfnz(e3,sin_po,cos_po);

tsincos(lat2,&sin_po,&cos_po);

ms2 = msfnz(e3,sin_po,cos_po);
qs2 = qsfnz(e3,sin_po,cos_po);

tsincos(lat0,&sin_po,&cos_po);

qs0 = qsfnz(e3,sin_po,cos_po);

if (fabs(lat1 - lat2) > EPSLN)
   ns0 = (ms1 * ms1 - ms2 *ms2)/ (qs2 - qs1);
else
   ns0 = con;
c = ms1 * ms1 + ns0 * qs1;
rh = r_major * sqrt(c - ns0 * qs0)/ns0;

/* Report parameters to the user
  -----------------------------*/
ptitle("ALBERS CONICAL EQUAL-AREA");
radius2(r_major, r_minor);
stanparl(lat1,lat2);
cenlonmer(lon_center);
origin(lat0);
offsetp(false_easting,false_northing);

return(OK);
}
Exemple #7
0
/* Initialize the Equidistant Conic projection
  ------------------------------------------*/
int eqconinvint(
double r_maj,			/* major axis			*/
double r_min,			/* minor axis			*/
double lat1,			/* latitude of standard parallel*/
double lat2,			/* latitude of standard parallel*/
double center_lon,		/* center longitude		*/
double center_lat,		/* center latitude		*/
double false_east,		/* x offset in meters		*/
double false_north,		/* y offset in meters		*/
long   mode)			/* which format is present A B	*/
{
double temp;			/* temporary variable		*/
double sinphi,cosphi;		/* sin and cos values		*/
double ms1,ms2;
double ml1,ml2;

/* Place parameters in static storage for common use
  -------------------------------------------------*/
r_major = r_maj;
r_minor = r_min;
lon_center = center_lon;
false_northing = false_north;
false_easting = false_east;

temp = r_minor / r_major;
es = 1.0 - SQUARE(temp);
e = sqrt(es);
e0 = e0fn(es);
e1 = e1fn(es);
e2 = e2fn(es);
e3 = e3fn(es);

tsincos(lat1,&sinphi,&cosphi);
ms1 = msfnz(e,sinphi,cosphi);
ml1 = mlfn(e0, e1, e2, e3, lat1);

/* format B
---------*/
if (mode != 0)
   {
   if (fabs(lat1 + lat2) < EPSLN)
      {
      p_error("Standard Parallels on opposite sides of equator","eqcon-for");
      return(81);
      }
   tsincos(lat2,&sinphi,&cosphi);
   ms2 = msfnz(e,sinphi,cosphi);
   ml2 = mlfn(e0, e1, e2, e3, lat2);
   if (fabs(lat1 - lat2) >= EPSLN)
      ns = (ms1 - ms2) / (ml2 - ml1);
   else
      ns = sinphi;
   }
else
   ns = sinphi;
g = ml1 + ms1/ns;
ml0 = mlfn(e0, e1, e2, e3, center_lat);
rh = r_major * (g - ml0);
   

/* Report parameters to the user
  -----------------------------*/
if (mode != 0)
   {
   ptitle("EQUIDISTANT CONIC"); 
   radius2(r_major, r_minor);
   stanparl(lat1,lat2);
   cenlonmer(lon_center);
   origin(center_lat);
   offsetp(false_easting,false_northing);
   }
else 
   {
   ptitle("EQUIDISTANT CONIC"); 
   radius2(r_major, r_minor);
   stparl1(lat1);
   cenlonmer(lon_center);
   origin(center_lat);
   offsetp(false_easting,false_northing);
   }

return(OK);
}
Exemple #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);
}