55 __TRACE_CALLSTACK; |
55 __TRACE_CALLSTACK; |
56 |
56 |
57 delete iFilePath; |
57 delete iFilePath; |
58 |
58 |
59 delete iMaptileGeocoder; |
59 delete iMaptileGeocoder; |
|
60 |
|
61 delete iLandmark; |
60 } |
62 } |
61 |
63 |
62 |
64 |
63 // ----------------------------------------------------------------------------- |
65 // ----------------------------------------------------------------------------- |
64 // CMapTileInterface::CMapTileInterface() |
66 // CMapTileInterface::CMapTileInterface() |
65 // Constructor |
67 // Constructor |
66 // ----------------------------------------------------------------------------- |
68 // ----------------------------------------------------------------------------- |
67 // |
69 // |
68 CMapTileInterface::CMapTileInterface() : |
70 CMapTileInterface::CMapTileInterface() : |
69 iMaptileGeocoder( NULL ), iFilePath( NULL ),iObserver(NULL) |
71 iMaptileGeocoder( NULL ), |
|
72 iFilePath( NULL ), |
|
73 iObserver(NULL), |
|
74 iLandmark(NULL) |
70 { |
75 { |
71 } |
76 } |
72 |
77 |
73 // ----------------------------------------------------------------------------- |
78 // ----------------------------------------------------------------------------- |
74 // CMapTileInterface::ConstructL() |
79 // CMapTileInterface::ConstructL() |
95 iObserver = aObserver; |
100 iObserver = aObserver; |
96 delete iFilePath; |
101 delete iFilePath; |
97 iFilePath = NULL; |
102 iFilePath = NULL; |
98 iFilePath = HBufC::NewL(aFilePath.Length()); |
103 iFilePath = HBufC::NewL(aFilePath.Length()); |
99 iFilePath->Des().Copy(aFilePath); |
104 iFilePath->Des().Copy(aFilePath); |
100 TConnectionOption conn = EInteractive; |
105 iStreetAvailable = EFalse; |
|
106 TConnectionOption conn = ESilent; |
101 iMaptileGeocoder->GetCoordinateByAddressL(aAddressDetails, conn); |
107 iMaptileGeocoder->GetCoordinateByAddressL(aAddressDetails, conn); |
102 } |
108 } |
103 // ----------------------------------------------------------------------------- |
109 // ----------------------------------------------------------------------------- |
104 // CMapTileInterface::GetMapTileImageL() |
110 // CMapTileInterface::GetMapTileImageL() |
105 // Interface for requesting maptile image for a landmark object |
111 // Interface for requesting maptile image for a landmark object |
114 iFilePath = NULL; |
120 iFilePath = NULL; |
115 iFilePath = HBufC::NewL(aFilePath.Length()); |
121 iFilePath = HBufC::NewL(aFilePath.Length()); |
116 iFilePath->Des().Copy(aFilePath); |
122 iFilePath->Des().Copy(aFilePath); |
117 |
123 |
118 TPtrC getStreet; |
124 TPtrC getStreet; |
119 |
|
120 aLandmark->GetPositionField(EPositionFieldStreet, getStreet); |
125 aLandmark->GetPositionField(EPositionFieldStreet, getStreet); |
121 |
126 |
122 if (getStreet.Length() > 0) |
127 if (getStreet.Length() > 0) |
123 { |
128 { |
124 iStreetAvailable = ETrue; |
129 iStreetAvailable = ETrue; |
125 } |
130 } |
126 |
131 TConnectionOption conn = ESilent; |
127 TConnectionOption conn = EInteractive; |
|
128 |
|
129 |
|
130 iMaptileGeocoder->GetCoordinateByAddressL(*aLandmark, conn); |
132 iMaptileGeocoder->GetCoordinateByAddressL(*aLandmark, conn); |
131 } |
133 } |
132 |
134 |
133 // ----------------------------------------------------------------------------- |
135 // ----------------------------------------------------------------------------- |
134 // CMapTileInterface::GetMapTileImageL() |
136 // CMapTileInterface::GetMapTileImageL() |
137 // |
139 // |
138 void CMapTileInterface::GetMapTileL(TReal aLatitude, TReal aLongitude) |
140 void CMapTileInterface::GetMapTileL(TReal aLatitude, TReal aLongitude) |
139 { |
141 { |
140 __TRACE_CALLSTACK;//Notification to observer , to update contact db, |
142 __TRACE_CALLSTACK;//Notification to observer , to update contact db, |
141 iObserver->RestGeoCodeCompleted(aLatitude, aLongitude); |
143 iObserver->RestGeoCodeCompleted(aLatitude, aLongitude); |
142 |
|
143 TInt zoom = KCityLevelZoom; |
144 TInt zoom = KCityLevelZoom; |
144 TInt size = KMapTileSize; |
145 TInt size = KMapTileSize; |
145 if (iStreetAvailable) |
146 if (iStreetAvailable) |
146 { |
147 { |
147 zoom = KStreetLvelZoom; |
148 zoom = KStreetLvelZoom; |
148 } |
149 } |
149 |
|
150 iStreetAvailable = EFalse; |
150 iStreetAvailable = EFalse; |
151 |
|
152 TMapTileParam mapTileparam(aLatitude, aLongitude, zoom, size); |
151 TMapTileParam mapTileparam(aLatitude, aLongitude, zoom, size); |
153 |
|
154 iMaptileGeocoder->GetMapTileByGeoCodeL( mapTileparam, *iFilePath ); |
152 iMaptileGeocoder->GetMapTileByGeoCodeL( mapTileparam, *iFilePath ); |
155 } |
153 } |
156 |
154 |
157 // ----------------------------------------------------------------------------- |
155 // ----------------------------------------------------------------------------- |
158 // CMapTileInterface::MapComplete() |
156 // CMapTileInterface::MapComplete() |
175 void CMapTileInterface::GeocodingCompleted(TInt aErrorcode, |
173 void CMapTileInterface::GeocodingCompleted(TInt aErrorcode, |
176 MAddressInfo& aAddressInfo) |
174 MAddressInfo& aAddressInfo) |
177 { |
175 { |
178 __TRACE_CALLSTACK; |
176 __TRACE_CALLSTACK; |
179 TReal latitude, longitude; |
177 TReal latitude, longitude; |
180 aAddressInfo.GetLatitude( latitude ); |
178 latitude=aAddressInfo.GetLatitude(); |
181 aAddressInfo.GetLongitude( longitude ); |
179 longitude=aAddressInfo.GetLongitude(); |
182 |
180 |
183 MYLOCLOGSTRING1("GeocodeCompleted() status-%d",aErrorcode); |
181 MYLOCLOGSTRING1("GeocodeCompleted() status-%d",aErrorcode); |
184 MYLOCLOGSTRING1("GeocodeCompleted() latitude-%f",latitude ); |
182 MYLOCLOGSTRING1("GeocodeCompleted() latitude-%f",latitude ); |
185 MYLOCLOGSTRING1("GeocodeCompleted() longitude-%f",longitude ); |
183 MYLOCLOGSTRING1("GeocodeCompleted() longitude-%f",longitude ); |
186 |
184 |
187 if (aErrorcode == KErrNone) |
185 if (aErrorcode == KErrNone) |
188 { |
186 { |
189 if ( latitude != KInvalidLatitudeLongitude |
187 if ( latitude != KInvalidLatitudeLongitude |
190 && longitude != KInvalidLatitudeLongitude) |
188 && longitude != KInvalidLatitudeLongitude) |
191 { |
189 { |
|
190 TRAP_IGNORE( SetLandMarkDetailsL(aAddressInfo) ); |
192 TRAPD( error, GetMapTileL(latitude, longitude) ); |
191 TRAPD( error, GetMapTileL(latitude, longitude) ); |
193 if ( error != KErrNone ) |
192 if ( error != KErrNone ) |
194 { |
193 { |
195 //Log error message |
194 //Log error message |
196 MYLOCLOGSTRING1("GetMapTileL() status-%d",error); |
195 MYLOCLOGSTRING1("GetMapTileL() status-%d",error); |
207 iObserver->MapTilefetchingCompleted(aErrorcode, KNullDesC); |
206 iObserver->MapTilefetchingCompleted(aErrorcode, KNullDesC); |
208 |
207 |
209 } |
208 } |
210 } |
209 } |
211 |
210 |
|
211 // ----------------------------------------------------------------------------- |
|
212 // CMapTileInterface::GetLandMarkDetails() |
|
213 // return pointer to CPosLandmark |
|
214 // ----------------------------------------------------------------------------- |
|
215 // |
|
216 CPosLandmark* CMapTileInterface::GetLandMarkDetails() |
|
217 { |
|
218 return iLandmark; |
|
219 |
|
220 } |
|
221 // ----------------------------------------------------------------------------- |
|
222 // CMapTileInterface::SetLandMarkDetails() |
|
223 // create CPosLandmark details from MAddressInfo |
|
224 // ----------------------------------------------------------------------------- |
|
225 // |
|
226 void CMapTileInterface::SetLandMarkDetailsL(MAddressInfo& aAddressInfo) |
|
227 { |
|
228 if(iLandmark) |
|
229 { |
|
230 delete iLandmark; |
|
231 iLandmark=NULL; |
|
232 } |
|
233 TReal latitude,longitude; |
|
234 latitude=aAddressInfo.GetLatitude(); |
|
235 longitude=aAddressInfo.GetLongitude(); |
|
236 TLocality position(TCoordinate(latitude,longitude),0); |
|
237 iLandmark=CPosLandmark::NewL(); |
|
238 //latitude and longitude |
|
239 iLandmark->SetPositionL(position); |
|
240 |
|
241 //street |
|
242 TPtrC tempText=aAddressInfo.GetThoroughfareName(); |
|
243 if(tempText.Length()>0) |
|
244 { |
|
245 iStreetAvailable=ETrue; |
|
246 } |
|
247 iLandmark->SetPositionFieldL(EPositionFieldStreet, tempText); |
|
248 //postal code |
|
249 tempText.Set(aAddressInfo.GetPincode()); |
|
250 iLandmark->SetPositionFieldL(EPositionFieldPostalCode, tempText); |
|
251 //city |
|
252 tempText.Set(aAddressInfo.GetCity()); |
|
253 iLandmark->SetPositionFieldL(EPositionFieldCity, tempText); |
|
254 //state |
|
255 tempText.Set(aAddressInfo.GetState()); |
|
256 iLandmark->SetPositionFieldL(EPositionFieldState, tempText); |
|
257 //country |
|
258 tempText.Set(aAddressInfo.GetCountryName()); |
|
259 iLandmark->SetPositionFieldL(EPositionFieldCountry, tempText); |
|
260 |
|
261 } |
|
262 //end of line |