Пример #1
0
//-----------------------------------------------------------------------------
// TCourse
//-----------------------------------------------------------------------------
EXPORT_C TCourse::TCourse()
/**
Default constructor for TCourse. Sets the member data to
default values (NaN).

*/
	{
	TRealX nan;
	nan.SetNaN();

	iSpeed = nan;
	iHeading = nan;
	iSpeedAccuracy = nan;
	iHeadingAccuracy = nan;
	iCourse = nan;
	iCourseAccuracy = nan;
	iVerticalSpeed = nan;
	iVerticalSpeedAccuracy = nan;
	}
Пример #2
0
EXPORT_C TCoordinate::TCoordinate(const TReal64& aLatitude,
                                  const TReal64& aLongitude)
/**
Constructor for TCoordinate. Allows the client to set just latitude and
longitude, and sets the altitude to its default value (NaN).

@param aLatitude specifies an initial value for latitude.
@param aLongitude specifies an initial value for longitude.
 */
 : iLatitude(aLatitude)
 , iLongitude(aLongitude)
 , iDatum(KPositionDatumWgs84)
	{
	TRealX nan;
	nan.SetNaN();
	iAltitude = nan;

	NormalizeCoordinate();
	}
Пример #3
0
EXPORT_C TInt Math::ACos(TReal& aTrg, const TReal& aSrc)
/**
Calculates the principal value of the inverse cosine of a number.

@param aTrg A reference containing the result in radians,
            a value between 0 and pi. 
@param aSrc The argument of the arccos function, a value
            between -1 and +1 inclusive. 

@return KErrNone if successful, otherwise another of the system-wide
        error codes.
*/
	{
	TRealX x;
	TInt r=x.Set(aSrc);
	if (r==KErrNone)
		r=CalcArcsinArccos(aTrg,x,ETrue);
	if (r==KErrNone)
		return r;
	SetNaN(aTrg);
	return KErrArgument;
	}
Пример #4
0
TInt RatioToReal(TRealX& a, const SRatio& aRatio)
	{
	a.iSign = 0;
	a.iFlag = 0;
	a.iMantLo = 0;
	a.iMantHi = aRatio.iM;
	if (!aRatio.iM)
		{
		a.SetZero();
		return KErrNone;
		}
	TInt exp = aRatio.iX + 31 + 32767;
	if (exp > 65534)
		{
		a.SetInfinite(EFalse);
		}
	else
		{
		a.iExp = (TUint16)exp;
		}
	return KErrNone;
	}
Пример #5
0
EXPORT_C TLocality::TLocality(const TCoordinate& aCoordinate,
                              TReal32 aHorizontalAccuracy)
/**
Constructor for TLocality. Allows the client to set a coordinate and a
'surface' accuracy.

@param aCoordinate specifies an initial value for the coordinate.
@param aHorizontalAccuracy specifies an initial value for the
horizontal accuracy.
@panic aHorizontalAccuracy is negative and not set to NaN.
 */
 : TCoordinate(aCoordinate)
 , iHorizontalAccuracy(aHorizontalAccuracy)
	{
	__ASSERT_ALWAYS(
		Math::IsNaN(aHorizontalAccuracy) || aHorizontalAccuracy >= TReal32(0),
		User::Panic(KPosClientFault, EPositionBadAccuracy));

	TRealX nan;
	nan.SetNaN();

	iVerticalAccuracy = nan;
	}
//----------------------------------------------------------------
// CLbsLocMonitorConversionHandler::AccuracyFromMatchLevel
// (other items were commented in a header).
//----------------------------------------------------------------
TReal32 CLbsLocMonitorConversionHandler::AccuracyFromMatchLevel(TPositionAreaExtendedInfo::TArea aMatchlevel)
    {
    TRealX outputAccuracy;
    outputAccuracy.SetNaN();
    switch(aMatchlevel)
        {
        case TPositionAreaExtendedInfo::EAreaUnknown:
            {
            break;
            }
        case TPositionAreaExtendedInfo::EAreaCountry:
            {
            outputAccuracy.Set(KCellCountryAccuracy);
            break;
            }
        case TPositionAreaExtendedInfo::EAreaRegion:
            {
            outputAccuracy.Set(KCellLocationAccuracy);
            break;
            }
        case TPositionAreaExtendedInfo::EAreaCity:
            {
            outputAccuracy.Set(KCellFullAccuracy);
            break;
            }
        case TPositionAreaExtendedInfo::EAreaDistrict:
            {
            outputAccuracy.Set(KWlanAccuracy);
            break;
            }
        case TPositionAreaExtendedInfo::EAreaStreet:
            {
            outputAccuracy.Set(KWlanAccuracy);
            break;
            }
        default:
            {
            break;
            }
        }
    return outputAccuracy;
    }
//----------------------------------------------------------------
// 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;
    }
/** 
PositionInstruct()

Populates the Requested Positioning Methods and Quality according to the 
Positioning Instructions component of the Measure Position Request message.

Note that the field Multiple Sets is ignored (indicates if multiple 
information sets may be sent if the device supports this GaNSS feature.

Note also that Environment Characterization component is also ignored. This
relates to expected multipath and NLOS in the current area.

@param aQuality QoP, populated as per received PositionInstruction parameters
@param aMethod  Request method, populated according to received PositionInstruction parameters
@return error indication, KErrNone otherwise
*/
EXPORT_C TInt CRrlpMeasurePositionRequest::GetPositionInstruct(TLbsNetPosRequestQuality& aQuality, TLbsNetPosRequestMethod&  aMethod)
	{
	SUPLLOG(ELogP1, "CRrlpMeasurePositionRequest::PositionInstruct() Begin\n");
	__ASSERT_DEBUG(iData->component.u.msrPositionReq != NULL, User::Invariant());
	
	ASN1T_MsrPosition_Req* msgBody = iData->component.u.msrPositionReq;

	TInt index = 0;
	TInt uncertainty = 0;
	TBool uncertaintySpecified = ETrue;
	TLbsNetPosMethod posMethods[4];
	
	// populate aMethod according to requested positioning methods
	TBool gpsSupported = (msgBody->positionInstruct.positionMethod != PositionMethod::eotd);
	TBool eotdSupported = (msgBody->positionInstruct.positionMethod != PositionMethod::gps);

	// build an array of requested pos methods, and set the uncertainty value
	switch (msgBody->positionInstruct.methodType.t)
		{
		case T_MethodType_msAssisted:
			if (gpsSupported)
				{
				posMethods[index].SetPosMethod(KLbsPositioningMeansGps, TPositionModuleInfo::ETechnologyNetwork | TPositionModuleInfo::ETechnologyAssisted);
				++index;
				}
			if (eotdSupported)
				{
				posMethods[index].SetPosMethod(KLbsPositioningMeansEotd, TPositionModuleInfo::ETechnologyNetwork | TPositionModuleInfo::ETechnologyAssisted);
				++index;
				}
			//Accuracy is an optional parameter in the case of TA 
			if (msgBody->positionInstruct.methodType.u.msAssisted->m.accuracyPresent)
				{
				uncertainty = msgBody->positionInstruct.methodType.u.msAssisted->accuracy;
				}
			else
			    {
			     //if accuracy is not being specified
			    uncertaintySpecified = EFalse;
			    }
			break;

		case T_MethodType_msBased:
			if (gpsSupported)
				{
				posMethods[index].SetPosMethod(KLbsPositioningMeansGps, TPositionModuleInfo::ETechnologyTerminal | TPositionModuleInfo::ETechnologyAssisted);
				++index;
				}
			if (eotdSupported)
				{
				posMethods[index].SetPosMethod(KLbsPositioningMeansEotd, TPositionModuleInfo::ETechnologyTerminal | TPositionModuleInfo::ETechnologyAssisted);
				++index;
				}
			
			uncertainty = msgBody->positionInstruct.methodType.u.msBased;
			break;

		case T_MethodType_msBasedPref:
			if (gpsSupported)
				{
				posMethods[index].SetPosMethod(KLbsPositioningMeansGps, TPositionModuleInfo::ETechnologyTerminal | TPositionModuleInfo::ETechnologyAssisted);
				++index;
				posMethods[index].SetPosMethod(KLbsPositioningMeansGps, TPositionModuleInfo::ETechnologyNetwork | TPositionModuleInfo::ETechnologyAssisted);
				++index;
				}
			if (eotdSupported)
				{
				posMethods[index].SetPosMethod(KLbsPositioningMeansEotd, TPositionModuleInfo::ETechnologyTerminal | TPositionModuleInfo::ETechnologyAssisted);
				++index;
				posMethods[index].SetPosMethod(KLbsPositioningMeansEotd, TPositionModuleInfo::ETechnologyNetwork | TPositionModuleInfo::ETechnologyAssisted);
				++index;
				}
			uncertainty = msgBody->positionInstruct.methodType.u.msBasedPref;
			break;

		case T_MethodType_msAssistedPref:
			if (gpsSupported)
				{
				posMethods[index].SetPosMethod(KLbsPositioningMeansGps, TPositionModuleInfo::ETechnologyNetwork | TPositionModuleInfo::ETechnologyAssisted);
				++index;
				posMethods[index].SetPosMethod(KLbsPositioningMeansGps, TPositionModuleInfo::ETechnologyTerminal | TPositionModuleInfo::ETechnologyAssisted);		
				++index;
				}
			if (eotdSupported)
				{
				posMethods[index].SetPosMethod(KLbsPositioningMeansEotd, TPositionModuleInfo::ETechnologyNetwork | TPositionModuleInfo::ETechnologyAssisted);
				++index;
				posMethods[index].SetPosMethod(KLbsPositioningMeansEotd, TPositionModuleInfo::ETechnologyTerminal | TPositionModuleInfo::ETechnologyAssisted);		
				++index;
				}
			uncertainty = msgBody->positionInstruct.methodType.u.msAssistedPref;
			break;

		default:
			__ASSERT_DEBUG(0, User::Invariant());
			return KErrCorrupt;
		}
	
	// populate the return pos method array
	// index now indicates number of pos methods in the array
	TInt err = aMethod.SetPosMethods(posMethods, index);
	if (KErrNone != err)
		{
		return err;
		}
	
	// set the uncertainty values
	if (uncertaintySpecified)
	    {
	    TReal32 uncertMeters = UncertaintyToMeters(uncertainty);
	    aQuality.SetMinHorizontalAccuracy(uncertMeters);
	    aQuality.SetMinVerticalAccuracy(uncertMeters);
	    }
	else
	    {
        // Set accuracy to NaN to prompt LBS to use accuracies from its pre-configured
        // profiles if available.
	    TRealX nan;
	    nan.SetNaN();
        aQuality.SetMinHorizontalAccuracy(nan);
        aQuality.SetMinVerticalAccuracy(nan);
	    }
    
	// set the maximum fix time
	TInt fixTimeSec;
	fixTimeSec = 1 << msgBody->positionInstruct.measureResponseTime;
	TTimeIntervalMicroSeconds timeMs(fixTimeSec * KLbsMilliSeconds);
	aQuality.SetMaxFixTime(timeMs);
	
	// indicate if GPS Timing Of Cell Frames data has been requested
	//   see ASN1T_Rel98_MsrPosition_Req_Extension
	if (msgBody->m.rel98_MsrPosition_Req_extensionPresent != 0
	   && msgBody->rel98_MsrPosition_Req_extension.m.gpsTimeAssistanceMeasurementRequestPresent != 0)
	    {
	    aMethod.SetGpsTimingOfCellFramesRequested(ETrue);
	    }
	
	// no RRLP component to populate the max fix age parameter.

	SUPLLOG(ELogP1, "CRrlpMeasurePositionRequest::PositionInstruct() End\n");
	return KErrNone;
	}
Пример #9
0
// -----------------------------------------------------------------------------
// 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;
    }