Skip to content

Commit

Permalink
(quince-science#3078) Improve dataset bounds logic
Browse files Browse the repository at this point in the history
  • Loading branch information
squaregoldfish committed Feb 13, 2025
1 parent 843ccf7 commit 76f7a29
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions WebApp/src/uk/ac/exeter/QuinCe/jobs/files/ExtractDataSetJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,25 @@ protected NextJobInfo execute(JobThread thread) throws JobFailedException {
.getCalibrationSet(conn, dataSet);

// Adjust the DataSet bounds to the latest start date and earliest end
// date of each file definition
// date of each file definition, if the dataset range is beyond them
Map<FileDefinition, TimeRangeBuilder> fileDefinitionRanges = new HashMap<FileDefinition, TimeRangeBuilder>();
instrument.getFileDefinitions()
.forEach(fd -> fileDefinitionRanges.put(fd, new TimeRangeBuilder()));

files
.forEach(f -> fileDefinitionRanges.get(f.getFileDefinition()).add(f));

dataSet.setStart(TimeRange.getLatestStart(fileDefinitionRanges.values()));
dataSet.setEnd(TimeRange.getEarliestEnd(fileDefinitionRanges.values()));
LocalDateTime filesLatestStart = TimeRange
.getLatestStart(fileDefinitionRanges.values());
if (filesLatestStart.isAfter(dataSet.getStart())) {
dataSet.setStart(filesLatestStart);
}

LocalDateTime filesEarliestEnd = TimeRange
.getEarliestEnd(fileDefinitionRanges.values());
if (filesEarliestEnd.isBefore(dataSet.getEnd())) {
dataSet.setEnd(filesEarliestEnd);
}

// Collect the data bounds
double minLon = Double.MAX_VALUE;
Expand Down

0 comments on commit 76f7a29

Please sign in to comment.