|
|
|
|
@ -11,6 +11,12 @@ public class TrackPoint {
|
|
|
|
|
private long expiry;
|
|
|
|
|
private double minAlpha;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates a new track point with fixed GPS coordinates and time, to reach minimum opacity on expiry.
|
|
|
|
|
* @param coordinate position of point on physical race map
|
|
|
|
|
* @param timeAdded system clock at time of addition
|
|
|
|
|
* @param expiry time to minimum opacity after added
|
|
|
|
|
*/
|
|
|
|
|
public TrackPoint(GPSCoordinate coordinate, long timeAdded, long expiry) {
|
|
|
|
|
this.coordinate = coordinate;
|
|
|
|
|
this.timeAdded = timeAdded;
|
|
|
|
|
@ -18,14 +24,26 @@ public class TrackPoint {
|
|
|
|
|
this.minAlpha = 0.1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the position of the point on physical race map.
|
|
|
|
|
* @return GPS coordinate of point
|
|
|
|
|
*/
|
|
|
|
|
public GPSCoordinate getCoordinate() {
|
|
|
|
|
return coordinate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets opacity of point scaled by age in proportion to expiry, between 1 and minimum opacity inclusive.
|
|
|
|
|
* @return greater of minimum opacity and scaled opacity
|
|
|
|
|
*/
|
|
|
|
|
public double getAlpha() {
|
|
|
|
|
return Double.max(minAlpha,1.0 - (double)(System.currentTimeMillis() - timeAdded) / expiry);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets time point was added to track.
|
|
|
|
|
* @return system clock at time of addition
|
|
|
|
|
*/
|
|
|
|
|
public long getTimeAdded() {
|
|
|
|
|
return timeAdded;
|
|
|
|
|
}
|
|
|
|
|
|