public static void writeIndexCoding(IndexCoding indexCoding, NVariable variable) throws IOException { final String[] indexNames = indexCoding.getIndexNames(); final int[] indexValues = new int[indexNames.length]; final StringBuilder meanings = new StringBuilder(); for (int i = 0; i < indexValues.length; i++) { String name = indexNames[i]; meanings.append(name).append(" "); indexValues[i] = indexCoding.getIndexValue(name); } variable.addAttribute(FLAG_MEANINGS, meanings.toString().trim()); variable.addAttribute(FLAG_VALUES, Array.factory(indexValues)); }
private void writeIndexCoding(IndexCoding indexCoding, NVariable variable) throws IOException { CfIndexCodingPart.writeIndexCoding(indexCoding, variable); final String[] indexNames = indexCoding.getIndexNames(); final StringBuilder descriptions = new StringBuilder(); for (String indexName : indexNames) { final MetadataAttribute index = indexCoding.getIndex(indexName); if (index != null) { final String description = index.getDescription(); if (description != null) { descriptions.append(description); } } descriptions.append(DESCRIPTION_SEPARATOR); } variable.addAttribute(INDEX_DESCRIPTIONS, descriptions.toString().trim()); variable.addAttribute(INDEX_CODING_NAME, indexCoding.getName()); }
final IndexCoding indexCoding = band.getIndexCoding(); if (indexCoding != null) { final String[] indexNames = indexCoding.getIndexNames(); if (rowIndex < indexNames.length) { final int indexValue = indexCoding.getAttributeIndex(indexCoding.getIndex(indexNames[rowIndex]));
IndexCoding indexCoding = product.getIndexCodingGroup().get(0); assertEquals("classification", indexCoding.getName()); assertArrayEquals(new String[]{"classA", "classB"}, indexCoding.getIndexNames());