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(); } }
/** * Used to create a TimeSeries from within a ProductReader * * @param tsProduct the product read * @param pm a progress monitor */ TimeSeriesImpl(Product tsProduct, ProgressMonitor pm) { init(tsProduct); initProductLocations(); storeProductsInMap(pm); setSourceImages(); fixBandTimeCodings(); updateAutoGrouping(); initImageInfos(); }
@Override public void removeProductLocation(ProductLocation productLocation) { // remove metadata final MetadataElement timeSeriesRootElement = tsProduct.getMetadataRoot().getElement(TIME_SERIES_ROOT_NAME); MetadataElement productLocationsElement = timeSeriesRootElement.getElement(PRODUCT_LOCATIONS); removeAttributeWithValue(PL_PATH, productLocation.getPath(), productLocationsElement); // remove variables for this productLocation updateAutoGrouping(); // TODO ??? final Band[] bands = tsProduct.getBands(); final MetadataElement sourceProductPaths = timeSeriesRootElement.getElement(SOURCE_PRODUCT_PATHS); for (Map.Entry<String, Product> productEntry : productLocation.getProducts(ProgressMonitor.NULL).entrySet()) { final Product product = productEntry.getValue(); removeAttributeWithValue(PL_PATH, productEntry.getKey(), sourceProductPaths); String timeString = formatTimeString(product); productTimeMap.remove(timeString); for (Band band : bands) { if (band.getName().endsWith(timeString)) { tsProduct.removeBand(band); } } } productLocation.closeProducts(); productLocationList.remove(productLocation); fireChangeEvent(new TimeSeriesChangeEvent(TimeSeriesChangeEvent.PROPERTY_PRODUCT_LOCATIONS, productLocationList, this)); }