|
1 /* |
|
2 * Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implements the CLandmarksViewDialog class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <e32std.h> |
|
21 #include <e32math.h> |
|
22 |
|
23 #include <aknnotewrappers.h> |
|
24 |
|
25 #include "LandmarksUtils.h" |
|
26 #include "LandmarksCommonData.h" |
|
27 |
|
28 // ============================= STATIC FUNCTIONS =============================== |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 void LandmarksUtils::FloatToDes(TReal aFloat, TDes& aDes, TRealFormat aRealFormat) |
|
34 { |
|
35 if (Math::IsNaN(aFloat)) |
|
36 { |
|
37 aDes = KNullDesC; |
|
38 } |
|
39 else |
|
40 { |
|
41 aDes.Num(aFloat, aRealFormat); |
|
42 } |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 void LandmarksUtils::LatLongToDes(TReal aFloat, TDes& aDes) |
|
49 { |
|
50 if (Math::IsNaN(aFloat)) |
|
51 { |
|
52 aDes = KNullDesC; |
|
53 } |
|
54 else |
|
55 { |
|
56 aDes.Format(KLatLongFormat, aFloat); |
|
57 } |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 void LandmarksUtils::LatLongFloatToDegMinSecDesL(TReal aLatLong, TDes& aDes) |
|
64 { |
|
65 if (!Math::IsNaN(aLatLong)) |
|
66 { |
|
67 // Convert to deg min sec |
|
68 SDegMinSec degMinSec; |
|
69 |
|
70 // Fetch degrees |
|
71 User::LeaveIfError(Math::Int(degMinSec.iDegrees, Abs(aLatLong))); |
|
72 |
|
73 // Fetch minutes |
|
74 TReal minutes = (Abs(aLatLong) - degMinSec.iDegrees) * KMinutesPerDegree; |
|
75 User::LeaveIfError(Math::Int(degMinSec.iMinutes, minutes)); |
|
76 |
|
77 // Fetch seconds |
|
78 degMinSec.iSeconds = |
|
79 ((minutes - degMinSec.iMinutes) * KSecondsPerMinute); |
|
80 |
|
81 // Check if seconds is going to be rounded to 60 |
|
82 const TReal KMaxSeconds = 59.999; |
|
83 if (degMinSec.iSeconds > KMaxSeconds) |
|
84 { |
|
85 degMinSec.iSeconds = 0; |
|
86 degMinSec.iMinutes++; |
|
87 if (degMinSec.iMinutes == KMinutesPerDegree) |
|
88 { |
|
89 degMinSec.iMinutes = 0; |
|
90 degMinSec.iDegrees++; |
|
91 // We do not need to check if degress > 90 or if degrees > 180. |
|
92 // Landmarks FW takes care of that. |
|
93 } |
|
94 } |
|
95 |
|
96 // Format output descriptor |
|
97 if (aLatLong >= 0) |
|
98 { |
|
99 aDes.Format(KListBoxLatLongFormat, &KPositiveSign, |
|
100 degMinSec.iDegrees, KDegreeSign, degMinSec.iMinutes, |
|
101 degMinSec.iSeconds); |
|
102 } |
|
103 else |
|
104 { |
|
105 aDes.Format(KListBoxLatLongFormat, &KNegativeSign, |
|
106 Abs(degMinSec.iDegrees), KDegreeSign, Abs(degMinSec.iMinutes), |
|
107 Abs(degMinSec.iSeconds)); |
|
108 } |
|
109 } |
|
110 else |
|
111 { |
|
112 aDes.Zero(); |
|
113 } |
|
114 } |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 void LandmarksUtils::Panic(TInt aReason) |
|
120 { |
|
121 _LIT(KPanic, "LmRefApp bug"); |
|
122 User::Panic(KPanic, aReason); |
|
123 } |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 void LandmarksUtils::ErrorNoteL( const TDesC& aErrorText ) |
|
129 { |
|
130 CAknErrorNote* errorNote = new (ELeave) CAknErrorNote( ETrue ); |
|
131 errorNote->ExecuteLD( aErrorText ); |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 void LandmarksUtils::InfoNoteL( const TDesC& aInfoText ) |
|
138 { |
|
139 CAknInformationNote* infoNote = new (ELeave) CAknInformationNote( ETrue ); |
|
140 infoNote->ExecuteLD( aInfoText ); |
|
141 } |