forked from petr-s/android-nmea-parser
-
Notifications
You must be signed in to change notification settings - Fork 3
/
GpsSatellite.kt
119 lines (107 loc) · 3.42 KB
/
GpsSatellite.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package com.github.petr_s.nmea
class GpsSatellite(
/**
* Returns the PRN (pseudo-random number) for the satellite.
*
* @return PRN number
*/
var prn: Int
) {
var mHasEphemeris = false
var mHasAlmanac = false
var mUsedInFix = false
/**
* Returns the signal to noise ratio for the satellite.
*
* @return the signal to noise ratio
*/
var snr = 0f
/**
* Returns the elevation of the satellite in degrees.
* The elevation can vary between 0 and 90.
*
* @return the elevation in degrees
*/
var elevation = 0f
/**
* Returns the azimuth of the satellite in degrees.
* The azimuth can vary between 0 and 360.
*
* @return the azimuth in degrees
*/
var azimuth = 0f
fun setHasEphemeris(hasEphemeris: Boolean) {
mHasEphemeris = hasEphemeris
}
fun setHasAlmanac(hasAlmanac: Boolean) {
mHasAlmanac = hasAlmanac
}
fun setUsedInFix(usedInFix: Boolean) {
mUsedInFix = usedInFix
}
/**
* Returns true if the GPS engine has ephemeris data for the satellite.
*
* @return true if the satellite has ephemeris data
*/
fun hasEphemeris(): Boolean {
return mHasEphemeris
}
/**
* Returns true if the GPS engine has almanac data for the satellite.
*
* @return true if the satellite has almanac data
*/
fun hasAlmanac(): Boolean {
return mHasAlmanac
}
/**
* Returns true if the satellite was used by the GPS engine when
* calculating the most recent GPS fix.
*
* @return true if the satellite was used to compute the most recent fix.
*/
fun usedInFix(): Boolean {
return mUsedInFix
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other == null || javaClass != other.javaClass) return false
val satellite = other as GpsSatellite
if (mHasEphemeris != satellite.mHasEphemeris) return false
if (mHasAlmanac != satellite.mHasAlmanac) return false
if (mUsedInFix != satellite.mUsedInFix) return false
if (prn != satellite.prn) return false
if (java.lang.Float.compare(satellite.snr, snr) != 0) return false
return if (java.lang.Float.compare(
satellite.elevation,
elevation
) != 0
) false else java.lang.Float.compare(
satellite.azimuth,
azimuth
) == 0
}
override fun hashCode(): Int {
var result = if (mHasEphemeris) 1 else 0
result = 31 * result + if (mHasAlmanac) 1 else 0
result = 31 * result + if (mUsedInFix) 1 else 0
result = 31 * result + prn
result = 31 * result + if (snr != +0.0f) java.lang.Float.floatToIntBits(snr) else 0
result =
31 * result + if (elevation != +0.0f) java.lang.Float.floatToIntBits(elevation) else 0
result = 31 * result + if (azimuth != +0.0f) java.lang.Float.floatToIntBits(azimuth) else 0
return result
}
override fun toString(): String {
return "GpsSatellite{" +
"mHasEphemeris=" + mHasEphemeris +
", mHasAlmanac=" + mHasAlmanac +
", mUsedInFix=" + mUsedInFix +
", mPrn=" + prn +
", mSnr=" + snr +
", mElevation=" + elevation +
", mAzimuth=" + azimuth +
'}'
}
}