| 1 |
/******************************************************************************* |
| 2 |
NAME ALBERS CONICAL EQUAL AREA |
| 3 |
|
| 4 |
PURPOSE: Transforms input longitude and latitude to Easting and Northing |
| 5 |
for the Albers Conical Equal Area projection. The longitude |
| 6 |
and latitude must be in radians. The Easting and Northing |
| 7 |
values will be returned in meters. |
| 8 |
|
| 9 |
PROGRAMMER DATE |
| 10 |
---------- ---- |
| 11 |
T. Mittan, Feb, 1992 |
| 12 |
|
| 13 |
ALGORITHM REFERENCES |
| 14 |
|
| 15 |
1. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological |
| 16 |
Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United |
| 17 |
State Government Printing Office, Washington D.C., 1987. |
| 18 |
|
| 19 |
2. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections", |
| 20 |
U.S. Geological Survey Professional Paper 1453 , United State Government |
| 21 |
Printing Office, Washington D.C., 1989. |
| 22 |
*******************************************************************************/ |
| 23 |
#include <stdio.h> |
| 24 |
#include "cproj.h" |
| 25 |
|
| 26 |
/* Variables common to all subroutines in this code file |
| 27 |
-----------------------------------------------------*/ |
| 28 |
static double r_major; /* major axis */ |
| 29 |
static double r_minor; /* minor axis */ |
| 30 |
static double c; /* constant c */ |
| 31 |
static double e3; /* eccentricity */ |
| 32 |
static double rh; /* heigth above elipsoid */ |
| 33 |
static double ns0; /* ratio between meridians */ |
| 34 |
static double lon_center; /* center longitude */ |
| 35 |
static double false_easting; /* x offset in meters */ |
| 36 |
static double false_northing; /* y offset in meters */ |
| 37 |
|
| 38 |
/* Initialize the Albers projection |
| 39 |
-------------------------------*/ |
| 40 |
int alberforint( |
| 41 |
double r_maj, /* major axis */ |
| 42 |
double r_min, /* minor axis */ |
| 43 |
double lat1, /* first standard parallel */ |
| 44 |
double lat2, /* second standard parallel */ |
| 45 |
double lon0, /* center longitude */ |
| 46 |
double lat0, /* center lattitude */ |
| 47 |
double false_east, /* x offset in meters */ |
| 48 |
double false_north) /* y offset in meters */ |
| 49 |
{ |
| 50 |
double sin_po,cos_po; /* sin and cos values */ |
| 51 |
double con; /* temporary variable */ |
| 52 |
double es,temp; /* eccentricity squared and temp var */ |
| 53 |
double ms1; /* small m 1 */ |
| 54 |
double ms2; /* small m 2 */ |
| 55 |
double qs0; /* small q 0 */ |
| 56 |
double qs1; /* small q 1 */ |
| 57 |
double qs2; /* small q 2 */ |
| 58 |
|
| 59 |
false_easting = false_east; |
| 60 |
false_northing = false_north; |
| 61 |
lon_center = lon0; |
| 62 |
if (fabs(lat1 + lat2) < EPSLN) |
| 63 |
{ |
| 64 |
p_error("Equal latitudes for St. Parallels on opposite sides of equator", |
| 65 |
"alber-forinit"); |
| 66 |
return(31); |
| 67 |
} |
| 68 |
r_major = r_maj; |
| 69 |
r_minor = r_min; |
| 70 |
temp = r_minor / r_major; |
| 71 |
es = 1.0 - SQUARE(temp); |
| 72 |
e3 = sqrt(es); |
| 73 |
|
| 74 |
tsincos(lat1, &sin_po, &cos_po); |
| 75 |
con = sin_po; |
| 76 |
|
| 77 |
ms1 = msfnz(e3,sin_po,cos_po); |
| 78 |
qs1 = qsfnz(e3,sin_po,cos_po); |
| 79 |
|
| 80 |
tsincos(lat2,&sin_po,&cos_po); |
| 81 |
|
| 82 |
ms2 = msfnz(e3,sin_po,cos_po); |
| 83 |
qs2 = qsfnz(e3,sin_po,cos_po); |
| 84 |
|
| 85 |
tsincos(lat0,&sin_po,&cos_po); |
| 86 |
|
| 87 |
qs0 = qsfnz(e3,sin_po,cos_po); |
| 88 |
|
| 89 |
if (fabs(lat1 - lat2) > EPSLN) |
| 90 |
ns0 = (ms1 * ms1 - ms2 *ms2)/ (qs2 - qs1); |
| 91 |
else |
| 92 |
ns0 = con; |
| 93 |
c = ms1 * ms1 + ns0 * qs1; |
| 94 |
rh = r_major * sqrt(c - ns0 * qs0)/ns0; |
| 95 |
|
| 96 |
/* Report parameters to the user |
| 97 |
-----------------------------*/ |
| 98 |
ptitle("ALBERS CONICAL EQUAL-AREA"); |
| 99 |
radius2(r_major, r_minor); |
| 100 |
stanparl(lat1,lat2); |
| 101 |
cenlonmer(lon_center); |
| 102 |
origin(lat0); |
| 103 |
offsetp(false_easting,false_northing); |
| 104 |
|
| 105 |
return(OK); |
| 106 |
} |
| 107 |
|
| 108 |
/* Albers Conical Equal Area forward equations--mapping lat,long to x,y |
| 109 |
-------------------------------------------------------------------*/ |
| 110 |
int alberfor( |
| 111 |
double lon, /* (I) Longitude */ |
| 112 |
double lat, /* (I) Latitude */ |
| 113 |
double *x, /* (O) X projection coordinate */ |
| 114 |
double *y) /* (O) Y projection coordinate */ |
| 115 |
{ |
| 116 |
double sin_phi,cos_phi; /* sine and cos values */ |
| 117 |
double qs; /* small q */ |
| 118 |
double theta; /* angle */ |
| 119 |
double rh1; /* height above ellipsoid */ |
| 120 |
|
| 121 |
tsincos(lat,&sin_phi,&cos_phi); |
| 122 |
qs = qsfnz(e3,sin_phi,cos_phi); |
| 123 |
rh1 = r_major * sqrt(c - ns0 * qs)/ns0; |
| 124 |
theta = ns0 * adjust_lon(lon - lon_center); |
| 125 |
*x = rh1 * sin(theta) + false_easting; |
| 126 |
*y = rh - rh1 * cos(theta) + false_northing; |
| 127 |
|
| 128 |
return(OK); |
| 129 |
} |