~ubuntu-branches/ubuntu/raring/geotranz/raring

« back to all changes in this revision

Viewing changes to dt_cc/usng/usng.h

  • Committer: Bazaar Package Importer
  • Author(s): Roberto Lumbreras
  • Date: 2008-10-17 14:43:09 UTC
  • Revision ID: james.westby@ubuntu.com-20081017144309-jb7uzfi1y1lvez8j
Tags: upstream-2.4.2
ImportĀ upstreamĀ versionĀ 2.4.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef USNG_H
 
2
  #define USNG_H
 
3
 
 
4
/***************************************************************************/
 
5
/* RSC IDENTIFIER:  USNG
 
6
 *
 
7
 * ABSTRACT
 
8
 *
 
9
 *    This component converts between geodetic coordinates (latitude and 
 
10
 *    longitude) and United States National Grid (USNG) 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
 *          USNG_NO_ERROR          : No errors occurred in function
 
20
 *          USNG_LAT_ERROR         : Latitude outside of valid range 
 
21
 *                                    (-90 to 90 degrees)
 
22
 *          USNG_LON_ERROR         : Longitude outside of valid range
 
23
 *                                    (-180 to 360 degrees)
 
24
 *          USNG_STR_ERROR         : An USNG string error: string too long,
 
25
 *                                    too short, or badly formed
 
26
 *          USNG_PRECISION_ERROR   : The precision must be between 0 and 5 
 
27
 *                                    inclusive.
 
28
 *          USNG_A_ERROR           : Semi-major axis less than or equal to zero
 
29
 *          USNG_INV_F_ERROR       : Inverse flattening outside of valid range
 
30
 *                                                                                        (250 to 350)
 
31
 *          USNG_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
 *          USNG_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
 *          USNG_ZONE_ERROR        : Zone outside of valid range (1 to 60)
 
38
 *          USNG_HEMISPHERE_ERROR  : Invalid hemisphere ('N' or 'S')
 
39
 *
 
40
 * REUSE NOTES
 
41
 *
 
42
 *    USNG is intended for reuse by any application that does conversions
 
43
 *    between geodetic coordinates and USNG coordinates.
 
44
 *
 
45
 * REFERENCES
 
46
 *
 
47
 *    Further information on USNG can be found in the Reuse Manual.
 
48
 *
 
49
 *    USNG originated from : Federal Geographic Data Committee
 
50
 *                           590 National Center
 
51
 *                           12201 Sunrise Valley Drive
 
52
 *                           Reston, VA  22092
 
53
 *
 
54
 * LICENSES
 
55
 *
 
56
 *    None apply to this component.
 
57
 *
 
58
 * RESTRICTIONS
 
59
 *
 
60
 *
 
61
 * ENVIRONMENT
 
62
 *
 
63
 *    USNG 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
 *    06-05-06          Original Code (cloned from MGRS)
 
73
 *
 
74
 */
 
75
 
 
76
 
 
77
/***************************************************************************/
 
78
/*
 
79
 *                              DEFINES
 
80
 */
 
81
 
 
82
  #define USNG_NO_ERROR                0x0000
 
83
  #define USNG_LAT_ERROR               0x0001
 
84
  #define USNG_LON_ERROR               0x0002
 
85
  #define USNG_STRING_ERROR            0x0004
 
86
  #define USNG_PRECISION_ERROR         0x0008
 
87
  #define USNG_A_ERROR                 0x0010
 
88
  #define USNG_INV_F_ERROR             0x0020
 
89
  #define USNG_EASTING_ERROR           0x0040
 
90
  #define USNG_NORTHING_ERROR          0x0080
 
91
  #define USNG_ZONE_ERROR              0x0100
 
92
  #define USNG_HEMISPHERE_ERROR        0x0200
 
93
  #define USNG_LAT_WARNING             0x0400
 
94
 
 
95
 
 
96
/***************************************************************************/
 
97
/*
 
98
 *                              FUNCTION PROTOTYPES
 
99
 */
 
100
 
 
101
/* ensure proper linkage to c++ programs */
 
102
  #ifdef __cplusplus
 
103
extern "C" {
 
104
  #endif
 
105
 
 
106
 
 
107
  long Set_USNG_Parameters(double a,
 
108
                           double f,
 
109
                           char   *Ellipsoid_Code);
 
110
/*
 
111
 * The function Set_USNG_Parameters receives the ellipsoid parameters and sets
 
112
 * the corresponding state variables. If any errors occur, the error code(s)
 
113
 * are returned by the function, otherwise USNG_NO_ERROR is returned.
 
114
 *
 
115
 *   a                : Semi-major axis of ellipsoid in meters (input)
 
116
 *   f                : Flattening of ellipsoid                                        (input)
 
117
 *   Ellipsoid_Code   : 2-letter code for ellipsoid            (input)
 
118
 */
 
119
 
 
120
 
 
121
  void Get_USNG_Parameters(double *a,
 
122
                           double *f,
 
123
                           char   *Ellipsoid_Code);
 
124
/*
 
125
 * The function Get_USNG_Parameters returns the current ellipsoid
 
126
 * parameters.
 
127
 *
 
128
 *  a                : Semi-major axis of ellipsoid, in meters (output)
 
129
 *  f                : Flattening of ellipsoid                                         (output)
 
130
 *  Ellipsoid_Code   : 2-letter code for ellipsoid             (output)
 
131
 */
 
132
 
 
133
 
 
134
  long Convert_Geodetic_To_USNG (double Latitude,
 
135
                                 double Longitude,
 
136
                                 long   Precision,
 
137
                                 char *USNG);
 
138
/*
 
139
 * The function Convert_Geodetic_To_USNG converts geodetic (latitude and
 
140
 * longitude) coordinates to a USNG coordinate string, according to the 
 
141
 * current ellipsoid parameters.  If any errors occur, the error code(s) 
 
142
 * are returned by the  function, otherwise USNG_NO_ERROR is returned.
 
143
 *
 
144
 *    Latitude   : Latitude in radians              (input)
 
145
 *    Longitude  : Longitude in radians             (input)
 
146
 *    Precision  : Precision level of USNG string   (input)
 
147
 *    USNG       : USNG coordinate string           (output)
 
148
 *  
 
149
 */
 
150
 
 
151
 
 
152
  long Convert_USNG_To_Geodetic (char *USNG,
 
153
                                 double *Latitude,
 
154
                                 double *Longitude);
 
155
/*
 
156
 * This function converts a USNG coordinate string to Geodetic (latitude
 
157
 * and longitude in radians) coordinates.  If any errors occur, the error 
 
158
 * code(s) are returned by the  function, otherwise USNG_NO_ERROR is returned.  
 
159
 *
 
160
 *    USNG       : USNG coordinate string           (input)
 
161
 *    Latitude   : Latitude in radians              (output)
 
162
 *    Longitude  : Longitude in radians             (output)
 
163
 *  
 
164
 */
 
165
 
 
166
 
 
167
  long Convert_UTM_To_USNG (long Zone,
 
168
                            char Hemisphere,
 
169
                            double Easting,
 
170
                            double Northing,
 
171
                            long Precision,
 
172
                            char *USNG);
 
173
/*
 
174
 * The function Convert_UTM_To_USNG converts UTM (zone, easting, and
 
175
 * northing) coordinates to a USNG coordinate string, according to the 
 
176
 * current ellipsoid parameters.  If any errors occur, the error code(s) 
 
177
 * are returned by the  function, otherwise USNG_NO_ERROR is returned.
 
178
 *
 
179
 *    Zone       : UTM zone                         (input)
 
180
 *    Hemisphere : North or South hemisphere        (input)
 
181
 *    Easting    : Easting (X) in meters            (input)
 
182
 *    Northing   : Northing (Y) in meters           (input)
 
183
 *    Precision  : Precision level of USNG string   (input)
 
184
 *    USNG       : USNG coordinate string           (output)
 
185
 */
 
186
 
 
187
 
 
188
  long Convert_USNG_To_UTM (char   *USNG,
 
189
                            long   *Zone,
 
190
                            char   *Hemisphere,
 
191
                            double *Easting,
 
192
                            double *Northing); 
 
193
/*
 
194
 * The function Convert_USNG_To_UTM converts a USNG coordinate string
 
195
 * to UTM projection (zone, hemisphere, easting and northing) coordinates 
 
196
 * according to the current ellipsoid parameters.  If any errors occur, 
 
197
 * the error code(s) are returned by the function, otherwise UTM_NO_ERROR 
 
198
 * is returned.
 
199
 *
 
200
 *    USNG       : USNG coordinate string           (input)
 
201
 *    Zone       : UTM zone                         (output)
 
202
 *    Hemisphere : North or South hemisphere        (output)
 
203
 *    Easting    : Easting (X) in meters            (output)
 
204
 *    Northing   : Northing (Y) in meters           (output)
 
205
 */
 
206
 
 
207
 
 
208
 
 
209
  long Convert_UPS_To_USNG ( char   Hemisphere,
 
210
                             double Easting,
 
211
                             double Northing,
 
212
                             long Precision,
 
213
                             char *USNG);
 
214
 
 
215
/*
 
216
 *  The function Convert_UPS_To_USNG converts UPS (hemisphere, easting, 
 
217
 *  and northing) coordinates to a USNG coordinate string according to 
 
218
 *  the current ellipsoid parameters.  If any errors occur, the error
 
219
 *  code(s) are returned by the function, otherwise UPS_NO_ERROR is 
 
220
 *  returned.
 
221
 *
 
222
 *    Hemisphere    : Hemisphere either 'N' or 'S'     (input)
 
223
 *    Easting       : Easting/X in meters              (input)
 
224
 *    Northing      : Northing/Y in meters             (input)
 
225
 *    Precision     : Precision level of USNG string   (input)
 
226
 *    USNG          : USNG coordinate string           (output)
 
227
 */
 
228
 
 
229
 
 
230
  long Convert_USNG_To_UPS ( char   *USNG,
 
231
                             char   *Hemisphere,
 
232
                             double *Easting,
 
233
                             double *Northing);
 
234
/*
 
235
 *  The function Convert_USNG_To_UPS converts a USNG coordinate string
 
236
 *  to UPS (hemisphere, easting, and northing) coordinates, according 
 
237
 *  to the current ellipsoid parameters. If any errors occur, the error 
 
238
 *  code(s) are returned by the function, otherwide UPS_NO_ERROR is returned.
 
239
 *
 
240
 *    USNG          : USNG coordinate string           (input)
 
241
 *    Hemisphere    : Hemisphere either 'N' or 'S'     (output)
 
242
 *    Easting       : Easting/X in meters              (output)
 
243
 *    Northing      : Northing/Y in meters             (output)
 
244
 */
 
245
 
 
246
 
 
247
 
 
248
  #ifdef __cplusplus
 
249
}
 
250
  #endif
 
251
 
 
252
#endif /* USNG_H */