1
/****************************************************************************/
2
/* RSC IDENTIFIER: Ellipsoid
6
* The purpose of ELLIPSOID is to provide access to ellipsoid parameters
7
* for a collection of common ellipsoids. A particular ellipsoid can be
8
* accessed by using its standard 2-letter code to find its index in the
9
* ellipsoid table. The index can then be used to retrieve the ellipsoid
10
* name and parameters.
12
* By sequentially retrieving all of the ellipsoid codes and/or names, a
13
* menu of the available ellipsoids can be constructed. The index values
14
* resulting from selections from this menu can then be used to access the
15
* parameters of the selected ellipsoid.
17
* This component depends on a data file named "ellips.dat", which contains
18
* the ellipsoid parameter values. A copy of this file must be located in
19
* the directory specified by the environment variable "GEOTRANS_DATA", if
20
* defined, or else in the current directory, whenever a program containing
21
* this component is executed.
23
* Additional ellipsoids can be added to this file, either manually or using
24
* the Create_Ellipsoid function. However, if a large number of ellipsoids
25
* are added, the ellipsoid table array size in this component will have to
30
* This component checks parameters for valid values. If an invalid value
31
* is found, the error code is combined with the current error code using
32
* the bitwise or. This combining allows multiple error codes to be
33
* returned. The possible error codes are:
35
* ELLIPSE_NO_ERROR : No errors occured in function
36
* ELLIPSE_FILE_OPEN_ERROR : Ellipsoid file opening error
37
* ELLIPSE_INITIALIZE_ERROR : Ellipsoid table can not initialize
38
* ELLIPSE_TABLE_OVERFLOW_ERROR : Ellipsoid table overflow
39
* ELLIPSE_NOT_INITIALIZED_ERROR: Ellipsoid table not initialized properly
40
* ELLIPSE_INVALID_INDEX_ERROR : Index is an invalid value
41
* ELLIPSE_INVALID_CODE_ERROR : Code was not found in table
42
* ELLIPSE_A_ERROR : Semi-major axis less than or equal to zero
43
* ELLIPSE_INV_F_ERROR : Inverse flattening outside of valid range
45
* ELLIPSE_IN_USE_ERROR : User defined ellipsoid is in use by a user
47
* ELLIPSE_NOT_USERDEF_ERROR : Ellipsoid is not user defined - cannot be
52
* Ellipsoid is intended for reuse by any application that requires Earth
53
* approximating ellipsoids.
57
* Further information on Ellipsoid can be found in the Reuse Manual.
59
* Ellipsoid originated from : U.S. Army Topographic Engineering Center (USATEC)
60
* Geospatial Information Division (GID)
62
* Alexandria, VA 22310-3864
66
* None apply to this component.
70
* Ellipsoid has no restrictions.
74
* Ellipsoid was tested and certified in the following environments
83
* 11-19-95 Original Code
84
* 17-Jan-97 Moved local constants out of public interface
85
* Improved efficiency in algorithms (GEOTRANS)
86
* 24-May-99 Added user-defined ellipsoids (GEOTRANS for JMTK)
87
* 06/27/06 Moved data file to data directory
92
/***************************************************************************/
104
* ctype.h - standard C character handling library
105
* stdio.h - standard C input/output library
106
* stdlib.h - standard C general utilities library
107
* string.h - standard C string handling library
108
* datum.h - used to determine if user defined ellipsoid
109
* is in use by a user defined datum
110
* ellipse.h - prototype error checking and error codes
114
/***************************************************************************/
116
* GLOBAL DATA STRUCTURES
119
#define MAX_ELLIPSOIDS 32 /* Maximum number of ellipsoids in table */
120
#define ELLIPSOID_CODE_LENGTH 3 /* Length of ellipsoid code (including null) */
121
#define ELLIPSOID_NAME_LENGTH 30 /* Max length of ellipsoid name */
122
#define ELLIPSOID_BUF 90
123
#define FILENAME_LENGTH 128
127
const char *WGS84_Ellipsoid_Code = "WE";
128
const char *WGS72_Ellipsoid_Code = "WD";
130
typedef struct Ellipsoid_Table_Row
132
char Name[ELLIPSOID_NAME_LENGTH];
133
char Code[ELLIPSOID_CODE_LENGTH];
137
long User_Defined; /* Identifies a user defined ellipsoid */
140
static Ellipsoid_Row Ellipsoid_Table[MAX_ELLIPSOIDS];
141
static long WGS84_Index = 0; /* Index of WGS84 in ellipsoid table */
142
static long WGS72_Index = 0; /* Index of WGS72 in ellipsoid table */
143
static long Number_of_Ellipsoids = 0; /* Number of ellipsoids in table */
144
static long Ellipsoid_Initialized = 0; /* Indicates successful initialization */
145
Thread_Mutex ellipsoid_mutex;
147
/***************************************************************************/
151
void Assign_Ellipsoid_Row (Ellipsoid_Row *destination,
152
const Ellipsoid_Row *source)
153
{ /* Begin Assign_Ellipsoid_Row */
155
* destination : The destination of the copy (output)
156
* source : The source for the copy (input)
158
* The function Assign_Ellipsoid_Row copies ellipsoid data.
161
strcpy(destination->Name, source->Name);
162
strcpy(destination->Code, source->Code);
163
destination->A = source->A;
164
destination->B = source->B;
165
destination->Recp_F = source->Recp_F;
166
destination->User_Defined = source->User_Defined;
167
} /* End Assign_Ellipsoid_Row */
170
long Initialize_Ellipsoids ()
171
{ /* Begin Initialize_Ellipsoids */
173
* The function Initialize_Ellipsoids reads ellipsoid data from ellips.dat in
174
* the current directory and builds the ellipsoid table from it. If an
175
* error occurs, the error code is returned, otherwise ELLIPSE_NO_ERROR is
179
char* PathName = NULL;
181
FILE* fp = NULL; /* File pointer to file ellips.dat */
182
char buffer[ELLIPSOID_BUF];
183
long index = 0; /* Array index */
184
long error_code = ELLIPSE_NO_ERROR;
185
long mutex_error = THREADS_NO_ERROR;
187
if (Ellipsoid_Initialized)
193
mutex_error = Threads_Create_Mutex("Ellipsoid_Mutex", &ellipsoid_mutex);
195
mutex_error = Threads_Create_Mutex(&ellipsoid_mutex);
199
mutex_error = Threads_Lock_Mutex(ellipsoid_mutex);
201
/* Check the environment for a user provided path, else current directory; */
202
/* Build a File Name, including specified or default path: */
204
PathName = getenv( "GEOTRANS_DATA" );
205
if (PathName != NULL)
207
FileName = calloc( strlen( PathName ) + 12, sizeof( char ) );
208
strcpy( FileName, PathName );
209
strcat( FileName, "/" );
213
FileName = calloc( 19, sizeof( char ) );
214
strcpy( FileName, "../data/" );
216
strcat( FileName, "ellips.dat" );
218
/* Open the File READONLY, or Return Error Condition: */
220
if (( fp = fopen( FileName, "r" ) ) == NULL)
225
return ELLIPSE_FILE_OPEN_ERROR;
229
while ((!feof(fp)) && (!error_code))
231
if (index <= MAX_ELLIPSOIDS)
233
if (fgets(buffer, ELLIPSOID_BUF, fp))
235
sscanf(buffer, "%30c %s %lf %lf %lf",
236
Ellipsoid_Table[index].Name,
237
Ellipsoid_Table[index].Code,
238
&(Ellipsoid_Table[index].A),
239
&(Ellipsoid_Table[index].B),
240
&(Ellipsoid_Table[index].Recp_F));
241
if (Ellipsoid_Table[index].Name[0] == '*')
244
Ellipsoid_Table[index].User_Defined = TRUE;
245
for (i = 0; i < ELLIPSOID_NAME_LENGTH; i++)
246
Ellipsoid_Table[index].Name[i] = Ellipsoid_Table[index].Name[i+1];
249
Ellipsoid_Table[index].User_Defined = FALSE;
250
Ellipsoid_Table[index].Name[ELLIPSOID_NAME_LENGTH - 1] = '\0'; /* null terminate */
255
error_code |= ELLIPSE_TABLE_OVERFLOW_ERROR;
259
Number_of_Ellipsoids = index;
263
Ellipsoid_Initialized = 0;
264
Number_of_Ellipsoids = 0;
267
Ellipsoid_Initialized = 1;
269
/* Store WGS84 Index*/
270
if (Ellipsoid_Index(WGS84_Ellipsoid_Code, &WGS84_Index))
271
error_code |= ELLIPSE_INITIALIZE_ERROR;
273
/* Store WGS72 Index*/
274
if (Ellipsoid_Index(WGS72_Ellipsoid_Code, &WGS72_Index))
275
error_code |= ELLIPSE_INITIALIZE_ERROR;
278
mutex_error = Threads_Unlock_Mutex(ellipsoid_mutex);
281
Threads_Destroy_Mutex(ellipsoid_mutex);
287
} /* End of Initialize_Ellipsoids */
290
long Create_Ellipsoid (const char* Code,
294
{ /* Begin Create_Ellipsoid */
296
* Code : 2-letter ellipsoid code. (input)
297
* Name : Name of the new ellipsoid (input)
298
* a : Semi-major axis, in meters, of new ellipsoid (input)
299
* f : Flattening of new ellipsoid. (input)
301
* The function Create_Ellipsoid creates a new ellipsoid with the specified
302
* Code, name, and axes. If the ellipsoid table has not been initialized,
303
* the specified code is already in use, or a new version of the ellips.dat
304
* file cannot be created, an error code is returned, otherwise ELLIPSE_NO_ERROR
305
* is returned. Note that the indexes of all ellipsoids in the ellipsoid
306
* table may be changed by this function.
309
long error_code = ELLIPSE_NO_ERROR;
311
long code_length = 0;
312
char *PathName = NULL;
313
char FileName[FILENAME_LENGTH];
314
char ellipsoid_code[ELLIPSOID_CODE_LENGTH];
315
FILE *fp = NULL; /* File pointer to file ellips.dat */
316
double inv_f = 1 / f;
318
if (!Ellipsoid_Initialized)
319
error_code |= ELLIPSE_NOT_INITIALIZED_ERROR;
320
else if (!(Number_of_Ellipsoids < MAX_ELLIPSOIDS))
321
error_code |= ELLIPSE_TABLE_OVERFLOW_ERROR;
324
code_length = strlen(Code);
325
if ((!Ellipsoid_Index(Code, &index)) || (code_length > (ELLIPSOID_CODE_LENGTH-1)))
326
error_code |= ELLIPSE_INVALID_CODE_ERROR;
328
error_code |= ELLIPSE_A_ERROR;
329
if ((inv_f < 250) || (inv_f > 350))
330
{ /* Inverse flattening must be between 250 and 350 */
331
error_code |= ELLIPSE_INV_F_ERROR;
336
strcpy(ellipsoid_code,Code);
337
/* Convert code to upper case */
338
for (i = 0; i < code_length; i++)
339
ellipsoid_code[i] = (char)toupper(ellipsoid_code[i]);
340
index = Number_of_Ellipsoids;
341
strcpy(Ellipsoid_Table[index].Name, Name);
342
strcpy(Ellipsoid_Table[index].Code, ellipsoid_code);
343
Ellipsoid_Table[index].A = a;
344
Ellipsoid_Table[index].B = a * (1 - f);
345
Ellipsoid_Table[index].Recp_F = inv_f;
346
Ellipsoid_Table[index].User_Defined = TRUE;
347
Number_of_Ellipsoids++;
348
/*output updated ellipsoid table*/
349
PathName = getenv( "GEOTRANS_DATA" );
350
if (PathName != NULL)
352
strcpy( FileName, PathName );
353
strcat( FileName, "/" );
357
strcpy( FileName, "../data/" );
359
strcat( FileName, "ellips.dat" );
361
if ((fp = fopen(FileName, "w")) == NULL)
363
return ELLIPSE_FILE_OPEN_ERROR;
367
while (index < Number_of_Ellipsoids)
369
if (Ellipsoid_Table[index].User_Defined)
370
fprintf(fp, "*%-29s %-2s %11.3f %12.4f %13.9f \n",
371
Ellipsoid_Table[index].Name,
372
Ellipsoid_Table[index].Code,
373
Ellipsoid_Table[index].A,
374
Ellipsoid_Table[index].B,
375
Ellipsoid_Table[index].Recp_F);
377
fprintf(fp, "%-29s %-2s %11.3f %12.4f %13.9f \n",
378
Ellipsoid_Table[index].Name,
379
Ellipsoid_Table[index].Code,
380
Ellipsoid_Table[index].A,
381
Ellipsoid_Table[index].B,
382
Ellipsoid_Table[index].Recp_F);
387
Ellipsoid_Index(WGS84_Ellipsoid_Code, &WGS84_Index);
389
Ellipsoid_Index(WGS72_Ellipsoid_Code, &WGS72_Index);
393
} /* End Create_Ellipsoid */
396
long Delete_Ellipsoid (const char* Code)
397
{/* Begin Delete_Ellipsoid */
399
* Code : 2-letter ellipsoid code. (input)
401
* The function Delete_Ellipsoid deletes a user defined ellipsoid with
402
* the specified Code. If the ellipsoid table has not been created,
403
* the specified code is in use by a user defined datum, or a new version
404
* of the ellips.dat file cannot be created, an error code is returned,
405
* otherwise ELLIPSE_NO_ERROR is returned. Note that the indexes of all
406
* ellipsoids in the ellipsoid table may be changed by this function.
409
long error_code = ELLIPSE_NO_ERROR;
411
char *PathName = NULL;
412
char FileName[FILENAME_LENGTH];
413
FILE *fp = NULL; /* File pointer to file ellips.dat */
415
if (!Ellipsoid_Initialized)
416
error_code |= ELLIPSE_NOT_INITIALIZED_ERROR;
419
if (!Ellipsoid_Index(Code, &index))
421
if (Ellipsoid_Table[index-1].User_Defined)
423
if (Datum_Uses_Ellipsoid(Code))
424
error_code |= ELLIPSE_IN_USE_ERROR;
427
error_code |= ELLIPSE_NOT_USERDEF_ERROR;
430
error_code |= ELLIPSE_NOT_USERDEF_ERROR;
435
for (i = index-1; i < Number_of_Ellipsoids-1; i++)
436
Ellipsoid_Table[i] = Ellipsoid_Table[i+1];
438
if (Number_of_Ellipsoids != MAX_ELLIPSOIDS)
439
Ellipsoid_Table[i] = Ellipsoid_Table[i+1];
442
strcpy(Ellipsoid_Table[i].Name, "");
443
strcpy(Ellipsoid_Table[i].Code, "");
444
Ellipsoid_Table[i].A = 0;
445
Ellipsoid_Table[i].B = 0;
446
Ellipsoid_Table[i].Recp_F = 0;
447
Ellipsoid_Table[i].User_Defined = ' ';
449
Number_of_Ellipsoids--;
450
/*output updated ellipsoid table*/
451
PathName = getenv( "GEOTRANS_DATA" );
452
if (PathName != NULL)
454
strcpy( FileName, PathName );
455
strcat( FileName, "/" );
459
strcpy( FileName, "../data/" );
461
strcat( FileName, "ellips.dat" );
462
if ((fp = fopen(FileName, "w")) == NULL)
464
return ELLIPSE_FILE_OPEN_ERROR;
468
while (index < Number_of_Ellipsoids)
470
if (Ellipsoid_Table[index].User_Defined)
471
fprintf(fp, "*%-29s %-2s %11.3f %12.4f %13.9f \n",
472
Ellipsoid_Table[index].Name,
473
Ellipsoid_Table[index].Code,
474
Ellipsoid_Table[index].A,
475
Ellipsoid_Table[index].B,
476
Ellipsoid_Table[index].Recp_F);
478
fprintf(fp, "%-29s %-2s %11.3f %12.4f %13.9f \n",
479
Ellipsoid_Table[index].Name,
480
Ellipsoid_Table[index].Code,
481
Ellipsoid_Table[index].A,
482
Ellipsoid_Table[index].B,
483
Ellipsoid_Table[index].Recp_F);
488
Ellipsoid_Index(WGS84_Ellipsoid_Code, &WGS84_Index);
490
Ellipsoid_Index(WGS72_Ellipsoid_Code, &WGS72_Index);
493
}/* End Delete_Ellipsoid */
496
long Ellipsoid_Count ( long *Count )
497
{ /* Begin Ellipsoid_Count */
499
* Count : The number of ellipsoids in the ellipsoid table. (output)
501
* The function Ellipsoid_Count returns the number of ellipsoids in the
502
* ellipsoid table. If the ellipsoid table has been initialized without error,
503
* ELLIPSE_NO_ERROR is returned, otherwise ELLIPSE_NOT_INITIALIZED_ERROR
506
long error_code = ELLIPSE_NO_ERROR;
507
if (!Ellipsoid_Initialized)
508
error_code |= ELLIPSE_NOT_INITIALIZED_ERROR;
509
*Count = Number_of_Ellipsoids;
511
} /* End Ellipsoid_Count */
514
long Ellipsoid_Index ( const char *Code,
516
{ /* Begin Ellipsoid_Index */
518
* Code : 2-letter ellipsoid code. (input)
519
* Index : Index of the ellipsoid in the ellipsoid table with the
520
* specified code (output)
522
* The function Ellipsoid_Index returns the index of the ellipsoid in
523
* the ellipsoid table with the specified code. If ellipsoid code is found,
524
* ELLIPSE_NO_ERROR is returned, otherwise ELLIPSE_INVALID_CODE_ERROR is
528
long error_code = ELLIPSE_NO_ERROR;
529
long i = 0; /* index for ellipsoid table */
532
if (Ellipsoid_Initialized)
534
while (j < ELLIPSOID_CODE_LENGTH)
536
temp_code[j] = (char)toupper(Code[j]);
539
temp_code[ELLIPSOID_CODE_LENGTH - 1] = 0;
540
while ((i < Number_of_Ellipsoids)
541
&& strcmp(temp_code, Ellipsoid_Table[i].Code))
545
if (strcmp(temp_code, Ellipsoid_Table[i].Code))
546
error_code |= ELLIPSE_INVALID_CODE_ERROR;
552
error_code |= ELLIPSE_NOT_INITIALIZED_ERROR;
555
} /* End Ellipsoid_Index */
558
long Ellipsoid_Name ( const long Index,
560
{ /* Begin Ellipsoid_Name */
562
* Index : Index of a given ellipsoid.in the ellipsoid table with the
563
* specified index (input)
564
* Name : Name of the ellipsoid referencd by index (output)
566
* The Function Ellipsoid_Name returns the name of the ellipsoid in
567
* the ellipsoid table with the specified index. If index is valid,
568
* ELLIPSE_NO_ERROR is returned, otherwise ELLIPSE_INVALID_INDEX_ERROR is
572
long error_code = ELLIPSE_NO_ERROR;
575
if (Ellipsoid_Initialized)
577
if ((Index < 1) || (Index > Number_of_Ellipsoids))
578
error_code |= ELLIPSE_INVALID_INDEX_ERROR;
580
strcpy(Name, Ellipsoid_Table[Index-1].Name);
583
error_code |= ELLIPSE_NOT_INITIALIZED_ERROR;
585
} /* End Ellipsoid_Name */
588
long Ellipsoid_Code ( const long Index,
590
{ /* Begin Ellipsoid_Code */
592
* Index : Index of a given ellipsoid in the ellipsoid table (input)
593
* Code : 2-letter ellipsoid code. (output)
595
* The Function Ellipsoid_Code returns the 2-letter code for the
596
* ellipsoid in the ellipsoid table with the specified index. If index is
597
* valid, ELLIPSE_NO_ERROR is returned, otherwise ELLIPSE_INVALID_INDEX_ERROR
601
long error_code = ELLIPSE_NO_ERROR;
604
if (Ellipsoid_Initialized)
606
if ((Index < 1) || (Index > Number_of_Ellipsoids))
607
error_code |= ELLIPSE_INVALID_INDEX_ERROR;
609
strcpy(Code, Ellipsoid_Table[Index-1].Code);
612
error_code |= ELLIPSE_NOT_INITIALIZED_ERROR;
614
} /* End Ellipsoid_Code */
617
long Ellipsoid_Parameters ( const long Index,
620
{ /* Begin Ellipsoid_Parameters */
622
* Index : Index of a given ellipsoid in the ellipsoid table (input)
623
* a : Semi-major axis, in meters, of ellipsoid (output)
624
* f : Flattening of ellipsoid. (output)
626
* The function Ellipsoid_Parameters returns the semi-major axis and flattening
627
* for the ellipsoid with the specified index. If index is valid,
628
* ELLIPSE_NO_ERROR is returned, otherwise ELLIPSE_INVALID_INDEX_ERROR is
632
long error_code = ELLIPSE_NO_ERROR;
636
if (Ellipsoid_Initialized)
638
if ((Index < 1) || (Index > Number_of_Ellipsoids))
640
error_code |= ELLIPSE_INVALID_INDEX_ERROR;
644
*a = Ellipsoid_Table[Index-1].A;
645
*f = 1 / Ellipsoid_Table[Index-1].Recp_F;
649
error_code |= ELLIPSE_NOT_INITIALIZED_ERROR;
651
} /* End Ellipsoid_Parameters */
654
long Ellipsoid_Eccentricity2 ( const long Index,
656
{ /* Begin Ellipsoid_Eccentricity2 */
658
* Index : Index of a given ellipsoid in the ellipsoid table (input)
659
* e2 : Square of eccentricity of ellipsoid (output)
661
* The function Ellipsoid_Eccentricity2 returns the square of the
662
* eccentricity for the ellipsoid with the specified index. If index is
663
* valid, ELLIPSE_NO_ERROR is returned, otherwise ELLIPSE_INVALID_INDEX_ERROR
667
long error_code = ELLIPSE_NO_ERROR;
670
if (Ellipsoid_Initialized)
672
if ((Index < 1) || (Index > Number_of_Ellipsoids))
674
error_code |= ELLIPSE_INVALID_INDEX_ERROR;
678
f = 1 / Ellipsoid_Table[Index-1].Recp_F;
683
error_code |= ELLIPSE_NOT_INITIALIZED_ERROR;
685
} /* End Ellipsoid_Eccentricity2 */
688
long Ellipsoid_User_Defined ( const long Index,
691
{ /* Begin Ellipsoid_User_Defined */
693
* Index : Index of a given ellipsoid in the ellipsoid table (input)
694
* result : Indicates whether specified ellipsoid is user defined (1)
695
* or not (0) (output)
697
* The function Ellipsoid_User_Defined returns 1 if the ellipsoid is user
698
* defined. Otherwise, 0 is returned. If index is valid ELLIPSE_NO_ERROR is
699
* returned, otherwise ELLIPSE_INVALID_INDEX_ERROR is returned.
702
long error_code = ELLIPSE_NO_ERROR;
706
if (Ellipsoid_Initialized)
708
if ((Index < 1) || (Index > Number_of_Ellipsoids))
709
error_code |= ELLIPSE_INVALID_INDEX_ERROR;
712
if (Ellipsoid_Table[Index-1].User_Defined)
717
error_code |= ELLIPSE_NOT_INITIALIZED_ERROR;
719
} /* End Ellipsoid_User_Defined */
722
long WGS84_Parameters ( double *a,
724
{ /* Begin WGS84_Parameters */
726
* a : Semi-major axis, in meters, of ellipsoid (output)
727
* f : Flattening of ellipsoid (output)
729
* The function WGS84_Parameters returns the semi-major axis and the
730
* flattening for the WGS84 ellipsoid. If the ellipsoid table was
731
* initialized successfully, ELLIPSE_NO_ERROR is returned, otherwise
732
* ELLIPSE_NOT_INITIALIZED_ERROR is returned.
735
long error_code = ELLIPSE_NO_ERROR;
739
if (Ellipsoid_Initialized)
741
*a = Ellipsoid_Table[WGS84_Index-1].A;
742
*f = 1 / Ellipsoid_Table[WGS84_Index-1].Recp_F;
745
error_code |= ELLIPSE_NOT_INITIALIZED_ERROR;
747
} /* End WGS84_Parameters */
750
long WGS84_Eccentricity2 ( double *e2 )
751
{ /* Begin WGS84_Eccentricity2 */
753
* e2 : Square of eccentricity of WGS84 ellipsoid (output)
755
* The function WGS84_Eccentricity2 returns the square of the
756
* eccentricity for the WGS84 ellipsoid. If the ellipsoid table was
757
* initialized successfully, ELLIPSE_NO_ERROR is returned, otherwise
758
* ELLIPSE_NOT_INITIALIZED_ERROR is returned.
761
long error_code = ELLIPSE_NO_ERROR;
765
if (Ellipsoid_Initialized)
767
f = 1 / Ellipsoid_Table[WGS84_Index-1].Recp_F;
771
error_code |= ELLIPSE_NOT_INITIALIZED_ERROR;
773
} /* End WGS84_Eccentricity2 */
776
long WGS72_Parameters( double *a,
778
{ /* Begin WGS72_Parameters */
780
* a : Semi-major axis, in meters, of ellipsoid (output)
781
* f : Flattening of ellipsoid (output)
783
* The function WGS72_Parameters returns the semi-major axis and the
784
* flattening for the WGS72 ellipsoid. If the ellipsoid table was
785
* initialized successfully, ELLIPSE_NO_ERROR is returned, otherwise
786
* ELLIPSE_NOT_INITIALIZED_ERROR is returned.
789
long error_code = ELLIPSE_NO_ERROR;
793
if (Ellipsoid_Initialized)
795
*a = Ellipsoid_Table[WGS72_Index-1].A;
796
*f = 1 / Ellipsoid_Table[WGS72_Index-1].Recp_F;
799
error_code |= ELLIPSE_NOT_INITIALIZED_ERROR;
801
} /* End WGS72_Parameters */
804
long WGS72_Eccentricity2 ( double *e2 )
805
{ /* Begin WGS72_Eccentricity2 */
807
* e2 : Square of eccentricity of WGS84 ellipsoid (output)
809
* The function WGS72_Eccentricity2 returns the square of the
810
* eccentricity for the WGS72 ellipsoid. If the ellipsoid table was
811
* initialized successfully, ELLIPSE_NO_ERROR is returned, otherwise
812
* ELLIPSE_NOT_INITIALIZED_ERROR is returned.
815
long error_code = ELLIPSE_NO_ERROR;
819
if (Ellipsoid_Initialized)
821
f = 1 / Ellipsoid_Table[WGS72_Index-1].Recp_F;
825
error_code |= ELLIPSE_NOT_INITIALIZED_ERROR;
827
} /* End WGS72_Eccentricity2 */