protected List<Mask> createMasksFromFlagCodding(Product product, FlagCoding flagCoding) { String flagCodingName = flagCoding.getName(); ArrayList<Mask> masks = new ArrayList<>(); final int width = product.getSceneRasterWidth(); final int height = product.getSceneRasterHeight(); for (String flagName : flagCoding.getFlagNames()) { MetadataAttribute flag = flagCoding.getFlag(flagName); masks.add(Mask.BandMathsType.create(flagName, flag.getDescription(), width, height, flagCodingName + "." + flagName, ColorIterator.next(), 0.5)); } return masks; }
FlagCoding contextFC = new FlagCoding(flagCodingName); for (String flagName : flagNames) { contextFC.addFlag(flagName, srcFC.getFlagMask(flagName), srcFC.getFlag(flagName).getDescription());
/** * Creates and adds masks to the product, by using the given flag coding. Each added mask uses the width and the height of the product. * * @param product the product on which the masks are added * @param flagCoding for each flag of this flagCoding parameter, a new mask is added, with the same name as the flag * @return the list of all the masks added to the product */ List<Mask> createMasksFromFlagCodding(Product product, FlagCoding flagCoding) { String flagCodingName = flagCoding.getName(); ArrayList<Mask> masks = new ArrayList<Mask>(); final int width = product.getSceneRasterWidth(); final int height = product.getSceneRasterHeight(); for (String flagName : flagCoding.getFlagNames()) { MetadataAttribute flag = flagCoding.getFlag(flagName); masks.add(Mask.BandMathsType.create(flagName, flag.getDescription(), width, height, flagCodingName + "." + flagName, ColorIterator.next(), 0.5)); } return masks; }