S60 3rd Edition SDK for Symbian OS
Example Applications Guide

LandmarksUtils Class Reference

#include <LandmarksUtils.h>

List of all members.

Static Public Member Functions

static void FloatToDesL (TReal aFloat, TDes &aDes, TRealFormat aRealFormat)
static void LatLongToDes (TReal aFloat, TDes &aDes)
static void LatLongFloatToDegMinSecDesL (TReal aLatLong, TDes &aDes)
static void Panic (TInt aReason)

Classes

struct  SDegMinSec
 Internal struct for LatLongFloatToDegMinSecDesL. More...


Detailed Description

Coordinate data conversion utility methods

Definition at line 22 of file LandmarksUtils.h.


Member Function Documentation

void LandmarksUtils::FloatToDesL (  TReal  aFloat,
TDes &  aDes,
TRealFormat  aRealFormat
)  [static]
 

Converts a float to a descriptor. Handles the case when the float is NaN

Parameters:
aFloat the source float
aDes the target descriptor
aRealFormat Format used for real value conversion to text

Definition at line 29 of file LandmarksUtils.cpp.

00030     {
00031     if (Math::IsNaN(aFloat))
00032         {
00033         aDes = KNullDesC;
00034         }
00035     else
00036         {
00037         User::LeaveIfError(aDes.Num(aFloat, aRealFormat));
00038         }
00039     }

void LandmarksUtils::LatLongToDes (  TReal  aFloat,
TDes &  aDes
)  [static]
 

Converts a float lat/long to a descriptor. Handles the case when the float is NaN

Parameters:
aFloat the source float
aDes the target descriptor

Definition at line 45 of file LandmarksUtils.cpp.

00046     {
00047     if (Math::IsNaN(aFloat))
00048         {
00049         aDes = KNullDesC;
00050         }
00051     else
00052         {
00053         aDes.Format(KLatLongFormat, aFloat);
00054         }
00055     }

void LandmarksUtils::LatLongFloatToDegMinSecDesL (  TReal  aLatLong,
TDes &  aDes
)  [static]
 

Converts a latitude or longitude in float format to a descriptor containing degrees, minutes and seconds.

Parameters:
aLatLong the source float
aDes the target descriptor (degrees, minutes and seconds)

Definition at line 61 of file LandmarksUtils.cpp.

References LandmarksUtils::SDegMinSec::iDegrees, LandmarksUtils::SDegMinSec::iMinutes, and LandmarksUtils::SDegMinSec::iSeconds.

00062     {
00063     if (!Math::IsNaN(aLatLong))
00064         {
00065         // Convert to deg min sec
00066         SDegMinSec degMinSec;
00067 
00068         // Fetch degrees
00069         User::LeaveIfError(Math::Int(degMinSec.iDegrees, Abs(aLatLong)));
00070 
00071         // Fetch minutes
00072         TReal minutes = (Abs(aLatLong) - degMinSec.iDegrees) * KMinutesPerDegree;
00073         User::LeaveIfError(Math::Int(degMinSec.iMinutes, minutes));
00074 
00075         // Fetch seconds
00076         degMinSec.iSeconds = 
00077             ((minutes - degMinSec.iMinutes) * KSecondsPerMinute);
00078 
00079         // Check if seconds is going to be rounded to 60
00080         const TReal KMaxSeconds = 59.999;
00081         if (degMinSec.iSeconds > KMaxSeconds)
00082             {
00083             degMinSec.iSeconds = 0;
00084             degMinSec.iMinutes++;
00085             if (degMinSec.iMinutes == KMinutesPerDegree)
00086                 {
00087                 degMinSec.iMinutes = 0;
00088                 degMinSec.iDegrees++;
00089                 // We do not need to check if degress > 90 or if degrees > 180.
00090                 // Landmarks FW takes care of that.
00091                 }
00092             }
00093 
00094         // Format output descriptor
00095         if (aLatLong >= 0)
00096             {
00097             aDes.Format(KListBoxLatLongFormat, &KPositiveSign, 
00098                 degMinSec.iDegrees, KDegreeSign, degMinSec.iMinutes, 
00099                 degMinSec.iSeconds);
00100             }
00101         else
00102             {
00103             aDes.Format(KListBoxLatLongFormat, &KNegativeSign, 
00104                 Abs(degMinSec.iDegrees), KDegreeSign, Abs(degMinSec.iMinutes), 
00105                 Abs(degMinSec.iSeconds));
00106             }
00107         }
00108     else
00109         {
00110         aDes.Zero();
00111         }
00112     }

void LandmarksUtils::Panic (  TInt  aReason  )  [static]
 

Panics the application due to some programming error

Parameters:
aReason The panic number or error code

Definition at line 118 of file LandmarksUtils.cpp.

00119     {
00120     _LIT(KPanic, "LmRefApp bug");
00121     User::Panic(KPanic, aReason);
00122     }


© Nokia 2006

Back to top