| 1 |
/******************************************************************************* |
| 2 |
NAME POLAR STEREOGRAPHIC |
| 3 |
|
| 4 |
PURPOSE: Transforms input longitude and latitude to Easting and |
| 5 |
Northing for the Polar Stereographic projection. The |
| 6 |
longitude and latitude must be in radians. The Easting |
| 7 |
and Northing values will be returned in meters. |
| 8 |
|
| 9 |
PROGRAMMER DATE |
| 10 |
---------- ---- |
| 11 |
T. Mittan 2-26-93 |
| 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 es; /* eccentricity squared */ |
| 31 |
static double e; /* eccentricity */ |
| 32 |
static double e4; /* e4 calculated from eccentricity*/ |
| 33 |
static double center_lon; /* center longitude */ |
| 34 |
static double center_lat; /* center latitude */ |
| 35 |
static double fac; /* sign variable */ |
| 36 |
static double ind; /* flag variable */ |
| 37 |
static double mcs; /* small m */ |
| 38 |
static double tcs; /* small t */ |
| 39 |
static double false_northing; /* y offset in meters */ |
| 40 |
static double false_easting; /* x offset in meters */ |
| 41 |
|
| 42 |
/* Initialize the Polar Stereographic projection |
| 43 |
--------------------------------------------*/ |
| 44 |
int psforint( |
| 45 |
double r_maj, /* major axis */ |
| 46 |
double r_min, /* minor axis */ |
| 47 |
double c_lon, /* center longitude */ |
| 48 |
double c_lat, /* center latitude */ |
| 49 |
double false_east, /* x offset in meters */ |
| 50 |
double false_north) /* y offset in meters */ |
| 51 |
|
| 52 |
{ |
| 53 |
double temp; /* temporary variable */ |
| 54 |
double con1; /* temporary angle */ |
| 55 |
double sinphi; /* sin value */ |
| 56 |
double cosphi; /* cos value */ |
| 57 |
|
| 58 |
r_major = r_maj; |
| 59 |
r_minor = r_min; |
| 60 |
false_northing = false_north; |
| 61 |
false_easting = false_east; |
| 62 |
temp = r_minor / r_major; |
| 63 |
es = 1.0 - SQUARE(temp); |
| 64 |
e = sqrt(es); |
| 65 |
e4 = e4fn(e); |
| 66 |
center_lon = c_lon; |
| 67 |
center_lat = c_lat; |
| 68 |
|
| 69 |
if (c_lat < 0) |
| 70 |
fac = -1.0; |
| 71 |
else |
| 72 |
fac = 1.0; |
| 73 |
ind = 0; |
| 74 |
if (fabs(fabs(c_lat) - HALF_PI) > EPSLN) |
| 75 |
{ |
| 76 |
ind = 1; |
| 77 |
con1 = fac * center_lat; |
| 78 |
tsincos(con1,&sinphi,&cosphi); |
| 79 |
mcs = msfnz(e,sinphi,cosphi); |
| 80 |
tcs = tsfnz(e,con1,sinphi); |
| 81 |
} |
| 82 |
/* Report parameters to the user |
| 83 |
-----------------------------*/ |
| 84 |
ptitle("POLAR STEREOGRAPHIC"); |
| 85 |
radius2(r_major, r_minor); |
| 86 |
cenlon(center_lon); |
| 87 |
offsetp(false_east,false_north); |
| 88 |
|
| 89 |
return(OK); |
| 90 |
} |
| 91 |
|
| 92 |
/* Polar Stereographic forward equations--mapping lat,long to x,y |
| 93 |
--------------------------------------------------------------*/ |
| 94 |
int psfor( |
| 95 |
double lon, /* (I) Longitude */ |
| 96 |
double lat, /* (I) Latitude */ |
| 97 |
double *x, /* (O) X projection coordinate */ |
| 98 |
double *y) /* (O) Y projection coordinate */ |
| 99 |
|
| 100 |
{ |
| 101 |
double con1; /* adjusted longitude */ |
| 102 |
double con2; /* adjusted latitude */ |
| 103 |
double rh; /* height above ellipsoid */ |
| 104 |
double sinphi; /* sin value */ |
| 105 |
double ts; /* value of small t */ |
| 106 |
|
| 107 |
con1 = fac * adjust_lon(lon - center_lon); |
| 108 |
con2 = fac * lat; |
| 109 |
sinphi = sin(con2); |
| 110 |
ts = tsfnz(e,con2,sinphi); |
| 111 |
if (ind != 0) |
| 112 |
rh = r_major * mcs * ts / tcs; |
| 113 |
else |
| 114 |
rh = 2.0 * r_major * ts / e4; |
| 115 |
*x = fac * rh * sin(con1) + false_easting; |
| 116 |
*y = -fac * rh * cos(con1) + false_northing;; |
| 117 |
|
| 118 |
return(OK); |
| 119 |
} |