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