|
|
@@ -171,7 +171,7 @@ public class ExportUtil {
|
|
|
ResultSet obsRes = SQLExecutor.getInstance().executeQuery(sqlObsQuery);
|
|
|
Map<Long, Map<LocalDateTime, List<Double>>> unitToObs = parseUnitObservation(obsRes);
|
|
|
|
|
|
- StringBuilder csv = new StringBuilder("unit_id;longitude;latitude");
|
|
|
+ StringBuilder csv = new StringBuilder("unit_id;sensor_id;longitude;latitude");
|
|
|
LocalDateTime tempTime = LocalDateTime.of(fromTime.toLocalDate(), LocalTime.of(fromTime.getHour(), 0));
|
|
|
List<LocalDateTime> timestampColumns = new LinkedList<>();
|
|
|
final DateTimeFormatter timestampPattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
@@ -182,16 +182,12 @@ public class ExportUtil {
|
|
|
}
|
|
|
csv.append("\n");
|
|
|
|
|
|
+ final Location defLocation = new Location(0, 0);
|
|
|
for (Map.Entry<Long, Map<LocalDateTime, List<Double>>> unitToEntry : unitToObs.entrySet()) {
|
|
|
long unitId = unitToEntry.getKey();
|
|
|
Map<LocalDateTime, List<Double>> obsAtTimestamp = unitToEntry.getValue();
|
|
|
- Location unitLocation = unitToPosition.get(unitId);
|
|
|
- if(unitLocation != null) {
|
|
|
- csv.append(unitId).append(";").append(unitLocation.lon).append(";").append(unitLocation.lat);
|
|
|
- }
|
|
|
- else {
|
|
|
- csv.append(unitId).append(";").append("").append(";").append("");
|
|
|
- }
|
|
|
+ Location unitLocation = unitToPosition.getOrDefault(unitId, defLocation);
|
|
|
+ csv.append(unitId).append(";").append(sensorId).append(";").append(unitLocation.lon).append(";").append(unitLocation.lat);
|
|
|
for (LocalDateTime timestampColumn : timestampColumns) {
|
|
|
double val = obsAtTimestamp.getOrDefault(timestampColumn, Collections.emptyList()).stream().mapToDouble(d -> d).average().orElse(Double.NaN);
|
|
|
csv.append(";").append(Double.isNaN(val) ? "" : val);
|