| 1 |
/******************************************************************************* |
| 2 |
NAME Cylinderical Equal Area |
| 3 |
|
| 4 |
PURPOSE: Transforms input Easting and Northing to longitude and |
| 5 |
latitude for the Cylinderical Equal Area projection. |
| 6 |
The Easting and Northing must be in meters. The longitude |
| 7 |
and latitude values will be returned in radians. |
| 8 |
|
| 9 |
|
| 10 |
PROGRAMMER DATE |
| 11 |
---------- ---- |
| 12 |
D. Steinwand, EROS Nov, 1991 |
| 13 |
T. Mittan Mar, 1993 |
| 14 |
Abe Taaheri/Emergent Info Tech, Inc. June, 2000 |
| 15 |
Abe Taaheri/L3 Comm. Analyrics Corp. Oct. 2002 Modified to support both |
| 16 |
spherical and ellipsoid |
| 17 |
models of earth for |
| 18 |
Cylinderical Equal Area |
| 19 |
projection. |
| 20 |
ALGORITHM REFERENCES |
| 21 |
|
| 22 |
1. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological |
| 23 |
Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United |
| 24 |
State Government Printing Office, Washington D.C., 1987. |
| 25 |
|
| 26 |
2. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections", |
| 27 |
U.S. Geological Survey Professional Paper 1453 , United State Government |
| 28 |
Printing Office, Washington D.C., 1989. |
| 29 |
*******************************************************************************/ |
| 30 |
#include <stdio.h> |
| 31 |
#include "cproj.h" |
| 32 |
|
| 33 |
/* Variables common to all subroutines in this code file |
| 34 |
-----------------------------------------------------*/ |
| 35 |
static double r_major; /* major axis */ |
| 36 |
static double r_minor; /* minor axis */ |
| 37 |
static double e; /* eccentricity */ |
| 38 |
static double es; /* eccentricity squared */ |
| 39 |
static double e_p4; /* eccentricity's 4th power */ |
| 40 |
static double e_p6; /* eccentricity's 6th power */ |
| 41 |
static double lon_center; /* Center longitude (projection center) */ |
| 42 |
static double lat_truesc; /* latitude of true scale */ |
| 43 |
static double false_northing; /* y offset in meters */ |
| 44 |
static double false_easting; /* x offset in meters */ |
| 45 |
static double cosphi1; /* cos of latitude of true scale */ |
| 46 |
static double sinphi1; /* sin of latitude of true scale */ |
| 47 |
static double kz; /* K_0 for Cylinderical Equal Area proj.*/ |
| 48 |
static double qp; /* qp for Cylinderical Equal Area proj.*/ |
| 49 |
static long ind; /* spherical flag */ |
| 50 |
|
| 51 |
/* Initialize the Cylinderical Equal Area projection |
| 52 |
-----------------------------------*/ |
| 53 |
int bceainvint( |
| 54 |
double r_maj, /* major axis */ |
| 55 |
double r_min, /* minor axis */ |
| 56 |
double center_lon, /* center longitude */ |
| 57 |
double center_lat, /* center latitude */ |
| 58 |
double false_east, /* x offset in meters */ |
| 59 |
double false_north) /* y offset in meters */ |
| 60 |
{ |
| 61 |
double temp; /* temporary variable */ |
| 62 |
|
| 63 |
/* Place parameters in static storage for common use |
| 64 |
-------------------------------------------------*/ |
| 65 |
r_major = r_maj; |
| 66 |
r_minor = r_min; |
| 67 |
lon_center = center_lon; |
| 68 |
lat_truesc = center_lat; |
| 69 |
false_northing = false_north; |
| 70 |
false_easting = false_east; |
| 71 |
|
| 72 |
|
| 73 |
temp = r_minor / r_major; |
| 74 |
es = 1.0 - SQUARE(temp); |
| 75 |
e = sqrt(es); |
| 76 |
e_p4 = es * es; |
| 77 |
e_p6 = e_p4 *es; |
| 78 |
|
| 79 |
if(e < 0.00001) |
| 80 |
{ |
| 81 |
ind = 1; |
| 82 |
qp = 2.0; |
| 83 |
} |
| 84 |
else |
| 85 |
{ |
| 86 |
ind = 0; |
| 87 |
qp = (1.0 - es)*((1.0/(1.0 - es))-(1.0/(2.0*e))*log((1.0 - e)/(1.0 + e))); |
| 88 |
} |
| 89 |
|
| 90 |
cosphi1 = cos(lat_truesc); |
| 91 |
sinphi1 = sin(lat_truesc); |
| 92 |
kz = cosphi1/(sqrt(1.0 - (es*sinphi1*sinphi1))); |
| 93 |
|
| 94 |
/* Report parameters to the user |
| 95 |
-----------------------------*/ |
| 96 |
ptitle("Cylinderical Equal Area"); |
| 97 |
radius2(r_major, r_minor); |
| 98 |
cenlonmer(lon_center); |
| 99 |
true_scale(lat_truesc); |
| 100 |
offsetp(false_easting,false_northing); |
| 101 |
return(OK); |
| 102 |
} |
| 103 |
|
| 104 |
|
| 105 |
/* Cylinderical Equal Area inverse equations--mapping x,y to lat/long |
| 106 |
--------------------------------------------------*/ |
| 107 |
int bceainv( |
| 108 |
double x, /* (O) X projection coordinate */ |
| 109 |
double y, /* (O) Y projection coordinate */ |
| 110 |
double *lon, /* (I) Longitude */ |
| 111 |
double *lat) /* (I) Latitude */ |
| 112 |
{ |
| 113 |
double beta; |
| 114 |
|
| 115 |
/* Inverse equations |
| 116 |
-----------------*/ |
| 117 |
x -= false_easting; |
| 118 |
y -= false_northing; |
| 119 |
|
| 120 |
if( ind != 0) /* sphere */ |
| 121 |
{ |
| 122 |
*lat = asin( y * cosphi1 / r_major); /* we may need to use asinz dfined in |
| 123 |
cproj.c instead of asin */ |
| 124 |
*lon = adjust_lon(lon_center + x/(r_major * cosphi1)); |
| 125 |
} |
| 126 |
else /* ellipsoid */ |
| 127 |
{ |
| 128 |
beta = asin(2.0 * y * kz/(r_major * qp)); |
| 129 |
|
| 130 |
*lat = beta +(((es / 3.0) + ((31.0/180.0) * e_p4)+ |
| 131 |
((517.0/5040.0) * e_p6)) * sin(2.0*beta))+ |
| 132 |
((((23.0/360.0) * e_p4)+ |
| 133 |
((251.0/3780.0) * e_p6)) * sin(4.0*beta))+ |
| 134 |
(((761.0/45360.0) * e_p6) * sin(6.0*beta)); |
| 135 |
*lon = adjust_lon(lon_center + x/(r_major * kz)); |
| 136 |
} |
| 137 |
|
| 138 |
return(OK); |
| 139 |
} |