// ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // void PosLmLandmarkHandler::ReadPositionL( RDbRowSet& aView, CPosLandmark& aLandmark) { if (!aView.IsColNull(EPosLmLcLatitudeCol) && !aView.IsColNull(EPosLmLcLongitudeCol)) { TLocality position; if (!aView.IsColNull(EPosLmLcAltitudeCol)) { position.SetCoordinate(aView.ColReal64(EPosLmLcLatitudeCol), aView.ColReal64(EPosLmLcLongitudeCol), aView.ColReal32(EPosLmLcAltitudeCol)); } else { position.SetCoordinate(aView.ColReal64(EPosLmLcLatitudeCol), aView.ColReal64(EPosLmLcLongitudeCol)); } if (!aView.IsColNull(EPosLmLcHorizAccCol)) { position.SetHorizontalAccuracy( aView.ColReal32(EPosLmLcHorizAccCol)); } if (!aView.IsColNull(EPosLmLcVertAccCol)) { position.SetVerticalAccuracy(aView.ColReal32(EPosLmLcVertAccCol)); } aLandmark.SetPositionL(position); } }
/** * Creates a position information from the passed position * @param aJniEnv A reference to the JNI environment * @param aCoordinates Latitude and longitude values * @param aCoordinateInfo Altitude, horizontal accuracy and vertical accurazy */ void CreateCoordinateInfos(JNIEnv& aJniEnv, const TLocality& aPosition, jdoubleArray aCoordinates, jfloatArray aCoordinateInfo) { JELOG2(EJavaLocation); __ASSERT_DEBUG( (aJniEnv.GetArrayLength(aCoordinates) >= KLAPINumCoordinates), LAPIError::Panic(ELAPIPanicJniIncorrectArrayLength)); __ASSERT_DEBUG((aJniEnv.GetArrayLength(aCoordinateInfo) >= KLAPINumCoordinateInfos), LAPIError::Panic( ELAPIPanicJniIncorrectArrayLength)); jdouble coordinates[KLAPINumCoordinates] = { aPosition.Latitude(), aPosition.Longitude() }; jfloat coordinateInfo[KLAPINumCoordinateInfos] = { aPosition.Altitude(), aPosition.HorizontalAccuracy(), aPosition.VerticalAccuracy() }; // Set coordinate values to the java array aJniEnv.SetDoubleArrayRegion(aCoordinates, 0, KLAPINumCoordinates, coordinates); // Set coordinate information to the java array aJniEnv.SetFloatArrayRegion(aCoordinateInfo, 0, KLAPINumCoordinateInfos, coordinateInfo); }
void CLbsLocMonitorConversionHandler::FillInPartialL() { TInt infoCount = iSubsetLocationInfoArray.Count(); TInt partialCount = iCachePartialResults.Count(); if((infoCount != partialCount) || infoCount == 0) return; for(TInt i = 0; i < infoCount; i++) { CLbsLocationInfo* locationInfo = static_cast<CLbsLocationInfo*>(iSubsetLocationInfoArray[i]); RLbsAreaInfoBaseArray locationArray; CleanupStack::PushL(TCleanupItem(*CleanUpResetAndDestroy, &locationArray)); locationInfo->GetAreaInfoL(locationArray, CLbsLocationInfo::ELbsPosInfo); if(locationArray.Count() > 0) { CLbsPositionInfo* location = static_cast<CLbsPositionInfo*>(locationArray[0]); TLocality pluginLocality; location->GetLocality(pluginLocality); if(!Math::IsNaN(iCachePartialResults[i].HorizontalAccuracy()) && (iCachePartialResults[i].HorizontalAccuracy() < pluginLocality.HorizontalAccuracy())) { locationInfo->ResetAreaInfo(CLbsLocationInfo::ELbsPosInfo); CLbsPositionInfo* newLocation = CLbsPositionInfo::NewL(iCachePartialResults[i]); locationInfo->AddAreaInfoL(newLocation); } } CleanupStack::PopAndDestroy(&locationArray); } }
//------------------------------------------------------------------------------ // CPosRevGeoCodePlugin::GetAddressByCoordinateL //------------------------------------------------------------------------------ void CPosRevGeoCodePlugin::GetAddressByCoordinateL( CPosLandmark& aLandmark ) { FUNC("CPosRevGeoCodePlugin::GetAddressByCoordinateL"); // Store the landmark object. iClientLandmark = &aLandmark; TLocality locality; User::LeaveIfError( aLandmark.GetPosition( locality ) ); TReal64 latitude = locality.Latitude(); TReal64 longitude = locality.Longitude(); iAuthCode.Copy( KAuthenticationToken ); iRefURL.Copy( KRefererURL ); GetLanguageForTheRequest( iLang ); //Form the request URI iQueryString.Format( KRequestFormat, &iAuthCode, &iRefURL, latitude, longitude, &iLang ); iHTTPClientEngine->IssueHTTPGetL( iQueryString ); if ( iConnectionTimer && iConnectionTimer->IsActive() ) { iConnectionTimer->Cancel(); } }
// --------------------------------------------------------------------------- // CLbtCellIdDatabase::InsertCidLocationL // // --------------------------------------------------------------------------- // void CLbtCellIdDatabase::InsertCidLocation( TInt32 aCountryCode, TInt32 aNetworkID, TInt32 aLac, TInt32 aCellId, TLocality aLocality ) { if( IsDuplicateEntry( aCountryCode,aNetworkID,aLac,aCellId,aLocality ) ) { return; } TCellIdCoordinateData cellIdCoordinateData; cellIdCoordinateData.iCountryCode = aCountryCode; cellIdCoordinateData.iNetworkID = aNetworkID; cellIdCoordinateData.iLac = aLac; cellIdCoordinateData.iCellId = aCellId; cellIdCoordinateData.iLocality.SetCoordinate( aLocality.Latitude(), aLocality.Longitude(), aLocality.Altitude() ); cellIdCoordinateData.iLocality.SetHorizontalAccuracy( aLocality.HorizontalAccuracy() ); if( iCellIdDbArray.Count() == KMaxEntry ) { iCellIdDbArray.Remove( EIndexToBeRemoved ); } TInt error = iCellIdDbArray.Append( cellIdCoordinateData ); }
// --------------------------------------------------------------------------- // CLbtCellIdDatabase::IsDuplicateEntry // // --------------------------------------------------------------------------- // TBool CLbtCellIdDatabase::IsDuplicateEntry( TInt32 aCountryCode, TInt32 aNetworkID, TInt32 aLac, TInt32 aCellId, TLocality aLocality ) { for( TInt i=0; i<iCellIdDbArray.Count(); i++ ) { if( iCellIdDbArray[i].iCountryCode == aCountryCode && iCellIdDbArray[i].iNetworkID == aNetworkID && iCellIdDbArray[i].iLac == aLac && iCellIdDbArray[i].iCellId == aCellId ) { // If the HA of the current entry is less than the existing entry, // replace the old entry with new one. if( aLocality.HorizontalAccuracy() < iCellIdDbArray[i].iLocality.HorizontalAccuracy() ) { iCellIdDbArray[i].iLocality.SetCoordinate( aLocality.Latitude(), aLocality.Longitude(), aLocality.Altitude() ); iCellIdDbArray[i].iLocality.SetHorizontalAccuracy( aLocality.HorizontalAccuracy() ); } return ETrue; } } return EFalse; }
// --------------------------------------------------------------------------- // CLbtCellIdDatabase::GetLocationForCid // // --------------------------------------------------------------------------- // TInt CLbtCellIdDatabase::GetLocationForCid( TInt32 aCountryCode, TInt32 aNetworkID, TInt32 aLac, TInt32 aCellId, TLocality& aLocality ) { for( TInt i=0; i<iCellIdDbArray.Count(); i++ ) { if( iCellIdDbArray[i].iCountryCode == aCountryCode && iCellIdDbArray[i].iNetworkID == aNetworkID && iCellIdDbArray[i].iLac == aLac && iCellIdDbArray[i].iCellId == aCellId ) { aLocality.SetCoordinate( iCellIdDbArray[i].iLocality.Latitude(), iCellIdDbArray[i].iLocality.Longitude(), iCellIdDbArray[i].iLocality.Altitude() ); aLocality.SetHorizontalAccuracy( iCellIdDbArray[i].iLocality.HorizontalAccuracy() ); // This entry has been used and should be deleted last compared to // unused entry. This is pushed to the end because we delete // entry from first when max cap is reached.Remove operation should be // performed only if append succeeds TInt error = iCellIdDbArray.Append( iCellIdDbArray[i] ); if( error == KErrNone ) { iCellIdDbArray.Remove( i ); } return KErrNone; } } return KErrNotFound; }
/** This method calculates the distance between two given localities (a source locality and a target locality). An estimate of the accuracy of the result is also provided. Both the distance and the distance delta are given as TReal64 values which is needed when used in other calculations. This method assumes that all arguments already have been error checked. @param aSrc @param aTar @param aDistance @param aDelta */ TInt Distance64(const TLocality& aSrc, const TLocality& aTar, TReal64& aDistance, TReal64& aDelta) { // Calculate the distance between the localities RETURN_IF_ERROR(Distance64(aSrc, aTar, aDistance)); // Calculate the distance delta aDelta = aSrc.HorizontalAccuracy() + aTar.HorizontalAccuracy(); return KErrNone; }
// ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // void PosLmLandmarkHandler::SetPositionL( RDbView& aView, const CPosLandmark& aLandmark) { TLocality position; if (aLandmark.GetPosition(position) == KErrNone) { aView.SetColL(EPosLmLcLatitudeCol, position.Latitude()); aView.SetColL(EPosLmLcLongitudeCol, position.Longitude()); if (!Math::IsNaN(position.Altitude())) { aView.SetColL(EPosLmLcAltitudeCol, position.Altitude()); } else { aView.SetColNullL(EPosLmLcAltitudeCol); } if (!Math::IsNaN(position.HorizontalAccuracy())) { aView.SetColL(EPosLmLcHorizAccCol, position.HorizontalAccuracy()); } else { aView.SetColNullL(EPosLmLcHorizAccCol); } if (!Math::IsNaN(position.VerticalAccuracy())) { aView.SetColL(EPosLmLcVertAccCol, position.VerticalAccuracy()); } else { aView.SetColNullL(EPosLmLcVertAccCol); } } else { aView.SetColNullL(EPosLmLcLatitudeCol); aView.SetColNullL(EPosLmLcLongitudeCol); aView.SetColNullL(EPosLmLcAltitudeCol); aView.SetColNullL(EPosLmLcHorizAccCol); aView.SetColNullL(EPosLmLcVertAccCol); } }
// ----------------------------------------------------------------------------- // CLandmarksEditDialog::ConfigureLocationFieldsL // // (other items were commented in a header). // ----------------------------------------------------------------------------- // void CLandmarksEditDialog::ConfigureLocationFieldsL(TLocality& aLocation) { TBuf<KPosLmMaxTextFieldLength> textFieldValue; // Configure latitude in float format LandmarksUtils::LatLongToDes(aLocation.Latitude(), textFieldValue); ConfigureTextFieldL(ELandmarkLatitudeField, textFieldValue); // Configure longitude in float format LandmarksUtils::LatLongToDes(aLocation.Longitude(), textFieldValue); ConfigureTextFieldL(ELandmarkLongitudeField, textFieldValue); // Configure altitude LandmarksUtils::FloatToDesL(aLocation.Altitude(), textFieldValue, iRealFormat); ConfigureTextFieldL(ELandmarkAltitudeField, textFieldValue); // Configure horizontal accuracy LandmarksUtils::FloatToDesL(aLocation.HorizontalAccuracy(), textFieldValue, iRealFormat); ConfigureTextFieldL(ELandmarkHorAccField, textFieldValue); // Configure vertical accuracy LandmarksUtils::FloatToDesL(aLocation.VerticalAccuracy(), textFieldValue, iRealFormat); ConfigureTextFieldL(ELandmarkVerAccField, textFieldValue); }
// --------------------------------------------------------- // CPosTp148::PrintLandmarkFieldsWithDescriptionL // // (other items were commented in a header). // --------------------------------------------------------- // void CPosTp148::PrintLandmarkFieldsWithDescriptionL(const CPosLandmark& aLandmark, TBool aTraceFlag) { iLog->Log(_L("Parsing Description ... \n")); TPositionFieldId sourceFieldId = aLandmark.FirstPositionFieldId(); TLocality loc; TInt err; TPtrC landmarkName; TPtrC landmarkDescription; err = aLandmark.GetLandmarkName( landmarkName ); if ( err == KErrNone ) { HBufC* buffer = HBufC::NewLC( landmarkName.Length() + 256 ); TPtr buf = buffer->Des(); buf.Append( _L(" \tLandmark Name: ")); buf.Append( landmarkName ); iLog->Log( buf ); if( aTraceFlag ) { TraceL( buf ); } CleanupStack::PopAndDestroy( buffer ); buffer = NULL; } err = aLandmark.GetPosition(loc); if (err == KErrNone) { HBufC* buffer = HBufC::NewLC( 1024 ); TPtr buf = buffer->Des(); TRealFormat format( 12, KRealFormatFixed ); format.iPoint = TChar('.'); format.iTriLen = KDoNotUseTriads; format.iPlaces = 6; TBuf<20> sLon, sLat, sVacc, sHacc, sAlt, sRad; sLon.Num( loc.Longitude(), format ); sLat.Num( loc.Latitude(), format ); sAlt.Num( loc.Altitude(), format ); sVacc.Num( loc.VerticalAccuracy(), format ); sHacc.Num( loc.HorizontalAccuracy(), format ); buf.Format( _L("\tLM: Long %S Lat %S vertAcc %S horAcc %S alt %S "), &sLon, &sLat, &sVacc, &sHacc, &sAlt); TReal32 sourceR; err = aLandmark.GetCoverageRadius(sourceR); if (err == KErrNone ) { sRad.Num( sourceR, format ); buf.AppendFormat(_L(" srcRadius %S" ), &sRad); } iLog->Log(buf); if (aTraceFlag) TraceL(buf); CleanupStack::PopAndDestroy( buffer ); buffer = NULL; } //Get landmark description err = aLandmark.GetLandmarkDescription(landmarkDescription); if (err == KErrNone) { HBufC* buffer = HBufC::NewLC( landmarkDescription.Length() + 256 ); TPtr buf = buffer->Des(); buf.Format(_L("\tLandmark Description: ")); buf.Append(landmarkDescription); iLog->Log(buf); if ( aTraceFlag ) { TraceL( buf ); } CleanupStack::PopAndDestroy( buffer ); buffer = NULL; } while (sourceFieldId != EPositionFieldNone) { TPtrC sourceValue; aLandmark.GetPositionField(sourceFieldId, sourceValue); HBufC* buffer = HBufC::NewLC( sourceValue.Length() + 256 ); TPtr buf = buffer->Des(); buf.Format( _L( "\tIdField Id: %d Value:" ), sourceFieldId ); buf.Append( sourceValue ); iLog->Log( buf ); if ( aTraceFlag ) { TraceL( buf ); } sourceFieldId = aLandmark.NextPositionFieldId( sourceFieldId ); CleanupStack::PopAndDestroy( buffer ); } }
//---------------------------------------------------------------- // CLbsLocMonitorConversionHandler::CacheSaveL // (other items were commented in a header). //---------------------------------------------------------------- TBool CLbsLocMonitorConversionHandler::CacheSaveL() { iState = EStateCacheSave; TBool saveRequested = EFalse; TInt infoCount = iSubsetLocationInfoArray.Count(); while((iSavedToCacheCount < infoCount) && !saveRequested) { CLbsLocationInfo* locationInfo = static_cast<CLbsLocationInfo*>(iSubsetLocationInfoArray[iSavedToCacheCount]); RLbsAreaInfoBaseArray cellArray; CleanupStack::PushL(TCleanupItem(*CleanUpResetAndDestroy, &cellArray)); locationInfo->GetAreaInfoL(cellArray, CLbsLocationInfo::ELbsGsmInfo | CLbsLocationInfo::ELbsWcdmaInfo); RLbsAreaInfoBaseArray locationArray; CleanupStack::PushL(TCleanupItem(*CleanUpResetAndDestroy, &locationArray)); locationInfo->GetAreaInfoL(locationArray, CLbsLocationInfo::ELbsPosInfo); // We should get only 1 pos back but may have passed in multiple cells // We want to save that pos against all cells if((locationArray.Count() > 0) && (cellArray.Count() > 0)) { CLbsPositionInfo* location = static_cast<CLbsPositionInfo*>(locationArray[0]); TLocality locality; location->GetLocality(locality); // Only locations that have an accuracy that is better than a cell // location code will be saved in the cache if(locality.HorizontalAccuracy() < KCellLocationAccuracy) { for(TInt i = 0; i < cellArray.Count(); i++) { TLbsLocMonitorAreaInfoGci areaInfoGci; if (cellArray[i]->Type() == ELbsAreaGsmCellInfoClass) { CLbsGsmCellInfo* cell = static_cast<CLbsGsmCellInfo*>(cellArray[i]); areaInfoGci.iMcc = cell->MobileCountryCode(); areaInfoGci.iMnc = cell->MobileNetworkCode(); areaInfoGci.iLac = cell->LocationAreaCode(); areaInfoGci.iCid = cell->CellId(); areaInfoGci.iValidity = ETrue; areaInfoGci.iIs3gNetworkMode = EFalse; } else { // by elimination type must be ELbsAreaWcmdaCellInfoClass! CLbsWcdmaCellInfo* cell = static_cast<CLbsWcdmaCellInfo*>(cellArray[i]); // If we don't have a valid LAC (which may happen with WCDMA) then we cannot // save to the cache and we should go to the next cell immediately. if (cell->LocalAreaCode() == -1) continue; areaInfoGci.iMcc = cell->MobileCountryCode(); areaInfoGci.iMnc = cell->MobileNetworkCode(); areaInfoGci.iLac = cell->LocalAreaCode(); areaInfoGci.iCid = cell->UniqueCellId(); areaInfoGci.iValidity = ETrue; areaInfoGci.iIs3gNetworkMode = ETrue; } RPointerArray<TLbsLocMonitorAreaInfoBase> areaArray; areaArray.Append(&areaInfoGci); TTime now; now.HomeTime(); TPosition pos(locality, now); TInt ret = iCache.SavePosition(pos, areaArray, EFalse, iStatus); if(ret != KErrNone) { saveRequested = EFalse; } else { saveRequested = ETrue; SetActive(); } areaArray.Reset(); } } } CleanupStack::PopAndDestroy(&locationArray); CleanupStack::PopAndDestroy(&cellArray); iSavedToCacheCount++; } if((iSavedToCacheCount >= infoCount) && !saveRequested) { return ETrue; } return EFalse; }
//---------------------------------------------------------------- // CLbsLocMonitorConversionHandler::CacheLookupL // (other items were commented in a header). //---------------------------------------------------------------- TBool CLbsLocMonitorConversionHandler::CacheLookupL() { iCachePartialResults.Reset(); // Does NOT own contents iSubsetLocationInfoArray.Reset(); TInt infoCount = iLocationInfoArray.Count(); // We only do lookups if the client wants a position if(iRequestedInfo != ELbsConversionOutputPosition) { // copy all into subset array, the cache has solved nothing for(TInt i = 0; i < infoCount; i++) { iSubsetLocationInfoArray.AppendL(iLocationInfoArray[i]); } return EFalse; } TInt cacheLoads = 0; TBool resolved = EFalse; for(TInt i=0; i < infoCount; i++) { CLbsLocationInfo* locationInfo = static_cast<CLbsLocationInfo*>(iLocationInfoArray[i]); RLbsAreaInfoBaseArray areaArray; CleanupStack::PushL(TCleanupItem(*CleanUpResetAndDestroy, &areaArray)); // NOTE! When locmonitor is expanded to cache wlan etc. this call must be changed! // Currently we know about GSM and 3g (WCDMA). locationInfo->GetAreaInfoL(areaArray, CLbsLocationInfo::ELbsGsmInfo|CLbsLocationInfo::ELbsWcdmaInfo); TInt areaCount = areaArray.Count(); TBool saved = EFalse; TRealX nan; nan.SetNaN(); TLocality partialLocality; partialLocality.SetCoordinate(nan, nan, nan); partialLocality.SetAccuracy(nan, nan); for (TInt j = 0; j < areaCount; j++) { resolved = EFalse; TLbsAreaInfoClassType type = areaArray[j]->Type(); TLbsLocMonitorAreaInfoGci areaInfoGci; switch(type) { case ELbsAreaGsmCellInfoClass: { CLbsGsmCellInfo* area = static_cast<CLbsGsmCellInfo*>(areaArray[j]); areaInfoGci.iMcc = area->MobileCountryCode(); areaInfoGci.iMnc = area->MobileNetworkCode(); areaInfoGci.iLac = area->LocationAreaCode(); areaInfoGci.iCid = area->CellId(); areaInfoGci.iValidity = ETrue; areaInfoGci.iIs3gNetworkMode = EFalse; resolved = ETrue; break; } case ELbsAreaWcmdaCellInfoClass : { CLbsWcdmaCellInfo* area = static_cast<CLbsWcdmaCellInfo*>(areaArray[j]); areaInfoGci.iMcc = area->MobileCountryCode(); areaInfoGci.iMnc = area->MobileNetworkCode(); areaInfoGci.iLac = area->LocalAreaCode(); areaInfoGci.iCid = area->UniqueCellId(); areaInfoGci.iValidity = ETrue; areaInfoGci.iIs3gNetworkMode = ETrue; resolved = ETrue; break; } default: { resolved = EFalse; break; } } if(resolved && !saved) { TPosition position; RPointerArray<TLbsLocMonitorAreaInfoBase> outArray; outArray.Append(&areaInfoGci); TPositionAreaExtendedInfo matchLevel; matchLevel.SetArea(TPositionAreaInfo::EAreaUnknown); TRequestStatus status; // Cache gets are fast and not really asynch, so no harm in blocking here TInt ret = iCache.GetPosition(position,outArray,matchLevel,status); if((ret == KErrNone) || (ret == KErrNotFound)) { User::WaitForRequest(status); } outArray.Reset(); if((ret == KErrNone) && (matchLevel.Area() >= TPositionAreaExtendedInfo::EAreaCity)) { TLocality locality; locality.SetCoordinate(position.Latitude(), position.Longitude(), position.Altitude()); TRealX nan; nan.SetNaN(); locality.SetAccuracy(AccuracyFromMatchLevel(matchLevel.Area()), nan); CLbsPositionInfo* positionInfo = CLbsPositionInfo::NewL(locality); CleanupStack::PushL(positionInfo); iLocationInfoArray[i]->AddAreaInfoL(positionInfo); CleanupStack::Pop(positionInfo); saved = ETrue; cacheLoads++; } else if ((ret == KErrNone) && (matchLevel.Area() > TPositionAreaExtendedInfo::EAreaUnknown)) { // we also store partial matches in case they are better than the plugin response partialLocality.SetCoordinate(position.Latitude(), position.Longitude(), position.Altitude()); TRealX nan; nan.SetNaN(); partialLocality.SetAccuracy(AccuracyFromMatchLevel(matchLevel.Area()), nan); } } } if(!saved) { //copy into subset array, we couldn't solve this from cache iSubsetLocationInfoArray.AppendL(iLocationInfoArray[i]); iCachePartialResults.AppendL(partialLocality); } CleanupStack::PopAndDestroy(&areaArray); } // If we've loaded as many results from the cache as there are requests // then we have fully satisfied the query return cacheLoads == infoCount; }
// ----------------------------------------------------------------------------- // CLandmarksEditDialog::SaveFormDataL // // (other items were commented in a header). // ----------------------------------------------------------------------------- // TBool CLandmarksEditDialog::SaveFormDataL() { CEikEdwin* editor = NULL; // Fetch name TBuf<KPosLmMaxTextFieldLength> name; editor = static_cast <CEikEdwin*> (Control(ELandmarkNameField)); editor->GetText(name); // Fetch description HBufC* descBuf = HBufC::NewLC(KPosLmMaxDescriptionLength); TPtr desc = descBuf->Des(); editor = static_cast <CEikEdwin*> (Control(ELandmarkDescField)); editor->GetText(desc); // Fetch existing location TLocality existingLocation; TBool locationExists = (iLandmark->GetPosition(existingLocation) == KErrNone); TRealX floatFieldValue; // Fetch Latitude TReal latitude = existingLocation.Latitude(); if (iIsRealValueEdited[ELatitudeEditor] || !locationExists) { FetchFloatL(floatFieldValue, ELandmarkLatitudeField, R_LMREFAPP_LATITUDE_ERROR); floatFieldValue.GetTReal(latitude); } // Fetch Longitude TReal longitude = existingLocation.Longitude(); if (iIsRealValueEdited[ELongitudeEditor] || !locationExists) { FetchFloatL(floatFieldValue, ELandmarkLongitudeField, R_LMREFAPP_LONGITUDE_ERROR); floatFieldValue.GetTReal(longitude); } // Fetch Altitude TReal32 altitude = existingLocation.Altitude(); if (iIsRealValueEdited[EAltitudeEditor] || !locationExists) { FetchFloatL(floatFieldValue, ELandmarkAltitudeField, R_LMREFAPP_ALTITUDE_ERROR); floatFieldValue.GetTReal(altitude); } // Fetch horizontal accuracy TReal32 horAcc = existingLocation.HorizontalAccuracy(); if (iIsRealValueEdited[EHorizontalAccEditor] || !locationExists) { FetchFloatL(floatFieldValue, ELandmarkHorAccField, R_LMREFAPP_HOR_ACC_ERROR); floatFieldValue.GetTReal(horAcc); } // Fetch vertical accuracy TReal32 verAcc = existingLocation.VerticalAccuracy(); if (iIsRealValueEdited[EVerticalAccEditor] || !locationExists) { FetchFloatL(floatFieldValue, ELandmarkVerAccField, R_LMREFAPP_VER_ACC_ERROR); floatFieldValue.GetTReal(verAcc); } // Fetch Coverage Radius TReal32 radius; TInt radiusExists = (iLandmark->GetCoverageRadius(radius) == KErrNone); if (iIsRealValueEdited[ERadiusEditor] || !radiusExists) { FetchFloatL(floatFieldValue, ELandmarkRadiusField, R_LMREFAPP_RADIUS_ERROR); floatFieldValue.GetTReal(radius); } // Fetch street TBuf<KPosLmMaxTextFieldLength> street; editor = static_cast <CEikEdwin*> (Control(ELandmarkStreetField)); editor->GetText(street); // Fetch postal code TBuf<KPosLmMaxTextFieldLength> postalCode; editor = static_cast <CEikEdwin*> (Control(ELandmarkPostalField)); editor->GetText(postalCode); // Fetch city TBuf<KPosLmMaxTextFieldLength> city; editor = static_cast <CEikEdwin*> (Control(ELandmarkCityField)); editor->GetText(city); // Fetch country TBuf<KPosLmMaxTextFieldLength> country; editor = static_cast <CEikEdwin*> (Control(ELandmarkCountryField)); editor->GetText(country); // Update category iLandmark->RemoveLandmarkAttributes(CPosLandmark::ECategoryInfo); for (TInt i = 0; i < iCategoryIds.Count(); i++) { iLandmark->AddCategoryL(iCategoryIds[i]); } // Check that at least some data is entered if (!name.Length() && !desc.Length() && !street.Length() && !city.Length() && !country.Length() && !postalCode.Length() && !iCategoryIds.Count() && Math::IsNaN(latitude) && Math::IsNaN(longitude) && Math::IsNaN(altitude) && Math::IsNaN(radius) && Math::IsNaN(horAcc) && Math::IsNaN(verAcc)) { NotifyErrorToUserL(R_LMREFAPP_EMPTY_LANDMARK); } // Update name iLandmark->SetLandmarkNameL(name); // Update description iLandmark->SetLandmarkDescriptionL(desc); CleanupStack::PopAndDestroy(descBuf); // Update coverage radius if (!Math::IsNaN(radius) && radius < 0) { NotifyErrorToUserL(R_LMREFAPP_RADIUS_ERROR); } iLandmark->SetCoverageRadius(radius); // Update street iLandmark->SetPositionFieldL(EPositionFieldStreet, street); // Update postal code iLandmark->SetPositionFieldL(EPositionFieldPostalCode, postalCode); // Update city iLandmark->SetPositionFieldL(EPositionFieldCity, city); // Update country iLandmark->SetPositionFieldL(EPositionFieldCountry, country); // Update location. There are some rules specified by TLocality and // TCoordinate how to update a location. These rules are taken into // account below when validating the location data. if (Math::IsNaN(latitude) && Math::IsNaN(longitude)) { // If lat long are undefined, then alt and hAcc // must be undefined if (!Math::IsNaN(horAcc)) { NotifyErrorToUserL(R_LMREFAPP_HACC_LAT_LONG_ERROR); } else if (!Math::IsNaN(altitude)) { NotifyErrorToUserL(R_LMREFAPP_ALT_LAT_LONG_ERROR); } else if (!Math::IsNaN(verAcc)) { NotifyErrorToUserL(R_LMREFAPP_VACC_ALT_ERROR); } else { // None position fields are set, Remove position info. iLandmark->RemoveLandmarkAttributes(CPosLandmark::EPosition); } } else if (!Math::IsNaN(latitude) && !Math::IsNaN(longitude)) { // If lat long are defined, hAcc must be positive if defined if (!Math::IsNaN(horAcc) && horAcc < 0) { NotifyErrorToUserL(R_LMREFAPP_HOR_ACC_ERROR); } // if altitude is undefined, then vertical accuracy // must be undefined if (Math::IsNaN(altitude) && !Math::IsNaN(verAcc)) { NotifyErrorToUserL(R_LMREFAPP_VACC_ALT_ERROR); } // vertical accuracy must be positive if defined if (!Math::IsNaN(verAcc) && verAcc < 0) { NotifyErrorToUserL(R_LMREFAPP_VER_ACC_ERROR); } // We are allowed to set the new locality TCoordinate coordinate(latitude, longitude, altitude); TLocality newLocation(coordinate, horAcc, verAcc); iLandmark->SetPositionL(newLocation); } else { // Inform user that no valid lat/long has been entered NotifyErrorToUserL(R_LMREFAPP_LAT_LONG_ERROR); } iEdited = ETrue; return ETrue; }