Skip to content

Commit d4e2085

Browse files
committed
fix: spotless
1 parent 08865d0 commit d4e2085

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

common/src/main/java/org/apache/sedona/common/raster/RasterBandAccessors.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,14 @@ public static double[] getZonalStatsAll(
114114
DescriptiveStatistics stats = (DescriptiveStatistics) objects.get(0);
115115
double[] pixelData = (double[]) objects.get(1);
116116

117-
// Shortcut for an edge case where ROI barely intersects with raster's extent, but it doesn't intersect with the
117+
// Shortcut for an edge case where ROI barely intersects with raster's extent, but it doesn't
118+
// intersect with the
118119
// centroid of the pixel.
119120
// This happens when allTouched parameter is false.
120121
if (pixelData.length == 0) {
121-
return new double[] {0, 0, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN};
122+
return new double[] {
123+
0, 0, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN
124+
};
122125
}
123126

124127
// order of stats

common/src/test/java/org/apache/sedona/common/raster/RasterBandAccessorsTest.java

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,36 @@ public void testBandNoDataValueIllegalBand() throws FactoryException, IOExceptio
8686

8787
@Test
8888
public void testZonalStatsIntersectingNoPixelData() throws FactoryException, ParseException {
89-
double[][] pixelsValues = new double[][] {
90-
new double[] {3, 7, 5, 40, 61, 70, 60, 80, 27, 55, 35, 44, 21, 36, 53, 54, 86, 28, 45, 24, 99, 22, 18, 98, 10}
91-
};
92-
GridCoverage2D raster = RasterConstructors.makeNonEmptyRaster(1, "", 5, 5, 1, -1, 1, -1, 0, 0, 0, pixelsValues);
93-
Geometry extent = Constructors.geomFromWKT("POLYGON ((5.822754 -6.620957, 6.965332 -6.620957, 6.965332 -5.834616, 5.822754 -5.834616, 5.822754 -6.620957))", 0);
89+
double[][] pixelsValues =
90+
new double[][] {
91+
new double[] {
92+
3, 7, 5, 40, 61, 70, 60, 80, 27, 55, 35, 44, 21, 36, 53, 54, 86, 28, 45, 24, 99, 22, 18,
93+
98, 10
94+
}
95+
};
96+
GridCoverage2D raster =
97+
RasterConstructors.makeNonEmptyRaster(1, "", 5, 5, 1, -1, 1, -1, 0, 0, 0, pixelsValues);
98+
Geometry extent =
99+
Constructors.geomFromWKT(
100+
"POLYGON ((5.822754 -6.620957, 6.965332 -6.620957, 6.965332 -5.834616, 5.822754 -5.834616, 5.822754 -6.620957))",
101+
0);
94102

95103
double actualZonalStats = RasterBandAccessors.getZonalStats(raster, extent, "mode");
96104
assertTrue(Double.isNaN(actualZonalStats));
97105

98-
99-
double [] actualZonalStatsAll = RasterBandAccessors.getZonalStatsAll(raster, extent);
100-
double[] expectedZonalStatsAll = new double[] {0.0, 0.0, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN};
106+
double[] actualZonalStatsAll = RasterBandAccessors.getZonalStatsAll(raster, extent);
107+
double[] expectedZonalStatsAll =
108+
new double[] {
109+
0.0,
110+
0.0,
111+
Double.NaN,
112+
Double.NaN,
113+
Double.NaN,
114+
Double.NaN,
115+
Double.NaN,
116+
Double.NaN,
117+
Double.NaN
118+
};
101119
assertArrayEquals(expectedZonalStatsAll, actualZonalStatsAll, FP_TOLERANCE);
102120
}
103121

0 commit comments

Comments
 (0)