features.accepts(new AbstractFeatureVisitor() {
public void visit(Feature feature) {
if (feature instanceof SimpleFeature) {
// get the feature
final SimpleFeature sf = (SimpleFeature) feature;
GranuleDescriptor granule = null;
// caching by granule's location
// synchronized (descriptorsCache) {
String featureId = sf.getID();
if(descriptorsCache.containsKey(featureId)){
granule = descriptorsCache.get(featureId);
} else{
// create the granule descriptor
MultiLevelROI footprint = getGranuleFootprint(sf);
if(footprint == null || !footprint.isEmpty()) {
// caching only if the footprint is eithery absent or present and NON-empty
granule = new GranuleDescriptor(
sf,
adaptee.suggestedRasterSPI,
adaptee.pathType,
adaptee.locationAttribute,
adaptee.parentLocation,
footprint,
adaptee.heterogeneous,
adaptee.hints); // retain hints since this may contain a reader or anything
descriptorsCache.put(featureId, granule);
}
}
if(granule != null) {
// check ROI inclusion
final Geometry footprint = granule.getFootprint();
if(intersectionGeometry==null||footprint==null||polygonOverlap(footprint, intersectionGeometry)){
visitor.visit(granule, null);
}else{
if(LOGGER.isLoggable(Level.FINE)){
LOGGER.fine("Skipping granule "+granule+"\n since its ROI does not intersect the requested area");