Debian Codegraph @

gctp/src/gvnspfor.c

raw
1 /*******************************************************************************
2 NAME GENERAL VERTICAL NEAR-SIDE PERSPECTIVE
3
4 PURPOSE: Transforms input longitude and latitude to Easting and
5 Northing for the General Vertical Near-Side Perspective
6 projection. The longitude and latitude must be in
7 radians. The Easting and Northing values will be
8 returned in meters.
9
10 PROGRAMMER DATE
11 ---------- ----
12 T. Mittan Mar, 1993
13
14 This function was adapted from the General Vertical Near-Side Perspective
15 projection code (FORTRAN) in the General Cartographic Transformation Package
16 software which is available from the U.S. Geological Survey National Mapping
17 Division.
18
19 ALGORITHM REFERENCES
20
21 1. "New Equal-Area Map Projections for Noncircular Regions", John P. Snyder,
22 The American Cartographer, Vol 15, No. 4, October 1988, pp. 341-355.
23
24 2. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
25 Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
26 State Government Printing Office, Washington D.C., 1987.
27
28 3. "Software Documentation for GCTP General Cartographic Transformation
29 Package", U.S. Geological Survey National Mapping Division, May 1982.
30 *******************************************************************************/
31 #include <stdio.h>
32 #include "cproj.h"
33
34 /* Variables common to all subroutines in this code file
35 -----------------------------------------------------*/
36 static double lon_center; /* Center longitude (projection center) */
37 static double R; /* Radius of the earth (sphere) */
38 static double p; /* Height above sphere */
39 static double sin_p15; /* Sine of the center latitude */
40 static double cos_p15; /* Cosine of the center latitude */
41 static double false_easting; /* x offset in meters */
42 static double false_northing; /* y offset in meters */
43
44 /* Initialize the General Vertical Near-Side Perspective projection
45 ---------------------------------------------------------------*/
46 int gvnspforint(
47 double r, /* (I) Radius of the earth (sphere) */
48 double h, /* height above sphere */
49 double center_long, /* (I) Center longitude */
50 double center_lat, /* (I) Center latitude */
51 double false_east, /* x offset in meters */
52 double false_north) /* y offset in meters */
53 {
54 /* Place parameters in static storage for common use
55 -------------------------------------------------*/
56 R = r;
57 p = 1.0 + h / R;
58 lon_center = center_long;
59 false_easting = false_east;
60 false_northing = false_north;
61 tsincos(center_lat, &sin_p15, &cos_p15);
62
63 /* Report parameters to the user
64 -----------------------------*/
65 ptitle("GENERAL VERTICAL NEAR-SIDE PERSPECTIVE");
66 radius(r);
67 genrpt(h,"Height of Point Above Surface of Sphere: ");
68 cenlon(center_long);
69 cenlat(center_lat);
70 offsetp(false_easting,false_northing);
71 return(OK);
72 }
73
74 /* General Vertical Near-Side Perspective forward equations--mapping
75 lat,long to x,y
76 ----------------------------------------------------------------*/
77 int gvnspfor(
78 double lon, /* (I) Longitude */
79 double lat, /* (I) Latitude */
80 double *x, /* (O) X projection coordinate */
81 double *y) /* (O) Y projection coordinate */
82
83 {
84 double dlon;
85 double sinphi,cosphi;
86 double coslon;
87 double g;
88 double ksp;
89
90 /* Forward equations
91 -----------------*/
92 dlon = adjust_lon(lon - lon_center);
93 tsincos(lat,&sinphi,&cosphi);
94 coslon = cos(dlon);
95 g = sin_p15 * sinphi + cos_p15 * cosphi * coslon;
96 if (g < (1.0/ p))
97 {
98 p_error("Point cannot be projected","gvnsp-for");
99 return(153);
100 }
101 ksp = (p - 1.0)/(p - g);
102 *x = false_easting + R * ksp * cosphi * sin(dlon);
103 *y = false_northing + R * ksp * (cos_p15 * sinphi - sin_p15 * cosphi * coslon);
104
105 return(OK);
106 }