|
1 /* |
|
2 * Copyright (c) 2007 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: CMnrpCoordConverter implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32base.h> |
|
20 |
|
21 #include "debug.h" |
|
22 #include "mnrpengine.h" |
|
23 #include "mnrpmapmodel.h" |
|
24 #include "mnrpcoordconverter.h" |
|
25 |
|
26 // ========================== MEMBER FUNCTIONS =============================== |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 // --------------------------------------------------------------------------- |
|
30 // |
|
31 CMnrpCoordConverter* CMnrpCoordConverter::NewL() |
|
32 { |
|
33 CMnrpCoordConverter* self = new (ELeave) CMnrpCoordConverter; |
|
34 CleanupStack::PushL( self ); |
|
35 |
|
36 self->iEngine = CMnrpEngine::NewL(); |
|
37 self->iModel = CMnrpMapModel::NewL( *self->iEngine ); |
|
38 |
|
39 CleanupStack::Pop( self ); |
|
40 return self; |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 CMnrpCoordConverter::CMnrpCoordConverter() |
|
47 { |
|
48 } |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 CMnrpCoordConverter::~CMnrpCoordConverter() |
|
54 { |
|
55 delete iModel; |
|
56 delete iEngine; |
|
57 } |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 TInt CMnrpCoordConverter::GetImageCoordinate( |
|
63 const TCoordinate& aWorldCoordinate, |
|
64 TPoint& aImagePoint ) |
|
65 { |
|
66 const TMnMapImageParams& params = MapImageParams(); |
|
67 |
|
68 if ( params.ImageType() == TMnMapImageParams::ETypeSatelliteImage ) |
|
69 { |
|
70 return KErrArgument; |
|
71 } |
|
72 |
|
73 iModel->UpdateModel( params ); |
|
74 |
|
75 aImagePoint = iModel->AbsoluteToScreen( aWorldCoordinate ); |
|
76 return KErrNone; |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 TInt CMnrpCoordConverter::GetWorldCoordinate( |
|
83 const TPoint& aImagePoint, |
|
84 TCoordinate& aWorldCoordinate ) |
|
85 { |
|
86 const TMnMapImageParams& params = MapImageParams(); |
|
87 |
|
88 if ( params.ImageType() == TMnMapImageParams::ETypeSatelliteImage ) |
|
89 { |
|
90 return KErrArgument; |
|
91 } |
|
92 |
|
93 iModel->UpdateModel( params ); |
|
94 |
|
95 aWorldCoordinate = iModel->ScreenToAbsolute( aImagePoint ); |
|
96 return KErrNone; |
|
97 } |