Skip to content

Commit

Permalink
Fix nullPointerException when checking for noDataValue
Browse files Browse the repository at this point in the history
  • Loading branch information
iGN5117 committed Nov 9, 2023
1 parent 31e0fb2 commit 81b09fe
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@
import java.awt.image.Raster;
import java.awt.image.RenderedImage;
import java.awt.image.WritableRaster;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.*;

/**
* Utility functions for working with GridCoverage2D objects.
Expand Down Expand Up @@ -91,7 +88,7 @@ public static GridCoverage2D create(WritableRaster raster, GridGeometry2D gridGe
*/
public static GridCoverage2D create(WritableRaster raster, GridCoverage2D referenceRaster, Double noDataValue) {
GridSampleDimension[] bands = referenceRaster.getSampleDimensions();
if (Double.isNaN(noDataValue)) {
if (Objects.isNull(noDataValue)) {
noDataValue = RasterBandAccessors.getBandNoDataValue(referenceRaster, 1); //resort to using noDataValue of the original raster.
}
Map propertyMap = referenceRaster.getProperties();
Expand Down Expand Up @@ -136,7 +133,7 @@ public static GridCoverage2D create(WritableRaster raster, GridCoverage2D refere
*/
public static GridCoverage2D create(RenderedImage image, GridCoverage2D referenceRaster, Double noDataValue) {
int numBand = image.getSampleModel().getNumBands();
if (Double.isNaN(noDataValue)) {
if (Objects.isNull(noDataValue)) {
noDataValue = RasterBandAccessors.getBandNoDataValue(referenceRaster, 1); //resort to using noDataValue of the original raster.
}
GridSampleDimension[] bands = referenceRaster.getSampleDimensions();
Expand Down

0 comments on commit 81b09fe

Please sign in to comment.