Debian Codegraph @

gctp/src/obleqfor.c

raw
1 /*******************************************************************************
2 NAME OBLATED EQUAL-AREA
3
4 PURPOSE: Transforms input longitude and latitude to Easting and
5 Northing for the Oblated Equal Area projection. The
6 longitude and latitude must be in radians. The Easting
7 and Northing values will be returned in meters.
8
9 PROGRAM HISTORY
10 PROGRAMMER DATE
11 ---------- ----
12 D. Steinwand May, 1991
13
14 ALGORITHM REFERENCES
15
16 1. "New Equal-Area Map Projections for Noncircular Regions", John P. Snyder,
17 The American Cartographer, Vol 15, No. 4, October 1988, pp. 341-355.
18
19 2. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
20 Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
21 State Government Printing Office, Washington D.C., 1987.
22
23 3. "Software Documentation for GCTP General Cartographic Transformation
24 Package", U.S. Geological Survey National Mapping Division, May 1982.
25 *******************************************************************************/
26 #include <stdio.h>
27 #include "cproj.h"
28
29 static double lon_center;
30 static double lat_o;
31 static double theta;
32 static double m;
33 static double n;
34 static double R;
35 static double sin_lat_o;
36 static double cos_lat_o;
37 static double false_easting;
38 static double false_northing;
39
40 int obleqforint(
41 double r,
42 double center_long,
43 double center_lat,
44 double shape_m,
45 double shape_n,
46 double angle,
47 double false_east,
48 double false_north)
49 {
50 /* Place parameters in static storage for common use
51 -------------------------------------------------*/
52 R = r;
53 lon_center = center_long;
54 lat_o = center_lat;
55 m = shape_m;
56 n = shape_n;
57 theta = angle;
58 false_easting = false_east;
59 false_northing = false_north;
60
61 /* Report parameters to the user (to device set up prior to this call)
62 -------------------------------------------------------------------*/
63 ptitle("OBLATED EQUAL-AREA");
64 radius(R);
65 cenlon(lon_center);
66 cenlat(lat_o);
67 genrpt(m,"Parameter m: ");
68 genrpt(n,"Parameter n: ");
69 genrpt(theta,"Theta: ");
70 offsetp(false_easting,false_northing);
71
72 /* Calculate the sine and cosine of the latitude of the center of the map
73 and store in static storage for common use.
74 -------------------------------------------*/
75 tsincos(lat_o, &sin_lat_o, &cos_lat_o);
76 return(OK);
77 }
78
79 int obleqfor(
80 double lon, /* (I) Longitude */
81 double lat, /* (I) Latitude */
82 double *x, /* (O) X projection coordinate */
83 double *y) /* (O) Y projection coordinate */
84 {
85 double delta_lon;
86 double sin_delta_lon;
87 double cos_delta_lon;
88 double sin_lat;
89 double cos_lat;
90 double z;
91 double Az;
92 double sin_Az;
93 double cos_Az;
94 double temp; /* Re-used temporary variable */
95 double x_prime;
96 double y_prime;
97 double M;
98 double N;
99
100 /* Forward equations
101 -----------------*/
102 delta_lon = lon - lon_center;
103 tsincos(lat, &sin_lat, &cos_lat);
104 tsincos(delta_lon, &sin_delta_lon, &cos_delta_lon);
105 z = acos(sin_lat_o * sin_lat + cos_lat_o * cos_lat * cos_delta_lon);
106 Az = atan2(cos_lat * sin_delta_lon , cos_lat_o * sin_lat - sin_lat_o *
107 cos_lat * cos_delta_lon) + theta;
108 tsincos(Az, &sin_Az, &cos_Az);
109 temp = 2.0 * sin(z / 2.0);
110 x_prime = temp * sin_Az;
111 y_prime = temp * cos_Az;
112 M = asin(x_prime / 2.0);
113 temp = y_prime / 2.0 * cos(M) / cos(2.0 * M / m);
114 N = asin(temp);
115 *y = n * R * sin(2.0 * N / n) + false_easting;
116 *x = m * R * sin(2.0 * M / m) * cos(N) / cos(2.0 * N / n) + false_northing;
117 return(OK);
118 }