| 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 |
PROGRAMMER DATE |
| 10 |
---------- ---- |
| 11 |
T. Mittan Mar, 1993 |
| 12 |
|
| 13 |
ALGORITHM REFERENCES |
| 14 |
|
| 15 |
1. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological |
| 16 |
Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United |
| 17 |
State Government Printing Office, Washington D.C., 1987. |
| 18 |
|
| 19 |
2. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections", |
| 20 |
U.S. Geological Survey Professional Paper 1453 , United State Government |
| 21 |
Printing Office, Washington D.C., 1989. |
| 22 |
*******************************************************************************/ |
| 23 |
#include <stdio.h> |
| 24 |
#include "cproj.h" |
| 25 |
|
| 26 |
/* Variables common to all subroutines in this code file |
| 27 |
-----------------------------------------------------*/ |
| 28 |
static double r_major; /* major axis */ |
| 29 |
static double lon_center; /* Center longitude (projection center) */ |
| 30 |
static double lat_origin; /* center latitude */ |
| 31 |
static double false_northing; /* y offset in meters */ |
| 32 |
static double false_easting; /* x offset in meters */ |
| 33 |
|
| 34 |
/* Initialize the Equirectangular projection |
| 35 |
----------------------------------------*/ |
| 36 |
int equiforint( |
| 37 |
double r_maj, /* major axis */ |
| 38 |
double center_lon, /* center longitude */ |
| 39 |
double lat1, /* latitude of true scale */ |
| 40 |
double false_east, /* x offset in meters */ |
| 41 |
double false_north) /* y offset in meters */ |
| 42 |
{ |
| 43 |
|
| 44 |
/* Place parameters in static storage for common use |
| 45 |
-------------------------------------------------*/ |
| 46 |
r_major = r_maj; |
| 47 |
lon_center = center_lon; |
| 48 |
lat_origin = lat1; |
| 49 |
false_northing = false_north; |
| 50 |
false_easting = false_east; |
| 51 |
|
| 52 |
/* Report parameters to the user |
| 53 |
-----------------------------*/ |
| 54 |
ptitle("EQUIRECTANGULAR"); |
| 55 |
radius(r_major); |
| 56 |
cenlonmer(lon_center); |
| 57 |
origin(lat_origin); |
| 58 |
offsetp(false_easting,false_northing); |
| 59 |
return(OK); |
| 60 |
} |
| 61 |
|
| 62 |
|
| 63 |
/* Equirectangular forward equations--mapping lat,long to x,y |
| 64 |
---------------------------------------------------------*/ |
| 65 |
int equifor( |
| 66 |
double lon, /* (I) Longitude */ |
| 67 |
double lat, /* (I) Latitude */ |
| 68 |
double *x, /* (O) X projection coordinate */ |
| 69 |
double *y) /* (O) Y projection coordinate */ |
| 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 |
} |