Search in sources :

Example 1 with TimeDescriptors

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;
}
Also used : TimeDescriptors(org.locationtech.geowave.core.geotime.util.TimeDescriptors) Instant(java.time.Instant)

Example 2 with TimeDescriptors

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());
}
Also used : TimeDescriptors(org.locationtech.geowave.core.geotime.util.TimeDescriptors) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) TimeDescriptorConfiguration(org.locationtech.geowave.core.geotime.util.TimeDescriptors.TimeDescriptorConfiguration) Test(org.junit.Test)

Example 3 with TimeDescriptors

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());
}
Also used : TimeDescriptors(org.locationtech.geowave.core.geotime.util.TimeDescriptors) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) TimeDescriptorConfiguration(org.locationtech.geowave.core.geotime.util.TimeDescriptors.TimeDescriptorConfiguration) Test(org.junit.Test)

Example 4 with TimeDescriptors

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());
}
Also used : TimeDescriptors(org.locationtech.geowave.core.geotime.util.TimeDescriptors) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) TimeDescriptorConfiguration(org.locationtech.geowave.core.geotime.util.TimeDescriptors.TimeDescriptorConfiguration) Test(org.junit.Test)

Example 5 with TimeDescriptors

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;
}
Also used : BoundingBoxStatistic(org.locationtech.geowave.core.geotime.store.statistics.BoundingBoxStatistic) TimeDescriptors(org.locationtech.geowave.core.geotime.util.TimeDescriptors) Statistic(org.locationtech.geowave.core.store.api.Statistic) CountStatistic(org.locationtech.geowave.core.store.statistics.adapter.CountStatistic) BoundingBoxStatistic(org.locationtech.geowave.core.geotime.store.statistics.BoundingBoxStatistic) TimeRangeStatistic(org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic) AttributeDescriptor(org.opengis.feature.type.AttributeDescriptor) CountStatistic(org.locationtech.geowave.core.store.statistics.adapter.CountStatistic) TimeRangeStatistic(org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic)

Aggregations

TimeDescriptors (org.locationtech.geowave.core.geotime.util.TimeDescriptors)12 SimpleFeatureType (org.opengis.feature.simple.SimpleFeatureType)8 Test (org.junit.Test)7 TimeDescriptorConfiguration (org.locationtech.geowave.core.geotime.util.TimeDescriptors.TimeDescriptorConfiguration)7 AttributeDescriptor (org.opengis.feature.type.AttributeDescriptor)3 GeotoolsFeatureDataAdapter (org.locationtech.geowave.core.geotime.store.GeotoolsFeatureDataAdapter)2 PersistentAdapterStore (org.locationtech.geowave.core.store.adapter.PersistentAdapterStore)2 Geometry (org.locationtech.jts.geom.Geometry)2 File (java.io.File)1 Instant (java.time.Instant)1 Calendar (java.util.Calendar)1 Collection (java.util.Collection)1 Date (java.util.Date)1 VectorLocalExportCommand (org.locationtech.geowave.adapter.vector.export.VectorLocalExportCommand)1 VectorLocalExportOptions (org.locationtech.geowave.adapter.vector.export.VectorLocalExportOptions)1 ManualOperationParams (org.locationtech.geowave.core.cli.parser.ManualOperationParams)1 InternalGeotoolsFeatureDataAdapter (org.locationtech.geowave.core.geotime.store.InternalGeotoolsFeatureDataAdapter)1 CompareOperation (org.locationtech.geowave.core.geotime.store.query.filter.SpatialQueryFilter.CompareOperation)1 BoundingBoxStatistic (org.locationtech.geowave.core.geotime.store.statistics.BoundingBoxStatistic)1 TimeRangeStatistic (org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic)1