| 1 |
/******************************************************************************* |
| 2 |
NAME ALASKA CONFORMAL |
| 3 |
|
| 4 |
PURPOSE: Transforms input longitude and latitude to Easting and Northing |
| 5 |
for the Alaska Conformal projection. The longitude and latitude |
| 6 |
must be in radians. The Easting and Northing values will |
| 7 |
be returned in meters. |
| 8 |
|
| 9 |
PROGRAMMER DATE |
| 10 |
---------- ---- |
| 11 |
T. Mittan March, 1993 |
| 12 |
|
| 13 |
This function was adapted from the Alaska Conformal projection code |
| 14 |
(FORTRAN) in the General Cartographic Transformation Package software |
| 15 |
which is available from the U.S. Geological Survey National Mapping Division. |
| 16 |
|
| 17 |
ALGORITHM REFERENCES |
| 18 |
|
| 19 |
1. "New Equal-Area Map Projections for Noncircular Regions", John P. Snyder, |
| 20 |
The American Cartographer, Vol 15, No. 4, October 1988, pp. 341-355. |
| 21 |
|
| 22 |
2. 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 |
3. "Software Documentation for GCTP General Cartographic Transformation |
| 27 |
Package", U.S. Geological Survey National Mapping Division, May 1982. |
| 28 |
*******************************************************************************/ |
| 29 |
#include <stdio.h> |
| 30 |
#include "cproj.h" |
| 31 |
|
| 32 |
/* Variables common to all subroutines in this code file |
| 33 |
-----------------------------------------------------*/ |
| 34 |
static double r_major; /* major axis */ |
| 35 |
static double r_minor; /* minor axis */ |
| 36 |
static double lon_center; /* Center longitude (projection center) */ |
| 37 |
static double lat_center; /* center latitude */ |
| 38 |
static double false_easting; /* x offset in meters */ |
| 39 |
static double false_northing; /* y offset in meters */ |
| 40 |
static double acoef[7]; |
| 41 |
static double bcoef[7]; |
| 42 |
static double sin_p26; |
| 43 |
static double cos_p26; |
| 44 |
static double e; |
| 45 |
static long n; |
| 46 |
|
| 47 |
/* Initialize the ALASKA CONFORMAL projection |
| 48 |
-----------------------------------------*/ |
| 49 |
int alconforint( |
| 50 |
double r_maj, /* Major axis */ |
| 51 |
double r_min, /* Minor axis */ |
| 52 |
double false_east, /* x offset in meters */ |
| 53 |
double false_north) /* y offset in meters */ |
| 54 |
{ |
| 55 |
double es; |
| 56 |
double chi; |
| 57 |
double esphi; |
| 58 |
|
| 59 |
/* Place parameters in static storage for common use |
| 60 |
-------------------------------------------------*/ |
| 61 |
r_major = r_maj; |
| 62 |
r_minor = r_min; |
| 63 |
false_easting = false_east; |
| 64 |
false_northing = false_north; |
| 65 |
lon_center = -152.0 * D2R; |
| 66 |
lat_center = 64.0 * D2R; |
| 67 |
n = 6; |
| 68 |
|
| 69 |
es = .006768657997291094; |
| 70 |
e = sqrt(es); |
| 71 |
|
| 72 |
acoef[1]= 0.9945303; |
| 73 |
acoef[2]= 0.0052083; |
| 74 |
acoef[3]= 0.0072721; |
| 75 |
acoef[4]= -0.0151089; |
| 76 |
acoef[5]= 0.0642675; |
| 77 |
acoef[6]= 0.3582802; |
| 78 |
bcoef[1]= 0.0; |
| 79 |
bcoef[2]= -.0027404; |
| 80 |
bcoef[3]= 0.0048181; |
| 81 |
bcoef[4]= -0.1932526; |
| 82 |
bcoef[5]= -0.1381226; |
| 83 |
bcoef[6]= -0.2884586; |
| 84 |
|
| 85 |
esphi = e * sin(lat_center); |
| 86 |
chi = 2.0 * atan(tan((HALF_PI + lat_center)/2.0) * |
| 87 |
pow(((1.0 - esphi)/(1.0 + esphi)),(e/2.0))) - HALF_PI; |
| 88 |
tsincos(chi,&sin_p26,&cos_p26); |
| 89 |
|
| 90 |
|
| 91 |
/* Report parameters to the user |
| 92 |
-----------------------------*/ |
| 93 |
ptitle("ALASKA CONFORMAL"); |
| 94 |
radius2(r_major,r_minor); |
| 95 |
cenlon(lon_center); |
| 96 |
cenlat(lat_center); |
| 97 |
offsetp(false_easting,false_northing); |
| 98 |
return(OK); |
| 99 |
} |
| 100 |
|
| 101 |
/* ALASKA CONFORMAL forward equations--mapping lat,long to x,y |
| 102 |
----------------------------------------------------------*/ |
| 103 |
int alconfor( |
| 104 |
double lon, /* (I) Longitude */ |
| 105 |
double lat, /* (I) Latitude */ |
| 106 |
double *x, /* (O) X projection coordinate */ |
| 107 |
double *y) /* (O) Y projection coordinate */ |
| 108 |
|
| 109 |
{ |
| 110 |
double dlon; |
| 111 |
double sinlon,coslon; |
| 112 |
double sinphi,cosphi; |
| 113 |
double esphi; |
| 114 |
double g; |
| 115 |
double s; |
| 116 |
double xp; |
| 117 |
double yp; |
| 118 |
double ar; |
| 119 |
double ai; |
| 120 |
double br; |
| 121 |
double bi; |
| 122 |
double arn; |
| 123 |
double ain; |
| 124 |
double chi; |
| 125 |
double r; |
| 126 |
long j; |
| 127 |
|
| 128 |
|
| 129 |
/* Forward equations |
| 130 |
-----------------*/ |
| 131 |
dlon = adjust_lon( lon - lon_center); |
| 132 |
|
| 133 |
/* caluclate x' and y' for Oblique Stereographic Proj for LAT/LONG |
| 134 |
----------------------------------------------------------------*/ |
| 135 |
tsincos(dlon,&sinlon,&coslon); |
| 136 |
esphi = e * sin(lat); |
| 137 |
chi = 2.0 * atan(tan((HALF_PI + lat) / 2.0) * |
| 138 |
pow(((1.0 - esphi) / (1.0 + esphi)),(e/2.0))) - HALF_PI; |
| 139 |
tsincos(chi,&sinphi,&cosphi); |
| 140 |
g = sin_p26 * sinphi + cos_p26 * cosphi * coslon; |
| 141 |
s = 2.0 / (1.0 + g); |
| 142 |
xp = s * cosphi * sinlon; |
| 143 |
yp = s * (cos_p26 * sinphi - sin_p26 * cosphi * coslon); |
| 144 |
|
| 145 |
/* Use Knuth algorithm for summing complex terms, to convert |
| 146 |
Oblique Stereographic to Modified-Stereographic coord |
| 147 |
----------------------------------------------------------*/ |
| 148 |
r = xp + xp; |
| 149 |
s = xp*xp + yp*yp; |
| 150 |
ar = acoef[n]; |
| 151 |
ai = bcoef[n]; |
| 152 |
br = acoef[n -1]; |
| 153 |
bi = bcoef[n -1]; |
| 154 |
for (j =2; j <= n; j++) |
| 155 |
{ |
| 156 |
arn = br + r * ar; |
| 157 |
ain = bi + r * ai; |
| 158 |
if (j < n) |
| 159 |
{ |
| 160 |
br = acoef[n - j] - s * ar; |
| 161 |
bi = bcoef[n - j] - s * ai; |
| 162 |
ar = arn; |
| 163 |
ai = ain; |
| 164 |
} |
| 165 |
} |
| 166 |
br = -s * ar; |
| 167 |
bi = -s * ai; |
| 168 |
ar = arn; |
| 169 |
ai = ain; |
| 170 |
*x = (xp * ar - yp * ai + br) * r_major + false_easting; |
| 171 |
*y = (yp * ar + xp * ai + bi) * r_major + false_northing; |
| 172 |
|
| 173 |
return(OK); |
| 174 |
} |