|
| 1 | +/** |
| 2 | + * Copyright 2011 Thorsten Höger, Taimos GmbH |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 5 | + * use this file except in compliance with the License. You may obtain a copy of |
| 6 | + * the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | + * License for the specific language governing permissions and limitations under |
| 14 | + * the License. |
| 15 | + */ |
| 16 | +package de.taimos.gpsd4java.types; |
| 17 | + |
| 18 | +/** |
| 19 | + * |
| 20 | + * @author aevdokimov |
| 21 | + */ |
| 22 | +public class SATObject implements IGPSObject { |
| 23 | + |
| 24 | + private int PRN = -1; |
| 25 | + |
| 26 | + private int azimuth = -1; |
| 27 | + |
| 28 | + private int elevation = -1; |
| 29 | + |
| 30 | + private int signalStrength = -1; |
| 31 | + |
| 32 | + private boolean used = false; |
| 33 | + |
| 34 | + /** |
| 35 | + * PRN ID of the satellite. 1-63 are GNSS satellites, 64-96 are GLONASS satellites, 100-164 are SBAS satellites |
| 36 | + * |
| 37 | + * @return PRN |
| 38 | + */ |
| 39 | + public int getPRN() { |
| 40 | + return this.PRN; |
| 41 | + } |
| 42 | + |
| 43 | + /** |
| 44 | + * PRN ID of the satellite. 1-63 are GNSS satellites, 64-96 are GLONASS satellites, 100-164 are SBAS satellites |
| 45 | + * |
| 46 | + * @param PRN |
| 47 | + * the PRN to set |
| 48 | + */ |
| 49 | + public void setPRN(final int PRN) { |
| 50 | + this.PRN = PRN; |
| 51 | + } |
| 52 | + |
| 53 | + /** |
| 54 | + * Azimuth, degrees from true north. |
| 55 | + * |
| 56 | + * @return azimuth |
| 57 | + */ |
| 58 | + public int getAzimuth() { |
| 59 | + return this.azimuth; |
| 60 | + } |
| 61 | + |
| 62 | + /** |
| 63 | + * Azimuth, degrees from true north. |
| 64 | + * |
| 65 | + * @param azimuth |
| 66 | + * the azimuth to set |
| 67 | + */ |
| 68 | + public void setAzimuth(final int azimuth) { |
| 69 | + this.azimuth = azimuth; |
| 70 | + } |
| 71 | + |
| 72 | + /** |
| 73 | + * Elevation in degrees. |
| 74 | + * |
| 75 | + * @return elevation |
| 76 | + */ |
| 77 | + public int getElevation() { |
| 78 | + return this.elevation; |
| 79 | + } |
| 80 | + |
| 81 | + /** |
| 82 | + * Elevation in degrees. |
| 83 | + * |
| 84 | + * @param elevation |
| 85 | + * the elevation to set |
| 86 | + */ |
| 87 | + public void setElevation(final int elevation) { |
| 88 | + this.elevation = elevation; |
| 89 | + } |
| 90 | + |
| 91 | + /** |
| 92 | + * Signal strength in dB. |
| 93 | + * |
| 94 | + * @return signal strength |
| 95 | + */ |
| 96 | + public int getSignalStrength() { |
| 97 | + return this.signalStrength; |
| 98 | + } |
| 99 | + |
| 100 | + /** |
| 101 | + * Signal strength in dB. |
| 102 | + * |
| 103 | + * @param signalStrength |
| 104 | + * the signal strength to set |
| 105 | + */ |
| 106 | + public void setSignalStrength(final int signalStrength) { |
| 107 | + this.signalStrength = signalStrength; |
| 108 | + } |
| 109 | + |
| 110 | + /** |
| 111 | + * Used in current solution? (SBAS/WAAS/EGNOS satellites may be flagged used if the solution has corrections from them, but not all drivers make this information available.) |
| 112 | + * |
| 113 | + * @return used |
| 114 | + */ |
| 115 | + public boolean getUsed() { |
| 116 | + return this.used; |
| 117 | + } |
| 118 | + |
| 119 | + /** |
| 120 | + * Used in current solution? (SBAS/WAAS/EGNOS satellites may be flagged used if the solution has corrections from them, but not all drivers make this information available.) |
| 121 | + * |
| 122 | + * @param used |
| 123 | + * the used flag to set |
| 124 | + */ |
| 125 | + public void setUsed(final boolean used) { |
| 126 | + this.used = used; |
| 127 | + } |
| 128 | + |
| 129 | + @Override |
| 130 | + public int hashCode() { |
| 131 | + final int prime = 31; |
| 132 | + int result = 1; |
| 133 | + long temp; |
| 134 | + temp = Double.doubleToLongBits(this.PRN); |
| 135 | + result = (prime * result) + (int) (temp ^ (temp >>> 32)); |
| 136 | + temp = Double.doubleToLongBits(this.azimuth); |
| 137 | + result = (prime * result) + (int) (temp ^ (temp >>> 32)); |
| 138 | + temp = Double.doubleToLongBits(this.elevation); |
| 139 | + result = (prime * result) + (int) (temp ^ (temp >>> 32)); |
| 140 | + temp = Double.doubleToLongBits(this.signalStrength); |
| 141 | + result = (prime * result) + (int) (temp ^ (temp >>> 32)); |
| 142 | + result = (prime * result) + ((this.used) ? 1 : 0); |
| 143 | + return result; |
| 144 | + } |
| 145 | + |
| 146 | + @Override |
| 147 | + public boolean equals(final Object obj) { |
| 148 | + if (this == obj) { |
| 149 | + return true; |
| 150 | + } |
| 151 | + if (obj == null) { |
| 152 | + return false; |
| 153 | + } |
| 154 | + if (this.getClass() != obj.getClass()) { |
| 155 | + return false; |
| 156 | + } |
| 157 | + final SATObject other = (SATObject) obj; |
| 158 | + if (Double.doubleToLongBits(this.PRN) != Double.doubleToLongBits(other.PRN)) { |
| 159 | + return false; |
| 160 | + } |
| 161 | + if (Double.doubleToLongBits(this.azimuth) != Double.doubleToLongBits(other.azimuth)) { |
| 162 | + return false; |
| 163 | + } |
| 164 | + if (Double.doubleToLongBits(this.elevation) != Double.doubleToLongBits(other.elevation)) { |
| 165 | + return false; |
| 166 | + } |
| 167 | + if (Double.doubleToLongBits(this.signalStrength) != Double.doubleToLongBits(other.signalStrength)) { |
| 168 | + return false; |
| 169 | + } |
| 170 | + if (this.used != other.used) { |
| 171 | + return false; |
| 172 | + } |
| 173 | + return true; |
| 174 | + } |
| 175 | + |
| 176 | + @Override |
| 177 | + public String toString() { |
| 178 | + final StringBuilder sb = new StringBuilder(); |
| 179 | + sb.append("SATObject{PRN="); |
| 180 | + sb.append(this.PRN); |
| 181 | + sb.append(", az="); |
| 182 | + sb.append(this.azimuth); |
| 183 | + sb.append(", el="); |
| 184 | + sb.append(this.elevation); |
| 185 | + sb.append(", ss="); |
| 186 | + sb.append(this.signalStrength); |
| 187 | + sb.append(", used="); |
| 188 | + sb.append(this.used ? "Y" : "N"); |
| 189 | + sb.append("}"); |
| 190 | + return sb.toString(); |
| 191 | + } |
| 192 | +} |
0 commit comments