Commit 51761d3a authored by Steve Ikeoka's avatar Steve Ikeoka
Browse files

[GEOS-6977] Fixed WCS 1.0.0 KVP ignoring custom dimension parameters.

parent a138433c
......@@ -14,6 +14,7 @@ import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import net.opengis.gml.CodeType;
import net.opengis.gml.DirectPositionType;
import net.opengis.gml.Gml4wcsFactory;
......@@ -34,6 +35,9 @@ import net.opengis.wcs10.TimeSequenceType;
import net.opengis.wcs10.TypedLiteralType;
import net.opengis.wcs10.Wcs10Factory;
import org.geoserver.catalog.Catalog;
import org.geoserver.catalog.CoverageInfo;
import org.geoserver.catalog.DimensionInfo;
import org.geoserver.catalog.ResourceInfo;
import org.geoserver.ows.kvp.EMFKvpRequestReader;
import org.geoserver.ows.util.KvpUtils;
import org.geoserver.ows.util.KvpUtils.Tokenizer;
......@@ -390,6 +394,27 @@ public class Wcs10GetCoverageRequestReader extends EMFKvpRequestReader {
} else checkTypeAxisRange(rangeSubset, axis, "ELEVATION");
}
// check for custom dimensions
CoverageInfo coverage = this.catalog.getCoverageByName(coverageName);
if (coverage != null) {
for (Entry<String, ?> entry : coverage.getMetadata().entrySet()) {
String name = entry.getKey();
if (name.startsWith(ResourceInfo.CUSTOM_DIMENSION_PREFIX)
&& entry.getValue() instanceof DimensionInfo
&& ((DimensionInfo) entry.getValue()).isEnabled()) {
name = name.substring(ResourceInfo.CUSTOM_DIMENSION_PREFIX.length());
Object value = kvp.get(name);
// ignore anything that got converted by a KVP parser so that they
// are only handled as keywords and not as a custom dimension since
// WCS 1.0.0 does not define away to avoid these name clashes.
if (value instanceof String) {
name = name.toUpperCase();
checkTypeAxisRange(rangeSubset, Arrays.asList(value), name);
}
}
}
}
return rangeSubset;
}
......
......@@ -56,6 +56,20 @@ public class CustomDimensionsTest extends CoverageTestSupport {
assertNull(image);
}
@Test
public void testGetCoverageKVPBadValue() throws Exception {
// check that we get no data when requesting an incorrect value for custom dimension
String request = getWaterTempRequestKVP("bad_dimension_value");
MockHttpServletResponse response = getAsServletResponse(request);
BufferedImage image = ImageIO.read(getBinaryInputStream(response));
assertNull(image);
request = request.replace(DIMENSION_NAME, DIMENSION_NAME.toLowerCase());
response = getAsServletResponse(request);
image = ImageIO.read(getBinaryInputStream(response));
assertNull(image);
}
@Test
public void testGetCoverageGoodValue() throws Exception {
// check that we get data when requesting a correct value for custom dimension
......@@ -72,6 +86,30 @@ public class CustomDimensionsTest extends CoverageTestSupport {
assertEquals("image/tiff", response.getContentType());
}
@Test
public void testGetCoverageKVPGoodValue() throws Exception {
// check that we get data when requesting a correct value for custom dimension
String request = getWaterTempRequestKVP("CustomDimValueA");
MockHttpServletResponse response = getAsServletResponse(request);
BufferedImage image = ImageIO.read(getBinaryInputStream(response));
assertNotNull(image);
assertEquals("image/tiff", response.getContentType());
request = request.replace(DIMENSION_NAME, DIMENSION_NAME.toLowerCase());
response = getAsServletResponse(request);
image = ImageIO.read(getBinaryInputStream(response));
assertNotNull(image);
assertEquals("image/tiff", response.getContentType());
}
private String getWaterTempRequestKVP(String dimensionValue) {
String url =
"wcs?service=WCS&version=1.0.0&request=GetCoverage"
+ "&sourceCoverage=%s&format=GEOTIFF&width=25&height=24"
+ "&crs=EPSG:4326&bbox=0.237,40.562,14.593,44.558&%s=%s";
return String.format(url, getLayerId(CUST_WATTEMP), DIMENSION_NAME, dimensionValue);
}
private String getWaterTempRequest(String dimensionValue) {
String request =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
......
......@@ -60,6 +60,20 @@ public class DynamicDimensionsTest extends CoverageTestSupport {
assertNull(image);
}
@Test
public void testGetCoverageKVPBadValue() throws Exception {
// check that we get no data when requesting an incorrect value for custom dimension
String request = getWaterTempRequestKVP("bad_dimension_value");
MockHttpServletResponse response = getAsServletResponse(request);
BufferedImage image = ImageIO.read(getBinaryInputStream(response));
assertNull(image);
request = request.replace(DIMENSION_NAME, DIMENSION_NAME.toUpperCase());
response = getAsServletResponse(request);
image = ImageIO.read(getBinaryInputStream(response));
assertNull(image);
}
@Test
public void testGetCoverageGoodValue() throws Exception {
// check that we get data when requesting a correct value for custom dimension
......@@ -76,6 +90,30 @@ public class DynamicDimensionsTest extends CoverageTestSupport {
assertEquals("image/tiff", response.getContentType());
}
@Test
public void testGetCoverageKVPGoodValue() throws Exception {
// check that we get data when requesting a correct value for custom dimension
String request = getWaterTempRequestKVP("100");
MockHttpServletResponse response = getAsServletResponse(request);
BufferedImage image = ImageIO.read(getBinaryInputStream(response));
assertNotNull(image);
assertEquals("image/tiff", response.getContentType());
request = request.replace(DIMENSION_NAME, DIMENSION_NAME.toUpperCase());
response = getAsServletResponse(request);
image = ImageIO.read(getBinaryInputStream(response));
assertNotNull(image);
assertEquals("image/tiff", response.getContentType());
}
private String getWaterTempRequestKVP(String dimensionValue) {
String url =
"wcs?service=WCS&version=1.0.0&request=GetCoverage"
+ "&sourceCoverage=%s&format=GEOTIFF&width=25&height=24"
+ "&crs=EPSG:4326&bbox=0.237,40.562,14.593,44.558&%s=%s";
return String.format(url, getLayerId(WATTEMP), DIMENSION_NAME, dimensionValue);
}
private String getWaterTempRequest(String dimensionValue) {
String request =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
......
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