- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# Y:/msp/devkits/temp_geotrans/master/geotrans3.1/CCS/src/dtcc/CoordinateSystems/ellipse/EllipsoidLibraryImplementation.h

Go to the documentation of this file.

    00001 // CLASSIFICATION: UNCLASSIFIED
    00002
    00003 #ifndef EllipsoidLibraryImplementation_H
    00004 #define EllipsoidLibraryImplementation_H
    00005
    00006 /****************************************************************************/
    00007 /* RSC IDENTIFIER:  Ellipsoid Library
    00008  *
    00009  * ABSTRACT
    00010  *
    00011  *    The purpose of ELLIPSOID is to provide access to ellipsoid parameters
    00012  *    for a collection of common ellipsoids.  A particular ellipsoid can be
    00013  *    accessed by using its standard 2-letter code to find its index in the
    00014  *    ellipsoid table.  The index can then be used to retrieve the ellipsoid
    00015  *    name and parameters.
    00016  *
    00017  *    By sequentially retrieving all of the ellipsoid codes and/or names, a
    00018  *    menu of the available ellipsoids can be constructed.  The index values
    00019  *    resulting from selections from this menu can then be used to access the
    00020  *    parameters of the selected ellipsoid.
    00021  *
    00022  *    This component depends on a data file named "ellips.dat", which contains
    00023  *    the ellipsoid parameter values.  A copy of this file must be located in
    00024  *    the directory specified by the environment variable "MSPCCS_DATA", if
    00025  *    defined, or else in the current directory, whenever a program containing
    00026  *    this component is executed.
    00027  *
    00028  *    Additional ellipsoids can be added to this file, either manually or using
    00029  *    the Create_Ellipsoid function.  However, if a large number of ellipsoids
    00030  *    are added, the ellipsoid table array size in this component will have to
    00031  *    be increased.
    00032  *
    00033  * ERROR HANDLING
    00034  *
    00035  *    This component checks parameters for valid values.  If an invalid value
    00036  *    is found, the error code is combined with the current error code using
    00037  *    the bitwise or.  This combining allows multiple error codes to be
    00038  *    returned. The possible error codes are:
    00039  *
    00040  *  ELLIPSE_NO_ERROR             : No errors occured in function
    00041  *  ELLIPSE_FILE_OPEN_ERROR      : Ellipsoid file opening error
    00042  *  ELLIPSE_INITIALIZE_ERROR     : Ellipsoid table can not initialize
    00043  *  ELLIPSE_TABLE_OVERFLOW_ERROR : Ellipsoid table overflow
    00044  *  ELLIPSE_NOT_INITIALIZED_ERROR: Ellipsoid table not initialized properly
    00045  *  ELLIPSE_INVALID_INDEX_ERROR  : Index is an invalid value
    00046  *  ELLIPSE_INVALID_CODE_ERROR   : Code was not found in table
    00047  *  ELLIPSE_A_ERROR              : Semi-major axis less than or equal to zero
    00048  *  ELLIPSE_INV_F_ERROR          : Inverse flattening outside of valid range
    00049  *                                  (250 to 350)
    00050  *  ELLIPSE_NOT_USERDEF_ERROR    : Ellipsoid is not user defined - cannot be
    00051  *                                  deleted
    00052  *
    00053  * REUSE NOTES
    00054  *
    00055  *    Ellipsoid is intended for reuse by any application that requires Earth
    00056  *    approximating ellipsoids.
    00057  *
    00058  * REFERENCES
    00059  *
    00060  *    Further information on Ellipsoid can be found in the Reuse Manual.
    00061  *
    00062  *    Ellipsoid originated from :  U.S. Army Topographic Engineering Center (USATEC)
    00063  *                                 Geospatial Information Division (GID)
    00064  *                                 7701 Telegraph Road
    00065  *                                 Alexandria, VA  22310-3864
    00066  *
    00067  * LICENSES
    00068  *
    00069  *    None apply to this component.
    00070  *
    00071  * RESTRICTIONS
    00072  *
    00073  *    Ellipsoid has no restrictions.
    00074  *
    00075  * ENVIRONMENT
    00076  *
    00077  *    Ellipsoid was tested and certified in the following environments
    00078  *
    00079  *    1. Solaris 2.5
    00080  *    2. Windows 95
    00081  *
    00082  * MODIFICATIONS
    00083  *
    00084  *    Date              Description
    00085  *    ----              -----------
    00086  *    11-19-95          Original Code
    00087  *    17-Jan-97         Moved local constants out of public interface
    00088  *                      Improved efficiency in algorithms (GEOTRANS)
    00089  *    24-May-99         Added user-defined ellipsoids (GEOTRANS for JMTK)
    00090  *    06-27-06          Moved data file to data directory
    00091  *    03-09-07          Original C++ Code
    00092  *
    00093  */
    00094
    00095
    00096 #include <vector>
    00097
    00098
    00099 namespace MSP
    00100 {
    00101   class CCSThreadMutex;
    00102   namespace CCS
    00103   {
    00104     class Ellipsoid;
    00105     class DatumLibraryImplementation;
    00106
    00107
    00108     /***************************************************************************/
    00109     /*
    00110      *                              DEFINES
    00111      */
    00112
    00113     class EllipsoidLibraryImplementation
    00114     {
    00115     friend class EllipsoidLibraryImplementationCleaner;
    00116
    00117     public:
    00118
    00119       /*
    00120        * The function getInstance returns an instance of the EllipsoidLibraryImplementation
    00121        */
    00122
    00123       static EllipsoidLibraryImplementation* getInstance();
    00124
    00125
    00126       /*
    00127        * The function removeInstance removes this EllipsoidLibraryImplementation instance from the
    00128        * total number of instances.
    00129        */
    00130
    00131       static void removeInstance();
    00132
    00133
    00134             ~EllipsoidLibraryImplementation( void );
    00135
    00136
    00137       /*
    00138        * The function defineEllipsoid creates a new ellipsoid with the specified
    00139        * Code, name, and axes.  If the ellipsoid table has not been initialized,
    00140        * the specified code is already in use, or a new version of the ellips.dat
    00141        * file cannot be created, an exception is thrown.
    00142        * Note that the indexes of all ellipsoids in the ellipsoid
    00143        * table may be changed by this function.
    00144        *
    00145        *   code           : 2-letter ellipsoid code.                      (input)
    00146        *   name           : Name of the new ellipsoid                     (input)
    00147        *   semiMajorAxis  : Semi-major axis, in meters, of new ellipsoid  (input)
    00148        *   flattening     : Flattening of new ellipsoid.                  (input)
    00149        *
    00150        */
    00151
    00152       void defineEllipsoid( const char* code, const char* name, double semiMajorAxis, double flattening );
    00153
    00154
    00155       /*
    00156        * The function removeEllipsoid deletes a user defined ellipsoid with
    00157        * the specified Code.  If the ellipsoid table has not been created,
    00158        * the specified code is in use by a user defined datum, or a new version
    00159        * of the ellips.dat file cannot be created, an exception is thrown.
    00160        * Note that the indexes of all
    00161        * ellipsoids in the ellipsoid table may be changed by this function.
    00162        *
    00163        *   code     : 2-letter ellipsoid code.                      (input)
    00164        *
    00165        */
    00166
    00167       void removeEllipsoid( const char* Code );
    00168
    00169
    00170       /*
    00171        * The function ellipsoidCount returns the number of ellipsoids in the
    00172        * ellipsoid table.  If the ellipsoid table has not been initialized,
    00173        * an exception is thrown.
    00174        *
    00175        *   count    : The number of ellipsoids in the ellipsoid table. (output)
    00176        *
    00177        */
    00178
    00179       void ellipsoidCount ( long *count );
    00180
    00181
    00182       /*
    00183        *  The function ellipsoidIndex returns the index of the ellipsoid in
    00184        *  the ellipsoid table with the specified code.  If ellipsoid code is not found,
    00185        *  an exception is thrown.
    00186        *
    00187        *    code     : 2-letter ellipsoid code.                      (input)
    00188        *    index    : Index of the ellipsoid in the ellipsoid table with the
    00189        *                  specified code                             (output)
    00190        *
    00191        */
    00192
    00193       void ellipsoidIndex( const char* code, long* index );
    00194
    00195
    00196       /*
    00197        *  The Function ellipsoidCode returns the 2-letter code for the
    00198        *  ellipsoid in the ellipsoid table with the specified index.  If index is
    00199        *  invalid, an exception is thrown.
    00200        *
    00201        *    index    : Index of a given ellipsoid in the ellipsoid table (input)
    00202        *    code     : 2-letter ellipsoid code.                          (output)
    00203        *
    00204        */
    00205
    00206       void ellipsoidCode( const long index, char *code );
    00207
    00208
    00209       /*
    00210        *  The Function ellipsoidName returns the name of the ellipsoid in
    00211        *  the ellipsoid table with the specified index.  If index is invalid,
    00212        *  an exception is thrown.
    00213        *
    00214        *    index   : Index of a given ellipsoid.in the ellipsoid table with the
    00215        *                 specified index                             (input)
    00216        *    name    : Name of the ellipsoid referencd by index       (output)
    00217        *
    00218        */
    00219
    00220       void ellipsoidName( const long index, char *name );
    00221
    00222
    00223       /*
    00224        *  The function ellipsoidParameters returns the semi-major axis and flattening
    00225        *  for the ellipsoid with the specified index.  If index is invalid,
    00226        *  an exception is thrown.
    00227        *
    00228        *    index    : Index of a given ellipsoid in the ellipsoid table (input)
    00229        *    a        : Semi-major axis, in meters, of ellipsoid          (output)
    00230        *    f        : Flattening of ellipsoid.                          (output)
    00231        *
    00232        */
    00233
    00234       void ellipsoidParameters( const long index, double *a, double *f );
    00235
    00236
    00237       /*
    00238        *  The function ellipsoidEccentricity2 returns the square of the
    00239        *  eccentricity for the ellipsoid with the specified index.  If index is
    00240        *  invalid, an exception is thrown.
    00241        *
    00242        *    index                : Index of a given ellipsoid in the ellipsoid table (input)
    00243        *    eccentricitySquared  : Square of eccentricity of ellipsoid               (output)
    00244        *
    00245        */
    00246
    00247       void ellipsoidEccentricity2( const long index, double *eccentricitySquared );
    00248
    00249
    00250       /*
    00251        *  The function ellipsoidUserDefined returns 1 if the ellipsoid is user
    00252        *  defined.  Otherwise, 0 is returned.  If index is invalid an
    00253        *  exception is thrown.
    00254        *
    00255        *    index    : Index of a given ellipsoid in the ellipsoid table (input)
    00256        *    result   : Indicates whether specified ellipsoid is user defined (1)
    00257        *               or not (0)                                        (output)
    00258        *
    00259        */
    00260
    00261       void ellipsoidUserDefined( const long index, long *result );
    00262
    00263
    00264       /*
    00265        *  The function setDatumLibraryImplementation sets the datum library information
    00266        *  which is needed to ensure a user defined ellipsoid is not in use before being deleted.
    00267        *
    00268        *   __datumLibraryImplementation  : Datum library implementation      (input)
    00269        *
    00270        */
    00271
    00272       void setDatumLibraryImplementation( DatumLibraryImplementation* __datumLibraryImplementation );
    00273
    00274
    00275     protected:
    00276
    00277       /*
    00278        * The constructor creates an empty list to store the ellipsoid data from ellips.dat,
    00279        * which is used to build the ellipsoid table.
    00280        */
    00281
    00282             EllipsoidLibraryImplementation();
    00283
    00284
    00285       EllipsoidLibraryImplementation( const EllipsoidLibraryImplementation &e );
    00286
    00287
    00288       EllipsoidLibraryImplementation& operator=( const EllipsoidLibraryImplementation &e );
    00289
    00290
    00291
    00292    private:
    00293
    00294       static CCSThreadMutex mutex;
    00295       static EllipsoidLibraryImplementation* instance;
    00296       static int instanceCount;
    00297
    00298       std::vector<Ellipsoid*> ellipsoidList;
    00299
    00300
    00301       DatumLibraryImplementation* _datumLibraryImplementation;
    00302
    00303       /*
    00304        * The function loadEllipsoids reads ellipsoid data from ellips.dat
    00305        * and builds the ellipsoid table from it.  If an error occurs,
    00306        * an exception is thrown.
    00307        */
    00308
    00309       void loadEllipsoids();
    00310
    00311
    00312       /*
    00313        * Delete the singleton.
    00314        */
    00315
    00316       static void deleteInstance();
    00317     };
    00318   }
    00319 }
    00320
    00321 #endif
    00322
    00323 // CLASSIFICATION: UNCLASSIFIED