OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimMgrs.h
Go to the documentation of this file.
1 #ifndef MGRS_H
2 #define MGRS_H 1
3 
4 /***************************************************************************/
5 /* RSC IDENTIFIER: MGRS
6  *
7  * ABSTRACT
8  *
9  * This component converts between geodetic coordinates (latitude and
10  * longitude) and Military Grid Reference System (MGRS) coordinates.
11  *
12  * ERROR HANDLING
13  *
14  * This component checks parameters for valid values. If an invalid value
15  * is found, the error code is combined with the current error code using
16  * the bitwise or. This combining allows multiple error codes to be
17  * returned. The possible error codes are:
18  *
19  * MGRS_NO_ERROR : No errors occurred in function
20  * MGRS_LAT_ERROR : Latitude outside of valid range
21  * (-90 to 90 degrees)
22  * MGRS_LON_ERROR : Longitude outside of valid range
23  * (-180 to 360 degrees)
24  * MGRS_STR_ERROR : An MGRS string error: string too long,
25  * too short, or badly formed
26  * MGRS_PRECISION_ERROR : The precision must be between 0 and 5
27  * inclusive.
28  * MGRS_A_ERROR : Semi-major axis less than or equal to zero
29  * MGRS_INV_F_ERROR : Inverse flattening outside of valid range
30  * (250 to 350)
31  * MGRS_EASTING_ERROR : Easting outside of valid range
32  * (100,000 to 900,000 meters for UTM)
33  * (0 to 4,000,000 meters for UPS)
34  * MGRS_NORTHING_ERROR : Northing outside of valid range
35  * (0 to 10,000,000 meters for UTM)
36  * (0 to 4,000,000 meters for UPS)
37  * MGRS_ZONE_ERROR : Zone outside of valid range (1 to 60)
38  * MGRS_HEMISPHERE_ERROR : Invalid hemisphere ('N' or 'S')
39  *
40  * REUSE NOTES
41  *
42  * MGRS is intended for reuse by any application that does conversions
43  * between geodetic coordinates and MGRS coordinates.
44  *
45  * REFERENCES
46  *
47  * Further information on MGRS can be found in the Reuse Manual.
48  *
49  * MGRS originated from : U.S. Army Topographic Engineering Center
50  * Geospatial Information Division
51  * 7701 Telegraph Road
52  * Alexandria, VA 22310-3864
53  *
54  * LICENSES
55  *
56  * None apply to this component.
57  *
58  * RESTRICTIONS
59  *
60  *
61  * ENVIRONMENT
62  *
63  * MGRS was tested and certified in the following environments:
64  *
65  * 1. Solaris 2.5 with GCC version 2.8.1
66  * 2. Windows 95 with MS Visual C++ version 6
67  *
68  * MODIFICATIONS
69  *
70  * Date Description
71  * ---- -----------
72  * 16-11-94 Original Code
73  * 15-09-99 Reengineered upper layers
74  *
75  */
76 
77 #include <ossim/base/ossimConstants.h> /* for OSSIM_DLL */
78 
79 /***************************************************************************/
80 /*
81  * DEFINES
82  */
83 
84 #define OSSIM_MGRS_NO_ERROR 0x0000
85 #define OSSIM_MGRS_LAT_ERROR 0x0001
86 #define OSSIM_MGRS_LON_ERROR 0x0002
87 #define OSSIM_MGRS_STRING_ERROR 0x0004
88 #define OSSIM_MGRS_PRECISION_ERROR 0x0008
89 #define OSSIM_MGRS_A_ERROR 0x0010
90 #define OSSIM_MGRS_INV_F_ERROR 0x0020
91 #define OSSIM_MGRS_EASTING_ERROR 0x0040
92 #define OSSIM_MGRS_NORTHING_ERROR 0x0080
93 #define OSSIM_MGRS_ZONE_ERROR 0x0100
94 #define OSSIM_MGRS_HEMISPHERE_ERROR 0x0200
95 
96 
97 /***************************************************************************/
98 /*
99  * FUNCTION PROTOTYPES
100  */
101 
102 /* ensure proper linkage to c++ programs */
103  #ifdef __cplusplus
104 extern "C" {
105  #endif
106 
107 
108  OSSIM_DLL long Set_OSSIM_MGRS_Parameters(double a,
109  double f,
110  const char* Ellipsoid_Code);
111 /*
112  * The function Set_MGRS_Parameters receives the ellipsoid parameters and sets
113  * the corresponding state variables. If any errors occur, the error code(s)
114  * are returned by the function, otherwise MGRS_NO_ERROR is returned.
115  *
116  * a : Semi-major axis of ellipsoid in meters (input)
117  * f : Flattening of ellipsoid (input)
118  * Ellipsoid_Code : 2-letter code for ellipsoid (input)
119  */
120 
121 
122  OSSIM_DLL void Get_OSSIM_MGRS_Parameters(double *a,
123  double *f,
124  char *Ellipsoid_Code);
125 /*
126  * The function Get_MGRS_Parameters returns the current ellipsoid
127  * parameters.
128  *
129  * a : Semi-major axis of ellipsoid, in meters (output)
130  * f : Flattening of ellipsoid (output)
131  * Ellipsoid_Code : 2-letter code for ellipsoid (output)
132  */
133 
134 
135  OSSIM_DLL long Convert_Geodetic_To_OSSIM_MGRS (double Latitude,
136  double Longitude,
137  long Precision,
138  char *MGRS);
139 /*
140  * The function Convert_Geodetic_To_MGRS converts geodetic (latitude and
141  * longitude) coordinates to an MGRS coordinate string, according to the
142  * current ellipsoid parameters. If any errors occur, the error code(s)
143  * are returned by the function, otherwise MGRS_NO_ERROR is returned.
144  *
145  * Latitude : Latitude in radians (input)
146  * Longitude : Longitude in radians (input)
147  * Precision : Precision level of MGRS string (input)
148  * MGRS : MGRS coordinate string (output)
149  *
150  */
151 
152 
153  OSSIM_DLL long Convert_OSSIM_MGRS_To_Geodetic (const char *MGRS,
154  double *Latitude,
155  double *Longitude);
156 /*
157  * This function converts an MGRS coordinate string to Geodetic (latitude
158  * and longitude in radians) coordinates. If any errors occur, the error
159  * code(s) are returned by the function, otherwise MGRS_NO_ERROR is returned.
160  *
161  * MGRS : MGRS coordinate string (input)
162  * Latitude : Latitude in radians (output)
163  * Longitude : Longitude in radians (output)
164  *
165  */
166 
167 
168  OSSIM_DLL long Convert_UTM_To_OSSIM_MGRS (long Zone,
169  char Hemisphere,
170  double Easting,
171  double Northing,
172  long Precision,
173  char *MGRS);
174 /*
175  * The function Convert_UTM_To_MGRS converts UTM (zone, easting, and
176  * northing) coordinates to an MGRS coordinate string, according to the
177  * current ellipsoid parameters. If any errors occur, the error code(s)
178  * are returned by the function, otherwise MGRS_NO_ERROR is returned.
179  *
180  * Zone : UTM zone (input)
181  * Hemisphere : North or South hemisphere (input)
182  * Easting : Easting (X) in meters (input)
183  * Northing : Northing (Y) in meters (input)
184  * Precision : Precision level of MGRS string (input)
185  * MGRS : MGRS coordinate string (output)
186  */
187 
188 
189  OSSIM_DLL long Convert_OSSIM_MGRS_To_UTM (const char *MGRS,
190  long *Zone,
191  char *Hemisphere,
192  double *Easting,
193  double *Northing);
194 /*
195  * The function Convert_MGRS_To_UTM converts an MGRS coordinate string
196  * to UTM projection (zone, hemisphere, easting and northing) coordinates
197  * according to the current ellipsoid parameters. If any errors occur,
198  * the error code(s) are returned by the function, otherwise UTM_NO_ERROR
199  * is returned.
200  *
201  * MGRS : MGRS coordinate string (input)
202  * Zone : UTM zone (output)
203  * Hemisphere : North or South hemisphere (output)
204  * Easting : Easting (X) in meters (output)
205  * Northing : Northing (Y) in meters (output)
206  */
207 
208 
209 
210  OSSIM_DLL long Convert_UPS_To_OSSIM_MGRS ( char Hemisphere,
211  double Easting,
212  double Northing,
213  long Precision,
214  char *MGRS);
215 
216 /*
217  * The function Convert_UPS_To_MGRS converts UPS (hemisphere, easting,
218  * and northing) coordinates to an MGRS coordinate string according to
219  * the current ellipsoid parameters. If any errors occur, the error
220  * code(s) are returned by the function, otherwise UPS_NO_ERROR is
221  * returned.
222  *
223  * Hemisphere : Hemisphere either 'N' or 'S' (input)
224  * Easting : Easting/X in meters (input)
225  * Northing : Northing/Y in meters (input)
226  * Precision : Precision level of MGRS string (input)
227  * MGRS : MGRS coordinate string (output)
228  */
229 
230 
231  OSSIM_DLL long Convert_OSSIM_MGRS_To_UPS ( const char *MGRS,
232  char *Hemisphere,
233  double *Easting,
234  double *Northing);
235 /*
236  * The function Convert_MGRS_To_UPS converts an MGRS coordinate string
237  * to UPS (hemisphere, easting, and northing) coordinates, according
238  * to the current ellipsoid parameters. If any errors occur, the error
239  * code(s) are returned by the function, otherwide UPS_NO_ERROR is returned.
240  *
241  * MGRS : MGRS coordinate string (input)
242  * Hemisphere : Hemisphere either 'N' or 'S' (output)
243  * Easting : Easting/X in meters (output)
244  * Northing : Northing/Y in meters (output)
245  */
246 
247 
248 
249  #ifdef __cplusplus
250 }
251  #endif
252 
253 #endif /* MGRS_H */
OSSIM_DLL void Get_OSSIM_MGRS_Parameters(double *a, double *f, char *Ellipsoid_Code)
OSSIM_DLL long Convert_UTM_To_OSSIM_MGRS(long Zone, char Hemisphere, double Easting, double Northing, long Precision, char *MGRS)
OSSIM_DLL long Convert_Geodetic_To_OSSIM_MGRS(double Latitude, double Longitude, long Precision, char *MGRS)
OSSIM_DLL long Convert_UPS_To_OSSIM_MGRS(char Hemisphere, double Easting, double Northing, long Precision, char *MGRS)
OSSIM_DLL long Convert_OSSIM_MGRS_To_Geodetic(const char *MGRS, double *Latitude, double *Longitude)
OSSIM_DLL long Set_OSSIM_MGRS_Parameters(double a, double f, const char *Ellipsoid_Code)
OSSIM_DLL long Convert_OSSIM_MGRS_To_UTM(const char *MGRS, long *Zone, char *Hemisphere, double *Easting, double *Northing)
OSSIM_DLL long Convert_OSSIM_MGRS_To_UPS(const char *MGRS, char *Hemisphere, double *Easting, double *Northing)
#define OSSIM_DLL