36
|
1 |
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// System
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
/**
|
|
19 |
@file
|
|
20 |
@internalTechnology
|
|
21 |
|
|
22 |
*/
|
|
23 |
|
|
24 |
#include <e32base.h>
|
|
25 |
#include <e32math.h>
|
|
26 |
|
|
27 |
// Component
|
|
28 |
#include "netpmutils.h"
|
|
29 |
|
|
30 |
/**
|
|
31 |
Constants used in encoding of uncertainty data
|
|
32 |
|
|
33 |
@see CSuplStart::Uncertainty()
|
|
34 |
@see CSuplStart::UncertaintyAltitude()
|
|
35 |
*/
|
|
36 |
const TReal KLbsLogOnePointOne = 0.095310179804324860043952123280765;
|
|
37 |
const TReal KLbsLogOnePointZeroTwoFive = 0.02469261259037150101430767543669;
|
|
38 |
const TInt KLbsMaxUncert = 127;
|
|
39 |
|
|
40 |
/**
|
|
41 |
* TODO: update asn1 code to use this version and delete the CSuplMessageBase version?
|
|
42 |
Uncertainty()
|
|
43 |
|
|
44 |
Converts a minumum accuracy value in meters to an uncertainty value K as
|
|
45 |
described in 3GPP 23.032 (Universal Geographical Area Description) section 6.2.
|
|
46 |
|
|
47 |
r = C((1+x)^K - 1)
|
|
48 |
|
|
49 |
where r = distance in meters
|
|
50 |
C = 10
|
|
51 |
x = 0.1
|
|
52 |
K = uncertainty value
|
|
53 |
|
|
54 |
hence K = ln(r/C + 1) / ln(1.1)
|
|
55 |
|
|
56 |
@param aDistance - distance measurement in meters
|
|
57 |
@return uncertainty value K
|
|
58 |
*/
|
|
59 |
EXPORT_C TInt NetPmUtils::Uncertainty(const TReal32& aDistance)
|
|
60 |
{
|
|
61 |
TReal uncert;
|
|
62 |
Math::Ln(uncert, (aDistance/10) + 1 );
|
|
63 |
uncert /= KLbsLogOnePointOne;
|
|
64 |
if (uncert>KLbsMaxUncert)
|
|
65 |
{
|
|
66 |
uncert = KLbsMaxUncert;
|
|
67 |
}
|
|
68 |
|
|
69 |
// round to nearest whole number
|
|
70 |
TReal uncertRounded;
|
|
71 |
Math::Round(uncertRounded, uncert, 0);
|
|
72 |
|
|
73 |
return (TInt)uncertRounded;
|
|
74 |
}
|
|
75 |
|
|
76 |
|
|
77 |
/**
|
|
78 |
UncertaintyAltitude()
|
|
79 |
|
|
80 |
Converts a minumum accuracy value in meters to an uncertainty altitude value K as
|
|
81 |
described in 3GPP 23.032 (Universal Geographical Area Description) section 6.4.
|
|
82 |
|
|
83 |
r = C((1+x)^K - 1)
|
|
84 |
|
|
85 |
where r = distance in meters
|
|
86 |
C = 45
|
|
87 |
x = 0.1
|
|
88 |
K = uncertainty value
|
|
89 |
|
|
90 |
hence K = ln(r/C + 1) / ln(1.1)
|
|
91 |
|
|
92 |
@param aDistance - altitude accuracy in meters
|
|
93 |
@return uncertainty altitude value K
|
|
94 |
*/
|
|
95 |
EXPORT_C TInt NetPmUtils::UncertaintyAltitude(const TReal32& aDistance)
|
|
96 |
{
|
|
97 |
|
|
98 |
TReal uncert;
|
|
99 |
Math::Ln(uncert, (aDistance/45) + 1 );
|
|
100 |
uncert /= KLbsLogOnePointZeroTwoFive;
|
|
101 |
if (uncert>KLbsMaxUncert)
|
|
102 |
{
|
|
103 |
uncert = KLbsMaxUncert;
|
|
104 |
}
|
|
105 |
// round to nearest whole number
|
|
106 |
TReal uncertRounded;
|
|
107 |
Math::Round(uncertRounded, uncert, 0);
|
|
108 |
|
|
109 |
return (TInt)uncertRounded;
|
|
110 |
}
|
|
111 |
|
|
112 |
/**
|
|
113 |
EncodeAltitude()
|
|
114 |
|
|
115 |
Converts an value for altiutude to an 15 bit binary coded number N
|
|
116 |
|
|
117 |
@param aAltitude - altitude in meters
|
|
118 |
@return uncertainty altitude value K
|
|
119 |
*/
|
|
120 |
EXPORT_C TInt NetPmUtils::EncodeAltitude(const TReal32& aAltitude)
|
|
121 |
{
|
|
122 |
TInt altEncoded = (TInt)aAltitude;
|
|
123 |
if (altEncoded>KLbsMaxAltitude)
|
|
124 |
{
|
|
125 |
altEncoded = KLbsMaxAltitude;
|
|
126 |
}
|
|
127 |
|
|
128 |
return altEncoded;
|
|
129 |
}
|