use of org.geotools.renderer.ScreenMap in project GeoGig by boundlessgeo.
the class GeogigFeatureSource method getReaderInternal.
@Override
protected FeatureReader<SimpleFeatureType, SimpleFeature> getReaderInternal(final Query query) throws IOException {
FeatureReader<SimpleFeatureType, SimpleFeature> reader;
final boolean naturalOrder = isNaturalOrder(query.getSortBy());
final int startIndex = Optional.fromNullable(query.getStartIndex()).or(Integer.valueOf(0));
final Integer maxFeatures = query.getMaxFeatures() == Integer.MAX_VALUE ? null : query.getMaxFeatures();
final Filter filter = query.getFilter();
final ScreenMap screenMap = (ScreenMap) query.getHints().get(Hints.SCREENMAP);
final String[] propertyNames = query.getPropertyNames();
if (naturalOrder) {
reader = getNativeReader(propertyNames, filter, startIndex, maxFeatures, screenMap);
} else {
reader = getNativeReader(propertyNames, filter, null, null, screenMap);
// sorting
reader = new SortedFeatureReader(DataUtilities.simple(reader), query);
if (startIndex > 0) {
// skip the first n records
for (int i = 0; i < startIndex && reader.hasNext(); i++) {
reader.next();
}
}
if (maxFeatures != null && maxFeatures > 0) {
reader = new MaxFeatureReader<SimpleFeatureType, SimpleFeature>(reader, maxFeatures);
}
}
return reader;
}
use of org.geotools.renderer.ScreenMap in project GeoGig by boundlessgeo.
the class GeogigFeatureSource method getCountInternal.
@Override
protected int getCountInternal(Query query) throws IOException {
final Filter filter = (Filter) query.getFilter().accept(new SimplifyingFilterVisitor(), null);
if (Filter.EXCLUDE.equals(filter)) {
return 0;
}
final Integer offset = query.getStartIndex();
final Integer maxFeatures = query.getMaxFeatures() == Integer.MAX_VALUE ? null : query.getMaxFeatures();
int size;
if (Filter.INCLUDE.equals(filter) && oldRoot == null && ChangeType.ADDED.equals(changeType())) {
RevTree tree = getTypeTree();
size = (int) tree.size();
if (offset != null) {
size = size - offset.intValue();
}
if (maxFeatures != null) {
size = Math.min(size, maxFeatures.intValue());
}
return size;
}
FeatureReader<SimpleFeatureType, SimpleFeature> features;
if (isNaturalOrder(query.getSortBy())) {
ScreenMap screenMap = (ScreenMap) query.getHints().get(Hints.SCREENMAP);
features = getNativeReader(Query.NO_NAMES, filter, offset, maxFeatures, screenMap);
} else {
features = getReader(query);
}
int count = 0;
try {
while (features.hasNext()) {
features.next();
count++;
}
} finally {
features.close();
}
return count;
}
use of org.geotools.renderer.ScreenMap in project GeoGig by boundlessgeo.
the class GeogigFeatureSource method getBoundsInternal.
@Override
protected ReferencedEnvelope getBoundsInternal(Query query) throws IOException {
final Filter filter = (Filter) query.getFilter().accept(new SimplifyingFilterVisitor(), null);
final CoordinateReferenceSystem crs = getSchema().getCoordinateReferenceSystem();
if (Filter.INCLUDE.equals(filter) && oldRoot == null && ChangeType.ADDED.equals(changeType())) {
NodeRef typeRef = getTypeRef();
ReferencedEnvelope bounds = new ReferencedEnvelope(crs);
typeRef.getNode().expand(bounds);
return bounds;
}
if (Filter.EXCLUDE.equals(filter)) {
return ReferencedEnvelope.create(crs);
}
FeatureReader<SimpleFeatureType, SimpleFeature> features;
if (isNaturalOrder(query.getSortBy())) {
Integer offset = query.getStartIndex();
Integer maxFeatures = query.getMaxFeatures() == Integer.MAX_VALUE ? null : query.getMaxFeatures();
ScreenMap screenMap = (ScreenMap) query.getHints().get(Hints.SCREENMAP);
features = getNativeReader(Query.NO_NAMES, filter, offset, maxFeatures, screenMap);
} else {
features = getReader(query);
}
ReferencedEnvelope bounds = new ReferencedEnvelope(crs);
try {
while (features.hasNext()) {
bounds.expandToInclude((ReferencedEnvelope) features.next().getBounds());
}
} finally {
features.close();
}
return bounds;
}
Aggregations