// basic information about the request
int width = getMapReq.getWidth();
int height = getMapReq.getHeight();
ReferencedEnvelope bbox = new ReferencedEnvelope(getMapReq.getBbox(), getMapReq.getCrs());
double scaleDenominator = RendererUtilities.calculateOGCScale(bbox, width, new HashMap());
FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(GeoTools.getDefaultHints());
final int layerCount = requestedLayers.length;
results = new ArrayList<FeatureCollection<? extends FeatureType,? extends Feature>>(layerCount);
metas = new ArrayList<MapLayerInfo>(layerCount);
try {
for (int i = 0; i < layerCount; i++) {
List<Rule> rules = getActiveRules(styles[i], scaleDenominator);
if(rules.size() == 0)
continue;
MapLayerInfo layerInfo = requestedLayers[i];
if (layerInfo.getType() == MapLayerInfo.TYPE_VECTOR) {
CoordinateReferenceSystem dataCRS = layerInfo.getCoordinateReferenceSystem();
// compute the request radius
double radius;
if(buffer <= 0) {
// estimate the radius given the currently active rules
MetaBufferEstimator estimator = new MetaBufferEstimator();
for (Rule rule : rules) {
rule.accept(estimator);
}
if(estimator.getBuffer() < 6.0 || !estimator.isEstimateAccurate()) {
radius = 3.0;
} else {
radius = estimator.getBuffer() / 2.0;
}
} else {
radius = buffer;
}
// make sure we don't go overboard, the admin might have set a maximum
int maxRadius = request.getWMS().getMaxBuffer();
if(maxRadius > 0 && radius > maxRadius)
radius = maxRadius;
Polygon pixelRect = getEnvelopeFilter(x, y, width, height, bbox, radius);
if ((requestedCRS != null) && !CRS.equalsIgnoreMetadata(dataCRS, requestedCRS)) {
try {
MathTransform transform = CRS.findMathTransform(requestedCRS, dataCRS, true);
pixelRect = (Polygon) JTS.transform(pixelRect, transform); // reprojected
} catch (MismatchedDimensionException e) {
LOGGER.severe(e.getLocalizedMessage());
} catch (TransformException e) {
LOGGER.severe(e.getLocalizedMessage());
} catch (FactoryException e) {
LOGGER.severe(e.getLocalizedMessage());
}
}
final FeatureSource<? extends FeatureType, ? extends Feature> featureSource;
featureSource = layerInfo.getFeatureSource(false);
FeatureType schema = featureSource.getSchema();
Filter getFInfoFilter = null;
try {
GeometryDescriptor geometryDescriptor = schema.getGeometryDescriptor();
String localName = geometryDescriptor.getLocalName();
getFInfoFilter = ff.intersects(ff.property(localName), ff.literal(pixelRect));
} catch (IllegalFilterException e) {
e.printStackTrace();
throw new WmsException(null, "Internal error : " + e.getMessage());
}
// include the eventual layer definition filter
if (filters[i] != null) {
getFInfoFilter = ff.and(getFInfoFilter, filters[i]);
}
// see if we can include the rule filters as well, if too many we'll do them in memory
Filter postFilter = Filter.INCLUDE;
Filter rulesFilters = buildRulesFilter(ff, rules);
if(!(rulesFilters instanceof Or) ||
(rulesFilters instanceof Or && ((Or) rulesFilters).getChildren().size() <= 20)) {
getFInfoFilter = ff.and(getFInfoFilter, rulesFilters);
} else {
postFilter = rulesFilters;
}
String typeName = schema.getName().getLocalPart();