OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
equifor.c
Go to the documentation of this file.
1 /*******************************************************************************
2 NAME EQUIRECTANGULAR
3 
4 PURPOSE: Transforms input longitude and latitude to Easting and
5  Northing for the Equirectangular projection. The
6  longitude and latitude must be in radians. The Easting
7  and Northing values will be returned in meters.
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 equiforint
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 forward equations--mapping lat,long to x,y
62  ---------------------------------------------------------*/
63 long equifor
64 (
65  double lon, /* (I) Longitude */
66  double lat, /* (I) Latitude */
67  double *x, /* (O) X projection coordinate */
68  double *y /* (O) Y projection coordinate */
69 )
70 {
71 double dlon; /* delta longitude value */
72 
73 /* Forward equations
74  -----------------*/
75 dlon = adjust_lon(lon - lon_center);
76 *x = false_easting + r_major * dlon * cos(lat_origin);
77 *y = false_northing + r_major * lat;
78 return(OK);
79 }
void gctp_print_origin(double A)
Definition: gctp_report.c:65
void gctp_print_title(const char *proj_name)
Definition: gctp_report.c:14
float * lat
double adjust_lon(double x)
Definition: proj_cproj.c:349
long equiforint(double r_maj, double center_lon, double lat1, double false_east, double false_north)
Definition: equifor.c:33
long equifor(double lon, double lat, double *x, double *y)
Definition: equifor.c:64
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
float * lon
void gctp_print_radius(double radius)
Definition: gctp_report.c:22