Ejemplo n.º 1
0
/* Initialize the Mercator projection
  -----------------------------------*/
int merinvint(
double r_maj,			/* major axis			*/
double r_min,			/* minor axis			*/
double center_lon,		/* center longitude		*/
double center_lat,		/* center latitude		*/
double false_east,		/* x offset in meters		*/
double false_north)		/* y offset in meters		*/
{
double temp;			/* temporary variable		*/
double e0fn(),e1fn(),e2fn(),e3fn(); 	/* 	functions	*/

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

temp = r_minor / r_major;
es = 1.0 - SQUARE(temp);
e = sqrt(es);
m1 = cos(center_lat)/(sqrt(1.0 - es * sin(center_lat) * sin(center_lat)));

/* Report parameters to the user
  -----------------------------*/
ptitle("MERCATOR"); 
radius2(r_major, r_minor);
cenlonmer(lon_center);
origin(lat_origin);
offsetp(false_easting,false_northing);
return(OK);
}
Ejemplo n.º 2
0
/* Initialize the Equirectangular projection
  ----------------------------------------*/
int equiforint(
double r_maj,			/* major axis			*/
double center_lon,		/* center longitude		*/
double lat1,			/* latitude of true scale	*/
double false_east,		/* x offset in meters		*/
double false_north)		/* y offset in meters		*/
{

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

/* Report parameters to the user
  -----------------------------*/
ptitle("EQUIRECTANGULAR"); 
radius(r_major);
cenlonmer(lon_center);
origin(lat_origin);
offsetp(false_easting,false_northing);
return(OK);
}
Ejemplo n.º 3
0
/* 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);
}
Ejemplo n.º 4
0
/* 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);
}
Ejemplo n.º 5
0
/* Initialize the Azimuthal projection
  ----------------------------------*/
int aziminvint(
double r_maj,			/* major axis			*/
double center_lon,		/* center longitude		*/
double center_lat,		/* 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_major = r_maj;
lon_center = center_lon;
lat_origin = center_lat;
false_northing = false_north;
false_easting = false_east;

tsincos(center_lat,&sin_p12,&cos_p12);

/* Report parameters to the user
  -----------------------------*/
ptitle("AZIMUTHAL EQUIDISTANT"); 
radius(r_major);
cenlonmer(lon_center);
origin(lat_origin);
offsetp(false_easting,false_northing);
return(OK);
}
Ejemplo n.º 6
0
/* 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);
}
Ejemplo n.º 7
0
/* 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);
}
Ejemplo n.º 8
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);
}
Ejemplo n.º 9
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);

}
Ejemplo n.º 10
0
/* Initialize the Cylinderical Equal Area projection
  -------------------------------------------------*/
int ceaforint(
double r_maj,			/* major axis			*/
double r_min,			/* minor axis			*/
double center_lon,		/* center longitude		*/
double center_lat,		/* center latitude		*/
double false_east,		/* x offset in meters		*/
double false_north)		/* y offset in meters		*/
{
double temp;			/* temporary variable		*/

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

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

 if(es < 0.00001)
   {
     ind = 1;
   }
 else
   {
     ind = 0;
   }

 cosphi1 = cos(lat_truesc);
 sinphi1 = sin(lat_truesc);
 kz = cosphi1/(sqrt(1.0 - (es*sinphi1*sinphi1)));

/* Report parameters to the user
  -----------------------------*/
ptitle("Cylinderical Equal Area"); 
radius2(r_major, r_minor);
cenlonmer(lon_center);
true_scale(lat_truesc);
offsetp(false_easting,false_northing);
return(OK);
}
Ejemplo n.º 11
0
/* 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);
}
Ejemplo n.º 12
0
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);
}
Ejemplo n.º 13
0
// Initialize the POLYCONIC projection
long Projectoid::polyinvint(
double r_maj,					// major axis
double r_min,					// minor axis
double center_lon_init,			// center longitude
double center_lat_init,			// center latitude
double false_east,				// x offset in meters
double false_north)				// y offset in meters
{
double temp;                    // temporary variable

// Place parameters in static storage for common use
r_major = r_maj;
r_minor = r_min;
lon_center = center_lon_init;
lat_origin = center_lat_init;
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);
ml0 = mlfn(e0, e1, e2, e3, lat_origin);

// Report parameters to the user
ptitle("POLYCONIC"); 
radius2(r_major, r_minor);
cenlonmer(lon_center);
origin(lat_origin);
offsetp(false_easting, false_northing);
InverseOK[WCS_PROJECTIONCODE_POLYC] = 1;
InverseTransform = &Projectoid::polyinv;

return(OK);

}
Ejemplo n.º 14
0
/* Initialize the POLYCONIC projection
  ----------------------------------*/
long polyforint
(
    double r_maj,			/* major axis			*/
    double r_min,			/* minor axis			*/
    double center_lon,		/* center longitude		*/
    double center_lat,		/* center latitude		*/
    double false_east,		/* x offset in meters		*/
    double false_north		/* y offset in meters		*/
)
{
double temp;			/* temporary variable		*/

/* Place parameters in static storage for common use
  -------------------------------------------------*/
r_major = r_maj;
r_minor = r_min;
lon_center = center_lon;
lat_origin = center_lat;
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);
ml0 = mlfn(e0, e1, e2, e3, lat_origin);

/* Report parameters to the user
  -----------------------------*/
ptitle("POLYCONIC"); 
radius2(r_major, r_minor);
cenlonmer(lon_center);
origin(lat_origin);
offsetp(false_easting,false_northing);
return(GCTP_OK);
}
Ejemplo n.º 15
0
/* 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);
}
Ejemplo n.º 16
0
// 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);

}
Ejemplo n.º 17
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);

}
Ejemplo n.º 18
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);
}
Ejemplo n.º 19
0
/*
!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;
}
Ejemplo n.º 20
0
/* 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);
}
Ejemplo n.º 21
0
// 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);

}
Ejemplo n.º 22
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);
}
Ejemplo n.º 23
0
Archivo: somfor.c Proyecto: dmm/cegis
long somforint( double r_major, double r_minor, long satnum, long path, double alf_in, double lon, double false_east, 
		double false_north, double time, long start1, long flag)
	
/*double r_major;		major axis
double r_minor;			minor axis
long satnum;			Landsat satellite number (1,2,3,4,5) 
long path;			Landsat path number 
double alf_in;
double lon;
double false_east;		x offset in meters
double false_north;		y offset in meters
double time;
long   start1;
long   flag;			*/
{
long i;
double alf,e2c,e2s,one_es;
double dlam,fb,fa2,fa4,fc1,fc3,suma2,suma4,sumc1,sumc3,sumb;

/* Place parameters in static storage for common use
  -------------------------------------------------*/
false_easting = false_east;
false_northing = false_north;
a = r_major;
b = r_minor;
es = 1.0 - SQUARE(r_minor/r_major);
if (flag != 0)
  {
  alf = alf_in;
  p21 = time / 1440.0;
  lon_center = lon; 
  start =  start1;
  }
else
  {
  if (satnum < 4)
    {
    alf = 99.092 * D2R;
    p21=103.2669323/1440.0;
    lon_center = (128.87 - (360.0/251.0 * path)) * D2R;
    }
  else
    {
    alf = 98.2 * D2R;
    p21=98.8841202/1440.0;
    lon_center = (129.30 - (360.0/233.0 * path)) * D2R;
    /*
    lon_center = (-129.30557714 - (360.0/233.0 * path)) * D2R;
    */
    }
  start=0.0;
  }

/* Report parameters to the user (to device set up prior to this call)
  -------------------------------------------------------------------*/
ptitle("SPACE OBLIQUE MERCATOR");
radius2(a,b);
if (flag == 0)
   {
   genrpt_long(path,     "Path Number:    ");
   genrpt_long(satnum,   "Satellite Number:    ");
   }
genrpt(alf*R2D,       "Inclination of Orbit:    ");
genrpt(lon_center*R2D,"Longitude of Ascending Orbit:    ");
offsetp(false_easting,false_northing);
genrpt(LANDSAT_RATIO, "Landsat Ratio:    ");

ca=cos(alf);
if (fabs(ca)<1.e-9) ca=1.e-9;
sa=sin(alf);
e2c=es*ca*ca;
e2s=es*sa*sa;
w=(1.0-e2c)/(1.0-es);
w=w*w-1.0;
one_es=1.0-es;
q = e2s / one_es;
t = (e2s*(2.0-es)) / (one_es*one_es);
u= e2c / one_es;
xj = one_es*one_es*one_es;
dlam=0.0;
som_series(&fb,&fa2,&fa4,&fc1,&fc3,&dlam);
suma2=fa2;
suma4=fa4;
sumb=fb;
sumc1=fc1;
sumc3=fc3;
for(i=9;i<=81;i+=18)
   {
   dlam=i;
   som_series(&fb,&fa2,&fa4,&fc1,&fc3,&dlam);
   suma2=suma2+4.0*fa2;
   suma4=suma4+4.0*fa4;
   sumb=sumb+4.0*fb;
   sumc1=sumc1+4.0*fc1;
   sumc3=sumc3+4.0*fc3;
   }
for(i=18; i<=72; i+=18)
   {
   dlam=i;
   som_series(&fb,&fa2,&fa4,&fc1,&fc3,&dlam);
   suma2=suma2+2.0*fa2;
   suma4=suma4+2.0*fa4;
   sumb=sumb+2.0*fb;
   sumc1=sumc1+2.0*fc1;
   sumc3=sumc3+2.0*fc3;
   }

dlam=90.0;
som_series(&fb,&fa2,&fa4,&fc1,&fc3,&dlam);
suma2=suma2+fa2;
suma4=suma4+fa4;
sumb=sumb+fb;
sumc1=sumc1+fc1;
sumc3=sumc3+fc3;
a2=suma2/30.0;
a4=suma4/60.0;
b=sumb/30.0;
c1=sumc1/15.0;
c3=sumc3/45.0;
return(OK);
}
Ejemplo n.º 24
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);
}