/** * Used to create a new TimeSeries from the user interface. * * @param tsProduct the newly created time series product * @param productLocations the product location to be used * @param variableNames the currently selected names of variables */ TimeSeriesImpl(Product tsProduct, List<ProductLocation> productLocations, List<String> variableNames) { init(tsProduct); for (ProductLocation location : productLocations) { addProductLocation(location); } storeProductsInMap(ProgressMonitor.NULL); for (String variable : variableNames) { setEoVariableSelected(variable, true); } setProductTimeCoding(tsProduct); initImageInfos(); }
private void addToVariableList(Product product) { final List<String> newVariables = new ArrayList<String>(); final List<String> variables = getEoVariables(); final Band[] bands = product.getBands(); for (Band band : bands) { final String bandName = band.getName(); boolean varExist = false; for (String variable : variables) { varExist |= variable.equals(bandName); } if (!varExist) { newVariables.add(bandName); } } for (String variable : newVariables) { addVariableToMetadata(variable); } if (!newVariables.isEmpty()) { updateAutoGrouping(); } }
private void initImageInfos() { for (String variable : getEoVariables()) { if (isEoVariableSelected(variable)) { final List<Band> bandList = getBandsForVariable(variable); adjustImageInfos(bandList.get(0)); } } }
private void addSpecifiedBandOfGivenProduct(String nodeName, Product product) { if (isProductCompatible(product, nodeName)) { final RasterDataNode raster = product.getRasterDataNode(nodeName); TimeCoding rasterTimeCoding = GridTimeCoding.create(product); final ProductData.UTC rasterStartTime = rasterTimeCoding.getStartTime(); final ProductData.UTC rasterEndTime = rasterTimeCoding.getEndTime(); Guardian.assertNotNull("rasterStartTime", rasterStartTime); final String bandName = variableToRasterName(nodeName, rasterTimeCoding); if (!tsProduct.containsBand(bandName)) { // band not already contained if (isAutoAdjustingTimeCoding() || !isTimeCodingSet()) { // automatically setting time coding // OR // first band to add to time series; time bounds of this band will be used // as ts-product's time bounds, no matter if auto adjust is true or false autoAdjustTimeInformation(rasterStartTime, rasterEndTime); } if (getTimeCoding().contains(rasterTimeCoding)) { // add only bands which are in the time bounds final Band addedBand = addBand(raster, rasterTimeCoding, bandName); final List<Band> bandsForVariable = getBandsForVariable(nodeName); if (!bandsForVariable.isEmpty()) { final ImageInfo imageInfo = bandsForVariable.get(0).getImageInfo(ProgressMonitor.NULL); addedBand.setImageInfo(imageInfo.createDeepCopy()); } } // todo no bands added message } } }
final String path = productLocation.getPath(); logger.log(Level.INFO, "Try to load product location type: '" + type + "' at path: '" + path + "'"); addProductLocationMetadata(productLocation); productLocationList.add(productLocation); List<String> variables = getEoVariables(); addProductMetadata(productEntry); addToVariableList(product); for (String variable : variables) { if (isEoVariableSelected(variable)) { addSpecifiedBandOfGivenProduct(variable, product); fireChangeEvent(new TimeSeriesChangeEvent(TimeSeriesChangeEvent.PROPERTY_PRODUCT_LOCATIONS, productLocationList, this));
@Override public void setTimeCoding(TimeCoding timeCoding) { final ProductData.UTC startTime = timeCoding.getStartTime(); if (tsProduct.getStartTime().getAsCalendar().compareTo(startTime.getAsCalendar()) != 0) { tsProduct.setStartTime(startTime); fireChangeEvent(new TimeSeriesChangeEvent(TimeSeriesChangeEvent.START_TIME_PROPERTY_NAME, startTime, this)); } final ProductData.UTC endTime = timeCoding.getEndTime(); if (tsProduct.getEndTime().getAsCalendar().compareTo(endTime.getAsCalendar()) != 0) { tsProduct.setEndTime(endTime); fireChangeEvent(new TimeSeriesChangeEvent(TimeSeriesChangeEvent.END_TIME_PROPERTY_NAME, endTime, this)); } List<String> variables = getEoVariables(); for (Product product : getAllProducts(ProgressMonitor.NULL)) { for (String variable : variables) { if (isEoVariableSelected(variable)) { addSpecifiedBandOfGivenProduct(variable, product); } } } for (Band band : tsProduct.getBands()) { final TimeCoding bandTimeCoding = getRasterTimeMap().get(band); if (!timeCoding.contains(bandTimeCoding)) { fireChangeEvent(new TimeSeriesChangeEvent(TimeSeriesChangeEvent.BAND_TO_BE_REMOVED, band, this)); tsProduct.removeBand(band); } } }
@Override public void setEoVariableSelected(String variableName, boolean selected) { // set in metadata final MetadataElement[] variables = getVariableMetadataElements(); for (MetadataElement elem : variables) { if (elem.getAttributeString(VARIABLE_NAME).equals(variableName)) { elem.setAttributeString(VARIABLE_SELECTION, String.valueOf(selected)); } } // set in product if (selected) { for (Product product : getAllProducts(ProgressMonitor.NULL)) { addSpecifiedBandOfGivenProduct(variableName, product); } } else { final Band[] bands = tsProduct.getBands(); for (Band band : bands) { if (variableName.equals(rasterToVariableName(band.getName()))) { tsProduct.removeBand(band); } } } fireChangeEvent(new TimeSeriesChangeEvent(TimeSeriesChangeEvent.PROPERTY_EO_VARIABLE_SELECTION, null, this)); }
/** * Creates a new TimeSeries from a given time series product. The given product has to be a time series product. * This method should only be called by the reader * * @param product a time series product * * @return a time series wrapping the given product */ public static AbstractTimeSeries create(Product product, ProgressMonitor pm) { final TimeSeriesImpl timeSeries = new TimeSeriesImpl(product, pm); TimeSeriesMapper.getInstance().put(product, timeSeries); return timeSeries; }
timeSeriesProduct.setPreferredTileSize(referenceProduct.getPreferredTileSize()); final AbstractTimeSeries timeSeries = new TimeSeriesImpl(timeSeriesProduct, productLocations, variableNames); TimeSeriesMapper.getInstance().put(timeSeriesProduct, timeSeries); return timeSeries;