Skip to content

Commit

Permalink
[GEOS-8212]: Do not report nodata value in CoverageDimensionInfo min/…
Browse files Browse the repository at this point in the history
…Max range (use dedicate nullValues field)
  • Loading branch information
dromagnoli committed Jul 6, 2017
1 parent b3cdfc3 commit 40acee9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
19 changes: 10 additions & 9 deletions src/main/src/main/java/org/geoserver/catalog/CatalogBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -1146,21 +1146,22 @@ List<CoverageDimensionInfo> getCoverageDimensions(GridSampleDimension[] sampleDi

dim.setDimensionType(sd.getSampleDimensionType());

double sdMin = sd.getMinimumValue();
double sdMax = sd.getMaximumValue();
label.append("[".intern());
label.append(sd.getMinimumValue());
label.append(sdMin);
label.append(",".intern());
label.append(sd.getMaximumValue());
label.append(sdMax);
label.append("]".intern());

dim.setDescription(label.toString());
// Since the nullValues element of the CoverageDimensionInfo reports
// the nodata (if available), let's switch to use the
// sampleDimension's min and max as Dimension's Range
// instead of the whole SampleDimension Range
// (the latter may include nodata categories).
dim.setRange(NumberRange.create(sdMin, sdMax));

if (sd.getRange() != null) {
dim.setRange(sd.getRange());
}
else {
dim.setRange(NumberRange.create(sd.getMinimumValue(), sd.getMaximumValue()));
}

final List<Category> categories = sd.getCategories();
if (categories != null) {
for (Category cat : categories) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public void testSingleBandedCoverage() throws Exception {
assertEquals("GRAY_INDEX", dimension.getName());
assertEquals(1, dimension.getNullValues().size());
assertEquals(-9999, dimension.getNullValues().get(0), 0d);
assertEquals(-9999, dimension.getRange().getMinimum(), 0d);
assertEquals(Double.NEGATIVE_INFINITY, dimension.getRange().getMinimum(), 0d);
// Huston, we have a problem here...
// assertEquals(9999, dimension.getRange().getMaximum(), 0d);
assertNull(dimension.getUnit());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -640,9 +640,9 @@ public void testCoverageWrapping() throws Exception {
CoverageDimensionInfo dimension = dimensions.get(0);
assertEquals( "GRAY_INDEX", dimension.getName());
NumberRange range = dimension.getRange();
assertEquals( -9999.0, range.getMinimum(), DELTA);
assertEquals( -9999.0, range.getMaximum(), DELTA);
assertEquals("GridSampleDimension[-9999.0,-9999.0]", dimension.getDescription());
assertEquals( Double.NEGATIVE_INFINITY, range.getMinimum(), DELTA);
assertEquals( Double.POSITIVE_INFINITY, range.getMaximum(), DELTA);
assertEquals("GridSampleDimension[-Infinity,Infinity]", dimension.getDescription());
List<Double> nullValues = dimension.getNullValues();
assertEquals( -9999.0, nullValues.get(0), DELTA);

Expand Down

0 comments on commit 40acee9

Please sign in to comment.