* @throws ActionException
* @throws NumberFormatException
*/
protected void checkRasterSize(File dataFile, UNREDDLayer layer) throws ActionException, NumberFormatException {
//= check that raster size is the expected one
GeoTiffReader reader;
try {
reader = new GeoTiffReader(dataFile);
} catch (Exception e) {
throw new ActionException(this, "Error reading tiff file " + dataFile, e);
}
GridEnvelope ge = reader.getOriginalGridRange();
// GridCoverage2D gc2d = reader.read(null);
// GridGeometry2D gg2d = gc2d.getGridGeometry();
// GridEnvelope ge = gg2d.getGridRange();
try {
int expectedW = Float.valueOf(layer.getAttribute(Attributes.RASTERPIXELWIDTH)).intValue();
int expectedH = Float.valueOf(layer.getAttribute(Attributes.RASTERPIXELHEIGHT)).intValue();
int foundW = ge.getSpan(0);
int foundH = ge.getSpan(1);
if ( expectedW != foundW || expectedH != foundH ) {
throw new ActionException(this, "Bad raster size " + foundW + "x" + foundH + ", expected " + expectedW + "x" + expectedH);
}
//= check that extent is the expected one
// checkCoord(layer, Attributes.RASTERX0)
double expectedX0 = Double.valueOf(layer.getAttribute(Attributes.RASTERX0));
double expectedX1 = Double.valueOf(layer.getAttribute(Attributes.RASTERX1));
double expectedY0 = Double.valueOf(layer.getAttribute(Attributes.RASTERY0));
double expectedY1 = Double.valueOf(layer.getAttribute(Attributes.RASTERY1));
Envelope env = reader.getOriginalEnvelope();
// Envelope env = gc2d.getEnvelope();
double foundX0 = env.getMinimum(0);
double foundX1 = env.getMaximum(0);
double foundY0 = env.getMinimum(1);
double foundY1 = env.getMaximum(1);