mi32/latlonfm.h

Go to the documentation of this file.
00001 /**
00002  * \file mi32/latlonfm.h 
00003  * \brief Definitions for Latitude/Longitude format conversions
00004  *
00005  * \if NODOC
00006  * $Id: latlonfm.h_v 1.16 2007/01/08 21:19:54 dwilliss Exp $
00007  *
00008  * $Log: latlonfm.h_v $
00009  * Revision 1.16  2007/01/08 21:19:54  dwilliss
00010  * Added GetLatLonTypeList
00011  *
00012  * Revision 1.15  2004/11/22 15:58:01  mju
00013  * Add more precise formats for DDD MM SS.ss... formats.
00014  *
00015  * Revision 1.14  2004/03/22 18:52:58  dwilliss
00016  * moving 3 functions into geom.dll
00017  *
00018  * Revision 1.13  2003/10/01 16:21:05  dwilliss
00019  * Fixed doxygen error
00020  *
00021  * Revision 1.12  2003/09/25 21:29:07  dwilliss
00022  * Don't capitalize enum any more. Genitor needed it, doxygen doesn't like it.
00023  *
00024  * Revision 1.11  2003/09/15 13:49:56  fileserver!dwilliss
00025  * Doxygen
00026  *
00027  * Revision 1.10  2003/09/08 20:39:21  dwilliss
00028  * Added doxygen tags for start/end function groups
00029  *
00030  * Revision 1.9  2003/07/24 19:46:30  mju
00031  * Add conversion fn returning MISTRING to avoid buffer reuse issue.
00032  *
00033  * Revision 1.8  2003/06/03 16:42:12  scowan
00034  * Added listitemdef get standard conversion function.
00035  *
00036  * Revision 1.7  2002/09/09 13:52:06  mju
00037  * Remove deprecated #defines.
00038  *
00039  * Revision 1.6  2001/12/20 21:41:23  mju
00040  * Enum docs.
00041  *
00042  * Revision 1.5  2001/08/07 16:57:37  mju
00043  * Add FLAG_Longitude360.
00044  *
00045  * Revision 1.4  2000/05/25 13:50:20  mju
00046  * Add see-also comments.
00047  *
00048  * Revision 1.3  2000/05/25 13:14:08  mju
00049  * Need to include stddefns for MI_DLLIMPORT/EXPORT defns.
00050  *
00051  * Revision 1.2  2000/05/24 23:15:38  scowan
00052  * Moved some functions to dll.
00053  *
00054  * Revision 1.1  2000/05/11 15:51:54  mju
00055  * Initial revision
00056  * \endif
00057 **/
00058 
00059 #ifndef  INC_MI32_LATLONFM_H
00060 #define  INC_MI32_LATLONFM_H
00061 
00062 #ifndef  INC_STDDEFN_H
00063 #include <mi32/stddefns.h>
00064 #endif
00065 
00066 #ifndef  INC_MI32_MISTRING_H
00067 #include <mi32/mistring.h>
00068 #endif
00069 
00070 #ifndef  INC_MI32_SIMPLEAR_H
00071 #include <mi32/simplear.h>
00072 #endif
00073 
00074 #ifdef GEOMDLL
00075    #define GEOMLIBEXPORT MI_DLLEXPORT
00076 #else
00077    #define GEOMLIBEXPORT MI_DLLIMPORT
00078 #endif
00079 
00080 /*----------------------------------------------------------------------------*/
00081 /*    Lat/Lon definitions for ConverLatLonType()                              */
00082 /*----------------------------------------------------------------------------*/
00083 
00084 #define DMSCONV_DecDegs       0x0001
00085 #define DMSCONV_DDDMMSS       0x0002
00086 #define DMSCONV_Seconds       0x0004
00087 #define DMSCONV_DF            0x0010         //!< Direction tag in front
00088 #define DMSCONV_DB            0x0020         //!< Direction tag in back
00089 #define DMSCONV_FS            0x0040         //!< Fractional seconds
00090 #define DMSCONV_FM            0x0080         //!< Fractional minutes
00091 #define DMSCONV_CD            0x0100         //!< Can be a double value
00092 #define DMSCONV_CW            0x0200         //!< Can be a word array
00093 #define DMSCONV_PMask         0xF000         //!< Precision mask
00094 #define DMSCONV_PShift        12             //!< Amount to shift precision flags
00095 #define DMSCONV_1P            0x1000         //!< 1 decimal precision
00096 #define DMSCONV_2P            0x2000         //!< 2 decimal precision
00097 #define DMSCONV_3P            0x3000         //!< 3 decimal precision
00098 #define DMSCONV_6P            0x6000         //!< 6 decimal precision
00099 
00100 enum DMSTYPE {
00101    DMSTYPE_None =             0,
00102    DMSTYPE_DecDeg =           DMSCONV_DecDegs | DMSCONV_CD,
00103    DMSTYPE_IDecDeg =          DMSCONV_DecDegs | DMSCONV_DF | DMSCONV_CD,
00104    DMSTYPE_DDDdddddd =        DMSCONV_DecDegs | DMSCONV_CD | DMSCONV_6P,
00105    DMSTYPE_IDDDdddddd =       DMSCONV_DecDegs | DMSCONV_DF | DMSCONV_CD | DMSCONV_6P,
00106    DMSTYPE_DDDMMSS =          DMSCONV_DDDMMSS | DMSCONV_CD | DMSCONV_CW,
00107    DMSTYPE_IDDDMMSS =         DMSCONV_DDDMMSS | DMSCONV_DF | DMSCONV_CW,
00108    DMSTYPE_DDDMMSSI =         DMSCONV_DDDMMSS | DMSCONV_DB | DMSCONV_CW,
00109    DMSTYPE_DDDMMSSS =         DMSCONV_DDDMMSS | DMSCONV_CD | DMSCONV_1P,
00110    DMSTYPE_IDDDMMSSS =        DMSCONV_DDDMMSS | DMSCONV_DF | DMSCONV_1P,
00111    DMSTYPE_DDDMMSSSI =        DMSCONV_DDDMMSS | DMSCONV_DB | DMSCONV_1P,
00112    DMSTYPE_DDDMMSSSS =        DMSCONV_DDDMMSS | DMSCONV_CD | DMSCONV_2P,
00113    DMSTYPE_IDDDMMSSSS =       DMSCONV_DDDMMSS | DMSCONV_DF | DMSCONV_2P,
00114    DMSTYPE_DDDMMSSSSI =       DMSCONV_DDDMMSS | DMSCONV_DB | DMSCONV_2P,
00115    DMSTYPE_DDDMMSSSSS =       DMSCONV_DDDMMSS | DMSCONV_CD | DMSCONV_3P,
00116    DMSTYPE_IDDDMMSSSSS =      DMSCONV_DDDMMSS | DMSCONV_DF | DMSCONV_3P,
00117    DMSTYPE_DDDMMSSSSSI =      DMSCONV_DDDMMSS | DMSCONV_DB | DMSCONV_3P,
00118    DMSTYPE_DDDMMSS_SS =       DMSCONV_DDDMMSS | DMSCONV_2P | DMSCONV_CD | DMSCONV_CW,
00119    DMSTYPE_IDDDMMSS_SS =      DMSCONV_DDDMMSS | DMSCONV_2P | DMSCONV_DF | DMSCONV_CW,
00120    DMSTYPE_DDDMMSS_SSI =      DMSCONV_DDDMMSS | DMSCONV_2P | DMSCONV_DB | DMSCONV_CW,
00121    DMSTYPE_DDDMMSS_sss =      DMSCONV_DDDMMSS | DMSCONV_3P | DMSCONV_CD | DMSCONV_CW,
00122    DMSTYPE_IDDDMMSS_sss =     DMSCONV_DDDMMSS | DMSCONV_3P | DMSCONV_DF | DMSCONV_CW,
00123    DMSTYPE_DDDMMSS_sssI =     DMSCONV_DDDMMSS | DMSCONV_3P | DMSCONV_DB | DMSCONV_CW,
00124    DMSTYPE_DDDMMSS_ssssss =   DMSCONV_DDDMMSS | DMSCONV_6P | DMSCONV_CD | DMSCONV_CW,
00125    DMSTYPE_IDDDMMSS_ssssss =  DMSCONV_DDDMMSS | DMSCONV_6P | DMSCONV_DF | DMSCONV_CW,
00126    DMSTYPE_DDDMMSS_ssssssI =  DMSCONV_DDDMMSS | DMSCONV_6P | DMSCONV_DB | DMSCONV_CW,
00127    DMSTYPE_DDDMM_MM =         DMSCONV_DDDMMSS | DMSCONV_FM | DMSCONV_CD | DMSCONV_CW,
00128    DMSTYPE_IDDDMM_MM =        DMSCONV_DDDMMSS | DMSCONV_FM | DMSCONV_DF | DMSCONV_CW,
00129    DMSTYPE_DDDMM_MMI =        DMSCONV_DDDMMSS | DMSCONV_FM | DMSCONV_DB | DMSCONV_CW,
00130    DMSTYPE_Seconds =          DMSCONV_Seconds | DMSCONV_CD,
00131    DMSTYPE_ISeconds =         DMSCONV_Seconds | DMSCONV_DF,
00132    DMSTYPE_SecondsI =         DMSCONV_Seconds | DMSCONV_DB,
00133    };
00134 
00135 enum CONVDMSFLAGS {
00136    CONVDMSFLAG_None =            0,
00137    CONVDMSFLAG_IN_String =       0x00010000,    //!< Input buffer is a char* string
00138    CONVDMSFLAG_IN_WArray =       0x00020000,    //!< Input buffer is Unicode string
00139    CONVDMSFLAG_IN_Double =       0x00040000,    //!< Input buffer is a double
00140    CONVDMSFLAG_OUT_String =      0x01000000,    //!< Output buffer is a char* string
00141    CONVDMSFLAG_OUT_WArray =      0x02000000,    //!< Output buffer is Unicode string
00142    CONVDMSFLAG_OUT_Double =      0x04000000,    //!< Output buffer is a double
00143    CONVDMSFLAG_OUT_PutSpaces =   0x10000000,    //!< Insert spaces between degrees, minutes, seconds if applicable
00144    CONVDMSFLAG_OUT_IsLatitude =  0x20000000,    //!< Use direction indicator for Latitude, otherwise Longitude assumed
00145    };
00146 DEFINE_ENUM_OPERATORS(CONVDMSFLAGS);
00147 
00148 struct DMSTYPEANDNAME {
00149    DMSTYPE type;
00150    TEXTID name;
00151    };
00152 
00153 /*----------------------------------------------------------------------------*/
00154 /*    Definitions for ConvertDegsToString()                                   */
00155 /*----------------------------------------------------------------------------*/
00156 
00157 enum DEGTOSTRFLAGS {
00158    DEGTOSTRFLAG_NoDir =          0x00000000,    //!< Don't include direction (N,S,E,W) indicator
00159    DEGTOSTRFLAG_Longitude =      0x00000001,    //!< Format as longitude
00160    DEGTOSTRFLAG_Latitude =       0x00000002,    //!< Format as latitude
00161    DEGTOSTRFLAG_DirLast =        0x00000010,    //!< Put direction indicator last
00162    DEGTOSTRFLAG_DecDegs =        0x00000020,    //!< Format as decimal degrees
00163    DEGTOSTRFLAG_DegDecMin =      0x00000040,    //!< Format as degrees and decimal minutes
00164    DEGTOSTRFLAG_DegMinSec =      0x00000080,    //!< Default if no other format specified
00165    DEGTOSTRFLAG_Longitude360 =   0x00000100,    //!< Display in range of W360 to E360
00166    };
00167 DEFINE_ENUM_OPERATORS(DEGTOSTRFLAGS);
00168 
00169 
00170 /*----------------------------------------------------------------------------*/
00171 /*    Function Prototypes                                                     */
00172 /*----------------------------------------------------------------------------*/
00173 
00174 namespace MGUI {
00175 #ifndef GENERATING_DOXYGEN_OUTPUT
00176 struct LISTITEMDEF;
00177 #endif // GENERATING_DOXYGEN_OUTPUT
00178 
00179 //! Get the standard Latitude / Longitude format list
00180 //! @return List of standard Latitude / Longitude convert to string formats, DO NOT FREE
00181 //! \deprecated MGUI::LISTITEMDEF is deprecated.  Use GetLatLonTypeList.
00182 const LISTITEMDEF* GetLatLonFormatList ();
00183 }  // End namespace MGUI
00184 
00185 
00186 //!:Associate with "Latitude/Longitude Format Conversions"
00187 //!\addtogroup latlonconv Latitude/Longitude Format Conversions
00188 //!@{
00189 
00190 //! Convert Latitude or Longitude value to char* string.
00191 //! @return Pointer to string
00192 //!   @see ConvLatLonToString, ConvertStringToDegs
00193 GEOMLIBEXPORT char* ConvertDegsToString (
00194    char* string,                       //!< String to hold result
00195    double value,                       //!< Value to convert in degrees
00196    DEGTOSTRFLAGS flags                 //!< Flags defining format
00197    );
00198 
00199 //! Convert Latitude or Longitude value to MISTRING.
00200 //! @return MISTRING containing converted value.
00201 //!   @see ConvLatLonToString, ConvertStringToDegs
00202 GEOMLIBEXPORT MISTRING ConvertDegsToString (
00203    double value,                       //!< Value to convert in degrees
00204    DEGTOSTRFLAGS flags                 //!< Flags defining format
00205    );
00206 
00207 //! Convert Latitude or Longitude string to decimal degrees.
00208 //!
00209 //! @return true if successful, false if not
00210 //!
00211 //! This function automatically recognizes the following formats:
00212 //!
00213 //!      D ddd mm ss.sss         D indicates direction (N, S, E or W)
00214 //!      D ddd mm.mmmm           and can be anywhere in the string
00215 //!      D ddd.ddddd
00216 //!
00217 //!    [-]ddd mm ss.sss       Sign (+ or -) is optional
00218 //!    [-]ddd mm.mmmm         Negative values indicate West and South
00219 //!    [-]ddd.ddddd           Do not type brackets []
00220 //!
00221 //!   @see ConvertStringToLatLon, ConvertDegsToString
00222 GEOMLIBEXPORT bool ConvertStringToDegs (
00223    const char* string,
00224    double* value
00225    );
00226 
00227 //! Convert Latitude/Longitude value to string.
00228 //!
00229 //! @see ConvertDegsToString, ConvStringToLatLon
00230 GEOMLIBEXPORT void ConvLatLonToString (
00231    double degrees,                     //!< Value to convert
00232    char *string,                       //!< String to hold result
00233    DMSTYPE desttype,                   //!< Destination format
00234    CONVDMSFLAGS flags                  //!< CONVDMS_OUT_...
00235    );
00236 
00237 //! Convert value to decimal degrees and/or another LatLon format.
00238 //!
00239 //! @return Converted value in degrees.
00240 GEOMLIBEXPORT double ConvLatLonValue (
00241    const void *srcbuf,                 //!< Pointer to source value, flags determine data type
00242    DMSTYPE srctype,                    //!< Source format
00243    void *destbuf,                      //!< Pointer to destination location, NULL if not needed
00244    DMSTYPE desttype,                   //!< Destination format
00245    CONVDMSFLAGS flags                  //!< Flags for input and output type
00246    );
00247 
00248 //! Convert double-precision value to decimal degrees
00249 //!
00250 //! @return Converted value in degrees.
00251 inline double ConvLatLonValue (
00252    double value,                       //!< Value to convert
00253    DMSTYPE srctype                     //!< Source format
00254    ) {
00255    return (ConvLatLonValue(&value,srctype,0,DMSTYPE_None,CONVDMSFLAG_IN_Double));
00256    }
00257 
00258 //! Convert string to decimal degrees.
00259 //!
00260 //! @return Converted value in degrees.
00261 //!
00262 //!   @see ConvertStringToDegs, ConvLatLonToString
00263 GEOMLIBEXPORT double ConvStringToLatLon (
00264    const char *string,                    //!< String to convert
00265    DMSTYPE srctype,                       //!< String format
00266    CONVDMSFLAGS flags = CONVDMSFLAG_None  //!< None presently used
00267    );
00268 
00269 //! Retrieve list of built-in latitude-longitude string formats.
00270 //!
00271 //! @return NULL-terminated array of strings containing format names.
00272 //! \deprecated Use GetLatLonTypeList
00273 GEOMLIBEXPORT const char** GetLatLonNames (void);
00274 
00275 //! Get latitude-longitude format conversion type for given index.
00276 //!
00277 //! @see ConvLatLonValue, ConvLatLonToString, ConvStringToLatLon
00278 //! \deprecated Use GetLatLonTypeList
00279 GEOMLIBEXPORT DMSTYPE GetLatLonType (
00280    int index
00281    );
00282 
00283 
00284 //! Retrieve list of built-in latitude-longitude string formats.
00285 //! 
00286 //! @see ConvLatLonValue, ConvLatLonToString, ConvStringToLatLon
00287 GEOMLIBEXPORT ERRVALUE GetLatLonTypeList (
00288    SIMPLE_ARRAY<DMSTYPEANDNAME>& types
00289    );
00290 
00291 //!@}
00292 
00293 #endif   // INC_MI32_LATLONFM_H

Generated on Thu Apr 26 04:45:02 2007 for TNTsdk by  doxygen 1.5.2