--- a/locationmanager/locationtrail/src/clocationrecord.cpp Tue Jul 06 14:44:37 2010 +0300
+++ b/locationmanager/locationtrail/src/clocationrecord.cpp Wed Aug 18 10:12:07 2010 +0300
@@ -21,6 +21,9 @@
#include <ecom.h>
#include <centralrepository.h>
#include <hwrmpowerstatesdkpskeys.h>
+#ifdef LOC_GEOTAGGING_CELLID
+#include <lbslocationinfo.h>
+#endif //LOC_GEOTAGGING_CELLID
#include "rlocationtrail.h"
#include "clocationrecord.h"
@@ -101,6 +104,7 @@
,iImageQuery(NULL)
,iTagQuery(NULL)
,iTagCreator( NULL )
+ ,iLastReverseGeocodeFails(EFalse)
,iRevGeocoderPlugin( NULL )
#endif
{
@@ -132,16 +136,12 @@
#ifdef LOC_REVERSEGEOCODE
iTagCreator = CTagCreator::NewL();
+ iRevGeocoderPlugin = reinterpret_cast<CReverseGeoCoderPlugin*>(
+ REComSession::CreateImplementationL(KReverseGeoCodeUid,iDtorKey));
- if (!iRevGeocoderPlugin)
- {
- iRevGeocoderPlugin = reinterpret_cast<CReverseGeoCoderPlugin*>(
- REComSession::CreateImplementationL(KReverseGeoCodeUid,iDtorKey));
- if(iRevGeocoderPlugin)
- {
- iRevGeocoderPlugin->AddObserverL(*this);
- }
- }
+ iRevGeocoderPlugin->AddObserverL(*this);
+
+
#endif
@@ -201,8 +201,11 @@
iLocationItems.Close();
#endif
delete iNetworkInfoChangeListener;
+ iNetworkInfoChangeListener = NULL;
delete iPositionInfo;
+ iPositionInfo = NULL;
delete iNetworkInfoTimer;
+ iNetworkInfoTimer = NULL;
#ifdef LOC_GEOTAGGING_CELLID
if(iGeoConverter)
{
@@ -355,7 +358,7 @@
LOG1( "CLocationRecord::GetLocationByTimeL - aTime: %Ld", aTime.Int64() );
TBuf<DateTimeStrMaxLength> str1;
aTime.FormatL( str1, KDateTimeFormat );
- // LOG1( "CLocationRecord::GetLocationByTimeL - aTime: %S", &str1 );
+ LOG1( "CLocationRecord::GetLocationByTimeL - aTime: %S", &str1 );
#endif
TTimeIntervalSeconds interval;
@@ -370,7 +373,7 @@
LOG1( "CLocationRecord::GetLocationByTimeL - Trail timestamp: %Ld", iTrail[i]->iTimeStamp.Int64() );
TBuf<DateTimeStrMaxLength> str;
iTrail[i]->iTimeStamp.FormatL( str, KDateTimeFormat );
- //LOG1( "CLocationRecord::GetLocationByTimeL - Trail timestamp: %S", &str );
+ LOG1( "CLocationRecord::GetLocationByTimeL - Trail timestamp: %S", &str );
LOG1( "CLocationRecord::GetLocationByTimeL - timeDiff: %d", timeDiff );
#endif
@@ -707,10 +710,12 @@
{
iNetwork.iLocationAreaCode = 0;
}
+#ifdef LOC_GEOTAGGING_CELLID
if ( iState == RLocationTrail::ETrailStarting && iTrailStarted )
{
SetCurrentState( RLocationTrail::ETrailStarted );
}
+#endif
}
else
{
@@ -797,13 +802,16 @@
if( iTrailStarted )
{
// Set the property only when trail is started to avoid icon flickering and wrong icon update in UI
- if( iGpsDataAvailableFlag ||
- iNetwork.iCellId > 0 &&
+ if( iGpsDataAvailableFlag
+#ifdef LOC_GEOTAGGING_CELLID
+ || ( iNetwork.iCellId > 0 &&
((iNetwork.iLocationAreaCode == 0 && iNetwork.iAccess == CTelephony::ENetworkAccessUtran) || // 3G
(iNetwork.iLocationAreaCode > 0 && (iNetwork.iAccess == CTelephony::ENetworkAccessGsm || // 2G
iNetwork.iAccess == CTelephony::ENetworkAccessGsmCompact))) &&
iNetwork.iCountryCode.Length() > 0 &&
iNetwork.iNetworkId.Length() > 0 )
+#endif // LOC_GEOTAGGING_CELLID
+ )
{
// set the value 3 to have Geo tag available icon else not available.
iProperty.Set( KPSUidLocationTrail, KLocationTrailState,
@@ -1053,7 +1061,11 @@
{
// if both locations have valid coordinates, calculate distance between points
- if ( !Math::IsNaN( lastLocationData.iPosition.Latitude() ) &&
+ if (
+#ifdef LOC_REVERSEGEOCODE
+ !iLastReverseGeocodeFails &&
+#endif //LOC_REVERSEGEOCODE
+ !Math::IsNaN( lastLocationData.iPosition.Latitude() ) &&
!Math::IsNaN( lastLocationData.iPosition.Longitude() ) &&
!Math::IsNaN( locationData.iPosition.Latitude() ) &&
!Math::IsNaN( locationData.iPosition.Longitude() ))
@@ -1191,8 +1203,6 @@
const TReal64 KMeterInDegrees = 0.000009;
const TReal64 KPi = 3.14159265358979;
const TReal32 K180Degrees = 180.0;
-
- //TLocationData locationData = iMediaItems[0].iLocationData;
TReal64 latitude = iMediaItems[0]->iLocationData.iPosition.Latitude();
TReal64 longitude = iMediaItems[0]->iLocationData.iPosition.Longitude();
@@ -1322,6 +1332,8 @@
if ( !Math::IsNaN( aLocationData.iPosition.Latitude() ) &&
!Math::IsNaN( aLocationData.iPosition.Longitude() ))
{
+ LOG1("Lan - %f", aLocationData.iPosition.Latitude());
+ LOG1("Lon - %f", aLocationData.iPosition.Longitude());
locationObject->AddReal64PropertyL( *iLatitudeDef, aLocationData.iPosition.Latitude() );
locationObject->AddReal64PropertyL( *iLongitudeDef, aLocationData.iPosition.Longitude() );
@@ -1344,36 +1356,46 @@
}
// network related properties
- if ( aLocationData.iNetworkInfo.iAreaKnown )
+ if ( aLocationData.iNetworkInfo.iAccess != CTelephony::ENetworkAccessUnknown )
+ {
+ LOG1("Cell id - %d", aLocationData.iNetworkInfo.iCellId);
+ locationObject->AddUint32PropertyL( cellIdDef, aLocationData.iNetworkInfo.iCellId );
+ }
+ if ( aLocationData.iNetworkInfo.iAreaKnown &&
+ aLocationData.iNetworkInfo.iLocationAreaCode != 0 &&
+ aLocationData.iNetworkInfo.iAccess != CTelephony::ENetworkAccessUnknown )
{
- if ( aLocationData.iNetworkInfo.iAccess != CTelephony::ENetworkAccessUnknown )
- {
- locationObject->AddUint32PropertyL( cellIdDef, aLocationData.iNetworkInfo.iCellId );
-
- }
- if ( aLocationData.iNetworkInfo.iLocationAreaCode != 0 &&
- aLocationData.iNetworkInfo.iAccess != CTelephony::ENetworkAccessUnknown )
- {
- locationObject->AddUint32PropertyL( locationCodeDef,
- aLocationData.iNetworkInfo.iLocationAreaCode );
-
- }
- if ( aLocationData.iNetworkInfo.iCountryCode.Length() > 0 )
- {
- locationObject->AddTextPropertyL( countryCodeDef,
- aLocationData.iNetworkInfo.iCountryCode );
-
- }
- if ( aLocationData.iNetworkInfo.iNetworkId.Length() > 0 )
- {
- locationObject->AddTextPropertyL(networkCodeDef, aLocationData.iNetworkInfo.iNetworkId);
-
- }
+ LOG1("Areacode - %d", aLocationData.iNetworkInfo.iLocationAreaCode);
+ locationObject->AddUint32PropertyL( locationCodeDef,
+ aLocationData.iNetworkInfo.iLocationAreaCode );
+ }
+#ifdef _DEBUG
+ TLex lexer( aLocationData.iNetworkInfo.iCountryCode );
+ TUint countryCode = 0;
+
+ User::LeaveIfError( lexer.Val( countryCode, EDecimal) );
+ LOG1("Country code - %d", countryCode);
+
+ //Set mobile network code
+ lexer = aLocationData.iNetworkInfo.iNetworkId;
+ TUint networkCode = 0;
+ User::LeaveIfError( lexer.Val( networkCode, EDecimal) );
+ LOG1("Network id - %d", networkCode);
+#endif
+ if ( aLocationData.iNetworkInfo.iCountryCode.Length() > 0 )
+ {
+ locationObject->AddTextPropertyL( countryCodeDef,
+ aLocationData.iNetworkInfo.iCountryCode );
+ }
+
+ if ( aLocationData.iNetworkInfo.iNetworkId.Length() > 0 )
+ {
+ locationObject->AddTextPropertyL(networkCodeDef, aLocationData.iNetworkInfo.iNetworkId);
}
// Add the location object to the database.
locationObjectId = iMdeSession->AddObjectL( *locationObject );
-
+ LOG1("Location id - %d", locationObjectId);
CleanupStack::PopAndDestroy( locationObject );
LOG( "CLocationRecord::DoCreateLocationL(), end" );
@@ -1553,7 +1575,6 @@
LOG( "CLocationRecord::HandleFindLocationFromDB(), begin" );
if ( iMediaItems.Count() > 0 )
{
- //TODO: by module owner
TInt trapErr = KErrNone;
TRAP(trapErr,FindLocationFromDBL());
// no memory, don't proceed further
@@ -1824,10 +1845,21 @@
iMediaHandlingFlag &= ~KSnapGeoConvertInPendingState;
}
#else
+ // cell id based geo tagging is not supported.. go for remapping.
locationId = DoCreateLocationL( iMediaItems[0]->iLocationData );
iMediaItems[0]->iLocationId = locationId;
- CreateRelationL( iMediaItems[0]->iObjectId, locationId );
+ TItemId relationId = CreateRelationL( iMediaItems[0]->iObjectId, locationId );
TLocationSnapshotItem* firstPtr = iMediaItems[0];
+
+ // Go for remapping.. get locationdata from trail with object time
+ TTime timestamp = GetMdeObjectTimeL( iMediaItems[0]->iObjectId );
+ TRemapItem remapItem;
+ remapItem.iObjectId = iMediaItems[0]->iObjectId;
+ remapItem.iTime = timestamp;
+ remapItem.iLocationId = locationId;
+ remapItem.iRelationId = relationId;
+ iRemapper->Append( remapItem );
+
iMediaItems.Remove(0);
delete firstPtr;
iMediaItems.Compress();
@@ -1881,7 +1913,6 @@
iNewItem.iLocationData.iQuality = aPosition.HorizontalAccuracy();
TItemId locationId = DoCreateLocationL( iNewItem.iLocationData );
iRemapper->UpdateRelationsL( locationId );
- // TODO: remap.
#ifdef LOC_REVERSEGEOCODE
if(!(iMediaHandlingFlag & KReverseGeoCodingInProgress))
{
@@ -1911,7 +1942,17 @@
TLocationSnapshotItem* item = iMediaItems[0];
TItemId locationId = DoCreateLocationL( iMediaItems[0]->iLocationData );
iMediaItems[0]->iLocationId = locationId;
- CreateRelationL( iMediaItems[0]->iObjectId, locationId );
+ TItemId relationId = CreateRelationL( iMediaItems[0]->iObjectId, locationId );
+
+ // Go for remapping.. get locationdata from trail with object time
+ TTime timestamp = GetMdeObjectTimeL( iMediaItems[0]->iObjectId );
+ TRemapItem remapItem;
+ remapItem.iObjectId = iMediaItems[0]->iObjectId;
+ remapItem.iTime = timestamp;
+ remapItem.iLocationId = locationId;
+ remapItem.iRelationId = relationId;
+ iRemapper->Append( remapItem );
+
if((iMediaItems[0]->iFlag & KSnapMediaFile) > 0)
{
iLastMediaItem = *(iMediaItems[0]);
@@ -1952,6 +1993,20 @@
else if ( iMediaItems.Count() > 0 )
{
TLocationSnapshotItem* item = iMediaItems[0];
+ // Fails may be becuase of n/w reason..create location + relation so that we can handle at 3:00 AM.
+ TItemId locationId = DoCreateLocationL( iMediaItems[0]->iLocationData );
+ iMediaItems[0]->iLocationId = locationId;
+ TItemId relationId = CreateRelationL( iMediaItems[0]->iObjectId, locationId );
+
+ // Go for remapping.. get locationdata from trail with object time
+ TTime timestamp = GetMdeObjectTimeL( iMediaItems[0]->iObjectId );
+ TRemapItem remapItem;
+ remapItem.iObjectId = iMediaItems[0]->iObjectId;
+ remapItem.iTime = timestamp;
+ remapItem.iLocationId = locationId;
+ remapItem.iRelationId = relationId;
+ iRemapper->Append( remapItem );
+
iMediaItems.Remove(0);
iMediaItems.Compress();
iMediaHandlingFlag &= ~KLocationQueryInProgress;
@@ -2209,7 +2264,6 @@
iNetLocationQuery->FindL(1, 1);
iMediaHandlingFlag |= KLocationQueryInProgress;
- // iMediaHandlingFlag |= KNetQueryInProgress;
}
else
{
@@ -2461,8 +2515,10 @@
iMediaHandlingFlag &= (~KReverseGeoCodingInProgress);
TLocationSnapshotItem* snapshotItem = NULL;
+ LOG1("Error - %d", aErrorcode);
if( aErrorcode == KErrNone )
{
+ iLastReverseGeocodeFails = EFalse;
TPtrC countryPtr( aAddressInfo.GetCountryName() );
TPtrC cityPtr( aAddressInfo.GetCity() );
TRAP_IGNORE( iTagCreator->CreateLocationTagsL( countryPtr, countryTagId,
@@ -2482,19 +2538,16 @@
TRAP_IGNORE( iTagCreator->AttachTagsL(
iLocationItems[0]->iObjectId, countryTagId, cityTagId ) );
+ if ( (iLastMediaItem.iFlag & KSnapMediaFile) > 0
+ && iLastMediaItem.iLocationId == iLastLocationItem.iLocationId )
+ {
+ LOG("Updating country/city\n");
+ iLastMediaItem.iCountryTagId = countryTagId;
+ iLastMediaItem.iCityTagId = cityTagId;
+ }
+
}
}
- if(iLastMediaItem.iFlag == 0)
- {
- LOG("Last media item is null\n");
- }
- if ( iLastMediaItem.iFlag > 0 && iLastMediaItem.iLocationId == iLastLocationItem.iLocationId )
- {
- LOG("Updating country/city\n");
- iLastMediaItem.iCountryTagId = countryTagId;
- iLastMediaItem.iCityTagId = cityTagId;
- }
-
//check other items in the array has same location
for ( TInt index = iLocationItems.Count() - 1; index > 0; index--)
{
@@ -2512,6 +2565,8 @@
else
{
//handle error
+ LOG("Reverse geo coding fails");
+ iLastReverseGeocodeFails = ETrue;
}
//irrespective of error or not, remove current(first) item to proceed further