Commit b70db194 authored by Devon Tucker's avatar Devon Tucker Committed by Torben Barsbsballe
Browse files

[GEOS-7270]

- Change multiband Qname to be public so it can be used in other tests
- Update Direct Raster Rendering WMS code to use null background to be more inline with the non-direct
see StreamingRenderer grid coverage and grid reader rendering, which both use Null background images
- Add test case with static expected result from rendering
- Minor linting fixes

- Deleted some debugging code that found its way in

-Removed extra white space
parent 09d283be
......@@ -80,7 +80,7 @@ import org.geotools.util.logging.Logging;
public class SystemTestData extends CiteTestData {
/** Multiband tiff */
private static final QName MULTIBAND = new QName(WCS_URI, "multiband", WCS_PREFIX);
public static final QName MULTIBAND = new QName(WCS_URI, "multiband", WCS_PREFIX);
static final Logger LOGGER = Logging.getLogger(SystemTestData.class);
......
......@@ -144,8 +144,7 @@ public class RenderedImageMapOutputFormat extends AbstractMapOutputFormat {
private final static String AA_FULL = "FULL";
private final static List<String> AA_SETTINGS = Arrays.asList(new String[] { AA_NONE, AA_TEXT,
AA_FULL });
private final static List<String> AA_SETTINGS = Arrays.asList(AA_NONE, AA_TEXT, AA_FULL);
/**
* The size of a megabyte
......@@ -261,7 +260,7 @@ public class RenderedImageMapOutputFormat extends AbstractMapOutputFormat {
}
/**
* Actually produces the map image, careing about meta tiling if {@code tiled == true}.
* Actually produces the map image, caring about meta tiling if {@code tiled == true}.
*
* @param mapContent
* @param tiled
......@@ -330,8 +329,8 @@ public class RenderedImageMapOutputFormat extends AbstractMapOutputFormat {
RenderedImage image = null;
// fast path for pure coverage rendering
if (DefaultWebMapService.isDirectRasterPathEnabled() &&
mapContent.layers().size() == 1
if (DefaultWebMapService.isDirectRasterPathEnabled()
&& mapContent.layers().size() == 1
&& mapContent.getAngle() == 0.0
&& (layout == null || layout.isEmpty())) {
List<GridCoverage2D> renderedCoverages = new ArrayList<GridCoverage2D>(2);
......@@ -944,8 +943,9 @@ public class RenderedImageMapOutputFormat extends AbstractMapOutputFormat {
mapRasterArea, worldToScreen, interpolationHints);
gcr.setAdvancedProjectionHandlingEnabled(true);
gcr.setWrapEnabled(wms.isContinuousMapWrappingEnabled());
//use null background here, background color is handled afterwards
image = gcr.renderImage(reader, readParameters, symbolizer, interpolation,
mapContent.getBgColor(), tileSizeX, tileSizeY);
null, tileSizeX, tileSizeY);
if (image == null) {
// we're outside of the coverage definition area, return an empty space
image = createBkgImage(mapWidth, mapHeight, bgColor, null);
......@@ -960,8 +960,8 @@ public class RenderedImageMapOutputFormat extends AbstractMapOutputFormat {
final boolean equalsMetadata = CRS.equalsIgnoreMetadata(mapCRS, coverageCRS);
boolean sameCRS;
try {
sameCRS = equalsMetadata ? true : CRS.findMathTransform(mapCRS, coverageCRS,
true).isIdentity();
sameCRS = equalsMetadata || CRS.findMathTransform(mapCRS, coverageCRS, true)
.isIdentity();
} catch (FactoryException e1) {
final IOException ioe = new IOException();
ioe.initCause(e1);
......@@ -1046,8 +1046,9 @@ public class RenderedImageMapOutputFormat extends AbstractMapOutputFormat {
gcr.setAdvancedProjectionHandlingEnabled(false);
// create a solid color empty image
// use null background, background is handled separately
image = gcr.renderImage(coverage, symbolizer, interpolation,
mapContent.getBgColor(), tileSizeX, tileSizeY);
null, tileSizeX, tileSizeY);
}
}
} catch (Throwable e) {
......@@ -1504,19 +1505,4 @@ public class RenderedImageMapOutputFormat extends AbstractMapOutputFormat {
}
return readParams;
}
/**
* Returns the list of raster symbolizers contained in a specific layer of the map context (the
* full map context is provided in order to compute the current scale and thus determine the
* active rules)
*
* @param mc
* @param layerIndex
* @return
*/
// static List<RasterSymbolizer> getRasterSymbolizers(WMSMapContent mc, int layerIndex) {
//
// }
}
......@@ -5,42 +5,13 @@
*/
package org.geoserver.wms.map;
import static org.geoserver.data.test.CiteTestData.STREAMS;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.awt.Color;
import java.awt.geom.NoninvertibleTransformException;
import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.media.jai.Interpolation;
import javax.media.jai.RenderedOp;
import javax.xml.namespace.QName;
import org.geoserver.catalog.Catalog;
import org.geoserver.catalog.CoverageInfo;
import org.geoserver.catalog.FeatureTypeInfo;
import org.geoserver.catalog.LayerInfo;
import org.geoserver.catalog.StyleInfo;
import com.vividsolutions.jts.geom.Envelope;
import org.geoserver.catalog.*;
import org.geoserver.data.test.MockData;
import org.geoserver.data.test.SystemTestData;
import org.geoserver.platform.ServiceException;
import org.geoserver.security.decorators.DecoratingFeatureSource;
import org.geoserver.wms.GetMapRequest;
import org.geoserver.wms.WMS;
import org.geoserver.wms.WMSMapContent;
import org.geoserver.wms.WMSPartialMapException;
import org.geoserver.wms.WMSTestSupport;
import org.geoserver.wms.*;
import org.geotools.coverage.grid.io.GridCoverage2DReader;
import org.geotools.data.FeatureSource;
import org.geotools.data.Query;
......@@ -51,19 +22,40 @@ import org.geotools.feature.IllegalAttributeException;
import org.geotools.feature.SchemaException;
import org.geotools.filter.IllegalFilterException;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.geotools.image.test.ImageAssert;
import org.geotools.map.FeatureLayer;
import org.geotools.map.Layer;
import org.geotools.referencing.crs.DefaultGeographicCRS;
import org.geotools.resources.coverage.FeatureUtilities;
import org.geotools.styling.Style;
import org.geotools.styling.StyleBuilder;
import org.geotools.util.logging.Logging;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.opengis.parameter.GeneralParameterValue;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.TransformException;
import com.vividsolutions.jts.geom.Envelope;
import javax.media.jai.Interpolation;
import javax.media.jai.RenderedOp;
import javax.xml.namespace.QName;
import java.awt.*;
import java.awt.geom.NoninvertibleTransformException;
import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import static org.geoserver.data.test.CiteTestData.STREAMS;
import static org.junit.Assert.*;
public class RenderedImageMapOutputFormatTest extends WMSTestSupport {
......@@ -78,6 +70,8 @@ public class RenderedImageMapOutputFormatTest extends WMSTestSupport {
public void setRasterMapProducer() throws Exception {
Logging.getLogger("org.geotools.rendering").setLevel(Level.OFF);
this.rasterMapProducer = getProducerInstance();
getTestData().addDefaultRasterLayer(SystemTestData.MULTIBAND, getCatalog());
}
protected RenderedImageMapOutputFormat getProducerInstance() {
......@@ -123,6 +117,52 @@ public class RenderedImageMapOutputFormatTest extends WMSTestSupport {
imageMap.dispose();
assertNotBlank("testSimpleGetMapQuery", image);
}
/**
* Test to make sure the "direct" raster path and the "nondirect" raster path
* produce matching results. This test was originally created after fixes to GEOS-7270
* where there were issues with images generated during the direct raster path but not
* in the normal path, stemming from not setting the background color the same way
*/
@Test
public void testDirectVsNonDirectRasterRender() throws Exception {
Catalog catalog = getCatalog();
CoverageInfo ci = catalog.getCoverageByName(
SystemTestData.MULTIBAND.getPrefix(), SystemTestData.MULTIBAND.getLocalPart());
final Envelope env = ci.boundingBox();
LOGGER.info("about to create map ctx for BasicPolygons with bounds " + env);
GetMapRequest request = new GetMapRequest();
CoordinateReferenceSystem crs = DefaultGeographicCRS.WGS84;
ReferencedEnvelope bbox = new ReferencedEnvelope(
new Envelope(-116.90673461649858211,
-114.30988665660261461, 32.07093728218402617, 33.89032847348440214), crs);
request.setBbox(bbox);
request.setSRS("urn:x-ogc:def:crs:EPSG:4326");
request.setFormat("image/png");
final WMSMapContent map = new WMSMapContent(request);
map.setMapWidth(300);
map.setMapHeight(300);
map.setBgColor(Color.red);
map.setTransparent(false);
map.getViewport().setBounds(bbox);
StyleBuilder builder = new StyleBuilder();
GridCoverage2DReader reader = (GridCoverage2DReader) ci.getGridCoverageReader(null, null);
reader.getCoordinateReferenceSystem();
Layer l = new CachedGridReaderLayer(
reader,
builder.createStyle(builder.createRasterSymbolizer()));
map.addLayer(l);
RenderedImageMap imageMap = this.rasterMapProducer.produceMap(map);
ImageAssert.assertEquals(new File(
"src/test/resources/org/geoserver/wms/map/direct-raster-expected.tif"), imageMap.getImage(), 0);
imageMap.dispose();
}
@Test
public void testTimeoutOption() throws Exception {
......@@ -511,5 +551,4 @@ public class RenderedImageMapOutputFormatTest extends WMSTestSupport {
super("image/gif", new String[] { "image/gif" }, wms);
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment