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

« back to all changes in this revision

Viewing changes to dt_cc/mercator/mercator.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 MERCATOR_H
 
2
  #define MERCATOR_H
 
3
 
 
4
/***************************************************************************/
 
5
/* RSC IDENTIFIER: MERCATOR
 
6
 *
 
7
 * ABSTRACT
 
8
 *
 
9
 *    This component provides conversions between Geodetic coordinates 
 
10
 *    (latitude and longitude in radians) and Mercator projection coordinates
 
11
 *    (easting and northing in meters).
 
12
 *
 
13
 * ERROR HANDLING
 
14
 *
 
15
 *    This component checks parameters for valid values.  If an invalid value
 
16
 *    is found, the error code is combined with the current error code using 
 
17
 *    the bitwise or.  This combining allows multiple error codes to be
 
18
 *    returned. The possible error codes are:
 
19
 *
 
20
 *          MERC_NO_ERROR                  : No errors occurred in function
 
21
 *          MERC_LAT_ERROR                 : Latitude outside of valid range
 
22
 *                                           (-89.5 to 89.5 degrees)
 
23
 *          MERC_LON_ERROR                 : Longitude outside of valid range
 
24
 *                                           (-180 to 360 degrees)
 
25
 *          MERC_EASTING_ERROR             : Easting outside of valid range
 
26
 *                                           (False_Easting +/- ~20,500,000 m,
 
27
 *                                           depending on ellipsoid parameters
 
28
 *                                           and Latitude_of_True_Scale)
 
29
 *          MERC_NORTHING_ERROR            : Northing outside of valid range
 
30
 *                                           (False_Northing +/- ~23,500,000 m,
 
31
 *                                           depending on ellipsoid parameters
 
32
 *                                           and Latitude_of_True_Scale)
 
33
 *          MERC_LAT_OF_TRUE_SCALE_ERROR   : Latitude of true scale outside of valid range
 
34
 *                                           (-89.5 to 89.5 degrees)
 
35
 *          MERC_CENT_MER_ERROR            : Central meridian outside of valid range
 
36
 *                                           (-180 to 360 degrees)
 
37
 *          MERC_A_ERROR                   : Semi-major axis less than or equal to zero
 
38
 *          MERC_INV_F_ERROR               : Inverse flattening outside of valid range
 
39
 *                                                                                               (250 to 350)
 
40
 *
 
41
 * REUSE NOTES
 
42
 *
 
43
 *    MERCATOR is intended for reuse by any application that performs a 
 
44
 *    Mercator projection or its inverse.
 
45
 *    
 
46
 * REFERENCES
 
47
 *
 
48
 *    Further information on MERCATOR can be found in the Reuse Manual.
 
49
 *
 
50
 *    MERCATOR originated from :  U.S. Army Topographic Engineering Center
 
51
 *                                Geospatial Information Division
 
52
 *                                7701 Telegraph Road
 
53
 *                                Alexandria, VA  22310-3864
 
54
 *
 
55
 * LICENSES
 
56
 *
 
57
 *    None apply to this component.
 
58
 *
 
59
 * RESTRICTIONS
 
60
 *
 
61
 *    MERCATOR has no restrictions.
 
62
 *
 
63
 * ENVIRONMENT
 
64
 *
 
65
 *    MERCATOR was tested and certified in the following environments:
 
66
 *
 
67
 *    1. Solaris 2.5 with GCC, version 2.8.1
 
68
 *    2. Windows 95 with MS Visual C++, version 6
 
69
 *
 
70
 * MODIFICATIONS
 
71
 *
 
72
 *    Date              Description
 
73
 *    ----              -----------
 
74
 *    10-02-97          Original Code
 
75
 *    03-18-08          Changed 'origin latitude' to 'latitude of true scale'
 
76
 */
 
77
 
 
78
 
 
79
/***************************************************************************/
 
80
/*
 
81
 *                              DEFINES
 
82
 */
 
83
 
 
84
  #define MERC_NO_ERROR                  0x0000
 
85
  #define MERC_LAT_ERROR                 0x0001
 
86
  #define MERC_LON_ERROR                 0x0002
 
87
  #define MERC_EASTING_ERROR             0x0004
 
88
  #define MERC_NORTHING_ERROR            0x0008
 
89
  #define MERC_LAT_OF_TRUE_SCALE_ERROR   0x0010
 
90
  #define MERC_CENT_MER_ERROR            0x0020
 
91
  #define MERC_A_ERROR                   0x0040
 
92
  #define MERC_INV_F_ERROR               0x0080
 
93
 
 
94
 
 
95
/***************************************************************************/
 
96
/*
 
97
 *                              FUNCTION PROTOTYPES
 
98
 *                                for MERCATOR.C
 
99
 */
 
100
 
 
101
/* ensure proper linkage to c++ programs */
 
102
  #ifdef __cplusplus
 
103
extern "C" {
 
104
  #endif
 
105
 
 
106
  long Set_Mercator_Parameters(double a,      
 
107
                               double f,
 
108
                               double Latitude_of_True_Scale,
 
109
                               double Central_Meridian,
 
110
                               double False_Easting,
 
111
                               double False_Northing,
 
112
                               double *Scale_Factor);
 
113
/*
 
114
 * The function Set_Mercator_Parameters receives the ellipsoid parameters and
 
115
 * Mercator projcetion parameters as inputs, and sets the corresponding state 
 
116
 * variables.  It calculates and returns the scale factor.  If any errors
 
117
 * occur, the error code(s) are returned by the function, otherwise 
 
118
 * MERC_NO_ERROR is returned.
 
119
 *
 
120
 *    a                        : Semi-major axis of ellipsoid, in meters   (input)
 
121
 *    f                        : Flattening of ellipsoid                                                       (input)
 
122
 *    Latitude_of_True_Scale   : Latitude in radians at which the          (input)
 
123
 *                               point scale factor is 1.0
 
124
 *    Central_Meridian         : Longitude in radians at the center of     (input)
 
125
 *                               the projection
 
126
 *    False_Easting            : A coordinate value in meters assigned to the
 
127
 *                               central meridian of the projection.       (input)
 
128
 *    False_Northing           : A coordinate value in meters assigned to the
 
129
 *                               origin latitude of the projection         (input)
 
130
 *    Scale_Factor             : Multiplier which reduces distances in the 
 
131
 *                               projection to the actual distance on the
 
132
 *                               ellipsoid                                 (output)
 
133
 */
 
134
 
 
135
 
 
136
  void Get_Mercator_Parameters(double *a,
 
137
                               double *f,
 
138
                               double *Latitude_of_True_Scale,
 
139
                               double *Central_Meridian,
 
140
                               double *False_Easting,
 
141
                               double *False_Northing,
 
142
                               double *Scale_Factor);
 
143
/*
 
144
 * The function Get_Mercator_Parameters returns the current ellipsoid
 
145
 * parameters, Mercator projection parameters, and scale factor.
 
146
 *
 
147
 *    a                        : Semi-major axis of ellipsoid, in meters   (output)
 
148
 *    f                        : Flattening of ellipsoid                                                       (output)
 
149
 *    Latitude_of_True_Scale   : Latitude in radians at which the          (output)
 
150
 *                               point scale factor is 1.0
 
151
 *    Central_Meridian         : Longitude in radians at the center of     (output)
 
152
 *                               the projection
 
153
 *    False_Easting            : A coordinate value in meters assigned to the
 
154
 *                               central meridian of the projection.       (output)
 
155
 *    False_Northing           : A coordinate value in meters assigned to the
 
156
 *                               origin latitude of the projection         (output)
 
157
 *    Scale_Factor             : Multiplier which reduces distances in the 
 
158
 *                               projection to the actual distance on the
 
159
 *                               ellipsoid                                 (output)
 
160
 */
 
161
 
 
162
 
 
163
  long Convert_Geodetic_To_Mercator (double Latitude,
 
164
                                     double Longitude,
 
165
                                     double *Easting,
 
166
                                     double *Northing); 
 
167
/*
 
168
 * The function Convert_Geodetic_To_Mercator converts geodetic (latitude and
 
169
 * longitude) coordinates to Mercator projection easting, and northing
 
170
 * coordinates, according to the current ellipsoid and Mercator projection
 
171
 * parameters.  If any errors occur, the error code(s) are returned by the
 
172
 * function, otherwise MERC_NO_ERROR is returned.
 
173
 *
 
174
 *    Latitude          : Latitude (phi) in radians           (input)
 
175
 *    Longitude         : Longitude (lambda) in radians       (input)
 
176
 *    Easting           : Easting (X) in meters               (output)
 
177
 *    Northing          : Northing (Y) in meters              (output)
 
178
 */
 
179
 
 
180
 
 
181
  long Convert_Mercator_To_Geodetic(double Easting,
 
182
                                    double Northing,
 
183
                                    double *Latitude,
 
184
                                    double *Longitude);
 
185
/*
 
186
 * The function Convert_Mercator_To_Geodetic converts Mercator projection
 
187
 * easting and northing coordinates to geodetic (latitude and longitude)
 
188
 * coordinates, according to the current ellipsoid and Mercator projection
 
189
 * coordinates.  If any errors occur, the error code(s) are returned by the
 
190
 * function, otherwise MERC_NO_ERROR is returned.
 
191
 *
 
192
 *    Easting           : Easting (X) in meters                  (input)
 
193
 *    Northing          : Northing (Y) in meters                 (input)
 
194
 *    Latitude          : Latitude (phi) in radians              (output)
 
195
 *    Longitude         : Longitude (lambda) in radians          (output)
 
196
 */
 
197
 
 
198
  #ifdef __cplusplus
 
199
}
 
200
  #endif
 
201
 
 
202
#endif /* MERCATOR_H */
 
203