Search in sources :

Example 1 with TemporalPredicate

use of ddf.catalog.pubsub.predicate.TemporalPredicate in project ddf by codice.

the class SubscriptionFilterVisitor method visit.

/**
 * During filter maps to a Temporal (Absolute and Modified) search criteria.
 */
@Override
public Object visit(During filter, Object data) {
    LOGGER.debug("ENTERING: During filter");
    AttributeExpressionImpl temporalTypeAttribute = (AttributeExpressionImpl) filter.getExpression1();
    String temporalType = temporalTypeAttribute.getPropertyName();
    LiteralExpressionImpl timePeriodLiteral = (LiteralExpressionImpl) filter.getExpression2();
    Object literal = timePeriodLiteral.getValue();
    Predicate returnPredicate = null;
    if (literal instanceof Period) {
        Period timePeriod = (Period) literal;
        // Extract the start and end dates from the OGC TOverlaps filter
        Date start = timePeriod.getBeginning().getPosition().getDate();
        Date end = timePeriod.getEnding().getPosition().getDate();
        LOGGER.debug("time period lowerBound = {}", start);
        LOGGER.debug("time period upperBound = {}", end);
        LOGGER.debug("EXITING: (temporal) filter");
        returnPredicate = new TemporalPredicate(start, end, DateType.getDateType(temporalType));
    // CREATE RELATIVE
    } else if (literal instanceof PeriodDuration) {
        DefaultPeriodDuration duration = (DefaultPeriodDuration) literal;
        long offset = duration.getTimeInMillis();
        LOGGER.debug("EXITING: (temporal) filter");
        returnPredicate = new TemporalPredicate(offset, DateType.getDateType(temporalType));
    }
    LOGGER.debug("temporalType: {}", temporalType);
    LOGGER.debug("Temporal Predicate: {}", returnPredicate);
    LOGGER.debug("EXITING: During filter");
    return returnPredicate;
}
Also used : TemporalPredicate(ddf.catalog.pubsub.predicate.TemporalPredicate) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) Period(org.opengis.temporal.Period) Date(java.util.Date) PeriodDuration(org.opengis.temporal.PeriodDuration) DefaultPeriodDuration(org.geotools.temporal.object.DefaultPeriodDuration) DefaultPeriodDuration(org.geotools.temporal.object.DefaultPeriodDuration) GeospatialPredicate(ddf.catalog.pubsub.predicate.GeospatialPredicate) ContentTypePredicate(ddf.catalog.pubsub.predicate.ContentTypePredicate) EntryPredicate(ddf.catalog.pubsub.predicate.EntryPredicate) TemporalPredicate(ddf.catalog.pubsub.predicate.TemporalPredicate) ContextualPredicate(ddf.catalog.pubsub.predicate.ContextualPredicate) Predicate(ddf.catalog.pubsub.predicate.Predicate)

Aggregations

ContentTypePredicate (ddf.catalog.pubsub.predicate.ContentTypePredicate)1 ContextualPredicate (ddf.catalog.pubsub.predicate.ContextualPredicate)1 EntryPredicate (ddf.catalog.pubsub.predicate.EntryPredicate)1 GeospatialPredicate (ddf.catalog.pubsub.predicate.GeospatialPredicate)1 Predicate (ddf.catalog.pubsub.predicate.Predicate)1 TemporalPredicate (ddf.catalog.pubsub.predicate.TemporalPredicate)1 Date (java.util.Date)1 AttributeExpressionImpl (org.geotools.filter.AttributeExpressionImpl)1 LiteralExpressionImpl (org.geotools.filter.LiteralExpressionImpl)1 DefaultPeriodDuration (org.geotools.temporal.object.DefaultPeriodDuration)1 Period (org.opengis.temporal.Period)1 PeriodDuration (org.opengis.temporal.PeriodDuration)1