1 /* |
|
2 * Copyright (c) 2004-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: CTestProviderCoordConverter class implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32base.h> |
|
20 |
|
21 #include "debug.h" |
|
22 #include "testprovidercoordconverter.h" |
|
23 |
|
24 // ========================== MEMBER FUNCTIONS =============================== |
|
25 |
|
26 // --------------------------------------------------------------------------- |
|
27 // --------------------------------------------------------------------------- |
|
28 // |
|
29 CTestProviderCoordConverter* CTestProviderCoordConverter::NewL() |
|
30 { |
|
31 CTestProviderCoordConverter* self = new (ELeave) CTestProviderCoordConverter; |
|
32 return self; |
|
33 } |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 // --------------------------------------------------------------------------- |
|
37 // |
|
38 CTestProviderCoordConverter::CTestProviderCoordConverter() |
|
39 { |
|
40 } |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 CTestProviderCoordConverter::~CTestProviderCoordConverter() |
|
46 { |
|
47 } |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 TInt CTestProviderCoordConverter::GetImageCoordinate( |
|
53 const TCoordinate& aWorldCoordinate, |
|
54 TPoint& aImagePoint ) |
|
55 { |
|
56 const TMnMapImageParams& params = MapImageParams(); |
|
57 TReal lat = aWorldCoordinate.Latitude(); |
|
58 TReal lon = aWorldCoordinate.Longitude(); |
|
59 |
|
60 switch ( params.ImageType() ) |
|
61 { |
|
62 case TMnMapImageParams::ETypeVectorMap: |
|
63 case TMnMapImageParams::ETypeSatelliteImage: |
|
64 { |
|
65 if ( lat < 0 || lat > params.Size().iWidth || |
|
66 lon < 0 || lon > params.Size().iHeight ) |
|
67 { |
|
68 return KErrUnknown; |
|
69 } |
|
70 break; |
|
71 } |
|
72 default: |
|
73 return KErrArgument; |
|
74 } |
|
75 aImagePoint.iX = aWorldCoordinate.Latitude(); |
|
76 aImagePoint.iY = aWorldCoordinate.Longitude(); |
|
77 return KErrNone; |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 TInt CTestProviderCoordConverter::GetWorldCoordinate( |
|
84 const TPoint& aImagePoint, |
|
85 TCoordinate& aWorldCoordinate ) |
|
86 { |
|
87 const TMnMapImageParams& params = MapImageParams(); |
|
88 switch ( params.ImageType() ) |
|
89 { |
|
90 case TMnMapImageParams::ETypeVectorMap: |
|
91 case TMnMapImageParams::ETypeSatelliteImage: |
|
92 { |
|
93 if ( aImagePoint.iX < -180 || aImagePoint.iX > 180 || |
|
94 aImagePoint.iY < -90 || aImagePoint.iY > 90 ) |
|
95 { |
|
96 return KErrUnknown; |
|
97 } |
|
98 break; |
|
99 } |
|
100 default: |
|
101 return KErrArgument; |
|
102 } |
|
103 aWorldCoordinate.SetCoordinate( aImagePoint.iX, aImagePoint.iY ); |
|
104 return KErrNone; |
|
105 } |
|