-This was necessary because one boat (the last one to be processed) would lag and jump, as sometimes there was not enough time for all location messages to be sent before the next lot were added. - The solution was to add a boatOffset, which means while the boats are still processed with3 coming after 2 coming after 1 etc, the loop starts with boat 0, then the next run through it wiull start with boat 1 and so on. -This eliminated the lag (or at least spread it evenly across all the boats) #story[778]main
parent
42ad1f78fc
commit
049f0f7331
@ -1,52 +0,0 @@
|
||||
package seng302.Model;
|
||||
|
||||
import com.github.bfsmith.geotimezone.TimeZoneLookup;
|
||||
import com.github.bfsmith.geotimezone.TimeZoneResult;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* Created by Gondr on 19/04/2017.
|
||||
*/
|
||||
public class RaceClock {
|
||||
private StringProperty time;
|
||||
private DateTimeFormatter dateTimeFormatter;
|
||||
private String timeZone;
|
||||
private ZoneId zoneId;
|
||||
|
||||
public RaceClock(GPSCoordinate gpsCoordinate) {
|
||||
TimeZoneLookup timeZoneLookup = new TimeZoneLookup();
|
||||
TimeZoneResult timeZoneResult = timeZoneLookup.getTimeZone(gpsCoordinate.getLatitude(), gpsCoordinate.getLongitude());
|
||||
zoneId = ZoneId.of(timeZoneResult.getResult());
|
||||
LocalDateTime localDateTime = LocalDateTime.now(zoneId);
|
||||
ZonedDateTime zonedDateTime = localDateTime.atZone(zoneId);
|
||||
dateTimeFormatter = DateTimeFormatter.ofPattern("dd-MM HH:mm:ss z");
|
||||
time = new SimpleStringProperty(dateTimeFormatter.format(zonedDateTime));
|
||||
DateTimeFormatter timeZoneFormatter = DateTimeFormatter.ofPattern("z");
|
||||
timeZone = timeZoneFormatter.format(zonedDateTime);
|
||||
}
|
||||
|
||||
public void updateTime() {
|
||||
LocalDateTime localDateTime = LocalDateTime.now(zoneId);
|
||||
ZonedDateTime zonedDateTime = localDateTime.atZone(zoneId);
|
||||
time.setValue(dateTimeFormatter.format(zonedDateTime));
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return time.get();
|
||||
}
|
||||
|
||||
public StringProperty timeProperty() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public String getTimeZone() {
|
||||
return timeZone;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue