Skip to content

Commit

Permalink
GEOS-6960: Updating GS code after viewsManager cleanup (GEOT-5050)
Browse files Browse the repository at this point in the history
  • Loading branch information
dromagnoli authored and n-lagomarsini committed Mar 30, 2015
1 parent 7b396ce commit edca4ca
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.geotools.coverage.grid.GridCoverage2D;
import org.geotools.coverage.grid.GridCoverageFactory;
import org.geotools.coverage.grid.GridGeometry2D;
import org.geotools.coverage.grid.ViewType;
import org.geotools.geometry.Envelope2D;
import org.geotools.referencing.crs.DefaultGeographicCRS;
import org.junit.Test;
Expand Down Expand Up @@ -106,7 +105,7 @@ private static void view(RenderedImage ri, GridGeometry2D gg, GridSampleDimensio
GridCoverage2D rendered = factory.create("Merged coverage", ri,
gg, gsd, null, null);

rendered.view(ViewType.RENDERED).show();
rendered.show();
}

@Test
Expand All @@ -127,11 +126,6 @@ public void testSame() throws InterruptedException {
pdst = cria.mapSourcePoint(psrc, 0);
assertNull(pdst);

// src.view(ViewType.RENDERED).show();
// dst.view(ViewType.RENDERED).show();
//// new Viewer(src.view(ViewType.RENDERED).getRenderedImage());
// new Viewer(getName(), cria);

// view(cria, dst.getGridGeometry(), src.getSampleDimensions());

// Viewer.show(src);
Expand All @@ -157,8 +151,6 @@ public void testSameWorldSmallerDstRaster() throws InterruptedException {
pdst = cria.mapSourcePoint(psrc, 0);
assertNull(pdst);

// src.view(ViewType.RENDERED).show();
// dst.view(ViewType.RENDERED).show();
// new Viewer(getName(), cria);
// Thread.sleep(15000);
}
Expand Down Expand Up @@ -189,8 +181,6 @@ public void testSameRasterSmallerWorld() throws InterruptedException {
assertEquals(250d + 15d, pdst.getY());
// System.out.println(pdst);

// src.view(ViewType.RENDERED).show();
// dst.view(ViewType.RENDERED).show();
// new Viewer(getName(), cria);
// Thread.sleep(15000);
}
Expand Down Expand Up @@ -221,8 +211,6 @@ public void testSameRasterTranslatedWorld0() throws InterruptedException {
double val = cria.getData().getSampleFloat(0, 0, 0);
assertEquals("Value should be noData", NODATA, val);

// src.view(ViewType.RENDERED).show();
// dst.view(ViewType.RENDERED).show();
// new Viewer(getName(), cria);
// Thread.sleep(20000);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/
package org.geoserver.catalog;

import java.awt.Color;
import java.awt.image.ColorModel;
import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -50,7 +49,6 @@
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.datum.PixelInCell;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.MathTransform1D;
import org.opengis.util.InternationalString;

/**
Expand Down Expand Up @@ -489,10 +487,6 @@ public Category getCategory(double sample) {
return sampleDim.getCategory(sample);
}
@Override
public Category getBackground() {
return sampleDim.getBackground();
}
@Override
public double[] getNoDataValues() throws IllegalStateException {
return configuredNoDataValues;
}
Expand Down Expand Up @@ -537,14 +531,6 @@ public double getScale() {
return sampleDim.getScale();
}
@Override
public MathTransform1D getSampleToGeophysics() {
return sampleDim.getSampleToGeophysics();
}
@Override
public GridSampleDimension geophysics(boolean geo) {
return sampleDim.geophysics(geo);
}
@Override
public int[][] getPalette() {
return sampleDim.getPalette();
}
Expand All @@ -568,10 +554,7 @@ public ColorModel getColorModel(int visibleBand, int numBands) {
public ColorModel getColorModel(int visibleBand, int numBands, int type) {
return sampleDim.getColorModel(visibleBand, numBands, type);
}
@Override
public GridSampleDimension rescale(double scale, double offset) {
return sampleDim.rescale(scale, offset);
}

@Override
public int hashCode() {
return sampleDim.hashCode();
Expand Down Expand Up @@ -695,8 +678,7 @@ public WrappedSampleDimension(GridSampleDimension sampleDim, CoverageDimensionIn
} else {
// Create the wrapped category
wrapped = new Category(Category.NODATA.getName(),
category.getColors(), NumberRange.create(minimum, maximum),
category.getSampleToGeophysics());
category.getColors(), NumberRange.create(minimum, maximum));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
*/
package org.geoserver.catalog;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import java.awt.Color;
import java.io.IOException;
Expand All @@ -20,8 +22,6 @@
import org.geoserver.test.GeoServerSystemTestSupport;
import org.geotools.coverage.Category;
import org.geotools.coverage.GridSampleDimension;
import org.geotools.referencing.operation.transform.IdentityTransform;
import org.geotools.referencing.operation.transform.LinearTransform1D;
import org.geotools.resources.i18n.Vocabulary;
import org.geotools.resources.i18n.VocabularyKeys;
import org.geotools.util.NumberRange;
Expand Down Expand Up @@ -103,7 +103,7 @@ public void testNoDataCategoryWrapping() throws IOException {
GridSampleDimension sampleDim = new GridSampleDimension("original",
new Category[] { new Category(
Vocabulary.formatInternational(VocabularyKeys.NODATA),
new Color(0, 0, 0, 0), 0) }, null);
new Color(0, 0, 0, 0), Double.NaN) }, null);

// Wrap the dimension
GridSampleDimension wrappedDim = new WrappedSampleDimension(sampleDim, coverageDim);
Expand All @@ -122,15 +122,13 @@ public void testNoDataCategoryWrapping() throws IOException {
assertTrue(category.getName().equals(Category.NODATA.getName()));

// Check that it does not contain sampleToGeophisics and that the Range contains only NaN
assertNull(category.getSampleToGeophysics());
assertEquals(category.geophysics(true).getRange().getMinimum(), Double.NaN, DELTA);
assertEquals(category.geophysics(true).getRange().getMaximum(), Double.NaN, DELTA);
assertEquals(category.getRange().getMinimum(), Double.NaN, DELTA);
assertEquals(category.getRange().getMaximum(), Double.NaN, DELTA);

// Quantitative nodata category
sampleDim = new GridSampleDimension("original", new Category[] { new Category(
Vocabulary.formatInternational(VocabularyKeys.NODATA), new Color[] { new Color(0,
0, 0, 0) }, NumberRange.create(-9999, -9999), NumberRange.create(-9999,
-9999)) }, null);
0, 0, 0) }, NumberRange.create(-9999, -9999)) }, null);

// Wrap the dimension
wrappedDim = new WrappedSampleDimension(sampleDim, coverageDim);
Expand All @@ -149,9 +147,8 @@ public void testNoDataCategoryWrapping() throws IOException {
assertTrue(category.getName().equals(Category.NODATA.getName()));

// Check if it contains sampleToGeophisics and the Range contains the first nodata defined
assertNotNull(category.getSampleToGeophysics());
assertEquals(category.geophysics(true).getRange().getMinimum(), noData1, DELTA);
assertEquals(category.geophysics(true).getRange().getMaximum(), noData1, DELTA);
assertEquals(category.getRange().getMinimum(), noData1, DELTA);
assertEquals(category.getRange().getMaximum(), noData1, DELTA);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.geotools.gce.geotiff.GeoTiffReader;
import org.geotools.image.ImageWorker;
import org.geotools.image.io.ImageIOExt;
import org.geotools.resources.coverage.CoverageUtilities;
import org.geotools.resources.i18n.Vocabulary;
import org.geotools.resources.i18n.VocabularyKeys;
import org.geotools.util.Converters;
Expand Down Expand Up @@ -188,7 +189,7 @@ private void initReaderFromFile(Hints inHints) throws IOException {
}

final GeoTiffReader geotiffReader = new GeoTiffReader(dataFile, hints);
this.crs = geotiffReader.getCrs();
this.crs = geotiffReader.getCoordinateReferenceSystem();
this.originalGridRange = geotiffReader.getOriginalGridRange();
this.originalEnvelope = geotiffReader.getOriginalEnvelope();
}
Expand Down Expand Up @@ -237,13 +238,11 @@ private GridCoverage2D createCoverage(String name, RenderedImage image) {
Category noDataCategory = new Category(
Vocabulary.formatInternational(VocabularyKeys.NODATA),
new Color[] { new Color(0, 0, 0, 0) },
NumberRange.create(DEFAULT_NODATA, DEFAULT_NODATA),
NumberRange.create(DEFAULT_NODATA, DEFAULT_NODATA));
Category[] categories = new Category[] { noDataCategory };
GridSampleDimension[] bands;
bands = new GridSampleDimension[1];
bands[0] =
new GridSampleDimension(null, categories, null).geophysics(true);
bands[0] = new GridSampleDimension(null, categories, null);
final Map<String, Double> properties = new HashMap<String, Double>();
properties.put("GC_NODATA", DEFAULT_NODATA);
return this.coverageFactory.create(name, image, this.originalEnvelope,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
*/
package org.geoserver.wcs2_0.response;

import it.geosolutions.imageio.utilities.SoftValueHashMap;

import java.io.IOException;
import java.util.HashSet;
import java.util.List;
Expand All @@ -25,6 +23,7 @@
import org.geoserver.platform.GeoServerExtensions;
import org.geoserver.wcs.responses.CoverageResponseDelegate;
import org.geoserver.wcs.responses.CoverageResponseDelegateFinder;
import org.geotools.util.SoftValueHashMap;
import org.geotools.util.Utilities;
import org.geotools.util.logging.Logging;
import org.springframework.beans.BeansException;
Expand Down

0 comments on commit edca4ca

Please sign in to comment.