1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
/*******************************************************************************
NAME LAMBERT CONFORMAL CONIC
PURPOSE: Transforms input Easting and Northing to longitude and
latitude for the Lambert Conformal Conic projection. The
Easting and Northing must be in meters. The longitude
and latitude values will be returned in radians.
PROGRAMMER DATE
---------- ----
T. Mittan 2-26-93
ALGORITHM REFERENCES
1. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
State Government Printing Office, Washington D.C., 1987.
2. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections",
U.S. Geological Survey Professional Paper 1453 , United State Government
Printing Office, Washington D.C., 1989.
*******************************************************************************/
#include "cproj.h"
/* Variables common to all subroutines in this code file
-----------------------------------------------------*/
static double r_major; /* major axis */
static double r_minor; /* minor axis */
static double es; /* eccentricity squared */
static double e; /* eccentricity */
static double center_lon; /* center longituted */
static double center_lat; /* cetner latitude */
static double ns; /* ratio of angle between meridian*/
static double f0; /* flattening of ellipsoid */
static double rh; /* height above ellipsoid */
static double false_easting; /* x offset in meters */
static double false_northing; /* y offset in meters */
/* Initialize the Lambert Conformal Conic projection
------------------------------------------------*/
long lamccinvint(r_maj,r_min,lat1,lat2,c_lon,c_lat,false_east,false_north)
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);
return(OK);
}
/* Lambert Conformal Conic inverse equations--mapping x,y to lat/long
-----------------------------------------------------------------*/
long lamccinv(x , y, lon, lat)
double x; /* (O) X projection coordinate */
double y; /* (O) Y projection coordinate */
double *lon; /* (I) Longitude */
double *lat; /* (I) Latitude */
{
double rh1; /* height above ellipsoid */
double con; /* sign variable */
double ts; /* small t */
double theta; /* angle */
long flag; /* error flag */
flag = 0;
x -= false_easting;
y = rh - y + false_northing;
if (ns > 0)
{
rh1 = sqrt (x * x + y * y);
con = 1.0;
}
else
{
rh1 = -sqrt (x * x + y * y);
con = -1.0;
}
theta = 0.0;
if (rh1 != 0)
theta = atan2((con * x),(con * y));
if ((rh1 != 0) || (ns > 0.0))
{
con = 1.0/ns;
ts = pow((rh1/(r_major * f0)),con);
*lat = phi2z(e,ts,&flag);
if (flag != 0)
return(flag);
}
else
*lat = -HALF_PI;
*lon = adjust_lon(theta/ns + center_lon);
return(OK);
}
|