OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
equiinv.c
Go to the documentation of this file.
1 /*******************************************************************************
2 NAME EQUIRECTANGULAR
3 
4 PURPOSE: Transforms input Easting and Northing to longitude and
5  latitude for the Equirectangular projection. The
6  Easting and Northing must be in meters. The longitude
7  and latitude values will be returned in radians.
8 
9 ALGORITHM REFERENCES
10 
11 1. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
12  Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
13  State Government Printing Office, Washington D.C., 1987.
14 
15 2. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections",
16  U.S. Geological Survey Professional Paper 1453 , United State Government
17  Printing Office, Washington D.C., 1989.
18 *******************************************************************************/
19 #include "oli_cproj.h"
20 #include "oli_local.h"
21 
22 /* Variables common to all subroutines in this code file
23  -----------------------------------------------------*/
24 static double r_major; /* major axis */
25 static double lon_center; /* Center longitude (projection center) */
26 static double lat_origin; /* center latitude */
27 static double false_northing; /* y offset in meters */
28 static double false_easting; /* x offset in meters */
29 
30 /* Initialize the Equirectangular projection
31  ----------------------------------------*/
32 long equiinvint
33 (
34  double r_maj, /* major axis */
35  double center_lon, /* center longitude */
36  double lat1, /* latitude of true scale */
37  double false_east, /* x offset in meters */
38  double false_north /* y offset in meters */
39 )
40 {
41 
42 /* Place parameters in static storage for common use
43  -------------------------------------------------*/
44 r_major = r_maj;
45 lon_center = center_lon;
46 lat_origin = lat1;
47 false_northing = false_north;
48 false_easting = false_east;
49 
50 /* Report parameters to the user
51  -----------------------------*/
52 gctp_print_title("EQUIRECTANGULAR");
53 gctp_print_radius(r_major);
54 gctp_print_cenlonmer(lon_center);
55 gctp_print_origin(lat_origin);
56 gctp_print_offsetp(false_easting,false_northing);
57 return(OK);
58 }
59 
60 
61 /* Equirectangular inverse equations--mapping x,y to lat/long
62  ---------------------------------------------------------*/
63 long equiinv
64 (
65  double x, /* (O) X projection coordinate */
66  double y, /* (O) Y projection coordinate */
67  double *lon, /* (I) Longitude */
68  double *lat /* (I) Latitude */
69 )
70 {
71 /* Inverse equations
72  -----------------*/
73 x -= false_easting;
74 y -= false_northing;
75 *lat = y / r_major;
76 if (fabs(*lat) > HALF_PI)
77  {
78  GCTP_PRINT_ERROR("Input data error");
79  return(174);
80  }
81 *lon = adjust_lon(lon_center + x / (r_major * cos(lat_origin)));
82 return(OK);
83 }
void gctp_print_origin(double A)
Definition: gctp_report.c:65
void gctp_print_title(const char *proj_name)
Definition: gctp_report.c:14
long equiinv(double x, double y, double *lon, double *lat)
Definition: equiinv.c:64
long equiinvint(double r_maj, double center_lon, double lat1, double false_east, double false_north)
Definition: equiinv.c:33
#define GCTP_PRINT_ERROR(format,...)
Definition: oli_local.h:81
float * lat
double adjust_lon(double x)
Definition: proj_cproj.c:349
#define HALF_PI
Definition: proj_define.h:84
void gctp_print_offsetp(double A, double B)
Definition: gctp_report.c:91
#define OK
Definition: ancil.h:30
void gctp_print_cenlonmer(double A)
Definition: gctp_report.c:48
#define fabs(a)
Definition: misc.h:93
float * lon
void gctp_print_radius(double radius)
Definition: gctp_report.c:22