org.opengis.filter.PropertyIsBetween Java Examples

The following examples show how to use org.opengis.filter.PropertyIsBetween. 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 PropertyIsBetween filter, final Object data) {
  final TemporalConstraints propertyExp =
      (TemporalConstraints) filter.getExpression().accept(this, data);

  final TemporalConstraints lowerBound =
      (TemporalConstraints) filter.getLowerBoundary().accept(this, data);
  final TemporalConstraints upperBound =
      (TemporalConstraints) filter.getUpperBoundary().accept(this, data);

  if (propertyExp.isEmpty()) {
    return new TemporalConstraints();
  }

  return new ParameterTimeConstraint(
      new TemporalRange(
          lowerBound.getStartRange().getStartTime(),
          upperBound.getEndRange().getEndTime()),
      propertyExp.getName());
}
 
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 testPropertyIsBetween() {
    PropertyIsBetween filter = ff.between(ff.property("doubleAttr"), ff.literal("4.5"), ff.literal("5.5"));
    Map<String,Object> expected = ImmutableMap.of("range",
            ImmutableMap.of("doubleAttr", ImmutableMap.of("gte", 4.5, "lte", 5.5)));

    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 testUnknownPropertyIsBetween() {
    PropertyIsBetween filter = ff.between(ff.property("unknownStr"), ff.literal("a"), ff.literal("c"));
    Map<String,Object> expected = ImmutableMap.of("range",
            ImmutableMap.of("unknownStr", ImmutableMap.of("gte", "a", "lte", "c")));

    builder.visit(filter, null);
    assertTrue(builder.createCapabilities().fullySupports(filter));
    assertEquals(expected, builder.getQueryBuilder());
}
 
Example #5
Source File: ElasticFeatureFilterIT.java    From elasticgeo with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testReadNumericArrayWithCsvStrategy() throws Exception {
    init();
    dataStore.setArrayEncoding(ArrayEncoding.CSV);
    FilterFactory ff = dataStore.getFilterFactory();
    PropertyIsBetween between = ff.between(ff.property("speed_is"), ff.literal(160), ff.literal(300));
    SimpleFeatureCollection features = featureSource.getFeatures(between);
    assertEquals(5, features.size());
    SimpleFeatureIterator iterator = features.features();
    while (iterator.hasNext()) {
        SimpleFeature f = iterator.next();
        assertFalse(f.getAttribute("speed_is") instanceof List);
    }
}
 
Example #6
Source File: ElasticFeatureFilterIT.java    From elasticgeo with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testGetFeaturesWithIsBetweenFilterOnObjectType() throws Exception {
    init();
    FilterFactory ff = dataStore.getFilterFactory();
    PropertyIsBetween f = ff.between(ff.property("object.hejda"), ff.literal(5), ff.literal(15));
    SimpleFeatureCollection features = featureSource.getFeatures(f);
    assertEquals(5, features.size());
}
 
Example #7
Source File: ElasticFeatureFilterIT.java    From elasticgeo with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testGetFeaturesWithIsBetweenFilterOnNestedType() throws Exception {
    init();
    FilterFactory ff = dataStore.getFilterFactory();
    PropertyIsBetween f = ff.between(ff.property("nested.hej"), ff.literal(5), ff.literal(15));
    SimpleFeatureCollection features = featureSource.getFeatures(f);
    assertEquals(10, features.size());
}
 
Example #8
Source File: PropertyIgnoringFilterVisitor.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
public Object visit(final PropertyIsBetween filter, final Object extraData) {
  if (!usesProperty(filter)) {
    return Filter.INCLUDE;
  }
  return super.visit(filter, extraData);
}
 
Example #9
Source File: PropertyIgnoringFilterVisitor.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
public Object visit(final PropertyIsBetween filter, final Object extraData) {
  if (!usesProperty(filter)) {
    return Filter.INCLUDE;
  }
  return super.visit(filter, extraData);
}
 
Example #10
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(PropertyIsBetween filter, Object userData) {
	String propertyName = getPropertyName(filter.getExpression());
	String finalName = parsePropertyName(propertyName, userData);

	Object lo = castLiteral(getLiteralValue(filter.getLowerBoundary()), propertyName);
	Object hi = castLiteral(getLiteralValue(filter.getUpperBoundary()), propertyName);
	return Restrictions.between(finalName, lo, hi);
}
 
Example #11
Source File: FilterNode.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Sets the filter.
 *
 * @param filter the new expression
 * @param filterConfig the filter config
 */
public void setFilter(Filter filter, FilterConfigInterface filterConfig) {
    this.filter = filter;
    this.filterConfig = filterConfig;

    setDisplayString();

    this.removeAllChildren();

    TypeManager.getInstance().reset();

    if (filterConfig != null) {
        FilterName filterName = filterConfig.getFilterConfiguration();

        if (filter instanceof Not) {
            setNotFilter(filter, filterName);
        } else if (filter instanceof LogicFilterImpl) {
            setLogicFilter(filter, filterName);
        } else if (filter instanceof BinaryTemporalOperator) {
            setExpressionParameter(
                    ((BinaryTemporalOperator) filter).getExpression1(),
                    filterName.getParameter(0));
            setExpressionParameter(
                    ((BinaryTemporalOperator) filter).getExpression2(),
                    filterName.getParameter(1));
        } else if (filter instanceof PropertyIsNull) {
            setExpressionParameter(
                    ((PropertyIsNull) filter).getExpression(), filterName.getParameter(0));
        } else if (filter instanceof PropertyIsBetween) {
            setExpressionParameter(
                    ((PropertyIsBetween) filter).getLowerBoundary(),
                    filterName.getParameter(0));
            setExpressionParameter(
                    ((PropertyIsBetween) filter).getExpression(), filterName.getParameter(1));
            setExpressionParameter(
                    ((PropertyIsBetween) filter).getUpperBoundary(),
                    filterName.getParameter(2));
        } else if (filter instanceof PropertyIsLike) {
            setExpressionParameter(
                    ((PropertyIsLike) filter).getExpression(), filterName.getParameter(0));
            setExpressionParameter(
                    ff.literal(((PropertyIsLike) filter).getLiteral()),
                    filterName.getParameter(1));
            setExpressionStringSizeParameter(
                    ff.literal(((PropertyIsLike) filter).getWildCard()),
                    filterName.getParameter(2),
                    1,
                    true);
            setExpressionStringSizeParameter(
                    ff.literal(((PropertyIsLike) filter).getSingleChar()),
                    filterName.getParameter(3),
                    1,
                    true);
            setExpressionStringSizeParameter(
                    ff.literal(((PropertyIsLike) filter).getEscape()),
                    filterName.getParameter(4),
                    1,
                    true);
            setExpressionParameter(
                    ff.literal(((PropertyIsLike) filter).isMatchingCase()),
                    filterName.getParameter(5));
        } else if (filter instanceof BinarySpatialOperator) {
            setBinarySpatialOperator(filter, filterName);
        } else if (filter instanceof BinaryComparisonAbstract) {
            setBinaryComparisonAbstract(filter, filterName);
        } else if (filter instanceof FidFilterImpl) {
            FidFilterImpl fidFilter = (FidFilterImpl) filter;

            for (Identifier identifier : fidFilter.getIdentifiers()) {
                setExpressionParameter(ff.literal(identifier), filterName.getParameter(0));
            }
        }
    }
}
 
Example #12
Source File: FilterPanelv2.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Adds the filter.
 *
 * @param node the node
 * @return the filter
 */
private Filter addFilter(FilterNode node) {
    Filter nodeFilter = node.getFilter();

    FilterConfigInterface filterConfig = node.getFilterConfig();

    if (nodeFilter instanceof LogicFilterImpl) {
        List<Filter> filterList = new ArrayList<>();

        createFilterList(node, filterList);

        return filterConfig.createLogicFilter(filterList);
    }

    List<Expression> parameterFilter = new ArrayList<>();

    if (originalFilter instanceof FidFilterImpl) {
        createExpressionParameterList(node, 1, parameterFilter);
    } else if (originalFilter instanceof BinaryTemporalOperator) {
        createExpressionParameterList(node, 2, parameterFilter);
    } else if (originalFilter instanceof PropertyIsBetween) {
        createExpressionParameterList(node, 3, parameterFilter);
    } else if (originalFilter instanceof PropertyIsNull) {
        createExpressionParameterList(node, 1, parameterFilter);
    } else if (originalFilter instanceof PropertyIsLike) {
        createExpressionParameterList(node, 6, parameterFilter);
    } else if (originalFilter instanceof BinarySpatialOperator) {
        createExpressionParameterList(node, 2, parameterFilter);
    } else if (originalFilter instanceof BinaryComparisonAbstract) {
        if (originalFilter instanceof Not) {
            createExpressionParameterList(node, 1, parameterFilter);
        } else if (originalFilter instanceof PropertyIsGreaterThan) {
            createExpressionParameterList(node, 2, parameterFilter);
        } else {
            createExpressionParameterList(node, 3, parameterFilter);
        }
    } else {
        return nodeFilter;
    }

    return filterConfig.createFilter(parameterFilter);
}
 
Example #13
Source File: FilterToElastic.java    From elasticgeo with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Writes the FilterBuilder for the PropertyIsBetween Filter.
 *
 * @param filter the Filter to be visited.
 *
 */
public Object visit(PropertyIsBetween filter, Object extraData) {
    LOGGER.finest("exporting PropertyIsBetween");

    Expression expr = filter.getExpression();
    Expression lowerbounds = filter.getLowerBoundary();
    Expression upperbounds = filter.getUpperBoundary();

    Class<?> context;
    nested = false;
    AttributeDescriptor attType = (AttributeDescriptor)expr.evaluate(featureType);
    if (attType != null) {
        context = attType.getType().getBinding();
        if (attType.getUserData().containsKey(NESTED)) {
            nested = (Boolean) attType.getUserData().get(NESTED);
        }
        if (Date.class.isAssignableFrom(context)) {
            updateDateFormatter(attType);
        }
    } else {
        //assume it's a string?
        context = String.class;
    }

    expr.accept(this, extraData);
    key = (String) field;
    lowerbounds.accept(this, context);
    lower = field;
    upperbounds.accept(this, context);
    Object upper = field;

    if(nested) {
        path = extractNestedPath(key);
    }

    queryBuilder = ImmutableMap.of("range", ImmutableMap.of(key, ImmutableMap.of("gte", lower, "lte", upper)));
    if(nested) {
        queryBuilder = ImmutableMap.of("nested", ImmutableMap.of("path", path, "query", queryBuilder));
    }

    return extraData;
}
 
Example #14
Source File: ExtractGeometryFilterVisitor.java    From geowave with Apache License 2.0 4 votes vote down vote up
@Override
public Object visit(final PropertyIsBetween filter, final Object data) {
  return new ExtractGeometryFilterVisitorResult(infinity(), null);
}