List<InternalFeature> features = response.getFeatures();
log.debug("Get features, was {}", features);
if (null == features) {
features = new ArrayList<InternalFeature>();
response.setFeatures(features);
VectorLayer layer = context.get(PipelineCode.LAYER_KEY, VectorLayer.class);
Filter filter = context.get(PipelineCode.FILTER_KEY, Filter.class);
int offset = context.get(PipelineCode.OFFSET_KEY, Integer.class);
int maxResultSize = context.get(PipelineCode.MAX_RESULT_SIZE_KEY, Integer.class);
int featureIncludes = context.get(PipelineCode.FEATURE_INCLUDES_KEY, Integer.class);
NamedStyleInfo style = context.get(PipelineCode.STYLE_KEY, NamedStyleInfo.class);
CrsTransform transformation = context.getOptional(PipelineCode.CRS_TRANSFORM_KEY, CrsTransform.class);
List<StyleFilter> styleFilters = context.getOptional(GetFeaturesStyleStep.STYLE_FILTERS_KEY, List.class);
if (log.isDebugEnabled()) {
log.debug("getElements " + filter + ", offset = " + offset + ", maxResultSize= " + maxResultSize);
}
Envelope bounds = null;
Iterator<?> it = layer.getElements(filter, 0, 0); // do not limit result here, security needs to be applied
int count = 0;
while (it.hasNext()) {
log.debug("process feature");
Object featureObj = it.next();
Geometry geometry = layer.getFeatureModel().getGeometry(featureObj);
InternalFeature feature = convertFeature(featureObj, geometry, layer, transformation,
styleFilters, style.getLabelStyle(), featureIncludes);
if (null != feature) {
count++;
if (count > offset) {
features.add(feature);
if (null != geometry) {
Envelope envelope = geometry.getEnvelopeInternal();
if (null == bounds) {
bounds = new Envelope();
}
bounds.expandToInclude(envelope);
}
if (features.size() == maxResultSize) {
break;
}
}
} else {
if (log.isDebugEnabled()) {
log.debug("feature not visible {}", layer.getFeatureModel().getId(featureObj));
}
}
}
response.setBounds(bounds);
}