if( layerNames.isEmpty()) {
LOGGER.warn("No layers defined for StatsDef '" + statsDefName+ "'");
}
final FlowUtil flowUtil = new FlowUtil(getTempDir(), getConfigDir());
// Loop on all layers on which this stat depends on
int layers = layerNames.size();
int layerCnt = 0;
for (String layerName : layerNames) {
float majorStep = layerCnt++ / layers;
LOGGER.info("Starting reprocessing StatsDef:" + statsDefName + " layer:" + layerName);
this.listenerForwarder.progressing(rescale(min, max, majorStep), "Reprocessing stats on layer " + layerName);
Resource layerRes = geoStoreUtil.searchLayer(layerName);
if(layerRes == null) {
LOGGER.warn("Could not find Layer '"+layerName+"' for StatsDef '"+statsDefName+"'");
continue;
}
UNREDDLayer layer = new UNREDDLayer(layerRes);
List<Resource> layerUpdates = geoStoreUtil.searchLayerUpdateByLayer(layerName);
LOGGER.info("Found " + layerUpdates.size() + " LayerUpdates for Layer " + layerName);
// Compute stats for every time coordinate this layer has
int layerUps = layerUpdates.size();
int layerUpsCnt = 0;
for (Resource layerUpdateRes : layerUpdates) {
float minorStep = layerUpsCnt++ / layerUps;
String msg = "Starting reprocessing StatsDef:" + statsDefName + " Layer:" + layerName + " LayerUpdate:" + layerUpdateRes.getName();
LOGGER.info(msg);
this.listenerForwarder.progressing(rescale(min, max, majorStep*(1+minorStep)), msg);
UNREDDLayerUpdate layerUpdate = new UNREDDLayerUpdate(layerUpdateRes);
String year = layerUpdate.getAttribute(UNREDDLayerUpdate.Attributes.YEAR);
String month = layerUpdate.getAttribute(UNREDDLayerUpdate.Attributes.MONTH);
String day = layerUpdate.getAttribute(UNREDDLayerUpdate.Attributes.DAY);
String rasterPath = layer.getAttribute(Attributes.MOSAICPATH);
String rasterFile = NameUtils.buildTifFileName(layerName, year, month, day);
String rasterFullPath = new File(rasterPath, rasterFile).getAbsolutePath();
Map<Tokens, String> tokens = FlowUtil.fillTokens(rasterFullPath, layerName, year, month, null);
flowUtil.processStatistics(geoStoreUtil, statsDefRes, year, month, day, tokens);
}
}
LOGGER.info("Reprocessing completed on StatsDef '" + statsDefName+ "'");
this.listenerForwarder.progressing(max, "Reprocessing completed on StatsDef '" + statsDefName+ "'");