Commit 31b57200 authored by Mauro Bartolomeoli's avatar Mauro Bartolomeoli
Browse files

GEOS-7022: fixes WMS GetMap interpolations behavior for layer groups

parent ec1245cb
......@@ -260,7 +260,7 @@ public class GetMapKvpRequestReader extends KvpRequestReader implements HttpServ
}
if(interpolationList.size() > 0) {
getMap.setInterpolations(parseInterpolations(interpolationList));
getMap.setInterpolations(parseInterpolations(requestedLayerInfos, interpolationList));
}
// pre parse filters
......@@ -506,22 +506,40 @@ public class GetMapKvpRequestReader extends KvpRequestReader implements HttpServ
return getMap;
}
private List<Interpolation> parseInterpolations(List<String> interpolationList) {
private List<Interpolation> parseInterpolations(List<Object> requestedLayers,
List<String> interpolationList) {
List<Interpolation> interpolations = new ArrayList<Interpolation>();
for (String interpolation : interpolationList) {
if ("".equals(interpolation)) {
// return null, this should flag request reader to use default for
// the associated layer
interpolations.add(null);
for (int i = 0; i < requestedLayers.size(); i++) {
// null interpolation means:
// use the default WMS one
Interpolation interpolation = null;
if(i < interpolationList.size()) {
String interpolationName = interpolationList.get(i);
if(!interpolationName.trim().equals("")) {
interpolation = getInterpolationObject(interpolationName);
}
}
Object o = requestedLayers.get(i);
if (o instanceof LayerInfo) {
interpolations.add(interpolation);
} else if (o instanceof LayerGroupInfo) {
List<LayerInfo> subLayers = ((LayerGroupInfo) o).layers();
for (LayerInfo layer : subLayers) {
interpolations.add(interpolation);
}
} else {
interpolations.add(Interpolation.getInstance(interpolationMethods.get(interpolation
.toUpperCase())));
throw new IllegalArgumentException("Unknown layer info type: " + o);
}
}
return interpolations;
}
private Interpolation getInterpolationObject(String interpolation) {
return Interpolation.getInstance(interpolationMethods.get(interpolation
.toUpperCase()));
}
private Style getDefaultStyle (LayerInfo layer) throws IOException{
if (layer.getResource() instanceof WMSLayerInfo) {
......
......@@ -19,6 +19,7 @@ import java.util.TimeZone;
import javax.media.jai.InterpolationBicubic;
import javax.media.jai.InterpolationBilinear;
import javax.media.jai.InterpolationNearest;
import junit.framework.Test;
......@@ -70,6 +71,15 @@ public class GetMapKvpRequestReaderTest extends KvpRequestReaderTestSupport {
gi.getStyles().add(getCatalog().getStyleByName("polygon"));
cb.calculateLayerGroupBounds(gi);
getCatalog().add(gi);
LayerGroupInfo gi2 = cf.createLayerGroup();
gi2.setName("testGroup2");
gi2.getLayers().add(getCatalog().getLayerByName(MockData.BASIC_POLYGONS.getLocalPart()));
gi2.getStyles().add(getCatalog().getStyleByName("raster"));
gi2.getLayers().add(getCatalog().getLayerByName(MockData.BUILDINGS.getLocalPart()));
gi2.getStyles().add(getCatalog().getStyleByName("raster"));
cb.calculateLayerGroupBounds(gi2);
getCatalog().add(gi2);
}
@Override
......@@ -248,6 +258,54 @@ public class GetMapKvpRequestReaderTest extends KvpRequestReaderTestSupport {
assertTrue(request.getInterpolations().get(2) instanceof InterpolationBilinear);
}
public void testInterpolationsForLayerGroups() throws Exception {
HashMap kvp = new HashMap();
kvp.put("layers", "testGroup2");
kvp.put("interpolations", "bicubic");
GetMapRequest request = (GetMapRequest) reader.createRequest();
request = (GetMapRequest) reader.read(request, parseKvp(kvp), caseInsensitiveKvp(kvp));
assertNotNull(request.getInterpolations());
assertEquals(2, request.getInterpolations().size());
assertNotNull(request.getInterpolations().get(0));
assertTrue(request.getInterpolations().get(0) instanceof InterpolationBicubic);
assertNotNull(request.getInterpolations().get(1));
assertTrue(request.getInterpolations().get(1) instanceof InterpolationBicubic);
kvp.put("layers", "testGroup2,testGroup,"+getLayerId(MockData.BASIC_POLYGONS));
kvp.put("interpolations", "bicubic,bilinear,nearest neighbor");
request = (GetMapRequest) reader.createRequest();
request = (GetMapRequest) reader.read(request, parseKvp(kvp), caseInsensitiveKvp(kvp));
assertNotNull(request.getInterpolations());
assertEquals(4, request.getInterpolations().size());
assertNotNull(request.getInterpolations().get(0));
assertTrue(request.getInterpolations().get(0) instanceof InterpolationBicubic);
assertNotNull(request.getInterpolations().get(1));
assertTrue(request.getInterpolations().get(1) instanceof InterpolationBicubic);
assertNotNull(request.getInterpolations().get(2));
assertTrue(request.getInterpolations().get(2) instanceof InterpolationBilinear);
assertNotNull(request.getInterpolations().get(3));
assertTrue(request.getInterpolations().get(3) instanceof InterpolationNearest);
kvp.put("layers", "testGroup2,testGroup,"+getLayerId(MockData.BASIC_POLYGONS));
kvp.put("interpolations", ",bilinear");
request = (GetMapRequest) reader.createRequest();
request = (GetMapRequest) reader.read(request, parseKvp(kvp), caseInsensitiveKvp(kvp));
assertNotNull(request.getInterpolations());
assertEquals(4, request.getInterpolations().size());
assertNull(request.getInterpolations().get(0));
assertNull(request.getInterpolations().get(1));
assertNotNull(request.getInterpolations().get(2));
assertTrue(request.getInterpolations().get(2) instanceof InterpolationBilinear);
assertNull(request.getInterpolations().get(3));
}
public void testFilter() throws Exception {
HashMap kvp = new HashMap();
kvp.put("layers", getLayerId(MockData.BASIC_POLYGONS));
......
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