|
1 /* |
|
2 * Copyright (c) 2008 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: JNI implementation of Coordinates class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INTERNAL INCLUDES |
|
20 #include "javax_microedition_location_Coordinates.h" |
|
21 #include <lbsposition.h> |
|
22 #include "logger.h" |
|
23 |
|
24 LOCAL_C void CalculateBearingToL(TCoordinate* aSrc, TCoordinate* aDest, |
|
25 TReal32* aBearing) |
|
26 { |
|
27 TReal32 bearing; |
|
28 User::LeaveIfError(aSrc->BearingTo(*aDest, bearing)); |
|
29 *aBearing = bearing; |
|
30 } |
|
31 |
|
32 /* |
|
33 * Class: javax_microedition_location_Coordinates |
|
34 * Method: _azimuthTo |
|
35 * Signature: (IDDDD)F |
|
36 */ |
|
37 JNIEXPORT jfloat JNICALL Java_javax_microedition_location_Coordinates__1azimuthTo( |
|
38 JNIEnv* /*aJniEnv*/, |
|
39 jobject /*aPeer*/, |
|
40 jdouble aSrcLatitude, |
|
41 jdouble aSrcLongitude, |
|
42 jdouble aDestLatitude, |
|
43 jdouble aDestLongitude) |
|
44 { |
|
45 JELOG2(EJavaLocation); |
|
46 |
|
47 TReal32 azimuth = 0.0f; |
|
48 |
|
49 TCoordinate src(aSrcLatitude, aSrcLongitude); |
|
50 TCoordinate dest(aDestLatitude, aDestLongitude); |
|
51 |
|
52 TRAPD(error, CalculateBearingToL( |
|
53 &src, |
|
54 &dest, |
|
55 &azimuth)); |
|
56 |
|
57 if (error != KErrNone) |
|
58 { |
|
59 ELOG1(EJavaLocation, |
|
60 "Java_javax_microedition_location_Coordinates__1azimuthTo - error %d", error); |
|
61 } |
|
62 |
|
63 return azimuth; |
|
64 } |
|
65 |
|
66 LOCAL_C void CalculateDistanceL(TCoordinate* aSrc, TCoordinate* aDest, |
|
67 TReal32* aDistance) |
|
68 { |
|
69 TReal32 distance; |
|
70 User::LeaveIfError(aSrc->Distance(*aDest, distance)); |
|
71 *aDistance = distance; |
|
72 } |
|
73 |
|
74 /* |
|
75 * Class: javax_microedition_location_Coordinates |
|
76 * Method: _distance |
|
77 * Signature: (IDDDD)F |
|
78 */ |
|
79 JNIEXPORT jfloat JNICALL Java_javax_microedition_location_Coordinates__1distance( |
|
80 JNIEnv* /*aJniEnv*/, |
|
81 jobject /*aPeer*/, |
|
82 jdouble aSrcLatitude, |
|
83 jdouble aSrcLongitude, |
|
84 jdouble aDestLatitude, |
|
85 jdouble aDestLongitude) |
|
86 { |
|
87 JELOG2(EJavaLocation); |
|
88 |
|
89 TReal32 distance = -1.0f; |
|
90 |
|
91 TCoordinate src(aSrcLatitude, aSrcLongitude); |
|
92 TCoordinate dest(aDestLatitude, aDestLongitude); |
|
93 |
|
94 // TInt error = src->Distance( *dest,distance); |
|
95 TRAPD(error, CalculateDistanceL( |
|
96 &src, |
|
97 &dest, |
|
98 &distance)); |
|
99 |
|
100 if (error != KErrNone) |
|
101 { |
|
102 ELOG1(EJavaLocation, |
|
103 "Java_javax_microedition_location_Coordinates__1distance - error %d", error); |
|
104 } |
|
105 |
|
106 return distance; |
|
107 } |
|
108 |
|
109 // End of file |