| 1 |
/******************************************************************************* |
| 2 |
NAME VAN DER GRINTEN |
| 3 |
|
| 4 |
PURPOSE: Transforms input longitude and latitude to Easting and |
| 5 |
Northing for the Van der Grinten 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 March, 1993 |
| 12 |
|
| 13 |
This function was adapted from the Lambert Azimuthal Equal Area projection |
| 14 |
code (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 lon_center; /* Center longitude (projection center) */ |
| 35 |
static double R; /* Radius of the earth (sphere) */ |
| 36 |
static double false_easting; /* x offset in meters */ |
| 37 |
static double false_northing; /* y offset in meters */ |
| 38 |
|
| 39 |
/* Initialize the Van Der Grinten projection |
| 40 |
----------------------------------------*/ |
| 41 |
int vandgforint( |
| 42 |
double r, /* (I) Radius of the earth (sphere) */ |
| 43 |
double center_long, /* (I) Center longitude */ |
| 44 |
double false_east, /* x offset in meters */ |
| 45 |
double false_north) /* y offset in meters */ |
| 46 |
{ |
| 47 |
/* Place parameters in static storage for common use |
| 48 |
-------------------------------------------------*/ |
| 49 |
R = r; |
| 50 |
lon_center = center_long; |
| 51 |
false_easting = false_east; |
| 52 |
false_northing = false_north; |
| 53 |
|
| 54 |
/* Report parameters to the user |
| 55 |
-----------------------------*/ |
| 56 |
ptitle("VAN DER GRINTEN"); |
| 57 |
radius(r); |
| 58 |
cenlon(center_long); |
| 59 |
offsetp(false_easting,false_northing); |
| 60 |
return(OK); |
| 61 |
} |
| 62 |
|
| 63 |
/* Van Der Grinten forward equations--mapping lat,long to x,y |
| 64 |
---------------------------------------------------------*/ |
| 65 |
int vandgfor( |
| 66 |
double lon, /* (I) Longitude */ |
| 67 |
double lat, /* (I) Latitude */ |
| 68 |
double *x, /* (O) X projection coordinate */ |
| 69 |
double *y) /* (O) Y projection coordinate */ |
| 70 |
|
| 71 |
{ |
| 72 |
double dlon; |
| 73 |
double theta; |
| 74 |
double al,asq; |
| 75 |
double g,gsq; |
| 76 |
double m,msq; |
| 77 |
double con; |
| 78 |
double costh,sinth; |
| 79 |
|
| 80 |
/* Forward equations |
| 81 |
-----------------*/ |
| 82 |
dlon = adjust_lon(lon - lon_center); |
| 83 |
|
| 84 |
if (fabs(lat) <= EPSLN) |
| 85 |
{ |
| 86 |
*x = false_easting + R * dlon; |
| 87 |
*y = false_northing; |
| 88 |
return (OK); |
| 89 |
} |
| 90 |
theta = asinz(2.0 * fabs(lat / PI)); |
| 91 |
if ((fabs(dlon) <= EPSLN) || (fabs(fabs(lat) - HALF_PI) <= EPSLN)) |
| 92 |
{ |
| 93 |
*x = false_easting; |
| 94 |
if (lat >= 0) |
| 95 |
*y = false_northing + PI * R * tan(.5 * theta); |
| 96 |
else |
| 97 |
*y = false_northing + PI * R * -tan(.5 * theta); |
| 98 |
return(OK); |
| 99 |
} |
| 100 |
al = .5 * fabs((PI / dlon) - (dlon / PI)); |
| 101 |
asq = al * al; |
| 102 |
tsincos(theta,&sinth,&costh); |
| 103 |
g = costh / (sinth + costh - 1.0); |
| 104 |
gsq = g * g; |
| 105 |
m = g * (2.0 / sinth - 1.0); |
| 106 |
msq = m * m; |
| 107 |
con = PI * R * (al * (g - msq) + sqrt(asq * (g - msq) * (g - msq) - (msq + asq) |
| 108 |
* (gsq - msq))) / (msq + asq); |
| 109 |
if (dlon < 0) |
| 110 |
con = -con; |
| 111 |
*x = false_easting + con; |
| 112 |
con = fabs(con / (PI * R)); |
| 113 |
if (lat >= 0) |
| 114 |
*y = false_northing + PI * R * sqrt(1.0 - con * con - 2.0 * al * con); |
| 115 |
else |
| 116 |
*y = false_northing - PI * R * sqrt(1.0 - con * con - 2.0 * al * con); |
| 117 |
|
| 118 |
return(OK); |
| 119 |
} |