Commit 381d86c5 authored by Andrea Aime's avatar Andrea Aime
Browse files

Merge pull request #1075 from mbarto/27x_geos7020_more_fix

GEOS-7020: additional fix to avoid overflows of hitArea outside of pa…
parents 38d7d11f 2cd480bd
......@@ -137,7 +137,7 @@ public class VectorRenderingLayerIdentifier extends AbstractVectorLayerIdentifie
final Style style = preprocessStyle(params.getStyle(), params.getLayer().getFeature().getFeatureType());
final int userBuffer = params.getBuffer() > 0 ? params.getBuffer() : MIN_BUFFER_SIZE;
final int buffer = Math.min(userBuffer, wms.getMaxBuffer());
final int buffer = getBuffer(userBuffer);
// check the style to see what's active
final List<Rule> rules = getActiveRules(style, params.getScaleDenominator());
......@@ -186,6 +186,9 @@ public class VectorRenderingLayerIdentifier extends AbstractVectorLayerIdentifie
// and now the listener that will check for painted pixels
int mid = radius;
int hitAreaSize = buffer * 2 + 1;
if(hitAreaSize > paintAreaSize) {
hitAreaSize = paintAreaSize;
}
Rectangle hitArea = new Rectangle(mid - buffer, mid - buffer, hitAreaSize, hitAreaSize);
final FeatureInfoRenderListener featureInfoListener = new FeatureInfoRenderListener(
image, hitArea, maxFeatures, params.getPropertyNames());
......@@ -206,6 +209,10 @@ public class VectorRenderingLayerIdentifier extends AbstractVectorLayerIdentifie
}
}
protected int getBuffer(final int userBuffer) {
return Math.min(userBuffer, wms.getMaxBuffer());
}
protected GetMapOutputFormat createMapOutputFormat(final BufferedImage image,
final FeatureInfoRenderListener featureInfoListener) {
return new RenderedImageMapOutputFormat(wms) {
......
......@@ -80,6 +80,53 @@ public class RenderingBasedFeatureInfoTest extends WMSTestSupport {
VectorRenderingLayerIdentifier.RENDERING_FEATUREINFO_ENABLED = true;
}
/**
* Test hitArea does not overflow out of painted area.
* @throws Exception
*/
@Test
public void testHitAreaSize() throws Exception {
int mapWidth = 100;
int mapHeight = 100;
Envelope mapbbox = new Envelope(0.0001955, 0.0002035, 0.000696, 0.000704);
VectorRenderingLayerIdentifier vrli = new VectorRenderingLayerIdentifier(getWMS(), null) {
@Override
protected int getBuffer(int userBuffer) {
return 3;
}
};
GetFeatureInfoRequest request = new GetFeatureInfoRequest();
GetMapRequest getMapRequest = new GetMapRequest();
List<MapLayerInfo> layers = new ArrayList<MapLayerInfo>();
layers.add(new MapLayerInfo(getCatalog().getLayerByName(
MockData.BRIDGES.getLocalPart())));
getMapRequest.setLayers(layers);
getMapRequest.setSRS("EPSG:4326");
getMapRequest.setBbox(mapbbox);
getMapRequest.setWidth(mapWidth);
getMapRequest.setFormat("image/png");
getMapRequest.setHeight(mapHeight);
request.setGetMapRequest(getMapRequest);
request.setQueryLayers(layers);
request.setXPixel(50);
request.setYPixel(50);
FeatureInfoRequestParameters params = new FeatureInfoRequestParameters(request);
assertEquals(0, vrli.identify(params, 10).size());
}
@Test
public void testBoxOffset() throws Exception {
// try the old way clicking in the area of the symbol that is transparent
......
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