Commit 27154ed5 authored by Louis Neumann's avatar Louis Neumann
Browse files

adjusted ageOfLocation() and added timestamp when created

parent a886bf18
......@@ -25,6 +25,7 @@ import java.util.Arrays;
import com.vividsolutions.jts.geom.Coordinate;
import de.tudarmstadt.maki.simonstrator.api.Time;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
/**
......@@ -53,7 +54,9 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
* assertions. Replace does now fully replace the position vector entries. PVs are now
* always at least 3D (with 0 altitude)
*
* @author Bjoern Richerzhagen, Julian Zobel
* - 14.03.2019 Louis Neumann: added timestamp when creating a PositionVector and adjusted ageOfLocation()
*
* @author Bjoern Richerzhagen, Julian Zobel, Louis Neumann
* @version 1.2, 10.09.2018
*/
public class PositionVector implements Location {
......@@ -67,6 +70,10 @@ public class PositionVector implements Location {
private double[] values;
private double accuracy = -1;
/**
* Timestamp with time when created
*/
private long created;
/**
* Create a new Position Vector
......@@ -84,6 +91,7 @@ public class PositionVector implements Location {
this.dimensions = dimensions;
this.values = new double[dimensions];
this.created = Time.getCurrentTime();
}
/**
......@@ -97,6 +105,7 @@ public class PositionVector implements Location {
for (int i = 0; i < vec.getDimensions(); i++) {
setEntry(i, vec.getEntry(i));
}
this.created = Time.getCurrentTime();
}
public PositionVector(double longitudeOrX, double latitudeOrY) {
......@@ -104,6 +113,7 @@ public class PositionVector implements Location {
this.setLatitudeOrY(latitudeOrY);
this.setLongitudeOrX(longitudeOrX);
this.setAltitude(0);
this.created = Time.getCurrentTime();
}
public PositionVector(double longitudeOrX, double latitudeOrY, double altitude) {
......@@ -111,6 +121,7 @@ public class PositionVector implements Location {
this.setLatitudeOrY(latitudeOrY);
this.setLongitudeOrX(longitudeOrX);
this.setAltitude(altitude);
this.created = Time.getCurrentTime();
}
public PositionVector(Location location) {
......@@ -126,6 +137,7 @@ public class PositionVector implements Location {
this.setLatitudeOrY(location.getLatitudeOrY());
this.setLongitudeOrX(location.getLongitudeOrX());
this.created = Time.getCurrentTime();
}
/**
......@@ -139,6 +151,7 @@ public class PositionVector implements Location {
for (int i = 0; i < values.length; i++) {
setEntry(i, values[i]);
}
this.created = Time.getCurrentTime();
}
@Override
......@@ -539,7 +552,8 @@ public class PositionVector implements Location {
@Override
public long getAgeOfLocation() {
return 0; // always a fresh location
return Time.getCurrentTime() - created;
}
@Override
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment