Commit 2fcba726 authored by Steve Ikeoka's avatar Steve Ikeoka
Browse files

[GEOS-9148] Fixed NPE for WCS 1.0.0 GetCoverage requests that do not intersect...

[GEOS-9148] Fixed NPE for WCS 1.0.0 GetCoverage requests that do not intersect the coverage bounding box.
parent 791f8ed3
......@@ -614,9 +614,14 @@ public class DefaultWebCoverageService100 implements WebCoverageService100 {
//
// compute intersection envelope to be used
GeneralEnvelope destinationEnvelope =
(GeneralEnvelope)
getHorizontalEnvelope(
computeIntersectionEnvelope(requestedEnvelope, nativeEnvelope));
computeIntersectionEnvelope(requestedEnvelope, nativeEnvelope);
if (destinationEnvelope == null) {
throw new WcsException(
"The request bbox is outside of the coverage area",
InvalidParameterValue,
"bbox");
}
destinationEnvelope = (GeneralEnvelope) getHorizontalEnvelope(destinationEnvelope);
if (targetCRS != null) {
destinationEnvelope = CRS.transform(destinationEnvelope, targetCRS);
destinationEnvelope.setCoordinateReferenceSystem(targetCRS);
......
......@@ -5,8 +5,10 @@
*/
package org.geoserver.wcs;
import static org.custommonkey.xmlunit.XMLAssert.assertXpathEvaluatesTo;
import static org.geoserver.data.test.MockData.TASMANIA_BM;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
......@@ -364,6 +366,22 @@ public class GetCoverageTest extends WCSTestSupport {
return service.getCoverage(getCoverage);
}
@Test
public void testBboxOutsideCoverage() throws Exception {
String queryString =
"&request=getcoverage&service=wcs&version=1.0.0&format=image/geotiff"
+ "&bbox=-147,44,-146,45&crs=EPSG:4326&width=150&height=150";
Document dom = getAsDOM("wcs?sourcecoverage=" + getLayerId(TASMANIA_BM) + queryString);
// print(dom);
assertEquals("ServiceExceptionReport", dom.getDocumentElement().getNodeName());
String error =
xpath.evaluate("/ServiceExceptionReport/ServiceException/text()", dom).trim();
assertThat(error, not(containsString("Exception")));
assertXpathEvaluatesTo(
"InvalidParameterValue", "/ServiceExceptionReport/ServiceException/@code", dom);
assertXpathEvaluatesTo("bbox", "/ServiceExceptionReport/ServiceException/@locator", dom);
}
@Test
public void testInputLimits() throws Exception {
try {
......
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