public double getValue() { return getData().getElemDouble(); } }
public double getValue() { return getData().getElemDouble(); } }
/** * Gets the no-data value as a primitive <code>double</code>. * <p>Note that the value returned is NOT necessarily the same as the value returned by * {@link #getGeophysicalNoDataValue()} because no scaling is applied. * <p>The no-data value is used to determine valid pixels. For more information * on valid pixels, please refer to the documentation of the {@link #isPixelValid(int, int, javax.media.jai.ROI)} * method. * <p>The method returns <code>0.0</code>, if no no-data value has been specified so far. * * @return the no-data value. It is returned as a <code>double</code> in order to cover all other numeric types. * @see #setNoDataValue(double) * @see #isNoDataValueSet() */ public double getNoDataValue() { return isNoDataValueSet() ? noData.getElemDouble() : 0.0; }
/** * Returns the double value of the attribute with the given name. <p>An Exception is thrown if an * attribute with the given name could not be found in this node. * * @param name the attribute name * * @return the attribute value as double. * * @throws NumberFormatException if the attribute type is ASCII but cannot be converted to a number * @throws IllegalArgumentException if an attribute with the given name could not be found */ public double getAttributeDouble(String name) { final MetadataAttribute attribute = getAttribute(name); if (attribute == null) { throw new IllegalArgumentException(getAttributeNotFoundMessage(name)); } if (attribute.getDataType() == ProductData.TYPE_ASCII) { return Double.parseDouble(attribute.getData().getElemString()); } return attribute.getData().getElemDouble(); }
/** * Returns the double value of the attribute with the given name. <p>The given default value is returned if an * attribute with the given name could not be found in this node. * * @param name the attribute name * @param defaultValue the default value * * @return the attribute value as double. * * @throws NumberFormatException if the attribute type is ASCII but cannot be converted to a number */ public double getAttributeDouble(String name, double defaultValue) { final MetadataAttribute attribute = getAttribute(name); if (attribute == null) { return defaultValue; } if (attribute.getDataType() == ProductData.TYPE_ASCII) { return Double.parseDouble(attribute.getData().getElemString()); } return attribute.getData().getElemDouble(); }
float projCentralLon = (float) globalAttributes.getAttribute(centralLonName).getData().getElemDouble(); float projCentralLat = (float) globalAttributes.getAttribute(centralLatName).getData().getElemDouble(); float sceneCenterLon = (float) globalAttributes.getAttribute(sceneCenterLonName).getData().getElemDouble(); float sceneCenterLat = (float) globalAttributes.getAttribute(sceneCenterLatName).getData().getElemDouble(); float east = (float) globalAttributes.getAttribute(westName).getData().getElemDouble(); float north = (float) globalAttributes.getAttribute(northName).getData().getElemDouble();
public void addGeocoding(Product product) { //todo: figure out how to handle NON-CYLINDRICAL projections... //float pixelX = 0.0f; //float pixelY = 0.0f; // Changed after conversation w/ Sean, Norman F., et al. float pixelX = 0.5f; float pixelY = 0.5f; float easting = (float) product.getMetadataRoot().getElement("Global_Attributes").getAttribute("Easternmost_Longitude").getData().getElemDouble(); float westing = (float) product.getMetadataRoot().getElement("Global_Attributes").getAttribute("Westernmost_Longitude").getData().getElemDouble(); float pixelSizeX = (easting - westing) / product.getSceneRasterWidth(); float northing = (float) product.getMetadataRoot().getElement("Global_Attributes").getAttribute("Northernmost_Latitude").getData().getElemDouble(); float southing = (float) product.getMetadataRoot().getElement("Global_Attributes").getAttribute("Southernmost_Latitude").getData().getElemDouble(); float pixelSizeY = (northing - southing) / product.getSceneRasterHeight(); try { product.setGeoCoding(new CrsGeoCoding(DefaultGeographicCRS.WGS84, product.getSceneRasterWidth(), product.getSceneRasterHeight(), westing, northing, pixelSizeX, pixelSizeY, pixelX, pixelY)); } catch (FactoryException e) { throw new IllegalStateException(e); } catch (TransformException e) { throw new IllegalStateException(e); } }
easting = (float) globalAttributes.getAttribute(east).getData().getElemDouble(); float westing = (float) globalAttributes.getAttribute(west).getData().getElemDouble(); pixelSizeX = Math.abs(easting - westing) / product.getSceneRasterWidth(); northing = (float) globalAttributes.getAttribute(north).getData().getElemDouble(); float southing = (float) globalAttributes.getAttribute(south).getData().getElemDouble(); if (northing < southing) { mustFlipY = true; northing = (float) globalAttributes.getAttribute(south).getData().getElemDouble(); southing = (float) globalAttributes.getAttribute(north).getData().getElemDouble();
assertEquals(65535L, instance.getElemUInt()); assertEquals(65535.0F, instance.getElemFloat(), 0.0e-12F); assertEquals(65535.0D, instance.getElemDouble(), 0.0e-12D); assertEquals("65535", instance.getElemString()); assertEquals(1, instance.getNumElems());
assertEquals(4294967295L, instance.getElemUInt()); assertEquals(4294967295.0F, instance.getElemFloat(), 0.0e-12F); assertEquals(4294967295.0D, instance.getElemDouble(), 0.0e-12D); assertEquals("4294967295", instance.getElemString()); assertEquals(1, instance.getNumElems());
assertEquals(35L, instance.getElemUInt()); assertEquals(35.0F, instance.getElemFloat(), 0.0e-12F); assertEquals(35.0D, instance.getElemDouble(), 0.0e-12D); assertEquals("#", instance.getElemString()); assertEquals(true, instance.getElemBoolean());
assertEquals(127L, instance.getElemUInt()); assertEquals(127.0F, instance.getElemFloat(), 0.0e-12F); assertEquals(127.0D, instance.getElemDouble(), 0.0e-12D); assertEquals("127", instance.getElemString()); assertEquals(1, instance.getNumElems());
assertEquals(255L, instance.getElemUInt()); assertEquals(255.0F, instance.getElemFloat(), 0.0e-12F); assertEquals(255.0D, instance.getElemDouble(), 0.0e-12D); assertEquals("255", instance.getElemString()); assertEquals(1, instance.getNumElems());
assertEquals(32767L, instance.getElemUInt()); assertEquals(32767.0F, instance.getElemFloat(), 0.0e-12F); assertEquals(32767.0D, instance.getElemDouble(), 0.0e-12D); assertEquals("32767", instance.getElemString()); assertEquals(1, instance.getNumElems());
assertEquals(2147483647L, instance.getElemUInt()); assertEquals(2147483647.0F, instance.getElemFloat(), 0.0e-12F); assertEquals(2147483647.0D, instance.getElemDouble(), 0.0e-12D); assertEquals("2147483647", instance.getElemString()); assertEquals(true, instance.getElemBoolean());