/** * */ package DataStructure; import java.io.Serializable; import java.util.Date; /** * @author richy * */ @SuppressWarnings("serial") public class GPScoordinate implements Comparable, Serializable { public Date time; public double coord1; public char coord1NS; public double coord2; public char coord2EW; public boolean isGood; public String coord1S; public String coord2S; // Constructor public GPScoordinate(Date time, double coord1, char coord1NS, double coord2, char coord2EW, boolean isGood) { this.time = time; this.coord1 = coord1; this.coord1NS = coord1NS; this.coord2 = coord2; this.coord2EW = coord2EW; this.isGood = isGood; } public boolean equals(GPScoordinate gps2) { return (coord1 == gps2.coord1 && coord2 == gps2.coord2); } public String toString() { String time = "noDate"; if (this.time != null) time = this.time.toString(); return (Double.toString(coord1) + coord1NS + ";" + Double.toString(coord2) + coord2EW + ";" + isGood + ";" + time); } public Double getCoord1AsDezim() { // int whole = (int) coord1; // double floor = (coord1 - whole) * 60; // return (whole + floor); return coord1; } public Double getCoord2AsDezim() { // int whole = (int) coord2; // double floor = (coord2 - whole) * 60; // return (whole + floor); return coord2; } public int compareTo(Date timestamp) { if (this.time == null || timestamp == null) { throw new NullPointerException("objects is null!"); } if (this.time.getTime() > timestamp.getTime()) { return 1; } else if (this.time.getTime() < timestamp.getTime()) { return -1; } else return 0; } public boolean isValid() { if (time == null || time.getTime() < 10l) { return false; } if (!isGood) { return false; } if (coord1 == 0 || coord2 == 0) { return false; } return true; } }