org.opengis.filter.temporal.After Java Examples

The following examples show how to use org.opengis.filter.temporal.After. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExtractTimeFilterVisitor.java    From geowave with Apache License 2.0 6 votes vote down vote up
@Override
public Object visit(final After after, final Object data) {
  final TemporalConstraints leftResult = btime(after.getExpression1().accept(this, data));
  final TemporalConstraints rightResult = btime(after.getExpression2().accept(this, data));

  if (leftResult.isEmpty() || rightResult.isEmpty()) {
    return new TemporalConstraints();
  }

  // property after value
  if (leftResult instanceof ParameterTimeConstraint) {
    return new ParameterTimeConstraint(
        new TemporalRange(
            rightResult.getMaxOr(TemporalRange.START_TIME, 1),
            TemporalRange.END_TIME),
        leftResult.getName());
  } else if (rightResult instanceof ParameterTimeConstraint) {
    return new ParameterTimeConstraint(
        new TemporalRange(
            TemporalRange.START_TIME,
            leftResult.getMinOr(TemporalRange.END_TIME, -1)),
        rightResult.getName());
  }
  // property after property
  return new TemporalConstraints();
}
 
Example #2
Source File: ElasticCapabilities.java    From elasticgeo with GNU General Public License v3.0 5 votes vote down vote up
public ElasticCapabilities() {
    super(new ElasticFilterCapabilities());

    addAll(LOGICAL_OPENGIS);
    addAll(SIMPLE_COMPARISONS_OPENGIS);
    addType(PropertyIsNull.class);
    addType(PropertyIsBetween.class);
    addType(Id.class);
    addType(IncludeFilter.class);
    addType(ExcludeFilter.class);
    addType(PropertyIsLike.class);

    // spatial filters
    addType(BBOX.class);
    addType(Contains.class);
    //addType(Crosses.class);
    addType(Disjoint.class);
    //addType(Equals.class);
    addType(Intersects.class);
    //addType(Overlaps.class);
    //addType(Touches.class);
    addType(Within.class);
    addType(DWithin.class);
    addType(Beyond.class);

    //temporal filters
    addType(After.class);
    addType(Before.class);
    addType(Begins.class);
    addType(BegunBy.class);
    addType(During.class);
    addType(Ends.class);
    addType(EndedBy.class);
    addType(TContains.class);
    addType(TEquals.class);
}
 
Example #3
Source File: ElasticFilterTest.java    From elasticgeo with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testTemporalStringLiteral() {
    After filter = ff.after(ff.property("dateAttr"), ff.literal("1970-01-01T00:00:00.000Z"));
    Map<String,Object> expected = ImmutableMap.of("range",
            ImmutableMap.of("dateAttr", ImmutableMap.of("gt", "1970-01-01T00:00:00.000Z")));

    builder.visit(filter, null);
    assertTrue(builder.createCapabilities().fullySupports(filter));
    assertEquals(expected, builder.getQueryBuilder());
}
 
Example #4
Source File: ElasticFilterTest.java    From elasticgeo with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testNestedTemporalStringLiteral() {
    After filter = ff.after(ff.property("nested.datehej"), ff.literal("1970-01-01T00:00:00.000Z"));
    Map<String,Object> expectedFilter = ImmutableMap.of("range",
            ImmutableMap.of("nested.datehej", ImmutableMap.of("gt", "1970-01-01T00:00:00.000Z")));
    Map<String,Object> expected = ImmutableMap.of("nested",
            ImmutableMap.of("path", "nested", "query", expectedFilter));

    builder.visit(filter, null);
    assertTrue(builder.createCapabilities().fullySupports(filter));
    assertEquals(expected, builder.getQueryBuilder());
}
 
Example #5
Source File: ElasticFilterTest.java    From elasticgeo with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testTemporalInstantLiteralDefaultFormat() throws ParseException {
    dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
    Date date1 = dateFormat.parse("1970-07-19");
    Instant temporalInstant = new DefaultInstant(new DefaultPosition(date1));
    After filter = ff.after(ff.property("dateAttr"), ff.literal(temporalInstant));
    Map<String,Object> expected = ImmutableMap.of("range",
            ImmutableMap.of("dateAttr", ImmutableMap.of("gt", "1970-07-19T00:00:00.000Z")));

    builder.visit(filter, null);
    assertTrue(builder.createCapabilities().fullySupports(filter));
    assertEquals(expected, builder.getQueryBuilder());
}
 
Example #6
Source File: ElasticFilterTest.java    From elasticgeo with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testTemporalInstanceLiteralExplicitFormat() throws ParseException {
    addDateWithFormatToFeatureType("yyyy-MM-dd");
    dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
    dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
    Date date1 = dateFormat.parse("1970-07-19T01:02:03.456-0100");
    Instant temporalInstant = new DefaultInstant(new DefaultPosition(date1));
    After filter = ff.after(ff.property("dateAttrWithFormat"), ff.literal(temporalInstant));
    Map<String,Object> expected = ImmutableMap.of("range",
            ImmutableMap.of("dateAttrWithFormat", ImmutableMap.of("gt", "1970-07-19")));

    builder.visit(filter, null);
    assertTrue(builder.createCapabilities().fullySupports(filter));
    assertEquals(expected, builder.getQueryBuilder());
}
 
Example #7
Source File: ElasticFilterTest.java    From elasticgeo with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testTemporalInstanceLiteralBasicDateTimeFormat() throws ParseException {
    addDateWithFormatToFeatureType("basic_date_time");
    dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
    dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
    Date date1 = dateFormat.parse("1970-07-19T01:02:03.456-0100");
    Instant temporalInstant = new DefaultInstant(new DefaultPosition(date1));
    After filter = ff.after(ff.property("dateAttrWithFormat"), ff.literal(temporalInstant));
    Map<String,Object> expected = ImmutableMap.of("range",
            ImmutableMap.of("dateAttrWithFormat", ImmutableMap.of("gt", "19700719T020203.456Z")));

    builder.visit(filter, null);
    assertTrue(builder.createCapabilities().fullySupports(filter));
    assertEquals(expected, builder.getQueryBuilder());
}
 
Example #8
Source File: ElasticFilterTest.java    From elasticgeo with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testAfterFilter() throws ParseException {
    dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
    dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
    Date date1 = dateFormat.parse("1970-07-19T01:02:03.456-0100");
    Instant temporalInstant = new DefaultInstant(new DefaultPosition(date1));
    After filter = ff.after(ff.property("dateAttr"), ff.literal(temporalInstant));
    Map<String,Object> expected = ImmutableMap.of("range",
            ImmutableMap.of("dateAttr", ImmutableMap.of("gt", "1970-07-19T02:02:03.456Z")));

    builder.visit(filter, null);
    assertTrue(builder.createCapabilities().fullySupports(filter));
    assertEquals(expected, builder.getQueryBuilder());
}
 
Example #9
Source File: ElasticFilterTest.java    From elasticgeo with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testAfterFilterSwapped() throws ParseException {
    dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
    dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
    Date date1 = dateFormat.parse("1970-07-19T01:02:03.456-0100");
    Instant temporalInstant = new DefaultInstant(new DefaultPosition(date1));
    After filter = ff.after(ff.literal(temporalInstant), ff.property("dateAttr"));
    Map<String,Object> expected = ImmutableMap.of("range",
            ImmutableMap.of("dateAttr", ImmutableMap.of("lt", "1970-07-19T02:02:03.456Z")));

    builder.visit(filter, null);
    assertTrue(builder.createCapabilities().fullySupports(filter));
    assertEquals(expected, builder.getQueryBuilder());
}
 
Example #10
Source File: ElasticFilterTest.java    From elasticgeo with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testAfterFilterPeriod() throws ParseException {
    Date date1 = dateFormat.parse("1970-07-19T01:02:03.456Z");
    Instant temporalInstant = new DefaultInstant(new DefaultPosition(date1));
    Date date2 = dateFormat.parse("1970-07-19T07:08:09.101Z");
    Instant temporalInstant2 = new DefaultInstant(new DefaultPosition(date2));
    Period period = new DefaultPeriod(temporalInstant, temporalInstant2);
    After filter = ff.after(ff.property("dateAttr"), ff.literal(period));
    Map<String,Object> expected = ImmutableMap.of("range",
            ImmutableMap.of("dateAttr", ImmutableMap.of("gt", "1970-07-19T07:08:09.101Z")));

    builder.visit(filter, null);
    assertTrue(builder.createCapabilities().fullySupports(filter));
    assertEquals(expected, builder.getQueryBuilder());
}
 
Example #11
Source File: ElasticFilterTest.java    From elasticgeo with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testAfterFilterPeriodSwapped() throws ParseException {
    Date date1 = dateFormat.parse("1970-07-19T01:02:03.456Z");
    Instant temporalInstant = new DefaultInstant(new DefaultPosition(date1));
    Date date2 = dateFormat.parse("1970-07-19T07:08:09.101Z");
    Instant temporalInstant2 = new DefaultInstant(new DefaultPosition(date2));
    Period period = new DefaultPeriod(temporalInstant, temporalInstant2);
    After filter = ff.after(ff.literal(period), ff.property("dateAttr"));
    Map<String,Object> expected = ImmutableMap.of("range",
            ImmutableMap.of("dateAttr", ImmutableMap.of("lt", "1970-07-19T01:02:03.456Z")));

    builder.visit(filter, null);
    assertTrue(builder.createCapabilities().fullySupports(filter));
    assertEquals(expected, builder.getQueryBuilder());
}
 
Example #12
Source File: PropertyIgnoringFilterVisitor.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
public Object visit(final After after, final Object extraData) {
  if (!usesProperty(after)) {
    return Filter.INCLUDE;
  }
  return super.visit(after, extraData);
}
 
Example #13
Source File: PropertyIgnoringFilterVisitor.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
public Object visit(final After after, final Object extraData) {
  if (!usesProperty(after)) {
    return Filter.INCLUDE;
  }
  return super.visit(after, extraData);
}
 
Example #14
Source File: CriteriaVisitor.java    From geomajas-project-server with GNU Affero General Public License v3.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public Object visit(After after, Object extraData) {
	String propertyName = getPropertyName(after.getExpression1());
	String finalName = parsePropertyName(propertyName, after);
	Object literal = getLiteralValue(after.getExpression2());
	if (literal instanceof Date) {
		return Restrictions.gt(finalName, literal);
	} else {
		throw new UnsupportedOperationException("visit(Object userData)");
	}
}
 
Example #15
Source File: CriteriaVisitorTest.java    From geomajas-project-server with GNU Affero General Public License v3.0 5 votes vote down vote up
@Test
public void testVisitAfter() throws GeomajasException {
	Filter f = filterService.parseFilter("myDate AFTER 2006-11-30T01:30:00Z");
	Criterion c = (Criterion) (new CriteriaVisitor((HibernateFeatureModel) layer.getFeatureModel(),
			DateFormat.getDateTimeInstance()).visit((After) f, null));
	Date date = ISODateTimeFormat.dateTimeNoMillis().parseDateTime("2006-11-30T01:30:00Z").toDate();
	Assert.assertEquals("myDate>" + date, c.toString());
}
 
Example #16
Source File: FilterToElastic.java    From elasticgeo with GNU General Public License v3.0 4 votes vote down vote up
public Object visit(After after, Object extraData) {
    return visitBinaryTemporalOperator(after, extraData);
}