| 1 |
/******************************************************************************* |
| 2 |
NAME ORTHOGRAPHIC |
| 3 |
|
| 4 |
PURPOSE: Transforms input longitude and latitude to Easting and |
| 5 |
Northing for the Orthographic 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 |
static double sin_p14; /* sin of center latitude */ |
| 34 |
static double cos_p14; /* cos of center latitude */ |
| 35 |
|
| 36 |
/* Initialize the Orthographic projection |
| 37 |
-------------------------------------*/ |
| 38 |
int orthforint( |
| 39 |
double r_maj, /* major axis */ |
| 40 |
double center_lon, /* center longitude */ |
| 41 |
double center_lat, /* center latitude */ |
| 42 |
double false_east, /* x offset in meters */ |
| 43 |
double false_north) /* y offset in meters */ |
| 44 |
{ |
| 45 |
|
| 46 |
/* Place parameters in static storage for common use |
| 47 |
-------------------------------------------------*/ |
| 48 |
r_major = r_maj; |
| 49 |
lon_center = center_lon; |
| 50 |
lat_origin = center_lat; |
| 51 |
false_northing = false_north; |
| 52 |
false_easting = false_east; |
| 53 |
|
| 54 |
tsincos(center_lat,&sin_p14,&cos_p14); |
| 55 |
|
| 56 |
/* Report parameters to the user |
| 57 |
-----------------------------*/ |
| 58 |
ptitle("ORTHOGRAPHIC"); |
| 59 |
radius(r_major); |
| 60 |
cenlonmer(lon_center); |
| 61 |
origin(lat_origin); |
| 62 |
offsetp(false_easting,false_northing); |
| 63 |
return(OK); |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
/* Orthographic forward equations--mapping lat,long to x,y |
| 68 |
---------------------------------------------------*/ |
| 69 |
int orthfor( |
| 70 |
double lon, /* (I) Longitude */ |
| 71 |
double lat, /* (I) Latitude */ |
| 72 |
double *x, /* (O) X projection coordinate */ |
| 73 |
double *y) /* (O) Y projection coordinate */ |
| 74 |
{ |
| 75 |
double sinphi, cosphi; /* sin and cos value */ |
| 76 |
double dlon; /* delta longitude value */ |
| 77 |
double coslon; /* cos of longitude */ |
| 78 |
double ksp; /* scale factor */ |
| 79 |
double g; |
| 80 |
|
| 81 |
/* Forward equations |
| 82 |
-----------------*/ |
| 83 |
dlon = adjust_lon(lon - lon_center); |
| 84 |
tsincos(lat,&sinphi,&cosphi); |
| 85 |
coslon = cos(dlon); |
| 86 |
g = sin_p14 * sinphi + cos_p14 * cosphi * coslon; |
| 87 |
ksp = 1.0; |
| 88 |
if ((g > 0) || (fabs(g) <= EPSLN)) |
| 89 |
{ |
| 90 |
*x = false_easting + r_major * ksp * cosphi * sin(dlon); |
| 91 |
*y = false_northing + r_major * ksp * (cos_p14 * sinphi - |
| 92 |
sin_p14 * cosphi * coslon); |
| 93 |
} |
| 94 |
else |
| 95 |
{ |
| 96 |
p_error("Point can not be projected","orth-for"); |
| 97 |
return(143); |
| 98 |
} |
| 99 |
return(OK); |
| 100 |
} |