use of org.geotools.feature.visitor.MaxVisitor in project geowave by locationtech.
the class GeoWaveFeatureReaderTest method testMax.
@Test
public void testMax() throws IllegalArgumentException, NoSuchElementException, IOException {
final FeatureReader<SimpleFeatureType, SimpleFeature> reader = dataStore.getFeatureReader(query, Transaction.AUTO_COMMIT);
final MaxVisitor visitor = new MaxVisitor("start", type);
unwrapDelegatingFeatureReader(reader).getFeatureCollection().accepts(visitor, null);
assertTrue(visitor.getMax().equals(mtime));
}
use of org.geotools.feature.visitor.MaxVisitor in project incubator-rya by apache.
the class GeoWaveFeatureReaderTest method testMax.
@Test
public void testMax() throws IllegalArgumentException, NoSuchElementException, IOException {
final FeatureReader<SimpleFeatureType, SimpleFeature> reader = dataStore.getFeatureReader(query, Transaction.AUTO_COMMIT);
final MaxVisitor visitor = new MaxVisitor("start", type);
unwrapDelegatingFeatureReader(reader).getFeatureCollection().accepts(visitor, null);
assertTrue(visitor.getMax().equals(etime));
}
use of org.geotools.feature.visitor.MaxVisitor in project geowave by locationtech.
the class GeoWaveGTPluginUtils method accepts.
protected static boolean accepts(final DataStatisticsStore statisticsStore, final DataTypeAdapter<?> adapter, final org.opengis.feature.FeatureVisitor visitor, final org.opengis.util.ProgressListener progress, final SimpleFeatureType featureType) throws IOException {
if ((visitor instanceof MinVisitor)) {
final ExtractAttributesFilter filter = new ExtractAttributesFilter();
final MinVisitor minVisitor = (MinVisitor) visitor;
final Collection<String> attrs = (Collection<String>) minVisitor.getExpression().accept(filter, null);
int acceptedCount = 0;
final Map<String, List<FieldStatistic<?>>> adapterFieldStatistics = getFieldStats(statisticsStore, adapter);
for (final String attr : attrs) {
if (!adapterFieldStatistics.containsKey(attr)) {
continue;
}
for (final FieldStatistic<?> stat : adapterFieldStatistics.get(attr)) {
if ((stat instanceof TimeRangeStatistic) && (stat.getBinningStrategy() == null)) {
final TimeRangeValue statValue = statisticsStore.getStatisticValue((TimeRangeStatistic) stat);
if (statValue != null) {
minVisitor.setValue(convertToType(attr, new Date(statValue.getMin()), featureType));
acceptedCount++;
}
} else if (stat instanceof NumericRangeStatistic) {
try (CloseableIterator<NumericRangeValue> values = statisticsStore.getStatisticValues((NumericRangeStatistic) stat)) {
NumericRangeValue statValue = ((NumericRangeStatistic) stat).createEmpty();
while (values.hasNext()) {
statValue.merge(values.next());
}
if (statValue.isSet()) {
minVisitor.setValue(convertToType(attr, statValue.getMin(), featureType));
acceptedCount++;
}
}
}
}
}
if (acceptedCount > 0) {
if (progress != null) {
progress.complete();
}
return true;
}
} else if ((visitor instanceof MaxVisitor)) {
final ExtractAttributesFilter filter = new ExtractAttributesFilter();
final MaxVisitor maxVisitor = (MaxVisitor) visitor;
final Collection<String> attrs = (Collection<String>) maxVisitor.getExpression().accept(filter, null);
int acceptedCount = 0;
final Map<String, List<FieldStatistic<?>>> adapterFieldStatistics = getFieldStats(statisticsStore, adapter);
for (final String attr : attrs) {
for (final FieldStatistic<?> stat : adapterFieldStatistics.get(attr)) {
if ((stat instanceof TimeRangeStatistic) && (stat.getBinningStrategy() == null)) {
final TimeRangeValue statValue = statisticsStore.getStatisticValue((TimeRangeStatistic) stat);
if (statValue != null) {
maxVisitor.setValue(convertToType(attr, new Date(statValue.getMax()), featureType));
acceptedCount++;
}
} else if (stat instanceof NumericRangeStatistic) {
try (CloseableIterator<NumericRangeValue> values = statisticsStore.getStatisticValues((NumericRangeStatistic) stat)) {
NumericRangeValue statValue = ((NumericRangeStatistic) stat).createEmpty();
while (values.hasNext()) {
statValue.merge(values.next());
}
if (statValue.isSet()) {
maxVisitor.setValue(convertToType(attr, statValue.getMax(), featureType));
acceptedCount++;
}
}
}
}
}
if (acceptedCount > 0) {
if (progress != null) {
progress.complete();
}
return true;
}
}
return false;
}
Aggregations