Unverified Commit c2047b2a authored by mbarto's avatar mbarto Committed by GitHub

Merge pull request #3465 from mbarto/geos9137_2_15_x

GEOS-9137: [Backport to 2.15.x] Add WMS configuration options for densification on reproje…
parents e091fdab 93aa77e4
......@@ -88,22 +88,32 @@ projection. This includes, among others:
transverse Mercator projection, or beyond 85 degrees north or south in a Mercator projection
* Make sure both "ends" of the world get queried for data when a map in polar stereographic is
hitting an area that includes the dateline
* Ability to optionally preprocess geometries with a densify operation that allows better results when a reprojection
operation causes a lot of deformation in the original geometry. Adding more points to the original geometry
produces a more precise reprojected one (e.g. straight lines that become curves when reprojected).
Along with advanced projection handling there is the possibility of creating a continuous map
across the dateline, wrapping the data on the other side of the longitude range, to get a continuous
map. This is called continuous map wrapping, and it's enabled in Mercator and Equirectangular (plate carrée) projections.
This also uses an heuristic to guess direction of lines that cross the dateline (west to east or east to west). The
heuristic can be disabled using the **Disable dateline wrapping heuristic** option.
Both functionalities are rather useful, and enabled by default, but the tendency to generate multiple
or-ed bounding boxes (to query both sides of the dateline) can cause extreme slowness in certain databases (e.g. Oracle),
and some users might simply not like the wrapping output, thus, it's possible to disable both functions
Advanced projection handling and continuous map wrapping functionalities are rather useful, and enabled by default, but the
tendency to generate multiple or-ed bounding boxes (to query both sides of the dateline) can cause extreme slowness in certain
databases (e.g. Oracle), and some users might simply not like the wrapping output, thus, it's possible to disable both functions
in the WMS UI:
.. figure:: img/services_WMS_aph.png
Continuous map wrapping is disabled if advanced projection handling is disabled.
Automatic densification can slow down rendering, so it's disabled by default, but can be enabled using the **Enable automatic
densification of geometries** option.
Advanced projection handling can also be disabled using the ``advancedProjectionHandling`` :ref:`Format Option <format_options>`.
Similarly, continuous map wrapping can also be disabled using the ``mapWrapping`` :ref:`Format Option <format_options>`.
Similarly, continuous map wrapping can also be disabled using the ``mapWrapping`` :ref:`Format Option <format_options>`,
automatic densification can be enabled using the ``advancedProjectionHandlingDensification`` :ref:`Format Option <format_options>`,
and the dateline heuristic can be disabled using the ``disableDatelineWrappingHeuristic`` :ref:`Format Option <format_options>`.
Restricting MIME types for GetMap and GetFeatureInfo requests
......
......@@ -46,6 +46,14 @@
<input type="checkbox" wicket:id="aph.wrap"></input>
<label for="aph.wrap"><wicket:message key="aph.wrap">Enable continous map wrapping</wicket:message></label>
</li>
<li>
<input type="checkbox" wicket:id="aph.densify"></input>
<label for="aph.densify"><wicket:message key="aph.densify">Enable automatic densification of geometries</wicket:message></label>
</li>
<li>
<input type="checkbox" wicket:id="aph.dlh"></input>
<label for="aph.dlh"><wicket:message key="aph.dlh">Disable dateline wrapping heuristic</wicket:message></label>
</li>
</ul>
</fieldset>
</li>
......
......@@ -140,6 +140,20 @@ public class WMSAdminPage extends BaseServiceAdminPage<WMSInfo> {
defaultedModel(metadataModel, WMS.MAP_WRAPPING_KEY, WMS.ENABLE_MAP_WRAPPING);
CheckBox aphWrapField = new CheckBox("aph.wrap", aphWrap);
form.add(aphWrapField);
MapModel aphDensify =
defaultedModel(
metadataModel,
WMS.ADVANCED_PROJECTION_DENSIFICATION_KEY,
WMS.ENABLE_ADVANCED_PROJECTION_DENSIFICATION);
CheckBox aphDensifyField = new CheckBox("aph.densify", aphDensify);
form.add(aphDensifyField);
MapModel aphHeuristic =
defaultedModel(
metadataModel,
WMS.DATELINE_WRAPPING_HEURISTIC_KEY,
WMS.DISABLE_DATELINE_WRAPPING_HEURISTIC);
CheckBox aphHeuristicField = new CheckBox("aph.dlh", aphHeuristic);
form.add(aphHeuristicField);
// general
form.add(
......
......@@ -146,6 +146,8 @@ WMSAdminPage.getMapMimeTypes = Allowed MIME types for a GetMap request
WMSAdminPage.projectionHandlingOptions = Projection handling options
WMSAdminPage.aph.enabled = Enable advanced projection handling
WMSAdminPage.aph.wrap = Enable continuous map wrapping
WMSAdminPage.aph.densify = Enable automatic densification of geometries
WMSAdminPage.aph.dlh = Disable dateline wrapping heuristic
WMSAdminPage.rootLayerInfo = Root Layer Info
WMSAdminPage.rootLayerTitle = Title
WMSAdminPage.rootLayerAbstract = Abstract
......
......@@ -15,6 +15,7 @@ import org.apache.wicket.markup.html.form.ValidationErrorFeedback;
import org.apache.wicket.util.tester.FormTester;
import org.geoserver.web.GeoServerHomePage;
import org.geoserver.web.GeoServerWicketTestSupport;
import org.geoserver.wms.WMS;
import org.geoserver.wms.WMSInfo;
import org.geoserver.wms.web.WMSAdminPage;
import org.junit.Before;
......@@ -92,6 +93,26 @@ public class WMSAdminPageTest extends GeoServerWicketTestSupport {
assertEquals(wms.getRootLayerAbstract(), "abstract test");
}
@Test
public void testDensification() throws Exception {
tester.startPage(WMSAdminPage.class);
FormTester ft = tester.newFormTester("form");
ft.setValue("aph.densify", true);
ft.submit("submit");
tester.assertNoErrorMessage();
assertEquals(wms.getMetadata().get(WMS.ADVANCED_PROJECTION_DENSIFICATION_KEY), true);
}
@Test
public void testDisableWrappingHeuristic() throws Exception {
tester.startPage(WMSAdminPage.class);
FormTester ft = tester.newFormTester("form");
ft.setValue("aph.dlh", true);
ft.submit("submit");
tester.assertNoErrorMessage();
assertEquals(wms.getMetadata().get(WMS.DATELINE_WRAPPING_HEURISTIC_KEY), true);
}
@Test
public void testDynamicStylingDisabled() throws Exception {
assertFalse(wms.isDynamicStylingDisabled());
......
......@@ -111,6 +111,11 @@
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.geoserver</groupId>
<artifactId>gs-main</artifactId>
......
......@@ -205,6 +205,18 @@ public class WMS implements ApplicationContextAware {
/** Advanced projection key */
public static String ADVANCED_PROJECTION_KEY = "advancedProjectionHandling";
/** Enable advanced projection handling */
public static Boolean ENABLE_ADVANCED_PROJECTION_DENSIFICATION = false;
/** Advanced projection densification key */
public static String ADVANCED_PROJECTION_DENSIFICATION_KEY = "advancedProjectionDensification";
/** Disable DateLine Wrapping Heuristic. */
public static Boolean DISABLE_DATELINE_WRAPPING_HEURISTIC = false;
/** DateLine Wrapping Heuristic key */
public static String DATELINE_WRAPPING_HEURISTIC_KEY = "disableDatelineWrappingHeuristic";
/** GIF disposal methods */
public static final String DISPOSAL_METHOD_NONE = "none";
......@@ -548,6 +560,24 @@ public class WMS implements ApplicationContextAware {
return enabled;
}
public boolean isAdvancedProjectionDensificationEnabled() {
Boolean enabled =
getMetadataValue(
ADVANCED_PROJECTION_DENSIFICATION_KEY,
ENABLE_ADVANCED_PROJECTION_DENSIFICATION,
Boolean.class);
return enabled;
}
public boolean isDateLineWrappingHeuristicDisabled() {
Boolean disabled =
getMetadataValue(
DATELINE_WRAPPING_HEURISTIC_KEY,
DISABLE_DATELINE_WRAPPING_HEURISTIC,
Boolean.class);
return disabled;
}
public int getMaxAllowedFrames() {
return getMetadataValue(MAX_ALLOWED_FRAMES, MAX_ALLOWED_FRAMES_DEFAULT, Integer.class);
}
......
......@@ -156,6 +156,10 @@ public class RenderedImageMapOutputFormat extends AbstractMapOutputFormat {
private static final String MAP_WRAPPING_FORMAT_OPTION = "mapWrapping";
private static final String ADV_PROJECTION_HANDLING_FORMAT_OPTION =
"advancedProjectionHandling";
private static final String ADV_PROJECTION_DENSIFICATION_FORMAT_OPTION =
"advancedProjectionHandlingDensification";
private static final String DISABLE_DATELINE_WRAPPING_HEURISTIC_FORMAT_OPTION =
"disableDatelineWrappingHeuristic";
/** The size of a megabyte */
private static final int KB = 1024;
......@@ -448,9 +452,27 @@ public class RenderedImageMapOutputFormat extends AbstractMapOutputFormat {
// turn on advanced projection handling
if (wms.isAdvancedProjectionHandlingEnabled()) {
rendererParams.put(StreamingRenderer.ADVANCED_PROJECTION_HANDLING_KEY, true);
if (request.getFormatOptions().get(ADV_PROJECTION_DENSIFICATION_FORMAT_OPTION)
!= null) {
rendererParams.put(
StreamingRenderer.ADVANCED_PROJECTION_DENSIFICATION_KEY,
getFormatOptionAsBoolean(
request, ADV_PROJECTION_DENSIFICATION_FORMAT_OPTION));
} else if (wms.isAdvancedProjectionDensificationEnabled()) {
rendererParams.put(StreamingRenderer.ADVANCED_PROJECTION_DENSIFICATION_KEY, true);
}
if (wms.isContinuousMapWrappingEnabled()) {
rendererParams.put(StreamingRenderer.CONTINUOUS_MAP_WRAPPING, true);
}
if (request.getFormatOptions().get(DISABLE_DATELINE_WRAPPING_HEURISTIC_FORMAT_OPTION)
!= null) {
rendererParams.put(
StreamingRenderer.DATELINE_WRAPPING_HEURISTIC_KEY,
!getFormatOptionAsBoolean(
request, DISABLE_DATELINE_WRAPPING_HEURISTIC_FORMAT_OPTION));
} else if (wms.isDateLineWrappingHeuristicDisabled()) {
rendererParams.put(StreamingRenderer.DATELINE_WRAPPING_HEURISTIC_KEY, false);
}
}
if (getFormatOptionAsBoolean(request, ADV_PROJECTION_HANDLING_FORMAT_OPTION) == false) {
......
......@@ -200,4 +200,24 @@ public class WMSTest extends WMSTestSupport {
getGeoServer().save(info);
assertTrue(wms.isRemoteStylesCacheEnabled());
}
@Test
public void testProjectionDensification() {
assertFalse(wms.isAdvancedProjectionDensificationEnabled());
WMSInfo info = wms.getServiceInfo();
info.getMetadata().put(WMS.ADVANCED_PROJECTION_DENSIFICATION_KEY, true);
getGeoServer().save(info);
assertTrue(wms.isAdvancedProjectionDensificationEnabled());
}
@Test
public void testWrappingHeuristic() {
assertFalse(wms.isDateLineWrappingHeuristicDisabled());
WMSInfo info = wms.getServiceInfo();
info.getMetadata().put(WMS.DATELINE_WRAPPING_HEURISTIC_KEY, true);
getGeoServer().save(info);
assertTrue(wms.isDateLineWrappingHeuristicDisabled());
}
}
......@@ -17,6 +17,8 @@ import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.RenderingHints.Key;
import java.awt.Shape;
import java.awt.geom.NoninvertibleTransformException;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
......@@ -81,6 +83,7 @@ import org.geotools.image.util.ImageUtilities;
import org.geotools.map.FeatureLayer;
import org.geotools.map.Layer;
import org.geotools.parameter.Parameter;
import org.geotools.referencing.CRS;
import org.geotools.referencing.crs.DefaultGeographicCRS;
import org.geotools.renderer.lite.LabelCache;
import org.geotools.renderer.lite.StreamingRenderer;
......@@ -101,6 +104,10 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.locationtech.jts.geom.Envelope;
import org.locationtech.jts.geom.LineString;
import org.locationtech.jts.geom.MultiLineString;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import org.opengis.feature.Feature;
import org.opengis.parameter.GeneralParameterValue;
import org.opengis.referencing.FactoryException;
......@@ -111,6 +118,16 @@ public class RenderedImageMapOutputFormatTest extends WMSTestSupport {
public static QName TAZ_BYTE = new QName(MockData.WCS_URI, "tazbyte", MockData.WCS_PREFIX);
static final QName STRAIGHT_VERTICAL_LINE =
new QName(MockData.CITE_URI, "STRAIGHT_VERTICAL_LINE", MockData.CITE_PREFIX);
static final String STRAIGHT_VERTICAL_LINE_STYLE = "verticalline";
static final QName CROSS_DATELINE =
new QName(MockData.CITE_URI, "CROSS_DATELINE", MockData.CITE_PREFIX);
static final String CROSS_DATELINE_STYLE = "crossline";
private static final Logger LOGGER =
org.geotools.util.logging.Logging.getLogger(
RenderedImageMapOutputFormatTest.class.getPackage().getName());
......@@ -225,6 +242,270 @@ public class RenderedImageMapOutputFormatTest extends WMSTestSupport {
assertNotBlank("testSimpleGetMapQuery", image);
}
@Test
public void testAdvancedProjectionDensification() throws Exception {
WMS wms = getWMS();
WMSInfo info = wms.getServiceInfo();
info.getMetadata().put(WMS.ADVANCED_PROJECTION_DENSIFICATION_KEY, true);
getGeoServer().save(info);
Graphics2D graphics = Mockito.mock(Graphics2D.class);
this.rasterMapProducer = new DummyRasterMapProducer(wms);
((DummyRasterMapProducer) this.rasterMapProducer).setGraphics(graphics);
Catalog catalog = getCatalog();
final FeatureSource fs =
catalog.getFeatureTypeByName(
STRAIGHT_VERTICAL_LINE.getPrefix(),
STRAIGHT_VERTICAL_LINE.getLocalPart())
.getFeatureSource(null, null);
final ReferencedEnvelope env =
new ReferencedEnvelope(10, 15, 0, 50, DefaultGeographicCRS.WGS84);
CoordinateReferenceSystem utm32 = CRS.decode("EPSG:32632");
ReferencedEnvelope targetEnv = env.transform(utm32, true);
GetMapRequest request = new GetMapRequest();
final WMSMapContent map = new WMSMapContent();
map.getViewport().setBounds(targetEnv);
map.getViewport().setCoordinateReferenceSystem(utm32);
map.setMapWidth(300);
map.setMapHeight(300);
map.setBgColor(Color.red);
map.setTransparent(false);
map.setRequest(request);
StyleInfo styleByName = catalog.getStyleByName(STRAIGHT_VERTICAL_LINE_STYLE);
Style basicStyle = styleByName.getStyle();
map.addLayer(new FeatureLayer(fs, basicStyle));
request.setFormat(getMapFormat());
RenderedImageMap imageMap = this.rasterMapProducer.produceMap(map);
BufferedImage image = (BufferedImage) imageMap.getImage();
imageMap.dispose();
assertNotBlank("densify", image);
ArgumentCaptor<Shape> shape = ArgumentCaptor.forClass(Shape.class);
Mockito.verify(graphics).draw(shape.capture());
LiteShape2 drawnShape = (LiteShape2) shape.getValue();
assertEquals(64, drawnShape.getGeometry().getCoordinates().length);
}
@Test
public void testAdvancedProjectionDensificationWithFormatOption() throws Exception {
Graphics2D graphics = Mockito.mock(Graphics2D.class);
this.rasterMapProducer = new DummyRasterMapProducer(getWMS());
((DummyRasterMapProducer) this.rasterMapProducer).setGraphics(graphics);
Catalog catalog = getCatalog();
final FeatureSource fs =
catalog.getFeatureTypeByName(
STRAIGHT_VERTICAL_LINE.getPrefix(),
STRAIGHT_VERTICAL_LINE.getLocalPart())
.getFeatureSource(null, null);
final ReferencedEnvelope env =
new ReferencedEnvelope(10, 15, 0, 50, DefaultGeographicCRS.WGS84);
CoordinateReferenceSystem utm32 = CRS.decode("EPSG:32632");
ReferencedEnvelope targetEnv = env.transform(utm32, true);
GetMapRequest request = new GetMapRequest();
request.getFormatOptions().put("advancedProjectionHandlingDensification", "true");
final WMSMapContent map = new WMSMapContent();
map.getViewport().setBounds(targetEnv);
map.getViewport().setCoordinateReferenceSystem(utm32);
map.setMapWidth(300);
map.setMapHeight(300);
map.setBgColor(Color.red);
map.setTransparent(false);
map.setRequest(request);
StyleInfo styleByName = catalog.getStyleByName(STRAIGHT_VERTICAL_LINE_STYLE);
Style basicStyle = styleByName.getStyle();
map.addLayer(new FeatureLayer(fs, basicStyle));
request.setFormat(getMapFormat());
RenderedImageMap imageMap = this.rasterMapProducer.produceMap(map);
BufferedImage image = (BufferedImage) imageMap.getImage();
imageMap.dispose();
assertNotBlank("densify", image);
ArgumentCaptor<Shape> shape = ArgumentCaptor.forClass(Shape.class);
Mockito.verify(graphics).draw(shape.capture());
LiteShape2 drawnShape = (LiteShape2) shape.getValue();
assertEquals(64, drawnShape.getGeometry().getCoordinates().length);
}
@Test
public void testWrappingHeuristic() throws Exception {
WMS wms = getWMS();
WMSInfo info = wms.getServiceInfo();
info.getMetadata().put(WMS.DATELINE_WRAPPING_HEURISTIC_KEY, false);
getGeoServer().save(info);
Graphics2D graphics = Mockito.mock(Graphics2D.class);
this.rasterMapProducer = new DummyRasterMapProducer(wms);
((DummyRasterMapProducer) this.rasterMapProducer).setGraphics(graphics);
Catalog catalog = getCatalog();
final FeatureSource fs =
catalog.getFeatureTypeByName(
CROSS_DATELINE.getPrefix(), CROSS_DATELINE.getLocalPart())
.getFeatureSource(null, null);
final ReferencedEnvelope env =
new ReferencedEnvelope(-150, 150, -30, 30, DefaultGeographicCRS.WGS84);
GetMapRequest request = new GetMapRequest();
final WMSMapContent map = new WMSMapContent();
map.getViewport().setBounds(env);
map.setMapWidth(300);
map.setMapHeight(300);
map.setBgColor(Color.red);
map.setTransparent(false);
map.setRequest(request);
StyleInfo styleByName = catalog.getStyleByName(STRAIGHT_VERTICAL_LINE_STYLE);
Style basicStyle = styleByName.getStyle();
map.addLayer(new FeatureLayer(fs, basicStyle));
request.setFormat(getMapFormat());
RenderedImageMap imageMap = this.rasterMapProducer.produceMap(map);
BufferedImage image = (BufferedImage) imageMap.getImage();
imageMap.dispose();
assertNotBlank("dateline_heuristic", image);
ArgumentCaptor<Shape> shape = ArgumentCaptor.forClass(Shape.class);
Mockito.verify(graphics).draw(shape.capture());
LiteShape2 drawnShape = (LiteShape2) shape.getValue();
assertTrue(drawnShape.getGeometry() instanceof MultiLineString);
}
@Test
public void testDisabledWrappingHeuristic() throws Exception {
WMS wms = getWMS();
WMSInfo info = wms.getServiceInfo();
info.getMetadata().put(WMS.DATELINE_WRAPPING_HEURISTIC_KEY, true);
getGeoServer().save(info);
Graphics2D graphics = Mockito.mock(Graphics2D.class);
this.rasterMapProducer = new DummyRasterMapProducer(wms);
((DummyRasterMapProducer) this.rasterMapProducer).setGraphics(graphics);
Catalog catalog = getCatalog();
final FeatureSource fs =
catalog.getFeatureTypeByName(
CROSS_DATELINE.getPrefix(), CROSS_DATELINE.getLocalPart())
.getFeatureSource(null, null);
final ReferencedEnvelope env =
new ReferencedEnvelope(-150, 150, -30, 30, DefaultGeographicCRS.WGS84);
GetMapRequest request = new GetMapRequest();
final WMSMapContent map = new WMSMapContent();
map.getViewport().setBounds(env);
map.setMapWidth(300);
map.setMapHeight(300);
map.setBgColor(Color.red);
map.setTransparent(false);
map.setRequest(request);
StyleInfo styleByName = catalog.getStyleByName(STRAIGHT_VERTICAL_LINE_STYLE);
Style basicStyle = styleByName.getStyle();
map.addLayer(new FeatureLayer(fs, basicStyle));
request.setFormat(getMapFormat());
RenderedImageMap imageMap = this.rasterMapProducer.produceMap(map);
BufferedImage image = (BufferedImage) imageMap.getImage();
imageMap.dispose();
assertNotBlank("dateline_heuristic", image);
ArgumentCaptor<Shape> shape = ArgumentCaptor.forClass(Shape.class);
Mockito.verify(graphics).draw(shape.capture());
LiteShape2 drawnShape = (LiteShape2) shape.getValue();
assertTrue(drawnShape.getGeometry() instanceof LineString);
}
@Test
public void testDisabledWrappingHeuristicWithFormatOption() throws Exception {
Graphics2D graphics = Mockito.mock(Graphics2D.class);
this.rasterMapProducer = new DummyRasterMapProducer(getWMS());
((DummyRasterMapProducer) this.rasterMapProducer).setGraphics(graphics);
Catalog catalog = getCatalog();
final FeatureSource fs =
catalog.getFeatureTypeByName(
CROSS_DATELINE.getPrefix(), CROSS_DATELINE.getLocalPart())
.getFeatureSource(null, null);
final ReferencedEnvelope env =
new ReferencedEnvelope(-150, 150, -30, 30, DefaultGeographicCRS.WGS84);
GetMapRequest request = new GetMapRequest();
request.getFormatOptions().put("disableDatelineWrappingHeuristic", "true");
final WMSMapContent map = new WMSMapContent();
map.getViewport().setBounds(env);
map.setMapWidth(300);
map.setMapHeight(300);
map.setBgColor(Color.red);
map.setTransparent(false);
map.setRequest(request);
StyleInfo styleByName = catalog.getStyleByName(STRAIGHT_VERTICAL_LINE_STYLE);
Style basicStyle = styleByName.getStyle();
map.addLayer(new FeatureLayer(fs, basicStyle));
request.setFormat(getMapFormat());
RenderedImageMap imageMap = this.rasterMapProducer.produceMap(map);
BufferedImage image = (BufferedImage) imageMap.getImage();
imageMap.dispose();
assertNotBlank("dateline_heuristic", image);
ArgumentCaptor<Shape> shape = ArgumentCaptor.forClass(Shape.class);
Mockito.verify(graphics).draw(shape.capture());
LiteShape2 drawnShape = (LiteShape2) shape.getValue();
assertTrue(drawnShape.getGeometry() instanceof LineString);
}
@Test
public void testAdvancedProjectionWithoutDensification() throws Exception {
WMS wms = getWMS();
WMSInfo info = wms.getServiceInfo();
info.getMetadata().put(WMS.ADVANCED_PROJECTION_DENSIFICATION_KEY, false);
getGeoServer().save(info);
Graphics2D graphics = Mockito.mock(Graphics2D.class);
this.rasterMapProducer = new DummyRasterMapProducer(wms);
((DummyRasterMapProducer) this.rasterMapProducer).setGraphics(graphics);
Catalog catalog = getCatalog();
final FeatureSource fs =
catalog.getFeatureTypeByName(
STRAIGHT_VERTICAL_LINE.getPrefix(),
STRAIGHT_VERTICAL_LINE.getLocalPart())
.getFeatureSource(null, null);
final ReferencedEnvelope env =
new ReferencedEnvelope(10, 15, 0, 50, DefaultGeographicCRS.WGS84);
CoordinateReferenceSystem utm32 = CRS.decode("EPSG:32632");
ReferencedEnvelope targetEnv = env.transform(utm32, true);
GetMapRequest request = new GetMapRequest();
final WMSMapContent map = new WMSMapContent();
map.getViewport().setBounds(targetEnv);
map.getViewport().setCoordinateReferenceSystem(utm32);
map.setMapWidth(300);
map.setMapHeight(300);
map.setBgColor(Color.red);
map.setTransparent(false);
map.setRequest(request);
StyleInfo styleByName = catalog.getStyleByName(STRAIGHT_VERTICAL_LINE_STYLE);
Style basicStyle = styleByName.getStyle();
map.addLayer(new FeatureLayer(fs, basicStyle));
request.setFormat(getMapFormat());
RenderedImageMap imageMap = this.rasterMapProducer.produceMap(map);
BufferedImage image = (BufferedImage) imageMap.getImage();
imageMap.dispose();
assertNotBlank("densify", image);
ArgumentCaptor<Shape> shape = ArgumentCaptor.forClass(Shape.class);
Mockito.verify(graphics).draw(shape.capture());
LiteShape2 drawnShape = (LiteShape2) shape.getValue();
assertEquals(2, drawnShape.getGeometry().getCoordinates().length);
}
/**
* 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
......@@ -461,6 +742,22 @@ public class RenderedImageMapOutputFormatTest extends WMSTestSupport {
super.onSetUp(testData);
testData.addDefaultRasterLayer(MockData.TASMANIA_DEM, getCatalog());
testData.addRasterLayer(TAZ_BYTE, "tazbyte.tiff", null, getCatalog());
testData.addStyle(
STRAIGHT_VERTICAL_LINE_STYLE, "verticalline.sld", getClass(), getCatalog());
Map properties = new HashMap();
properties.put(MockData.KEY_STYLE, STRAIGHT_VERTICAL_LINE_STYLE);
testData.addVectorLayer(
STRAIGHT_VERTICAL_LINE,
properties,
"VerticalLine.properties",
getClass(),
getCatalog());
testData.addStyle(CROSS_DATELINE_STYLE, "crossline.sld", getClass(), getCatalog());
properties = new HashMap();
properties.put(MockData.KEY_STYLE, CROSS_DATELINE_STYLE);
testData.addVectorLayer(
CROSS_DATELINE, properties, "CrossLine.properties", getClass(), getCatalog());
}
@Test
......@@ -1280,8 +1577,26 @@ public class RenderedImageMapOutputFormatTest extends WMSTestSupport {
*/
static class DummyRasterMapProducer extends RenderedImageMapOutputFormat {
Graphics2D graphics = null;