Skip to content
Snippets Groups Projects
Commit a3e15201 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Refactoring WARNING_STATUS to separate parameter

parent ca884867
No related branches found
No related tags found
No related merge requests found
...@@ -28,12 +28,14 @@ public class LocationResult { ...@@ -28,12 +28,14 @@ public class LocationResult {
private Double latitude; private Double latitude;
private Double altitude; private Double altitude;
private Double[][] data; private Double[][] data;
private Integer[] warningStatus;
public LocationResult(Double longitude, Double latitude, Double altitude, int rows, int columns){ public LocationResult(Double longitude, Double latitude, Double altitude, int rows, int columns){
this.longitude = longitude; this.longitude = longitude;
this.latitude = latitude; this.latitude = latitude;
this.altitude = altitude; this.altitude = altitude;
this.data = new Double[rows][columns]; this.data = new Double[rows][columns];
this.warningStatus = new Integer[rows];
} }
public LocationResult(){ public LocationResult(){
...@@ -150,4 +152,18 @@ public class LocationResult { ...@@ -150,4 +152,18 @@ public class LocationResult {
public void setAltitude(Double altitude) { public void setAltitude(Double altitude) {
this.altitude = altitude; this.altitude = altitude;
} }
/**
* @return the warningStatus
*/
public Integer[] getWarningStatus() {
return warningStatus;
}
/**
* @param warningStatus the warningStatus to set
*/
public void setWarningStatus(Integer[] warningStatus) {
this.warningStatus = warningStatus;
}
} }
...@@ -83,7 +83,7 @@ public class DataTransformer { ...@@ -83,7 +83,7 @@ public class DataTransformer {
// b) check all possible result parameters // b) check all possible result parameters
Collections.sort(VIPSResults); Collections.sort(VIPSResults);
Set<String> resultParameters = new HashSet<>(); Set<String> resultParameters = new HashSet<>();
resultParameters.add("WARNING_STATUS"); //resultParameters.add("WARNING_STATUS");
Long minSecondsBetween = null; Long minSecondsBetween = null;
Long lastTime = null; Long lastTime = null;
for(Result r:VIPSResults) for(Result r:VIPSResults)
...@@ -113,20 +113,18 @@ public class DataTransformer { ...@@ -113,20 +113,18 @@ public class DataTransformer {
retVal.setTimeEnd(VIPSResults.get(VIPSResults.size()-1).getValidTimeStart().toInstant()); retVal.setTimeEnd(VIPSResults.get(VIPSResults.size()-1).getValidTimeStart().toInstant());
LocationResult locationResult = new LocationResult(); LocationResult locationResult = new LocationResult();
Long rows = 1 + (retVal.getTimeEnd().getEpochSecond() - retVal.getTimeStart().getEpochSecond()) / retVal.getInterval(); Long rows = 1 + (retVal.getTimeEnd().getEpochSecond() - retVal.getTimeStart().getEpochSecond()) / retVal.getInterval();
Double[][] data = new Double[rows.intValue()][retVal.getResultParameters().length]; // TODO Set correct dimensions Double[][] data = new Double[rows.intValue()][retVal.getResultParameters().length];
Integer[] warningStatus = new Integer[rows.intValue()];
for(Result r:VIPSResults) for(Result r:VIPSResults)
{ {
// Calculate which row, based on // Calculate which row, based on
Long row = (r.getValidTimeStart().getTime()/1000 - retVal.getTimeStart().getEpochSecond()) / retVal.getInterval(); Long row = (r.getValidTimeStart().getTime()/1000 - retVal.getTimeStart().getEpochSecond()) / retVal.getInterval();
warningStatus[row.intValue()] = r.getWarningStatus();
// Using the ordering in the resultParameters // Using the ordering in the resultParameters
for(int i=0;i<retVal.getResultParameters().length;i++) for(int i=0;i<retVal.getResultParameters().length;i++)
{ {
data[row.intValue()][i] = null; data[row.intValue()][i] = null;
if(VIPSResultParameters[i].equals("WARNING_STATUS")) if(VIPSResultParameters[i] != null)
{
data[row.intValue()][i] = r.getWarningStatus().doubleValue();
}
else if(VIPSResultParameters[i] != null)
{ {
if(r.getAllValues().get(VIPSResultParameters[i]) != null) if(r.getAllValues().get(VIPSResultParameters[i]) != null)
{ {
...@@ -135,6 +133,7 @@ public class DataTransformer { ...@@ -135,6 +133,7 @@ public class DataTransformer {
} }
} }
} }
locationResult.setWarningStatus(warningStatus);
locationResult.setData(data); locationResult.setData(data);
retVal.addLocationResult(locationResult); retVal.addLocationResult(locationResult);
return retVal; return retVal;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment