|
S60 3rd Edition SDK for Symbian OS Example Applications Guide |
#include <LBSReferenceContainer.h>
Inheritance diagram for CLbsReferenceContainer:

Public Member Functions | |
| CLbsReferenceContainer () | |
| void | ConstructL (const TRect &aRect) |
| ~CLbsReferenceContainer () | |
| void | PositionInfoUpdatedL (TPositionInfoBase &aPosInfo, const TDesC &aModulename) |
| void | ShowErrorL (const TDesC &aErrorString) |
| void | ShowMessageL (const TDesC &aMessage) |
| virtual TKeyResponse | OfferKeyEventL (const TKeyEvent &aKeyEvent, TEventCode aType) |
Private Member Functions | |
| void | GetDegreesString (const TReal64 &aDegrees, TBuf< KDegreeLength > &aDegreesString) const |
| void | ProcessPositionInfoL (const TPositionInfo &aPositionInfo) |
| void | ProcessSatelliteInfoL (const TPositionSatelliteInfo &aSatelliteInfo) |
| void | AddItemInListL (const TDesC &aLabel, const TDesC &aValue) |
| void | SizeChanged () |
| TInt | CountComponentControls () const |
| CCoeControl * | ComponentControl (TInt aIndex) const |
| void | Draw (const TRect &aRect) const |
| void | HandleResourceChange (TInt aType) |
Private Attributes | |
| CAknDoubleStyleListBox * | iListBox |
| CDesCArray * | iItemArray |
| TBuf< KValueMaxLength > | iValueBuffer |
| TBuf< KPositionMaxModuleName+KValueMaxLength > | iListItemBuffer |
| TBuf< KPositionMaxModuleName > | iModuleName |
| CLbsPositionRequestor * | iPositionRequestor |
Definition at line 44 of file LBSReferenceContainer.h.
|
|
Constructor Definition at line 72 of file LBSReferenceContainer.cpp. 00073 : iListBox(NULL), iItemArray(NULL), iValueBuffer(), iListItemBuffer(), 00074 iModuleName(), iPositionRequestor(NULL) 00075 { 00076 }
|
|
|
Destructor. Definition at line 121 of file LBSReferenceContainer.cpp. References iListBox, and iPositionRequestor. 00122 { 00123 //Delete text control 00124 delete iListBox; 00125 00126 //Delete requestor 00127 delete iPositionRequestor; 00128 }
|
|
|
Symbian default constructor.
Definition at line 85 of file LBSReferenceContainer.cpp. References iItemArray, iListBox, iPositionRequestor, and CLbsPositionRequestor::NewL(). 00086 { 00087 TResourceReader rr; 00088 00089 // Create a window for this application view 00090 CreateWindowL(); 00091 00092 iEikonEnv->CreateResourceReaderLC(rr, R_LOC_LISTBOX_RESOURCE); 00093 00094 iListBox = new (ELeave) CAknDoubleStyleListBox (); 00095 iListBox->SetContainerWindowL( *this); 00096 iListBox->ConstructFromResourceL( rr ); 00097 CleanupStack::PopAndDestroy(); // resource stuffs. 00098 00099 CEikScrollBarFrame* sb = iListBox->CreateScrollBarFrameL(); 00100 sb->SetScrollBarVisibilityL (CEikScrollBarFrame::EOn, CEikScrollBarFrame::EOn); 00101 00102 MDesCArray* itemList = iListBox->Model()->ItemTextArray(); 00103 iItemArray = (CDesCArray*) itemList; 00104 00105 // Set the windows size 00106 SetRect(aRect); 00107 00108 // Activate the window, which makes it visible 00109 ActivateL(); 00110 00111 // Create and initialise position requestor 00112 iPositionRequestor = CLbsPositionRequestor::NewL(*this); 00113 }
|
|
||||||||||||
|
Changes latitude or longitude represented as degrees to a string of a form +DDD'MM''SS.SSSS
Definition at line 485 of file LBSReferenceContainer.cpp. 00487 { 00488 const TReal KSecondsInMinute = 60.0; 00489 const TInt KNumWidth = 3; 00490 00491 // If the aDegree is a proper number 00492 if ( !Math::IsNaN(aDegrees) ) 00493 { 00494 // Integer part of the degrees 00495 TInt intDegrees = static_cast<TInt>(aDegrees); 00496 00497 // Positive float of the degrees 00498 TReal64 realDegrees = aDegrees; 00499 00500 // Convert to positive values 00501 if ( intDegrees < 0 ) 00502 { 00503 intDegrees = -intDegrees; 00504 realDegrees = -realDegrees; 00505 } 00506 00507 // Minutes 00508 TReal64 realMinutes = (realDegrees - intDegrees) * KSecondsInMinute; 00509 00510 // Integer part of the minutes 00511 TInt intMinutes = static_cast<TInt>(realMinutes); 00512 00513 // Seconds 00514 TReal64 realSeconds = (realMinutes - intMinutes) * KSecondsInMinute; 00515 TInt intSeconds = static_cast<TInt>((realMinutes - intMinutes) * KSecondsInMinute); 00516 00517 // Check the sign of the result 00518 if ( aDegrees >= 0 ) 00519 { 00520 aDegreesString.Append(KDelimPlus); 00521 } 00522 else 00523 { 00524 aDegreesString.Append(KDelimMinus); 00525 } 00526 00527 // Add the degrees 00528 TInt64 value = intDegrees; 00529 aDegreesString.AppendNum(value); 00530 00531 // Add the separator 00532 aDegreesString.Append(KDelimDegree); 00533 00534 // Add the minutes 00535 value = intMinutes; 00536 aDegreesString.AppendNum(value); 00537 00538 // Add the separator 00539 aDegreesString.Append(KApostrophe); 00540 00541 // Add the seconds 00542 value = intSeconds; 00543 aDegreesString.AppendNum(value); 00544 00545 // Add the separator 00546 aDegreesString.Append(KDelimQuot); 00547 00548 // Add the separator 00549 aDegreesString.Append(KDelimDot); 00550 00551 // Get six last digits 00552 realSeconds -= intSeconds; 00553 realSeconds *= 1000; 00554 00555 // Add the seconds 00556 aDegreesString.AppendNumFixedWidth(static_cast<TInt>(realSeconds), EDecimal, KNumWidth); 00557 } 00558 else 00559 { 00560 // The conversion can not be done, return NaN 00561 aDegreesString = KNan; 00562 } 00563 }
|
|
|
Processes position info to string representation.
Definition at line 315 of file LBSReferenceContainer.cpp. References AddItemInListL(), GetDegreesString(), and iValueBuffer. 00317 { 00318 const TInt KRealNumberFigureAmount = 2; 00319 const TInt KRealNumberWidth = 5; 00320 00321 // Standard location information 00322 TPosition position; 00323 TRealFormat format; 00324 format.iPlaces = KRealNumberFigureAmount; 00325 format.iWidth = KRealNumberWidth; 00326 00327 // Get basic position data 00328 aPositionInfo.GetPosition(position); 00329 00330 // Get the latitude and format it 00331 TBuf<KDegreeLength> latitude; 00332 GetDegreesString(position.Latitude(), latitude); 00333 00334 // Get the longitude and format it 00335 TBuf<KDegreeLength> longitude; 00336 GetDegreesString(position.Longitude(), longitude); 00337 00338 //Get the altitude 00339 TReal altitude = position.Altitude(); 00340 00341 // Get the horizontal accuracy 00342 TReal horizontalAccuracy = position.HorizontalAccuracy(); 00343 00344 // Get the vertical accuracy 00345 TReal verticalAccuracy = position.VerticalAccuracy(); 00346 00347 // Get the timestamp of the fix 00348 TTime time = position.Time(); 00349 00350 // Temporary buffer for date formatting 00351 TBuf<KDateTimeLength> positionDateTime; 00352 00353 //Format dates and times 00354 time.FormatL(positionDateTime, KDateString); 00355 00356 // Clear the buffer 00357 iValueBuffer.Zero(); 00358 00359 AddItemInListL(KTxtLatitude, latitude); 00360 AddItemInListL(KTxtLongitude, longitude); 00361 00362 iValueBuffer.Zero(); 00363 iValueBuffer.AppendNum(altitude, format); 00364 AddItemInListL(KTxtAltitude, iValueBuffer); 00365 00366 iValueBuffer.Zero(); 00367 iValueBuffer.AppendNum(horizontalAccuracy, format); 00368 AddItemInListL(KTxtHRMS, iValueBuffer); 00369 00370 iValueBuffer.Zero(); 00371 iValueBuffer.AppendNum(verticalAccuracy, format); 00372 AddItemInListL(KTxtVRMS, iValueBuffer); 00373 00374 iValueBuffer.Zero(); 00375 iValueBuffer.Append(positionDateTime); 00376 AddItemInListL(KTxtTime, positionDateTime); 00377 00378 }
|
|
|
Processes satellite position info to string representation.
Definition at line 386 of file LBSReferenceContainer.cpp. References AddItemInListL(), iValueBuffer, and ProcessPositionInfoL(). 00388 { 00389 const TReal SpeedRatio = 36.0/10.0; 00390 const TInt KRealNumberFigureAmount = 2; 00391 const TInt KRealNumberWidth = 5; 00392 00393 // Process the basic info 00394 ProcessPositionInfoL(static_cast<TPositionInfo>(aSatelliteInfo)); 00395 00396 // The course info 00397 TCourse course; 00398 00399 // Get the satellite info 00400 aSatelliteInfo.GetCourse(course); 00401 00402 // Get the speed (m/s) 00403 TReal speed = course.Speed(); 00404 00405 // Convert to km/h if the speedAccuracy is not NaN 00406 if ( !Math::IsNaN(STATIC_CAST(TReal64, speed)) ) 00407 { 00408 // Convert to km/h 00409 speed = speed * SpeedRatio; 00410 } 00411 00412 // Get the speed accuracy (m/s) 00413 TReal speedAccuracy = course.SpeedAccuracy(); 00414 00415 // Convert to km/h if the speedAccuracy is not NaN 00416 if ( !Math::IsNaN(speedAccuracy) ) 00417 { 00418 // Convert to km/h 00419 speedAccuracy = speedAccuracy * SpeedRatio; 00420 } 00421 00422 // Get the heading (degrees) 00423 TReal heading = course.Heading(); 00424 00425 // Get the heading accuracy (degrees) 00426 TReal headingAccuracy = course.HeadingAccuracy(); 00427 00428 // Get the satellite time 00429 TTime time = aSatelliteInfo.SatelliteTime(); 00430 00431 // Format the date 00432 TBuf<KDateTimeLength> satelliteDateTime; 00433 00434 //Format dates and times 00435 time.FormatL(satelliteDateTime,KDateString); 00436 00437 // Get the number of visible satellites 00438 TInt numSatellitesInView = aSatelliteInfo.NumSatellitesInView(); 00439 00440 // Get the number of satellites utilized 00441 TInt numSatellitesUsed = aSatelliteInfo.NumSatellitesUsed(); 00442 00443 TRealFormat format; 00444 format.iPlaces = KRealNumberFigureAmount; 00445 format.iWidth = KRealNumberWidth; 00446 00447 // Append the information in list box item array 00448 iValueBuffer.Zero(); 00449 iValueBuffer.AppendNum(speed, format); 00450 AddItemInListL(KTxtSpeed, iValueBuffer); 00451 00452 iValueBuffer.Zero(); 00453 iValueBuffer.AppendNum(speedAccuracy, format); 00454 AddItemInListL(KTxtSpeedAccuracy, iValueBuffer); 00455 00456 iValueBuffer.Zero(); 00457 iValueBuffer.AppendNum(heading, format); 00458 AddItemInListL(KTxtHeading, iValueBuffer); 00459 00460 iValueBuffer.Zero(); 00461 iValueBuffer.AppendNum(headingAccuracy, format); 00462 AddItemInListL(KTxtHeadingAccuracy, iValueBuffer); 00463 00464 AddItemInListL(KTxtSatelliteTime, satelliteDateTime); 00465 00466 TInt64 value = numSatellitesInView; 00467 iValueBuffer.Zero(); 00468 iValueBuffer.AppendNum(value); 00469 AddItemInListL(KTxtSatellitesInView, iValueBuffer); 00470 00471 value = numSatellitesUsed; 00472 iValueBuffer.Zero(); 00473 iValueBuffer.AppendNum(value); 00474 AddItemInListL(KTxtSatellitesUsed, iValueBuffer); 00475 00476 }
|
|
||||||||||||
|
PositionInfoUpdatedL informs the listener about new location information
Implements MLbsPositionListener. Definition at line 151 of file LBSReferenceContainer.cpp. References AddItemInListL(), iItemArray, iModuleName, and ProcessSatelliteInfoL(). 00153 { 00154 TInt count = iItemArray->Count(); 00155 iItemArray->Reset(); 00156 00157 // Set the module name 00158 iModuleName = aModulename; 00159 AddItemInListL(KTxtModuleName, iModuleName); 00160 00161 // Check the type of the updated position information 00162 // and process that information. 00163 00164 // Check if position information class type is TPositionSatelliteInfo 00165 if (aPosInfo.PositionClassType() & EPositionSatelliteInfoClass) 00166 { 00167 // Cast the TPositionInfoBase object to TPositionSatelliteInfo 00168 TPositionSatelliteInfo* posInfo = static_cast<TPositionSatelliteInfo*>(&aPosInfo); 00169 00170 // Process the satellite information 00171 ProcessSatelliteInfoL( *posInfo ); 00172 00173 } 00174 // Check if position information class type is TPositionInfo 00175 else if (aPosInfo.PositionClassType() & EPositionInfoClass) 00176 { 00177 00178 //Cast the TPositionInfoBase object to TPositionInfo 00179 TPositionInfo* posInfo = static_cast<TPositionInfo*>(&aPosInfo); 00180 00181 //Process the position information 00182 ProcessPositionInfoL( *posInfo ); 00183 00184 } 00185 if (count < iItemArray->Count()) 00186 { 00187 iListBox->HandleItemAdditionL(); 00188 } 00189 else if (count > iItemArray->Count()) 00190 { 00191 iListBox->HandleItemRemovalL(); 00192 } 00193 else 00194 { 00195 iListBox->DrawNow(); 00196 } 00197 }
|
|
|
ShowErrorL informs the listener about occurred error during position request process
Implements MLbsPositionListener. Definition at line 207 of file LBSReferenceContainer.cpp. References AddItemInListL(), iItemArray, and iListBox. 00208 { 00209 TInt count = iItemArray->Count(); 00210 iItemArray->Reset(); 00211 00212 _LIT( KLocError, "Location error"); 00213 AddItemInListL( KLocError, aErrorString); 00214 00215 if (iItemArray->Count() < count) 00216 { 00217 iListBox->HandleItemRemovalL(); 00218 } 00219 iListBox->DrawNow(); 00220 }
|
|
|
ShowMessageL informs the listener about occurred event during position request process
Implements MLbsPositionListener. Definition at line 230 of file LBSReferenceContainer.cpp. 00231 { 00232 CAknInformationNote* note = new (ELeave) CAknInformationNote(); 00233 note->SetTextL(aMessage); 00234 note->ExecuteLD(); 00235 }
|
|
© Nokia 2006 |