-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLocation.pde
More file actions
42 lines (36 loc) · 1.32 KB
/
Location.pde
File metadata and controls
42 lines (36 loc) · 1.32 KB
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
class Location {
// data from log
float longitude;
float latitude;
long timestamp;
int accuracy;
// generated data
int day, month, year;
int second, minute, hour, millisecond;
int daystamp;
String date, time;
public Location(float longitude, float latitude, long timestamp, int accuarcy) {
this.longitude = longitude;
this.latitude = latitude;
this.timestamp = timestamp;
this.accuracy = accuracy;
// calculate date
Calendar calender = GregorianCalendar.getInstance();
calender.setTimeInMillis(timestamp - timeOffset);
day = calender.get(Calendar.DAY_OF_MONTH);
month = calender.get(Calendar.MONTH)+1;
year = calender.get(Calendar.YEAR);
date = String.format("%02d", day)+"."+String.format("%02d", month)+"."+year;
// calculate time
millisecond = calender.get(Calendar.MILLISECOND);
second = calender.get(Calendar.SECOND);
minute = calender.get(Calendar.MINUTE);
hour = calender.get(Calendar.HOUR_OF_DAY);
time = hour+":"+String.format("%02d", minute)+":"+String.format("%02d", second)+"'"+String.format("%03d", millisecond);
// calculate daystamp (millisecond timestamp starting at each day)
daystamp = millisecond + 1000*(second + 60*(minute + 60*hour));
}
String toString() {
return longitude + " " + latitude;
}
}