GPS4Palm

Source Code Documentation


tranmerc.h

Go to the documentation of this file.
00001 #ifndef TRANMERC_H
00002   #define TRANMERC_H
00003 
00004 /***************************************************************************/
00005 /* RSC IDENTIFIER: TRANSVERSE MERCATOR
00006  *
00007  * ABSTRACT
00008  *
00009  *    This component provides conversions between Geodetic coordinates 
00010  *    (latitude and longitude) and Transverse Mercator projection coordinates
00011  *    (easting and northing).
00012  *
00013  * ERROR HANDLING
00014  *
00015  *    This component checks parameters for valid values.  If an invalid value
00016  *    is found the error code is combined with the current error code using 
00017  *    the bitwise or.  This combining allows multiple error codes to be
00018  *    returned. The possible error codes are:
00019  *
00020  *       TRANMERC_NO_ERROR           : No errors occurred in function
00021  *       TRANMERC_LAT_ERROR          : Latitude outside of valid range
00022  *                                      (-90 to 90 degrees)
00023  *       TRANMERC_LON_ERROR          : Longitude outside of valid range
00024  *                                      (-180 to 360 degrees, and within
00025  *                                        +/-90 of Central Meridian)
00026  *       TRANMERC_EASTING_ERROR      : Easting outside of valid range
00027  *                                      (depending on ellipsoid and
00028  *                                       projection parameters)
00029  *       TRANMERC_NORTHING_ERROR     : Northing outside of valid range
00030  *                                      (depending on ellipsoid and
00031  *                                       projection parameters)
00032  *       TRANMERC_ORIGIN_LAT_ERROR   : Origin latitude outside of valid range
00033  *                                      (-90 to 90 degrees)
00034  *       TRANMERC_CENT_MER_ERROR     : Central meridian outside of valid range
00035  *                                      (-180 to 360 degrees)
00036  *       TRANMERC_A_ERROR            : Semi-major axis less than or equal to zero
00037  *       TRANMERC_INV_F_ERROR        : Inverse flattening outside of valid range
00038  *                                                                                        (250 to 350)
00039  *       TRANMERC_SCALE_FACTOR_ERROR : Scale factor outside of valid
00040  *                                     range (0.3 to 3.0)
00041  *               TM_LON_WARNING              : Distortion will result if longitude is more
00042  *                                      than 9 degrees from the Central Meridian
00043  *
00044  * REUSE NOTES
00045  *
00046  *    TRANSVERSE MERCATOR is intended for reuse by any application that 
00047  *    performs a Transverse Mercator projection or its inverse.
00048  *    
00049  * REFERENCES
00050  *
00051  *    Further information on TRANSVERSE MERCATOR can be found in the 
00052  *    Reuse Manual.
00053  *
00054  *    TRANSVERSE MERCATOR originated from :  
00055  *                      U.S. Army Topographic Engineering Center
00056  *                      Geospatial Information Division
00057  *                      7701 Telegraph Road
00058  *                      Alexandria, VA  22310-3864
00059  *
00060  * LICENSES
00061  *
00062  *    None apply to this component.
00063  *
00064  * RESTRICTIONS
00065  *
00066  *    TRANSVERSE MERCATOR has no restrictions.
00067  *
00068  * ENVIRONMENT
00069  *
00070  *    TRANSVERSE MERCATOR was tested and certified in the following 
00071  *    environments:
00072  *
00073  *    1. Solaris 2.5 with GCC, version 2.8.1
00074  *    2. Windows 95 with MS Visual C++, version 6
00075  *
00076  * MODIFICATIONS
00077  *
00078  *    Date              Description
00079  *    ----              -----------
00080  *    10-02-97          Original Code
00081  *    03-02-97          Re-engineered Code
00082  *
00083  */
00084 
00085 
00086 /***************************************************************************/
00087 /*
00088  *                              DEFINES
00089  */
00090 
00091   #define TRANMERC_NO_ERROR           0x0000
00092   #define TRANMERC_LAT_ERROR          0x0001
00093   #define TRANMERC_LON_ERROR          0x0002
00094   #define TRANMERC_EASTING_ERROR      0x0004
00095   #define TRANMERC_NORTHING_ERROR     0x0008
00096   #define TRANMERC_ORIGIN_LAT_ERROR   0x0010
00097   #define TRANMERC_CENT_MER_ERROR     0x0020
00098   #define TRANMERC_A_ERROR            0x0040
00099   #define TRANMERC_INV_F_ERROR        0x0080
00100   #define TRANMERC_SCALE_FACTOR_ERROR 0x0100
00101   #define TRANMERC_LON_WARNING        0x0200
00102 
00103 
00104 #define TRANMERC_SECTION   __attribute__ ((section ("geo")))
00105 
00106 /***************************************************************************/
00107 /*
00108  *                              FUNCTION PROTOTYPES
00109  *                                for TRANMERC.C
00110  */
00111 
00112 /* ensure proper linkage to c++ programs */
00113   #ifdef __cplusplus
00114 extern "C" {
00115   #endif
00116 
00117 
00118   long Set_Transverse_Mercator_Parameters(double a,      
00119                                           double f,
00120                                           double Origin_Latitude,
00121                                           double Central_Meridian,
00122                                           double False_Easting,
00123                                           double False_Northing,
00124                                           double Scale_Factor)
00125                                           TRANMERC_SECTION;
00126 /*
00127  * The function Set_Tranverse_Mercator_Parameters receives the ellipsoid
00128  * parameters and Tranverse Mercator projection parameters as inputs, and
00129  * sets the corresponding state variables. If any errors occur, the error
00130  * code(s) are returned by the function, otherwise TRANMERC_NO_ERROR is
00131  * returned.
00132  *
00133  *    a                 : Semi-major axis of ellipsoid, in meters    (input)
00134  *    f                 : Flattening of ellipsoid                    (input)
00135  *    Origin_Latitude   : Latitude in radians at the origin of the   (input)
00136  *                         projection
00137  *    Central_Meridian  : Longitude in radians at the center of the  (input)
00138  *                         projection
00139  *    False_Easting     : Easting/X at the center of the projection  (input)
00140  *    False_Northing    : Northing/Y at the center of the projection (input)
00141  *    Scale_Factor      : Projection scale factor                    (input) 
00142  */
00143 
00144 
00145   void Get_Transverse_Mercator_Parameters(double *a,
00146                                           double *f,
00147                                           double *Origin_Latitude,
00148                                           double *Central_Meridian,
00149                                           double *False_Easting,
00150                                           double *False_Northing,
00151                                           double *Scale_Factor)
00152                                           TRANMERC_SECTION;
00153 /*
00154  * The function Get_Transverse_Mercator_Parameters returns the current
00155  * ellipsoid and Transverse Mercator projection parameters.
00156  *
00157  *    a                 : Semi-major axis of ellipsoid, in meters    (output)
00158  *    f                 : Flattening of ellipsoid                    (output)
00159  *    Origin_Latitude   : Latitude in radians at the origin of the   (output)
00160  *                         projection
00161  *    Central_Meridian  : Longitude in radians at the center of the  (output)
00162  *                         projection
00163  *    False_Easting     : Easting/X at the center of the projection  (output)
00164  *    False_Northing    : Northing/Y at the center of the projection (output)
00165  *    Scale_Factor      : Projection scale factor                    (output) 
00166  */
00167 
00168 
00169   long Convert_Geodetic_To_Transverse_Mercator (double Latitude,
00170                                                 double Longitude,
00171                                                 double *Easting,
00172                                                 double *Northing)
00173                                                 TRANMERC_SECTION;
00174 
00175 /*
00176  * The function Convert_Geodetic_To_Transverse_Mercator converts geodetic
00177  * (latitude and longitude) coordinates to Transverse Mercator projection
00178  * (easting and northing) coordinates, according to the current ellipsoid
00179  * and Transverse Mercator projection coordinates.  If any errors occur, the
00180  * error code(s) are returned by the function, otherwise TRANMERC_NO_ERROR is
00181  * returned.
00182  *
00183  *    Latitude      : Latitude in radians                         (input)
00184  *    Longitude     : Longitude in radians                        (input)
00185  *    Easting       : Easting/X in meters                         (output)
00186  *    Northing      : Northing/Y in meters                        (output)
00187  */
00188 
00189 
00190   long Convert_Transverse_Mercator_To_Geodetic (double Easting,
00191                                                 double Northing,
00192                                                 double *Latitude,
00193                                                 double *Longitude)
00194                                                 TRANMERC_SECTION;
00195 
00196 /*
00197  * The function Convert_Transverse_Mercator_To_Geodetic converts Transverse
00198  * Mercator projection (easting and northing) coordinates to geodetic
00199  * (latitude and longitude) coordinates, according to the current ellipsoid
00200  * and Transverse Mercator projection parameters.  If any errors occur, the
00201  * error code(s) are returned by the function, otherwise TRANMERC_NO_ERROR is
00202  * returned.
00203  *
00204  *    Easting       : Easting/X in meters                         (input)
00205  *    Northing      : Northing/Y in meters                        (input)
00206  *    Latitude      : Latitude in radians                         (output)
00207  *    Longitude     : Longitude in radians                        (output)
00208  */
00209 
00210 
00211   #ifdef __cplusplus
00212 }
00213   #endif
00214 
00215 #endif /* TRANMERC_H */

Created: Mon, 08 Oct 2007 22:33:16 +0200
Copyright ©2004 M. Prinke