- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# Y:/msp/devkits/temp_geotrans/master/geotrans3.1/CCS/src/CoordinateConversion/CoordinateConversionService.h

Go to the documentation of this file.

    00001 // CLASSIFICATION: UNCLASSIFIED
    00002 #ifndef CoordinateConversionService_H
    00003 #define CoordinateConversionService_H
    00004
    00005 /***************************************************************************/
    00006 /* RSC IDENTIFIER: Coordinate Conversion Service
    00007  *
    00008  * ABSTRACT
    00009  *
    00010  *    This component is the coordinate conversion service for the MSPCCS
    00011  *    application.  It provides an external input interface that supports the
    00012  *    MSPCCS GUI (Java) and the MSPCCS file processing
    00013  *    component.
    00014  *
    00015  *    This component depends on the DT&CC modules:  DATUM, ELLIPSOID,
    00016  *    GEOCENTRIC, GEOREF, MERCATOR, TRANSVERSE MERCATOR, UTM, MGRS, USNG, POLAR
    00017  *    STEREOGRAPHIC, UPS, LAMBERT_1, LAMBERT_2, ALBERS, AZIMUTHAL EQUIDISTANT, BONNE,
    00018  *    BRITISH NATIONAL GRID,  CASSINI, CYLINDRICAL EQUAL AREA,ECKERT4, ECKERT6,
    00019  *    EQUIDISTANT CYLINDRICAL, GARS, GNOMONIC, LOCAL CARTESIAN, MILLER, MOLLWEIDE,
    00020  *    NEYS, NEW ZEALAND MAP GRID, OBLIQUE MERCATOR, ORTHOGRAPHIC, POLYCONIC,
    00021  *    SINUSOIDAL, STEREOGRAPHIC, TRANSVERSE CYLINDRICAL EQUAL AREA, and VAN DER GRINTEN.
    00022  *
    00023  *
    00024  * ERROR HANDLING
    00025  *
    00026  *    This component checks for error codes returned by the DT&CC modules.
    00027  *    If an error code is returned, it is combined with the current
    00028  *    error code using the bitwise or.  This combining allows multiple error
    00029  *    codes to be returned. The possible error codes are listed below.
    00030  *
    00031  *
    00032  * REUSE NOTES
    00033  *
    00034  *    Coordinate Conversion Service is intended for reuse by other applications that require
    00035  *    coordinate conversions between multiple coordinate systems and/or datum
    00036  *    transformations between multiple datums.
    00037  *
    00038  *
    00039  * REFERENCES
    00040  *
    00041  *    Further information on Coordinate Conversion Service can be found in the Coordinate
    00042  *    Conversion Service Reuse Manual.
    00043  *
    00044  *    Coordinate Conversion Service originated from : U.S. Army Topographic Engineering Center
    00045  *                             Digital Concepts & Analysis Center
    00046  *                                       7701 Telegraph Road
    00047  *                                       Alexandria, VA  22310-3864
    00048  *
    00049  *
    00050  * LICENSES
    00051  *
    00052  *    None apply to this component.
    00053  *
    00054  * RESTRICTIONS
    00055  *
    00056  *    Coordinate Conversion Service has no restrictions.
    00057  *
    00058  * ENVIRONMENT
    00059  *
    00060  *    Coordinate Conversion Service was tested and certified in the following environments:
    00061  *
    00062  *    1. Solaris 2.5 with GCC, version 2.8.1
    00063  *    2. Windows XP with MS Visual C++, version 6
    00064  *
    00065  * MODIFICATIONS
    00066  *
    00067  *    Date              Description
    00068  *    ----              -----------
    00069  *    04-22-97          Original Code
    00070  *    09-30-99          Added support for 15 new projections
    00071  *    05-30-00          Added support for 2 new projections
    00072  *    06-30-00          Added support for 1 new projection
    00073  *    09-30-00          Added support for 4 new projections
    00074  *    03-24-05          Added support for Lambert Conformal Conic (1 Standard Parallel)
    00075  *    08-17-05          Changed Lambert_Conformal_Conic to Lambert_Conformal_Conic_2
    00076  *    06-06-06          Added support for USNG
    00077  *    07-17-06          Added support for GARS
    00078  *    03-17-07          Original C++ Code
    00079  *    07-20-10          NGL BAEts27152 Updated getServiceVersion to return an int
    00080  */
    00081
    00082
    00083 #include <vector>
    00084 #include "CoordinateType.h"
    00085 #include "Precision.h"
    00086 #include "SourceOrTarget.h"
    00087 #include "CoordinateTuple.h"
    00088
    00089
    00090 #ifdef WIN32
    00091 #ifdef MSP_CCS_EX
    00092 #define MSP_CCS __declspec(dllexport)
    00093 #else
    00094 #define MSP_CCS __declspec(dllimport)
    00095 #endif
    00096 #endif
    00097
    00098
    00099 namespace MSP
    00100 {
    00101   class CCSThreadMutex;
    00102   namespace CCS
    00103   {
    00104     class EllipsoidLibrary;
    00105     class EllipsoidLibraryImplementation;
    00106     class DatumLibrary;
    00107     class DatumLibraryImplementation;
    00108     class GeoidLibrary;
    00109     class Accuracy;
    00110     class CoordinateSystemParameters;
    00111     class CoordinateTuple;
    00112     class MapProjection3Parameters;
    00113     class MapProjection4Parameters;
    00114     class MapProjection5Parameters;
    00115     class MapProjection6Parameters;
    00116     class EquidistantCylindricalParameters;
    00117     class GeodeticParameters;
    00118     class LocalCartesianParameters;
    00119     class MercatorStandardParallelParameters;
    00120     class MercatorScaleFactorParameters;
    00121     class NeysParameters;
    00122     class ObliqueMercatorParameters;
    00123     class PolarStereographicStandardParallelParameters;
    00124     class PolarStereographicScaleFactorParameters;
    00125     class UTMParameters;
    00126     class MapProjectionCoordinates;
    00127     class BNGCoordinates;
    00128     class CartesianCoordinates;
    00129     class GeodeticCoordinates;
    00130     class GEOREFCoordinates;
    00131     class GARSCoordinates;
    00132     class MGRSorUSNGCoordinates;
    00133     class UPSCoordinates;
    00134     class UTMCoordinates;
    00135     class CoordinateSystem;
    00136
    00137
    00138   /***************************************************************************/
    00139   /*
    00140    *                              DEFINES
    00141    */
    00142
    00143     /* Symbolic constants */
    00144     const int NUMBER_COORD_SYS = 37;       /* Number of coordinate systems        */
    00145     const int COORD_SYS_CODE_LENGTH = 3;   /* Length of coordinate system codes (including null) */
    00146     const int COORD_SYS_NAME_LENGTH = 50;  /* Max length of coordinate system names (including null) */
    00147     const int DATUM_CODE_LENGTH = 7;       /* Length of datum codes (including null) */
    00148     const int DATUM_NAME_LENGTH = 33;      /* Max length of datum names (including null) */
    00149     const int ELLIPSOID_CODE_LENGTH = 3;   /* Length of ellipsoid codes (including null) */
    00150     const int ELLIPSOID_NAME_LENGTH = 30;  /* Max length of ellipsoid names (including null) */
    00151     const int CONVERT_MSG_LENGTH = 2048;   /* Max length of coordinate conversion status message */
    00152     const int RETURN_MSG_LENGTH = 256;     /* Max length of return code status message */
    00153
    00154
    00158     struct Color
    00159     {
    00161       enum Enum
    00162       {
    00163         red,
    00164         yellow,
    00165         green
    00166       };
    00167     };
    00168
    00173 #ifdef WIN32
    00174    class MSP_CCS CoordinateConversionService
    00175 #else
    00176    class CoordinateConversionService
    00177 #endif
    00178     {
    00179     public:
    00180
    00192       CoordinateConversionService( const char* sourceDatumCode, MSP::CCS::CoordinateSystemParameters* sourceParameters, const char* targetDatumCode, MSP::CCS::CoordinateSystemParameters* targetParameters );
    00193
    00199       CoordinateConversionService( const CoordinateConversionService &ccs );
    00200
    00204       ~CoordinateConversionService( void );
    00205
    00211       CoordinateConversionService &operator=( const CoordinateConversionService &ccs );
    00212
    00213
    00226       void convertSourceToTarget( CoordinateTuple* sourceCoordinates, Accuracy* sourceAccuracy, CoordinateTuple& targetCoordinates, Accuracy& targetAccuracy );
    00227
    00228
    00241       void convertTargetToSource( CoordinateTuple* targetCoordinates, Accuracy* targetAccuracy, CoordinateTuple& sourceCoordinates, Accuracy& sourceAccurac );
    00242
    00243
    00254       void convertSourceToTargetCollection( const std::vector<MSP::CCS::CoordinateTuple*>& sourceCoordinates, const std::vector<MSP::CCS::Accuracy*>& sourceAccuracy, std::vector<MSP::CCS::CoordinateTuple*>& targetCoordinates, std::vector<MSP::CCS::Accuracy*>& targetAccuracy );
    00255
    00256
    00267       void convertTargetToSourceCollection( const std::vector<MSP::CCS::CoordinateTuple*>& targetCoordinates, const std::vector<MSP::CCS::Accuracy*>& targetAccuracy, std::vector<MSP::CCS::CoordinateTuple*>& sourceCoordinates, std::vector<MSP::CCS::Accuracy*>& sourceAccuracy );
    00268
    00269
    00270       /*
    00271        * The function getEllipsoidLibrary returns the ellipsoid library
    00272        * which provides access to ellipsoidparameter information.
    00273        *
    00274        */
    00275
    00276       EllipsoidLibrary* getEllipsoidLibrary();
    00277
    00278
    00279       /*
    00280       * The function getDatumLibrary returns the datum library
    00281       * which provides access to datum transformation and parameter information.
    00282       *
    00283       * @return Datum library
    00284       */
    00285       DatumLibrary* getDatumLibrary();
    00286
    00287
    00288      /*
    00289       * The function getServiceVersion returns current service version.
    00290       *
    00291       * @return Service version
    00292       */
    00293       int getServiceVersion();
    00294
    00295
    00296      /*
    00297       *  The function getDatum returns the index of the current datum.
    00298       *
    00299       * @param[in] direction - indicates whether the datum is to be used for input or output
    00300       * @return Index identifying the index of the current datum
    00301       */
    00302
    00303       const char* getDatum( const SourceOrTarget::Enum direction ) const;
    00304
    00305
    00306      /*
    00307       *  The function getCoordinateSystem returns the current coordinate system
    00308       *  type.
    00309       *
    00310       *  @param[in] direction  - Indicates whether the coordinate system is to
    00311       *                          be used for input or output
    00312       *  @return Parameters identifies current coordinate system type
    00313       */
    00314
    00315       MSP::CCS::CoordinateSystemParameters* getCoordinateSystem( const SourceOrTarget::Enum direction ) const;
    00316
    00317
    00318     private:
    00319
    00320       static CCSThreadMutex mutex;
    00321
    00322       /* Object used to keep track of the number of ccs objects */
    00323       struct CCSData
    00324       {
    00325         int refCount;
    00326
    00327         EllipsoidLibrary* ellipsoidLibrary;
    00328         EllipsoidLibraryImplementation* ellipsoidLibraryImplementation;
    00329         DatumLibrary* datumLibrary;
    00330         DatumLibraryImplementation* datumLibraryImplementation;
    00331         GeoidLibrary* geoidLibrary;
    00332
    00333         CCSData();
    00334         ~CCSData();
    00335       };
    00336
    00337       CCSData* ccsData;
    00338
    00339       EllipsoidLibraryImplementation* ellipsoidLibraryImplementation;
    00340       DatumLibraryImplementation* datumLibraryImplementation;
    00341       GeoidLibrary* geoidLibrary;
    00342
    00343 //compiler bug on solaris 8. Parameters needs to be public
    00344 #ifdef SOLARIS
    00345     public:
    00346 #endif
    00347
    00348       /* Coordinate System Definition with Multiple Variants */
    00349       union Parameters
    00350       {
    00351         CoordinateSystemParameters*        coordinateSystemParameters;
    00352         MapProjection3Parameters*          mapProjection3Parameters;
    00353         MapProjection4Parameters*          mapProjection4Parameters;
    00354         MapProjection5Parameters*          mapProjection5Parameters;
    00355         MapProjection6Parameters*          mapProjection6Parameters;
    00356         EquidistantCylindricalParameters*  equidistantCylindricalParameters;
    00357         GeodeticParameters*                geodeticParameters;
    00358         LocalCartesianParameters*          localCartesianParameters;
    00359         MercatorStandardParallelParameters* mercatorStandardParallelParameters;
    00360         MercatorScaleFactorParameters*     mercatorScaleFactorParameters;
    00361         NeysParameters*                    neysParameters;
    00362         ObliqueMercatorParameters*         obliqueMercatorParameters;
    00363         PolarStereographicStandardParallelParameters* polarStereographicStandardParallelParameters;
    00364         PolarStereographicScaleFactorParameters* polarStereographicScaleFactorParameters;
    00365         UTMParameters*                     utmParameters;
    00366       };
    00367
    00368       /* Coordinate Tuple Definition with Multiple Variants */
    00369       union Coordinates
    00370       {
    00371         MapProjectionCoordinates*     mapProjectionCoordinates;
    00372         BNGCoordinates*               bngCoordinates;
    00373         CartesianCoordinates*         cartesianCoordinates;
    00374         GeodeticCoordinates*          geodeticCoordinates;
    00375         GEOREFCoordinates*            georefCoordinates;
    00376         GARSCoordinates*              garsCoordinates;
    00377         MGRSorUSNGCoordinates*        mgrsOrUSNGCoordinates;
    00378         UPSCoordinates*               upsCoordinates;
    00379         UTMCoordinates*               utmCoordinates;
    00380       };
    00381
    00382       struct Coordinate_System_Row
    00383       {
    00384         char Name[COORD_SYS_NAME_LENGTH];
    00385         char Code[COORD_SYS_CODE_LENGTH];
    00386         CoordinateType::Enum coordinateSystem;
    00387       };
    00388
    00389
    00390       /* Coordinate Conversion Service State Definition */
    00391       struct Coordinate_State_Row
    00392       {
    00393         char datumCode[DATUM_CODE_LENGTH];   /* currently specified datum code  */
    00394         long datumIndex;                     /* currently specified datum index */
    00395         CoordinateType::Enum coordinateType; /* current coordinate system type  */
    00396         Parameters parameters;               /* current coordinate system parameters */
    00397         CoordinateSystem* coordinateSystem;  /* current coordinate system */
    00398       };
    00399
    00400       /* coordinateSystemState[x] is set up as follows:
    00401          c = Number of IO states (Source, Target, etc.) */
    00402       Coordinate_State_Row coordinateSystemState[2];
    00403
    00404       /* Local State Variables */
    00405       Coordinate_System_Row Coordinate_System_Table[NUMBER_COORD_SYS];
    00406
    00407       long WGS84_datum_index;
    00408
    00409
    00410       /*
    00411        *  The function setDataLibraries sets the initial state of the engine in
    00412        *  in preparation for coordinate conversion and/or datum transformation
    00413        *  operations.
    00414        */
    00415
    00416       void setDataLibraries();
    00417
    00418
    00419       /*
    00420        *  The function initCoordinateSystemState initializes coordinateSystemState.
    00421        *
    00422        *  direction  : Indicates whether the coordinate system is to be used for
    00423        *               source or target                                      (input)
    00424        */
    00425
    00426       void initCoordinateSystemState( const SourceOrTarget::Enum direction );
    00427
    00428
    00429       /*
    00430        *  The function deleteCoordinateSystem frees memory of coordinateSystemState.
    00431        *
    00432        *  direction  : Indicates whether the coordinate system is to be used for
    00433        *               source or target                                      (input)
    00434        */
    00435
    00436       void deleteCoordinateSystem( const SourceOrTarget::Enum direction );
    00437
    00438
    00439       /*
    00440        *  The function copyParameters uses the input parameters to set the value of the
    00441        *  current parameters.
    00442        *
    00443        *  direction       : Indicates whether the coordinate system is to be used for
    00444        *                  source or target                                      (input)
    00445        *  coordinateType  : Coordinate system type                              (input)
    00446        *  parameters      : Coordinate system parameters to copy                (input)
    00447        */
    00448
    00449       void copyParameters( SourceOrTarget::Enum direction, CoordinateType::Enum coordinateType, Parameters parameters );
    00450
    00451
    00452       /*
    00453        *  The function setDatum sets the datum to the
    00454        *  datum corresponding to the specified index.
    00455        *
    00456        *  direction  : Indicates whether the datum is to be used for input or
    00457        *               output                                                (input)
    00458        *  index      : Identifies the index of the datum to be used          (input)
    00459        */
    00460
    00461       void setDatum( const SourceOrTarget::Enum direction, const char* index );
    00462
    00463
    00464       /*
    00465        *  The function setCoordinateSystem sets the coordinate system
    00466        *  to the specified coordinate system type.
    00467        *
    00468        *  direction  : Indicates whether the coordinate system is to be used for
    00469        *               input or output                                       (input)
    00470        *  parameters : Coordinate system parameters to be used               (input)
    00471        */
    00472
    00473       void setCoordinateSystem( const SourceOrTarget::Enum direction, MSP::CCS::CoordinateSystemParameters* parameters );
    00474
    00475
    00476       /*
    00477        *  The function setParameters calls the setParameters function of the source or target
    00478        *  coordinate system.
    00479        *
    00480        *  direction  : Indicates whether the coordinate system is to be used for
    00481        *               source or target                                      (input)
    00482        */
    00483
    00484       void setParameters( const SourceOrTarget::Enum direction );
    00485
    00486
    00487       /*
    00488        *  The function convert converts the current input coordinates in the coordinate
    00489        *  system defined by the current input coordinate system parameters and input datum,
    00490        *  into output coordinates in the coordinate system defined by the output coordinate
    00491        *  system parameters and output datum.
    00492        *
    00493        *  sourceDirection: Indicates which set of coordinates and parameters to use as the source (input)
    00494        *  targetDirection: Indicates which set of coordinates and parameters to use as the target (input)
    00495        */
    00496
    00497       void convert( SourceOrTarget::Enum sourceDirection, SourceOrTarget::Enum targetDirection, CoordinateTuple* sourceCoordinates, Accuracy* sourceAccuracy, CoordinateTuple& targetCoordinates, Accuracy& targetAccuracy );
    00498
    00499
    00500       GeodeticCoordinates* convertSourceToGeodetic( SourceOrTarget::Enum sourceDirection, CoordinateTuple* sourceCoordinates, char* sourceWarningMessage );
    00501
    00502
    00503       void convertGeodeticToTarget( SourceOrTarget::Enum targetDirection, GeodeticCoordinates* _shiftedGeodetic, CoordinateTuple& targetCoordinates, char* targetWarningMessage );
    00504
    00505
    00506       /*
    00507        *  The function convertCollection will convert a list of source coordinates to a list of target coordinates
    00508        *  in a single step.
    00509        *
    00510        *  sourceCoordinatesCollection      : Coordinates of the source coordinate system to be converted   (input)
    00511        *  sourceAccuracyCollection         : Source circular, linear and spherical errors                  (input)
    00512        *  targetCoordinatesCollection      : Converted coordinates of the target coordinate system         (output)
    00513        *  targetAccuracyCollection         : Target circular, linear and spherical errors                  (output)
    00514        */
    00515
    00516       void convertCollection( const std::vector<MSP::CCS::CoordinateTuple*>& sourceCoordinatesCollection, const std::vector<MSP::CCS::Accuracy*>& sourceAccuracyCollection, std::vector<MSP::CCS::CoordinateTuple*>& targetCoordinatesCollection, std::vector<MSP::CCS::Accuracy*>& targetAccuracyCollection );
    00517     };
    00518   }
    00519 }
    00520
    00521 #endif
    00522
    00523
    00524 // CLASSIFICATION: UNCLASSIFIED