use of org.locationtech.geowave.core.geotime.util.TimeDescriptors in project geowave by locationtech.
the class VectorTimeRangeAggregation method getInterval.
@Override
protected Interval getInterval(final SimpleFeature entry) {
if ((fieldNameParam != null) && !fieldNameParam.isEmpty()) {
return TimeUtils.getInterval(entry, fieldNameParam.getFieldName());
}
final String type = entry.getType().getName().getLocalPart();
TimeDescriptors desc = descMap.get(type);
if (desc == null) {
desc = TimeUtils.inferTimeAttributeDescriptor(entry.getFeatureType());
descMap.put(type, desc);
}
if ((desc.getStartRange() != null) && (desc.getEndRange() != null)) {
final Object start = entry.getAttribute(desc.getStartRange().getName());
final Object end = entry.getAttribute(desc.getStartRange().getName());
if ((start == null) || (end == null)) {
LOGGER.warn("start or end value is null, ignoring feature");
return null;
}
// TODO we may want to sanity check that start is less than end?
return Interval.of(Instant.ofEpochMilli(TimeUtils.getTimeMillis(start)), Instant.ofEpochMilli(TimeUtils.getTimeMillis(end)));
} else if (desc.getTime() != null) {
final Object time = entry.getAttribute(desc.getTime().getName());
if ((time == null)) {
LOGGER.warn("time attribute value is null, ignoring feature");
return null;
}
final Instant instant = Instant.ofEpochMilli(TimeUtils.getTimeMillis(time));
return Interval.of(instant, instant);
}
LOGGER.error("time field not found for type '" + entry.getFeatureType().getTypeName() + "'. Consider explicitly setting field name.");
return null;
}
use of org.locationtech.geowave.core.geotime.util.TimeDescriptors in project geowave by locationtech.
the class TimeDescriptorsTest method testWhenAndEndTime.
@Test
public void testWhenAndEndTime() throws SchemaException {
final SimpleFeatureType schema = DataUtilities.createType("sp.geostuff", "geometry:Geometry:srid=4326,pop:java.lang.Long,when:Date,end:Date,pid:String");
final TimeDescriptorConfiguration timeConfig = new TimeDescriptorConfiguration();
timeConfig.configureFromType(schema);
final TimeDescriptors td = new TimeDescriptors(schema, timeConfig);
assertEquals("when", td.getTime().getLocalName());
assertNull(td.getStartRange());
assertNull(td.getEndRange());
assertTrue(td.hasTime());
}
use of org.locationtech.geowave.core.geotime.util.TimeDescriptors in project geowave by locationtech.
the class TimeDescriptorsTest method testMixedTime.
@Test
public void testMixedTime() throws SchemaException {
final SimpleFeatureType schema = DataUtilities.createType("sp.geostuff", "geometry:Geometry:srid=4326,pop:java.lang.Long,when:Date,start:Date,end:Date,pid:String");
final TimeDescriptorConfiguration timeConfig = new TimeDescriptorConfiguration();
timeConfig.configureFromType(schema);
final TimeDescriptors td = new TimeDescriptors(schema, timeConfig);
assertEquals("start", td.getStartRange().getLocalName());
assertEquals("end", td.getEndRange().getLocalName());
assertNull(td.getTime());
assertTrue(td.hasTime());
}
use of org.locationtech.geowave.core.geotime.util.TimeDescriptors in project geowave by locationtech.
the class TimeDescriptorsTest method testJustEndTime.
@Test
public void testJustEndTime() throws SchemaException {
final SimpleFeatureType schema = DataUtilities.createType("sp.geostuff", "geometry:Geometry:srid=4326,pop:java.lang.Long,end:Date,pid:String");
final TimeDescriptorConfiguration timeConfig = new TimeDescriptorConfiguration();
timeConfig.configureFromType(schema);
final TimeDescriptors td = new TimeDescriptors(schema, timeConfig);
assertEquals("end", td.getTime().getLocalName());
assertNull(td.getStartRange());
assertNull(td.getEndRange());
assertTrue(td.hasTime());
}
use of org.locationtech.geowave.core.geotime.util.TimeDescriptors in project geowave by locationtech.
the class FeatureDataAdapter method getDefaultStatistics.
@Override
public List<Statistic<? extends StatisticValue<?>>> getDefaultStatistics() {
final List<Statistic<?>> statistics = Lists.newArrayList();
final CountStatistic count = new CountStatistic(getTypeName());
count.setInternal();
statistics.add(count);
for (int i = 0; i < featureType.getAttributeCount(); i++) {
final AttributeDescriptor ad = featureType.getDescriptor(i);
if (Geometry.class.isAssignableFrom(ad.getType().getBinding())) {
final BoundingBoxStatistic bbox = new BoundingBoxStatistic(getTypeName(), ad.getLocalName());
bbox.setInternal();
statistics.add(bbox);
}
}
final TimeDescriptors timeDescriptors = getTimeDescriptors();
if (timeDescriptors.hasTime()) {
if (timeDescriptors.getTime() != null) {
final TimeRangeStatistic timeRange = new TimeRangeStatistic(getTypeName(), timeDescriptors.getTime().getLocalName());
timeRange.setInternal();
statistics.add(timeRange);
}
if (timeDescriptors.getStartRange() != null) {
final TimeRangeStatistic timeRange = new TimeRangeStatistic(getTypeName(), timeDescriptors.getStartRange().getLocalName());
timeRange.setInternal();
statistics.add(timeRange);
}
if (timeDescriptors.getEndRange() != null) {
final TimeRangeStatistic timeRange = new TimeRangeStatistic(getTypeName(), timeDescriptors.getEndRange().getLocalName());
timeRange.setInternal();
statistics.add(timeRange);
}
}
return statistics;
}
Aggregations