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

« back to all changes in this revision

Viewing changes to dt_cc/albers/albers.c

  • 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
/***************************************************************************/
 
2
/* RSC IDENTIFIER: ALBERS
 
3
 *
 
4
 * ABSTRACT
 
5
 *
 
6
 *    This component provides conversions between Geodetic coordinates
 
7
 *    (latitude and longitude in radians) and Albers Equal Area Conic
 
8
 *    projection coordinates (easting and northing in meters) defined
 
9
 *    by two standard parallels.
 
10
 *
 
11
 * ERROR HANDLING
 
12
 *
 
13
 *    This component checks parameters for valid values.  If an invalid value
 
14
 *    is found the error code is combined with the current error code using
 
15
 *    the bitwise or.  This combining allows multiple error codes to be
 
16
 *    returned. The possible error codes are:
 
17
 *
 
18
 *       ALBERS_NO_ERROR           : No errors occurred in function
 
19
 *       ALBERS_LAT_ERROR          : Latitude outside of valid range
 
20
 *                                     (-90 to 90 degrees)
 
21
 *       ALBERS_LON_ERROR          : Longitude outside of valid range
 
22
 *                                     (-180 to 360 degrees)
 
23
 *       ALBERS_EASTING_ERROR      : Easting outside of valid range
 
24
 *                                     (depends on ellipsoid and projection
 
25
 *                                     parameters)
 
26
 *       ALBERS_NORTHING_ERROR     : Northing outside of valid range
 
27
 *                                     (depends on ellipsoid and projection
 
28
 *                                     parameters)
 
29
 *       ALBERS_FIRST_STDP_ERROR   : First standard parallel outside of valid
 
30
 *                                     range (-90 to 90 degrees)
 
31
 *       ALBERS_SECOND_STDP_ERROR  : Second standard parallel outside of valid
 
32
 *                                     range (-90 to 90 degrees)
 
33
 *       ALBERS_ORIGIN_LAT_ERROR   : Origin latitude outside of valid range
 
34
 *                                     (-90 to 90 degrees)
 
35
 *       ALBERS_CENT_MER_ERROR     : Central meridian outside of valid range
 
36
 *                                     (-180 to 360 degrees)
 
37
 *       ALBERS_A_ERROR            : Semi-major axis less than or equal to zero
 
38
 *       ALBERS_INV_F_ERROR        : Inverse flattening outside of valid range
 
39
 *                                                                                       (250 to 350)
 
40
 *       ALBERS_HEMISPHERE_ERROR   : Standard parallels cannot be opposite
 
41
 *                                     latitudes
 
42
 *       ALBERS_FIRST_SECOND_ERROR : The 1st & 2nd standard parallels cannot
 
43
 *                                   both be 0
 
44
 *
 
45
 *
 
46
 * REUSE NOTES
 
47
 *
 
48
 *    ALBERS is intended for reuse by any application that performs an Albers
 
49
 *    Equal Area Conic projection or its inverse.
 
50
 *
 
51
 * REFERENCES
 
52
 *
 
53
 *    Further information on ALBERS can be found in the Reuse Manual.
 
54
 *
 
55
 *    ALBERS originated from:     U.S. Army Topographic Engineering Center
 
56
 *                                Geospatial Information Division
 
57
 *                                7701 Telegraph Road
 
58
 *                                Alexandria, VA  22310-3864
 
59
 *
 
60
 * LICENSES
 
61
 *
 
62
 *    None apply to this component.
 
63
 *
 
64
 * RESTRICTIONS
 
65
 *
 
66
 *    ALBERS has no restrictions.
 
67
 *
 
68
 * ENVIRONMENT
 
69
 *
 
70
 *    ALBERS was tested and certified in the following environments:
 
71
 *
 
72
 *    1. Solaris 2.5 with GCC, version 2.8.1
 
73
 *    2. MSDOS with MS Visual C++, version 6
 
74
 *
 
75
 * MODIFICATIONS
 
76
 *
 
77
 *    Date              Description
 
78
 *    ----              -----------
 
79
 *    07-09-99          Original Code
 
80
 *    
 
81
 *
 
82
 */
 
83
 
 
84
 
 
85
 
 
86
/***************************************************************************/
 
87
/*
 
88
 *                               INCLUDES
 
89
 */
 
90
 
 
91
#include <math.h>
 
92
#include "albers.h"
 
93
 
 
94
/*
 
95
 *    math.h     - Standard C math library
 
96
 *    albers.h   - Is for prototype error checking
 
97
 */
 
98
 
 
99
 
 
100
/***************************************************************************/
 
101
/*
 
102
 *                               DEFINES
 
103
 */
 
104
 
 
105
#define PI         3.14159265358979323e0  /* PI                            */
 
106
#define PI_OVER_2  ( PI / 2.0)                 
 
107
#define TWO_PI     (2.0 * PI)                    
 
108
#define ES_SIN(sinlat)          (es * sinlat)
 
109
#define ONE_MINUS_SQR(x)        (1.0 - x * x)
 
110
#define ALBERS_M(clat,oneminussqressin)   (clat / sqrt(oneminussqressin))
 
111
#define ALBERS_Q(slat,oneminussqressin,essin) (one_MINUS_es2)*(slat / (oneminussqressin)-    \
 
112
                                                                                          (1 / (two_es)) *log((1 - essin) / (1 + essin)))
 
113
 
 
114
/***************************************************************************/
 
115
/*
 
116
 *                               GLOBALS
 
117
 */
 
118
 
 
119
/* Ellipsoid Parameters, default to WGS 84 */
 
120
static double Albers_a = 6378137.0;                   /* Semi-major axis of ellipsoid in meters */
 
121
static double Albers_f = 1 / 298.257223563;           /* Flattening of ellipsoid */
 
122
static double es = 0.08181919084262188000;            /* Eccentricity of ellipsoid */
 
123
static double es2 = 0.0066943799901413800;            /* Eccentricity squared         */
 
124
static double C =1.4896626908850;                     /* constant c   */
 
125
static double rho0 = 6388749.3391064;                 /* height above ellipsoid         */
 
126
static double n = .70443998701755;                    /* ratio between meridians                */
 
127
static double Albers_a_OVER_n = 9054194.9882824;      /* Albers_a / n */
 
128
static double one_MINUS_es2 = .99330562000986;        /* 1 - es2 */
 
129
static double two_es = .16363838168524;               /* 2 * es */
 
130
 
 
131
/* Albers Projection Parameters */
 
132
static double Albers_Origin_Lat = (45 * PI / 180);    /* Latitude of origin in radians     */
 
133
static double Albers_Origin_Long = 0.0;               /* Longitude of origin in radians    */
 
134
static double Albers_Std_Parallel_1 = (40 * PI / 180);
 
135
static double Albers_Std_Parallel_2 = (50 * PI / 180);
 
136
static double Albers_False_Easting = 0.0;
 
137
static double Albers_False_Northing = 0.0;
 
138
 
 
139
static double Albers_Delta_Northing = 40000000;
 
140
static double Albers_Delta_Easting =  40000000;
 
141
/*
 
142
 * These state variables are for optimization purposes.  The only function
 
143
 * that should modify them is Set_Albers_Parameters.
 
144
 */
 
145
 
 
146
 
 
147
/***************************************************************************/
 
148
/*
 
149
 *                              FUNCTIONS
 
150
 */
 
151
long Set_Albers_Parameters(double a,
 
152
                           double f,
 
153
                           double Origin_Latitude,
 
154
                           double Central_Meridian,
 
155
                           double Std_Parallel_1,
 
156
                           double Std_Parallel_2,
 
157
                           double False_Easting,
 
158
                           double False_Northing)
 
159
 
 
160
{ /* BEGIN Set_Albers_Parameters */
 
161
/*
 
162
 * The function Set_Albers_Parameters receives the ellipsoid parameters and
 
163
 * projection parameters as inputs, and sets the corresponding state
 
164
 * variables.  If any errors occur, the error code(s) are returned by the function, 
 
165
 * otherwise ALBERS_NO_ERROR is returned.
 
166
 *
 
167
 *    a                 : Semi-major axis of ellipsoid, in meters   (input)
 
168
 *    f                 : Flattening of ellipsoid                   (input)
 
169
 *    Origin_Latitude   : Latitude in radians at which the          (input)
 
170
 *                          point scale factor is 1.0
 
171
 *    Central_Meridian  : Longitude in radians at the center of     (input)
 
172
 *                          the projection
 
173
 *    Std_Parallel_1    : First standard parallel                   (input)
 
174
 *    Std_Parallel_2    : Second standard parallel                  (input)
 
175
 *    False_Easting     : A coordinate value in meters assigned to the
 
176
 *                          central meridian of the projection.     (input)
 
177
 *    False_Northing    : A coordinate value in meters assigned to the
 
178
 *                          origin latitude of the projection       (input)
 
179
 */
 
180
 
 
181
  double sin_lat, sin_lat_1, cos_lat;
 
182
  double m1, m2, SQRm1;
 
183
  double q0, q1, q2;
 
184
  double es_sin, one_MINUS_SQRes_sin;
 
185
  double nq0;
 
186
  double inv_f = 1 / f;
 
187
  long Error_Code = ALBERS_NO_ERROR;
 
188
 
 
189
  if (a <= 0.0)
 
190
  { /* Semi-major axis must be greater than zero */
 
191
    Error_Code |= ALBERS_A_ERROR;
 
192
  }
 
193
  if ((inv_f < 250) || (inv_f > 350))
 
194
  { /* Inverse flattening must be between 250 and 350 */
 
195
    Error_Code |= ALBERS_INV_F_ERROR;
 
196
  }
 
197
  if ((Origin_Latitude < -PI_OVER_2) || (Origin_Latitude > PI_OVER_2))
 
198
  { /* origin latitude out of range */
 
199
    Error_Code |= ALBERS_ORIGIN_LAT_ERROR;
 
200
  }
 
201
  if ((Central_Meridian < -PI) || (Central_Meridian > TWO_PI))
 
202
  { /* origin longitude out of range */
 
203
    Error_Code |= ALBERS_CENT_MER_ERROR;
 
204
  }
 
205
  if ((Std_Parallel_1 < -PI_OVER_2) || (Std_Parallel_1 > PI_OVER_2))
 
206
  { /* First Standard Parallel out of range */
 
207
    Error_Code |= ALBERS_FIRST_STDP_ERROR;
 
208
  }
 
209
  if ((Std_Parallel_2 < -PI_OVER_2) || (Std_Parallel_2 > PI_OVER_2))
 
210
  { /* Second Standard Parallel out of range */
 
211
    Error_Code |= ALBERS_SECOND_STDP_ERROR;
 
212
  }
 
213
  if ((Std_Parallel_1 == 0.0) && (Std_Parallel_2 == 0.0))
 
214
  { /* First & Second Standard Parallels equal 0 */
 
215
    Error_Code |= ALBERS_FIRST_SECOND_ERROR;
 
216
  }
 
217
  if (Std_Parallel_1 == -Std_Parallel_2)
 
218
  { /* Parallels are opposite latitudes */
 
219
    Error_Code |= ALBERS_HEMISPHERE_ERROR;
 
220
  }
 
221
 
 
222
  if (!Error_Code)
 
223
  { /* no errors */
 
224
    Albers_a = a;
 
225
    Albers_f = f;
 
226
    Albers_Origin_Lat = Origin_Latitude;
 
227
    Albers_Std_Parallel_1 = Std_Parallel_1;
 
228
    Albers_Std_Parallel_2 = Std_Parallel_2;
 
229
    if (Central_Meridian > PI)
 
230
      Central_Meridian -= TWO_PI;
 
231
    Albers_Origin_Long = Central_Meridian;
 
232
    Albers_False_Easting = False_Easting;
 
233
    Albers_False_Northing = False_Northing;
 
234
 
 
235
    es2 = 2 * Albers_f - Albers_f * Albers_f;
 
236
    es = sqrt(es2);
 
237
    one_MINUS_es2 = 1 - es2;
 
238
    two_es = 2 * es;
 
239
 
 
240
    sin_lat = sin(Albers_Origin_Lat);
 
241
    es_sin = ES_SIN(sin_lat);
 
242
    one_MINUS_SQRes_sin = ONE_MINUS_SQR(es_sin);
 
243
    q0 = ALBERS_Q(sin_lat, one_MINUS_SQRes_sin, es_sin);
 
244
 
 
245
    sin_lat_1 = sin(Albers_Std_Parallel_1);
 
246
    cos_lat = cos(Albers_Std_Parallel_1);
 
247
    es_sin = ES_SIN(sin_lat_1);
 
248
    one_MINUS_SQRes_sin = ONE_MINUS_SQR(es_sin);
 
249
    m1 = ALBERS_M(cos_lat, one_MINUS_SQRes_sin);
 
250
    q1 = ALBERS_Q(sin_lat_1, one_MINUS_SQRes_sin, es_sin);
 
251
 
 
252
    SQRm1 = m1 * m1;
 
253
    if (fabs(Albers_Std_Parallel_1 - Albers_Std_Parallel_2) > 1.0e-10)
 
254
    {
 
255
      sin_lat = sin(Albers_Std_Parallel_2);
 
256
      cos_lat = cos(Albers_Std_Parallel_2);
 
257
      es_sin = ES_SIN(sin_lat);
 
258
      one_MINUS_SQRes_sin = ONE_MINUS_SQR(es_sin);
 
259
      m2 = ALBERS_M(cos_lat, one_MINUS_SQRes_sin);
 
260
      q2 = ALBERS_Q(sin_lat, one_MINUS_SQRes_sin, es_sin);
 
261
      n = (SQRm1 - m2 * m2) / (q2 - q1);
 
262
    }
 
263
    else
 
264
      n = sin_lat_1;
 
265
 
 
266
    C = SQRm1 + n * q1;
 
267
    Albers_a_OVER_n = Albers_a / n;
 
268
    nq0 = n * q0;
 
269
    if (C < nq0)
 
270
      rho0 = 0;
 
271
    else
 
272
      rho0 = Albers_a_OVER_n * sqrt(C - nq0);
 
273
 
 
274
 
 
275
  } /* END OF if(!Error_Code) */
 
276
  return (Error_Code);
 
277
} /* END OF Set_Albers_Parameters */
 
278
 
 
279
 
 
280
void Get_Albers_Parameters(double *a,
 
281
                           double *f,
 
282
                           double *Origin_Latitude,
 
283
                           double *Central_Meridian,
 
284
                           double *Std_Parallel_1,
 
285
                           double *Std_Parallel_2,
 
286
                           double *False_Easting,
 
287
                           double *False_Northing)
 
288
 
 
289
{ /* BEGIN Get_Albers_Parameters */
 
290
/*
 
291
 * The function Get_Albers_Parameters returns the current ellipsoid
 
292
 * parameters, and Albers projection parameters.
 
293
 *
 
294
 *    a                 : Semi-major axis of ellipsoid, in meters   (output)
 
295
 *    f                 : Flattening of ellipsoid                                                                               (output)
 
296
 *    Origin_Latitude   : Latitude in radians at which the          (output)
 
297
 *                          point scale factor is 1.0
 
298
 *    Origin_Longitude  : Longitude in radians at the center of     (output)
 
299
 *                          the projection
 
300
 *    Std_Parallel_1    : First standard parallel                   (output)
 
301
 *    Std_Parallel_2    : Second standard parallel                  (output)
 
302
 *    False_Easting     : A coordinate value in meters assigned to the
 
303
 *                          central meridian of the projection.     (output)
 
304
 *    False_Northing    : A coordinate value in meters assigned to the
 
305
 *                          origin latitude of the projection       (output)
 
306
 */
 
307
 
 
308
  *a = Albers_a;
 
309
  *f = Albers_f;
 
310
  *Origin_Latitude = Albers_Origin_Lat;
 
311
  *Std_Parallel_1 = Albers_Std_Parallel_1;
 
312
  *Std_Parallel_2 = Albers_Std_Parallel_2;
 
313
  *Central_Meridian = Albers_Origin_Long;
 
314
  *False_Easting = Albers_False_Easting;
 
315
  *False_Northing = Albers_False_Northing;
 
316
  return;
 
317
} /* END OF Get_Albers_Parameters */
 
318
 
 
319
 
 
320
long Convert_Geodetic_To_Albers (double Latitude,
 
321
                                 double Longitude,
 
322
                                 double *Easting,
 
323
                                 double *Northing)
 
324
 
 
325
{ /* BEGIN Convert_Geodetic_To_Albers */
 
326
/*
 
327
 * The function Convert_Geodetic_To_Albers converts geodetic (latitude and
 
328
 * longitude) coordinates to Albers projection (easting and northing)
 
329
 * coordinates, according to the current ellipsoid and Albers projection
 
330
 * parameters.  If any errors occur, the error code(s) are returned by the
 
331
 * function, otherwise ALBERS_NO_ERROR is returned.
 
332
 *
 
333
 *    Latitude          : Latitude (phi) in radians           (input)
 
334
 *    Longitude         : Longitude (lambda) in radians       (input)
 
335
 *    Easting           : Easting (X) in meters               (output)
 
336
 *    Northing          : Northing (Y) in meters              (output)
 
337
 */
 
338
 
 
339
  double dlam;                      /* Longitude - Central Meridan */
 
340
  double sin_lat, cos_lat;
 
341
  double es_sin, one_MINUS_SQRes_sin;
 
342
  double q;
 
343
  double rho;
 
344
  double theta;
 
345
  double nq;
 
346
  long Error_Code = ALBERS_NO_ERROR;
 
347
 
 
348
  if ((Latitude < -PI_OVER_2) || (Latitude > PI_OVER_2))
 
349
  {  /* Latitude out of range */
 
350
    Error_Code |= ALBERS_LAT_ERROR;
 
351
  }
 
352
  if ((Longitude < -PI) || (Longitude > TWO_PI))
 
353
  {  /* Longitude out of range */
 
354
    Error_Code|= ALBERS_LON_ERROR;
 
355
  }
 
356
 
 
357
  if (!Error_Code)
 
358
  { /* no errors */
 
359
 
 
360
    dlam = Longitude - Albers_Origin_Long;
 
361
    if (dlam > PI)
 
362
    {
 
363
      dlam -= TWO_PI;
 
364
    }
 
365
    if (dlam < -PI)
 
366
    {
 
367
      dlam += TWO_PI;
 
368
    }
 
369
    sin_lat = sin(Latitude);
 
370
    cos_lat = cos(Latitude);
 
371
    es_sin = ES_SIN(sin_lat);
 
372
    one_MINUS_SQRes_sin = ONE_MINUS_SQR(es_sin);
 
373
    q = ALBERS_Q(sin_lat, one_MINUS_SQRes_sin, es_sin);
 
374
    nq = n * q;
 
375
    if (C < nq)
 
376
      rho = 0;
 
377
    else
 
378
      rho = Albers_a_OVER_n * sqrt(C - nq);
 
379
 
 
380
 
 
381
    theta = n * dlam;
 
382
    *Easting = rho * sin(theta) + Albers_False_Easting;
 
383
    *Northing = rho0 - rho * cos(theta) + Albers_False_Northing;
 
384
  }
 
385
  return (Error_Code);
 
386
} /* END OF Convert_Geodetic_To_Albers */
 
387
 
 
388
 
 
389
long Convert_Albers_To_Geodetic(double Easting,
 
390
                                double Northing,
 
391
                                double *Latitude,
 
392
                                double *Longitude)
 
393
{ /* BEGIN Convert_Albers_To_Geodetic */
 
394
/*
 
395
 * The function Convert_Albers_To_Geodetic converts Albers projection
 
396
 * (easting and northing) coordinates to geodetic (latitude and longitude)
 
397
 * coordinates, according to the current ellipsoid and Albers projection
 
398
 * coordinates.  If any errors occur, the error code(s) are returned by the
 
399
 * function, otherwise ALBERS_NO_ERROR is returned.
 
400
 *
 
401
 *    Easting           : Easting (X) in meters                  (input)
 
402
 *    Northing          : Northing (Y) in meters                 (input)
 
403
 *    Latitude          : Latitude (phi) in radians              (output)
 
404
 *    Longitude         : Longitude (lambda) in radians          (output)
 
405
 */
 
406
  double dy, dx;
 
407
  double rho0_MINUS_dy;
 
408
  double q, qconst, q_OVER_2;
 
409
  double rho, rho_n;
 
410
  double PHI, Delta_PHI = 1.0;
 
411
  double sin_phi;
 
412
  double es_sin, one_MINUS_SQRes_sin;
 
413
  double theta = 0.0;
 
414
  int count = 30;
 
415
  double tolerance = 4.85e-10;        /* approximately 1/1000th of
 
416
                              an arc second or 1/10th meter */
 
417
  long Error_Code = ALBERS_NO_ERROR; 
 
418
 
 
419
  if ((Easting < (Albers_False_Easting - Albers_Delta_Easting)) 
 
420
      || (Easting > Albers_False_Easting + Albers_Delta_Easting))
 
421
  { /* Easting out of range  */
 
422
    Error_Code |= ALBERS_EASTING_ERROR;
 
423
  }
 
424
  if ((Northing < (Albers_False_Northing - Albers_Delta_Northing)) 
 
425
      || (Northing > Albers_False_Northing + Albers_Delta_Northing))
 
426
  { /* Northing out of range */
 
427
    Error_Code |= ALBERS_NORTHING_ERROR;
 
428
  }
 
429
 
 
430
  if (!Error_Code)
 
431
  {
 
432
    dy = Northing - Albers_False_Northing;
 
433
    dx = Easting - Albers_False_Easting;
 
434
    rho0_MINUS_dy = rho0 - dy;
 
435
    rho = sqrt(dx * dx + rho0_MINUS_dy * rho0_MINUS_dy);
 
436
 
 
437
    if (n < 0)
 
438
    {
 
439
      rho *= -1.0;
 
440
      dy *= -1.0;
 
441
      dx *= -1.0;
 
442
      rho0_MINUS_dy *= -1.0;
 
443
    }
 
444
 
 
445
    if (rho != 0.0)
 
446
      theta = atan2(dx, rho0_MINUS_dy);
 
447
    rho_n = rho * n;
 
448
    q = (C - (rho_n * rho_n) / (Albers_a * Albers_a)) / n;
 
449
    qconst = 1 - ((one_MINUS_es2) / (two_es)) * log((1.0 - es) / (1.0 + es));
 
450
    if (fabs(fabs(qconst) - fabs(q)) > 1.0e-6)
 
451
    {
 
452
      q_OVER_2 = q / 2.0;
 
453
      if (q_OVER_2 > 1.0)
 
454
        *Latitude = PI_OVER_2;
 
455
      else if (q_OVER_2 < -1.0)
 
456
        *Latitude = -PI_OVER_2;
 
457
      else
 
458
      {
 
459
        PHI = asin(q_OVER_2);
 
460
        if (es < 1.0e-10)
 
461
          *Latitude = PHI;
 
462
        else
 
463
        {
 
464
          while ((fabs(Delta_PHI) > tolerance) && count)
 
465
          {
 
466
            sin_phi = sin(PHI);
 
467
            es_sin = ES_SIN(sin_phi);
 
468
            one_MINUS_SQRes_sin = ONE_MINUS_SQR(es_sin);
 
469
            Delta_PHI = (one_MINUS_SQRes_sin * one_MINUS_SQRes_sin) / (2.0 * cos(PHI)) *
 
470
                        (q / (one_MINUS_es2) - sin_phi / one_MINUS_SQRes_sin +
 
471
                         (log((1.0 - es_sin) / (1.0 + es_sin)) / (two_es)));
 
472
            PHI += Delta_PHI;
 
473
            count --;
 
474
          }
 
475
 
 
476
          if(!count)
 
477
            return Error_Code |= ALBERS_NORTHING_ERROR;
 
478
 
 
479
          *Latitude = PHI;
 
480
        }
 
481
 
 
482
        if (*Latitude > PI_OVER_2)  /* force distorted values to 90, -90 degrees */
 
483
          *Latitude = PI_OVER_2;
 
484
        else if (*Latitude < -PI_OVER_2)
 
485
          *Latitude = -PI_OVER_2;
 
486
 
 
487
      }
 
488
    }
 
489
    else
 
490
    {
 
491
      if (q >= 0.0)
 
492
        *Latitude = PI_OVER_2;
 
493
      else
 
494
        *Latitude = -PI_OVER_2;
 
495
    }
 
496
    *Longitude = Albers_Origin_Long + theta / n;
 
497
 
 
498
    if (*Longitude > PI)
 
499
      *Longitude -= TWO_PI;
 
500
    if (*Longitude < -PI)
 
501
      *Longitude += TWO_PI;
 
502
 
 
503
    if (*Longitude > PI) /* force distorted values to 180, -180 degrees */
 
504
      *Longitude = PI;
 
505
    else if (*Longitude < -PI)
 
506
      *Longitude = -PI;
 
507
 
 
508
  }
 
509
  return (Error_Code);
 
510
} /* END OF Convert_Albers_To_Geodetic */
 
511
 
 
512
 
 
513