private static void extendAttribute(MetadataAttribute attribute, String unit, String description) { if (unit != null) { attribute.setUnit(unit); } if (description != null) { attribute.setDescription(description); } } }
public static void addCenterToIndexCoding(IndexCoding indexCoding, Band[] sourceBands, double[][] means) { NumberFormat numberFormat = NumberFormat.getInstance(); numberFormat.setMaximumFractionDigits(3); final int numAttributes = indexCoding.getNumAttributes(); for (int i = 0; i < numAttributes; i++) { MetadataAttribute attribute = indexCoding.getAttributeAt(i); String description = "Cluster " + i + ", Center("; for (int j = 0; j < sourceBands.length; j++) { String number = numberFormat.format(means[i][j]); description += sourceBands[j].getName() + "=" + number; if (j != sourceBands.length - 1) { description += ", "; } } description += ")"; attribute.setDescription(description); } }
/** * Adds an attribute from src to dest * * @param tag the name of the attribute * @param value the string value * @param dest the destination element * @param desc the description */ private static void addAbstractedAttribute(String tag, String value, MetadataElement dest, String desc) { if (value == null || value.isEmpty()) value = " "; final MetadataAttribute attribute = new MetadataAttribute(tag, ProductData.TYPE_ASCII, 1); attribute.getData().setElems(value); attribute.setDescription(desc); dest.addAttribute(attribute); }
/** * @param attributeName the name of the attribute * @param attributeDescription the descrption of the atttribute * * @return the <code>int</code> value of the attribute * * @throws IOException */ private int parseAndAddAttributeToSPH(String attributeName, String attributeDescription) throws IOException { int nData = parseInt(RECORD_CONTENTS_SIZE); ProductData data = ProductData.createInstance(new int[]{nData}); MetadataAttribute attribute = new MetadataAttribute(attributeName, data, true); attribute.setDescription(attributeDescription); _sph.addAttribute(attribute); return nData; }
/** * Adds an attribute from src to dest * * @param src the source element * @param tag the name of the attribute * @param dest the destination element * @param desc the description */ private static void addAbstractedAttribute(MetadataElement src, String tag, MetadataElement dest, String desc) { final MetadataAttribute attrib = src.getAttribute(tag); if (attrib != null) { MetadataAttribute copiedAttrib = attrib.createDeepClone(); copiedAttrib.setReadOnly(false); copiedAttrib.setDescription(desc); dest.addAttribute(copiedAttrib); } }
/** * Parses an integer attribute from the stream */ private MetadataAttribute parseIntAttribute(int size, String name, String description, String unit) throws IOException { int nData = 0; MetadataAttribute attribute = null; ProductData data = null; nData = parseInt(size); data = ProductData.createInstance(new int[]{nData}); attribute = new MetadataAttribute(name, data, true); if (description != null) { attribute.setDescription(description); } if (unit != null) { attribute.setUnit(unit); } return attribute; }
/** * Parses an integer array attribute from the stream */ private MetadataAttribute parseIntArrayAttribute(int size, int numElems, String name, String description, String unit) throws IOException { int[] nData = null; MetadataAttribute attribute = null; ProductData data = null; nData = parseIntArray(size, numElems); data = ProductData.createInstance(nData); attribute = new MetadataAttribute(name, data, true); if (description != null) { attribute.setDescription(description); } if (unit != null) { attribute.setUnit(unit); } return attribute; }
/** * Adds a new coding value to this sample coding. * * @param name the coding name * @param value the value * @param description the description text * @throws IllegalArgumentException if <code>name</code> is null * @return A new attribute representing the coded sample. */ public MetadataAttribute addSample(String name, int value, String description) { Guardian.assertNotNull("name", name); MetadataAttribute attribute = new MetadataAttribute(name, ProductData.TYPE_INT32); attribute.setDataElems(new int[]{value}); if (description != null) { attribute.setDescription(description); } addAttribute(attribute); return attribute; }
/** * Parses a float attribute from the stream */ private MetadataAttribute parseFloatAttribute(int size, String name, String description, String unit) throws IOException { float fData = 0.f; MetadataAttribute attribute = null; ProductData data = null; fData = parseFloat(size); data = ProductData.createInstance(new float[]{fData}); attribute = new MetadataAttribute(name, data, true); if (description != null) { attribute.setDescription(description); } if (unit != null) { attribute.setUnit(unit); } return attribute; }
/** * Parses a string attribute from the stream */ private MetadataAttribute parseStringAttribute(int size, String name, String description, String unit) throws IOException { String string = null; MetadataAttribute attribute = null; ProductData data = null; string = parseString(size); data = ProductData.createInstance(string); attribute = new MetadataAttribute(name, data, true); if (description != null) { attribute.setDescription(description); } if (unit != null) { attribute.setUnit(unit); } return attribute; }
private static FlagCoding createNdviFlagCoding() { FlagCoding ndviFlagCoding = new FlagCoding("ndvi_flags"); ndviFlagCoding.setDescription("NDVI Flag Coding"); MetadataAttribute attribute; attribute = new MetadataAttribute(NDVI_ARITHMETIC_FLAG_NAME, ProductData.TYPE_INT32); attribute.getData().setElemInt(NDVI_ARITHMETIC_FLAG_VALUE); attribute.setDescription("NDVI value calculation failed due to an arithmetic exception"); ndviFlagCoding.addAttribute(attribute); attribute = new MetadataAttribute(NDVI_LOW_FLAG_NAME, ProductData.TYPE_INT32); attribute.getData().setElemInt(NDVI_LOW_FLAG_VALUE); attribute.setDescription("NDVI value is too low"); ndviFlagCoding.addAttribute(attribute); attribute = new MetadataAttribute(NDVI_HIGH_FLAG_NAME, ProductData.TYPE_INT32); attribute.getData().setElemInt(NDVI_HIGH_FLAG_VALUE); attribute.setDescription("NDVI value is too high"); ndviFlagCoding.addAttribute(attribute); return ndviFlagCoding; }
/** * Adds an attribute from src to dest * * @param tag the name of the attribute * @param value the UTC value * @param unit the unit string * @param dest the destination element * @param desc the description */ private static void addAbstractedAttribute(String tag, int value, String unit, MetadataElement dest, String desc) { final MetadataAttribute attribute = new MetadataAttribute(tag, ProductData.TYPE_INT32, 1); attribute.getData().setElemInt(value); attribute.setUnit(unit); attribute.setDescription(desc); dest.addAttribute(attribute); }
/** * Adds an attribute from src to dest * * @param tag the name of the attribute * @param value the double value * @param unit the unit string * @param dest the destination element * @param desc the description */ private static void addAbstractedAttribute(String tag, double value, String unit, MetadataElement dest, String desc) { final MetadataAttribute attribute = new MetadataAttribute(tag, ProductData.TYPE_FLOAT64, 1); attribute.getData().setElems(new double[]{value}); attribute.setUnit(unit); attribute.setDescription(desc); dest.addAttribute(attribute); }
/** * Adds an attribute from src to dest * * @param tag the name of the attribute * @param value the UTC value * @param dest the destination element * @param desc the description */ private static void addAbstractedAttribute(String tag, ProductData.UTC value, MetadataElement dest, String desc) { final MetadataAttribute attribute = new MetadataAttribute(tag, ProductData.TYPE_UTC, 1); attribute.getData().setElems(value.getArray()); attribute.setUnit("utc"); attribute.setDescription(desc); dest.addAttribute(attribute); }
private static IndexCoding readIndexCoding(Variable variable, String indexCodingName) throws ProductIOException { final IndexCoding indexCoding = CfIndexCodingPart.readIndexCoding(variable, indexCodingName); if (indexCoding != null) { final Attribute descriptionsAtt = variable.findAttributeIgnoreCase(INDEX_DESCRIPTIONS); if (descriptionsAtt != null) { final String[] descriptions = descriptionsAtt.getStringValue().split(DESCRIPTION_SEPARATOR); if (indexCoding.getNumAttributes() == descriptions.length) { for (int i = 0; i < descriptions.length; i++) { indexCoding.getAttributeAt(i).setDescription(descriptions[i]); } } } final Attribute nameAtt = variable.findAttributeIgnoreCase(INDEX_CODING_NAME); if (nameAtt != null) { indexCoding.setName(nameAtt.getStringValue()); } } return indexCoding; } }
public MetadataAttribute createDeepClone() { MetadataAttribute clone = new MetadataAttribute(getName(), getData().createDeepClone(), isReadOnly()); clone.setDescription(getDescription()); clone.setSynthetic(isSynthetic()); clone.setUnit(getUnit()); return clone; } }
private void addUTMProjectionMetadata(final MetadataElement projMeta) throws IOException, IllegalCeosFormatException { final PrismLeaderFile lf = leaderFile; addAttribute(projMeta, "HEMISPHERE", ProductData.createInstance(lf.isUTMSouthHemisphere() ? "South" : "North")); addAttribute(projMeta, "UTM_ZONE_NUMBER", ProductData.createInstance(new long[]{lf.getUTMZoneIndex()})); addAttribute(projMeta, "UTM_NORTHING", ProductData.createInstance(new double[]{lf.getUTMNorthing()}), UNIT_KILOMETER); addAttribute(projMeta, "UTM_EASTING", ProductData.createInstance(new double[]{lf.getUTMEasting()}), UNIT_KILOMETER); final MetadataAttribute orientation = addAttribute(projMeta, "ORIENTATION", ProductData.createInstance(new double[]{ lf.getUTMOrientationAngle() }), UNIT_DEGREE); orientation.setDescription("Angle between the map projection vertical axis and the true north at scene center"); }
private void addUTMProjectionMetadata(final MetadataElement projMeta) throws IOException, IllegalCeosFormatException { addAttribute(projMeta, "HEMISPHERE", ProductData.createInstance(isUTMSouthHemisphere() ? "South" : "North")); addAttribute(projMeta, "UTM_ZONE_NUMBER", ProductData.createInstance(new long[]{getUTMZoneIndex()})); addAttribute(projMeta, "UTM_NORTHING", ProductData.createInstance(new double[]{getUTMNorthing()}), UNIT_KILOMETER); addAttribute(projMeta, "UTM_EASTING", ProductData.createInstance(new double[]{getUTMEasting()}), UNIT_KILOMETER); final MetadataAttribute orientation = addAttribute(projMeta, "ORIENTATION", ProductData.createInstance(new double[]{ getUTMOrientationAngle() }), UNIT_DEGREE); orientation.setDescription("Angle between the map projection vertical axis and the true north at scene center"); }
private void addPSProjectionMetadata(final MetadataElement projMeta) throws IOException, IllegalCeosFormatException { final GeoPos origin = getPSProjectionOrigin(); addAttribute(projMeta, "MAP_PROJECTION_ORIGIN", ProductData.createInstance(origin.getLatString() + " , " + origin.getLonString())); final GeoPos reference = getPSReferencePoint(); addAttribute(projMeta, "REFERENCE_POINT", ProductData.createInstance(reference.getLatString() + " , " + reference.getLonString())); addAttribute(projMeta, "COORDINATE_CENTER_X", ProductData.createInstance(new double[]{getPSXCoordinate()}), UNIT_KILOMETER); addAttribute(projMeta, "COORDINATE_CENTER_Y)", ProductData.createInstance(new double[]{getPSYCoordinate()}), UNIT_KILOMETER); final MetadataAttribute orientation = addAttribute(projMeta, "ORIENTATION", ProductData.createInstance( new double[]{getPSOrientationAngle()}), UNIT_DEGREE); orientation.setDescription("Angle between the map projection vertical axis and the true north at scene center"); }
private void addPSProjectionMetadata(final MetadataElement projMeta) throws IOException, IllegalCeosFormatException { final PrismLeaderFile lf = leaderFile; final GeoPos origin = lf.getPSProjectionOrigin(); addAttribute(projMeta, "MAP_PROJECTION_ORIGIN", ProductData.createInstance(origin.getLatString() + " , " + origin.getLonString())); final GeoPos reference = lf.getPSReferencePoint(); addAttribute(projMeta, "REFERENCE_POINT", ProductData.createInstance(reference.getLatString() + " , " + reference.getLonString())); addAttribute(projMeta, "COORDINATE_CENTER_X", ProductData.createInstance(new double[]{lf.getPSXCoordinate()}), UNIT_KILOMETER); addAttribute(projMeta, "COORDINATE_CENTER_Y)", ProductData.createInstance(new double[]{lf.getPSYCoordinate()}), UNIT_KILOMETER); final MetadataAttribute orientation = addAttribute(projMeta, "ORIENTATION", ProductData.createInstance( new double[]{lf.getPSOrientationAngle()}), UNIT_DEGREE); orientation.setDescription("Angle between the map projection vertical axis and the true north at scene center"); }