OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
gvnspfor.c
Go to the documentation of this file.
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 This function was adapted from the General Vertical Near-Side Perspective
11 projection code (FORTRAN) in the General Cartographic Transformation Package
12 software which is available from the U.S. Geological Survey National Mapping
13 Division.
14 
15 ALGORITHM REFERENCES
16 
17 1. "New Equal-Area Map Projections for Noncircular Regions", John P. Snyder,
18  The American Cartographer, Vol 15, No. 4, October 1988, pp. 341-355.
19 
20 2. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
21  Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
22  State Government Printing Office, Washington D.C., 1987.
23 
24 3. "Software Documentation for GCTP General Cartographic Transformation
25  Package", U.S. Geological Survey National Mapping Division, May 1982.
26 *******************************************************************************/
27 #include "oli_cproj.h"
28 #include "oli_local.h"
29 
30 /* Variables common to all subroutines in this code file
31  -----------------------------------------------------*/
32 static double lon_center; /* Center longitude (projection center) */
33 static double R; /* Radius of the earth (sphere) */
34 static double p; /* Height above sphere */
35 static double sin_p15; /* Sine of the center latitude */
36 static double cos_p15; /* Cosine of the center latitude */
37 static double false_easting; /* x offset in meters */
38 static double false_northing; /* y offset in meters */
39 
40 /* Initialize the General Vertical Near-Side Perspective projection
41  ---------------------------------------------------------------*/
42 long gvnspforint
43 (
44  double r, /* (I) Radius of the earth (sphere) */
45  double h, /* height above sphere */
46  double center_long, /* (I) Center longitude */
47  double center_lat, /* (I) Center latitude */
48  double false_east, /* x offset in meters */
49  double false_north /* y offset in meters */
50 )
51 {
52 /* Place parameters in static storage for common use
53  -------------------------------------------------*/
54 R = r;
55 p = 1.0 + h / R;
56 lon_center = center_long;
57 false_easting = false_east;
58 false_northing = false_north;
59 sincos(center_lat, &sin_p15, &cos_p15);
60 
61 /* Report parameters to the user
62  -----------------------------*/
63 gctp_print_title("GENERAL VERTICAL NEAR-SIDE PERSPECTIVE");
65 gctp_print_genrpt(h,"Height of Point Above Surface of Sphere: ");
66 gctp_print_cenlon(center_long);
67 gctp_print_cenlat(center_lat);
68 gctp_print_offsetp(false_easting,false_northing);
69 return(OK);
70 }
71 
72 /* General Vertical Near-Side Perspective forward equations--mapping
73  lat,long to x,y
74  ----------------------------------------------------------------*/
75 long gvnspfor
76 (
77  double lon, /* (I) Longitude */
78  double lat, /* (I) Latitude */
79  double *x, /* (O) X projection coordinate */
80  double *y /* (O) Y projection coordinate */
81 )
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 sincos(lat,&sinphi,&cosphi);
94 coslon = cos(dlon);
95 g = sin_p15 * sinphi + cos_p15 * cosphi * coslon;
96 if (g < (1.0/ p))
97  {
98  GCTP_PRINT_ERROR("Point cannot be projected");
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 }
int r
Definition: decode_rs.h:73
void gctp_print_title(const char *proj_name)
Definition: gctp_report.c:14
void gctp_print_cenlon(double A)
Definition: gctp_report.c:40
#define GCTP_PRINT_ERROR(format,...)
Definition: oli_local.h:81
float h[MODELMAX]
Definition: atrem_corl1.h:131
float * lat
double adjust_lon(double x)
Definition: proj_cproj.c:349
long gvnspforint(double r, double h, double center_long, double center_lat, double false_east, double false_north)
Definition: gvnspfor.c:43
void gctp_print_offsetp(double A, double B)
Definition: gctp_report.c:91
#define OK
Definition: ancil.h:30
void gctp_print_genrpt(double A, const char *S)
Definition: gctp_report.c:117
long gvnspfor(double lon, double lat, double *x, double *y)
Definition: gvnspfor.c:76
#define sincos
Definition: proj_define.h:108
float * lon
void gctp_print_radius(double radius)
Definition: gctp_report.c:22
#define R
Definition: make_L3_v1.1.c:96
float p[MODELMAX]
Definition: atrem_corl1.h:131
void gctp_print_cenlat(double A)
Definition: gctp_report.c:57