summaryrefslogtreecommitdiffstats
path: root/DataStructure/GPScoordinate.java
blob: dee0748963af2b66b58e650c142930ed89cacf49 (plain) (blame)
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
/**
 * 
 */
package DataStructure;

import java.io.Serializable;
import java.util.Date;

/**
 * @author richy
 * 
 */
@SuppressWarnings("serial")
public class GPScoordinate implements Comparable<Date>, 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;
	}

}