| 1 | /**
|
|---|
| 2 | *
|
|---|
| 3 | */
|
|---|
| 4 | package livegps;
|
|---|
| 5 |
|
|---|
| 6 | import org.openstreetmap.josm.data.coor.LatLon;
|
|---|
| 7 |
|
|---|
| 8 | /**
|
|---|
| 9 | * @author cdaller
|
|---|
| 10 | *
|
|---|
| 11 | */
|
|---|
| 12 | public class LiveGpsData {
|
|---|
| 13 | private LatLon latLon;
|
|---|
| 14 | private float course;
|
|---|
| 15 | private float speed;
|
|---|
| 16 | private boolean fix;
|
|---|
| 17 | /**
|
|---|
| 18 | * @param latitude
|
|---|
| 19 | * @param longitude
|
|---|
| 20 | * @param course
|
|---|
| 21 | * @param speed
|
|---|
| 22 | * @param haveFix
|
|---|
| 23 | */
|
|---|
| 24 | public LiveGpsData(double latitude, double longitude, float course, float speed, boolean haveFix) {
|
|---|
| 25 | super();
|
|---|
| 26 | this.latLon = new LatLon(latitude, longitude);
|
|---|
| 27 | this.course = course;
|
|---|
| 28 | this.speed = speed;
|
|---|
| 29 | this.fix = haveFix;
|
|---|
| 30 | }
|
|---|
| 31 | /**
|
|---|
| 32 | *
|
|---|
| 33 | */
|
|---|
| 34 | public LiveGpsData() {
|
|---|
| 35 | // TODO Auto-generated constructor stub
|
|---|
| 36 | }
|
|---|
| 37 | /**
|
|---|
| 38 | * @return the course
|
|---|
| 39 | */
|
|---|
| 40 | public float getCourse() {
|
|---|
| 41 | return this.course;
|
|---|
| 42 | }
|
|---|
| 43 | /**
|
|---|
| 44 | * @param course the course to set
|
|---|
| 45 | */
|
|---|
| 46 | public void setCourse(float course) {
|
|---|
| 47 | this.course = course;
|
|---|
| 48 | }
|
|---|
| 49 | /**
|
|---|
| 50 | * @return the haveFix
|
|---|
| 51 | */
|
|---|
| 52 | public boolean isFix() {
|
|---|
| 53 | return this.fix;
|
|---|
| 54 | }
|
|---|
| 55 | /**
|
|---|
| 56 | * @param haveFix the haveFix to set
|
|---|
| 57 | */
|
|---|
| 58 | public void setFix(boolean haveFix) {
|
|---|
| 59 | this.fix = haveFix;
|
|---|
| 60 | }
|
|---|
| 61 | /**
|
|---|
| 62 | * @return the latitude
|
|---|
| 63 | */
|
|---|
| 64 | public double getLatitude() {
|
|---|
| 65 | return this.latLon.lat();
|
|---|
| 66 | }
|
|---|
| 67 | /**
|
|---|
| 68 | * @return the longitude
|
|---|
| 69 | */
|
|---|
| 70 | public double getLongitude() {
|
|---|
| 71 | return this.latLon.lon();
|
|---|
| 72 | }
|
|---|
| 73 | /**
|
|---|
| 74 | * @return the speed in metres per second!
|
|---|
| 75 | */
|
|---|
| 76 | public float getSpeed() {
|
|---|
| 77 | return this.speed;
|
|---|
| 78 | }
|
|---|
| 79 | /**
|
|---|
| 80 | * @param speed the speed to set
|
|---|
| 81 | */
|
|---|
| 82 | public void setSpeed(float speed) {
|
|---|
| 83 | this.speed = speed;
|
|---|
| 84 | }
|
|---|
| 85 |
|
|---|
| 86 | /**
|
|---|
| 87 | * @return the latlon
|
|---|
| 88 | */
|
|---|
| 89 | public LatLon getLatLon() {
|
|---|
| 90 | return this.latLon;
|
|---|
| 91 | }
|
|---|
| 92 |
|
|---|
| 93 | /**
|
|---|
| 94 | * @param latLon
|
|---|
| 95 | */
|
|---|
| 96 | public void setLatLon(LatLon latLon) {
|
|---|
| 97 | this.latLon = latLon;
|
|---|
| 98 | }
|
|---|
| 99 |
|
|---|
| 100 | public String toString() {
|
|---|
| 101 | return getClass().getSimpleName() + "[fix=" + fix + ", lat=" + latLon.lat()
|
|---|
| 102 | + ", long=" + latLon.lon() + ", speed=" + speed + ", course=" + course + "]";
|
|---|
| 103 |
|
|---|
| 104 | }
|
|---|
| 105 | /* (non-Javadoc)
|
|---|
| 106 | * @see java.lang.Object#hashCode()
|
|---|
| 107 | */
|
|---|
| 108 | @Override
|
|---|
| 109 | public int hashCode() {
|
|---|
| 110 | final int prime = 31;
|
|---|
| 111 | int result = 1;
|
|---|
| 112 | result = prime * result + Float.floatToIntBits(this.course);
|
|---|
| 113 | result = prime * result + ((this.latLon == null) ? 0 : this.latLon.hashCode());
|
|---|
| 114 | result = prime * result + Float.floatToIntBits(this.speed);
|
|---|
| 115 | return result;
|
|---|
| 116 | }
|
|---|
| 117 | /* (non-Javadoc)
|
|---|
| 118 | * @see java.lang.Object#equals(java.lang.Object)
|
|---|
| 119 | */
|
|---|
| 120 | @Override
|
|---|
| 121 | public boolean equals(Object obj) {
|
|---|
| 122 | if (this == obj)
|
|---|
| 123 | return true;
|
|---|
| 124 | if (obj == null)
|
|---|
| 125 | return false;
|
|---|
| 126 | if (getClass() != obj.getClass())
|
|---|
| 127 | return false;
|
|---|
| 128 | final LiveGpsData other = (LiveGpsData) obj;
|
|---|
| 129 | if (Float.floatToIntBits(this.course) != Float.floatToIntBits(other.course))
|
|---|
| 130 | return false;
|
|---|
| 131 | if (this.latLon == null) {
|
|---|
| 132 | if (other.latLon != null)
|
|---|
| 133 | return false;
|
|---|
| 134 | } else if (!this.latLon.equals(other.latLon))
|
|---|
| 135 | return false;
|
|---|
| 136 | if (Float.floatToIntBits(this.speed) != Float.floatToIntBits(other.speed))
|
|---|
| 137 | return false;
|
|---|
| 138 | return true;
|
|---|
| 139 | }
|
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 |
|
|---|
| 143 | }
|
|---|