-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathGpsSatellite.java
148 lines (126 loc) · 3.88 KB
/
GpsSatellite.java
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
package com.github.petr_s.nmea;
public class GpsSatellite {
boolean mHasEphemeris;
boolean mHasAlmanac;
boolean mUsedInFix;
int mPrn;
float mSnr;
float mElevation;
float mAzimuth;
public GpsSatellite(int prn) {
mPrn = prn;
}
public void setHasEphemeris(boolean hasEphemeris) {
this.mHasEphemeris = hasEphemeris;
}
public void setHasAlmanac(boolean hasAlmanac) {
this.mHasAlmanac = hasAlmanac;
}
public void setUsedInFix(boolean usedInFix) {
this.mUsedInFix = usedInFix;
}
/**
* Returns the PRN (pseudo-random number) for the satellite.
*
* @return PRN number
*/
public int getPrn() {
return mPrn;
}
/**
* Returns the signal to noise ratio for the satellite.
*
* @return the signal to noise ratio
*/
public float getSnr() {
return mSnr;
}
public void setSnr(float snr) {
this.mSnr = snr;
}
/**
* Returns the elevation of the satellite in degrees.
* The elevation can vary between 0 and 90.
*
* @return the elevation in degrees
*/
public float getElevation() {
return mElevation;
}
public void setElevation(float elevation) {
this.mElevation = elevation;
}
/**
* Returns the azimuth of the satellite in degrees.
* The azimuth can vary between 0 and 360.
*
* @return the azimuth in degrees
*/
public float getAzimuth() {
return mAzimuth;
}
public void setAzimuth(float azimuth) {
this.mAzimuth = azimuth;
}
/**
* Returns true if the GPS engine has ephemeris data for the satellite.
*
* @return true if the satellite has ephemeris data
*/
public boolean hasEphemeris() {
return mHasEphemeris;
}
/**
* Returns true if the GPS engine has almanac data for the satellite.
*
* @return true if the satellite has almanac data
*/
public boolean hasAlmanac() {
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.
*/
public boolean usedInFix() {
return mUsedInFix;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
GpsSatellite satellite = (GpsSatellite) o;
if (mHasEphemeris != satellite.mHasEphemeris) return false;
if (mHasAlmanac != satellite.mHasAlmanac) return false;
if (mUsedInFix != satellite.mUsedInFix) return false;
if (mPrn != satellite.mPrn) return false;
if (Float.compare(satellite.mSnr, mSnr) != 0) return false;
if (Float.compare(satellite.mElevation, mElevation) != 0) return false;
return Float.compare(satellite.mAzimuth, mAzimuth) == 0;
}
@Override
public int hashCode() {
int result = (mHasEphemeris ? 1 : 0);
result = 31 * result + (mHasAlmanac ? 1 : 0);
result = 31 * result + (mUsedInFix ? 1 : 0);
result = 31 * result + mPrn;
result = 31 * result + (mSnr != +0.0f ? Float.floatToIntBits(mSnr) : 0);
result = 31 * result + (mElevation != +0.0f ? Float.floatToIntBits(mElevation) : 0);
result = 31 * result + (mAzimuth != +0.0f ? Float.floatToIntBits(mAzimuth) : 0);
return result;
}
@Override
public String toString() {
return "GpsSatellite{" +
"mHasEphemeris=" + mHasEphemeris +
", mHasAlmanac=" + mHasAlmanac +
", mUsedInFix=" + mUsedInFix +
", mPrn=" + mPrn +
", mSnr=" + mSnr +
", mElevation=" + mElevation +
", mAzimuth=" + mAzimuth +
'}';
}
}