|
1 /* |
|
2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Class for handling searching for landmarks nearest a specified position. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CPOSLMLOCALNEARESTSEARCH_H |
|
20 #define CPOSLMLOCALNEARESTSEARCH_H |
|
21 |
|
22 #include "EPos_CPosLmLocalSearchHandler.h" |
|
23 #include "EPos_TPosLmNearestLandmark.h" |
|
24 |
|
25 class CPosLmNearestCriteria; |
|
26 class TPosLmLocalSortPref; |
|
27 |
|
28 /** |
|
29 * Class for handling searching for landmarks nearest a specified position. |
|
30 */ |
|
31 class CPosLmLocalNearestSearch : public CPosLmLocalSearchHandler |
|
32 { |
|
33 public: // Constructors and destructor |
|
34 |
|
35 /** |
|
36 * Two-phased constructor. |
|
37 * |
|
38 * @param[in] aDbAccess The access handle to the database to search in. |
|
39 * @param[in] aCriteria The search criteria. |
|
40 * @param[in] aSortPref A sort preference object. |
|
41 * @param[in] aDisplayData The displayable data. |
|
42 * @param[in] aMaxNumOfMatches The max number of items that will be |
|
43 * searched for. |
|
44 */ |
|
45 static CPosLmLocalNearestSearch* NewL( |
|
46 CPosLmLocalDatabase& aDatabase, |
|
47 const CPosLmSearchCriteria& aCriteria, |
|
48 const TPosLmLocalSortPref& aSortPref, |
|
49 CPosLmDisplayData* aDisplayData, |
|
50 TInt aMaxNumOfMatches ); |
|
51 |
|
52 /** |
|
53 * Destructor. |
|
54 */ |
|
55 ~CPosLmLocalNearestSearch(); |
|
56 |
|
57 public: // New functions |
|
58 |
|
59 public: // From CPosLmLocalSearchHandler |
|
60 |
|
61 /** |
|
62 * @return ETrue. |
|
63 */ |
|
64 TBool IsValidForLandmarkSearch() const; |
|
65 |
|
66 /** |
|
67 * @param[out] aProgress Will be set to the progress of the search when |
|
68 * the step has finished. |
|
69 * @return @p KPosLmOperationNotComplete if the step has completed but |
|
70 * more steps are needed before the search has finished, |
|
71 * @p KErrNone if the search has finished successfully. |
|
72 */ |
|
73 TInt NextStepL( TReal32& aProgress ); |
|
74 |
|
75 protected: |
|
76 |
|
77 private: |
|
78 |
|
79 void PrepareSearchL(); |
|
80 void SearchL(); |
|
81 |
|
82 void PrepareSearchQueryL(); |
|
83 void PrepareSortQueryIfNeededL(); |
|
84 |
|
85 /** Finds area restriction for this search. If coverage radius |
|
86 * is not used in comparisons, then it is possible to define |
|
87 * bounding area for given center and mas distance. To improve |
|
88 * search performance this filter is used to calculate distances |
|
89 * only for those landmarks, which fall into such bounding area. |
|
90 */ |
|
91 void CalculateAreaRestrictionsL( |
|
92 TReal64& aMinLatitude, |
|
93 TReal64& aMaxLatitude, |
|
94 TReal64& aMinLongitude, |
|
95 TReal64& aMaxLongitude ); |
|
96 |
|
97 void ReadFromDbAndCalculateAndAddIfMatchL(); |
|
98 |
|
99 void AddMatchesAsCurrentMatchesL(); |
|
100 |
|
101 /** |
|
102 * C++ default constructor. |
|
103 * @param[in] aDbAccess The access handle to the database to search in. |
|
104 * @param[in] aCriteria The search criteria. |
|
105 * @param[in] aSortPref A sort preference object. |
|
106 * @param[in] aMaxNumOfMatches The max number of items that will be |
|
107 * searched for. |
|
108 */ |
|
109 CPosLmLocalNearestSearch( |
|
110 CPosLmLocalDatabase& aDatabase, |
|
111 const CPosLmSearchCriteria& aCriteria, |
|
112 const TPosLmLocalSortPref& aSortPref, |
|
113 TInt aMaxNumOfMatches ); |
|
114 |
|
115 /** |
|
116 * By default Symbian 2nd phase constructor is private. |
|
117 * @param[in] aCriteria The search criteria. |
|
118 * @param[in] aDisplayData The displayable data. |
|
119 */ |
|
120 void ConstructL( |
|
121 const CPosLmSearchCriteria& aCriteria, |
|
122 CPosLmDisplayData* aDisplayData ); |
|
123 |
|
124 // By default, prohibit copy constructor |
|
125 CPosLmLocalNearestSearch( const CPosLmLocalNearestSearch& ); |
|
126 // Prohibit assigment operator |
|
127 CPosLmLocalNearestSearch& operator= ( const CPosLmLocalNearestSearch& ); |
|
128 |
|
129 private: |
|
130 |
|
131 enum TNearestSearchStatus |
|
132 { |
|
133 ESearchNotStarted = 0, |
|
134 |
|
135 EPrepareNearestSearch, |
|
136 ENearestSearch, |
|
137 EReadDisplayData, |
|
138 |
|
139 EPrepareSorting, |
|
140 ESorting, |
|
141 |
|
142 ESearchCompleted |
|
143 }; |
|
144 |
|
145 TNearestSearchStatus iSearchStatus; |
|
146 |
|
147 CPosLmNearestCriteria* iCriteria; |
|
148 |
|
149 TBool iSortSearch; |
|
150 |
|
151 RArray<TPosLmNearestLandmark> iArray; |
|
152 |
|
153 TInt iCurrentResult; |
|
154 |
|
155 TBool iIncludeAreaCondition; |
|
156 }; |
|
157 |
|
158 #endif // CPOSLMLOCALNEARESTSEARCH_H |
|
159 |
|
160 // End of File |