Package org.opengis.filter

Examples of org.opengis.filter.BinaryComparisonOperator


            Map hints) throws IOException, OperationNotSupportedException {
            if (!canEncode(element, value, hints)) {
                return;
            }

            BinaryComparisonOperator cf = (BinaryComparisonOperator) value;

            output.startElement(element.getNamespace(), element.getName(), null);

            // TODO is this order dependant?
            encodeExpr(cf.getExpression1(), output, hints);
            encodeExpr(cf.getExpression2(), output, hints);

            output.endElement(element.getNamespace(), element.getName());
        }
View Full Code Here


        return BinaryComparisonOperator.class;
    }
   
    @Override
    public Object getProperty(Object object, QName name) throws Exception {
        BinaryComparisonOperator op = (BinaryComparisonOperator) object;
        if ("matchAction".equals(name.getLocalPart())) {
            return op.getMatchAction().name();
        }
        if ("matchCase".equals(name.getLocalPart())) {
            return op.isMatchingCase();
        }
        if (FES.expression.equals(name)) {
            return new Expression[]{op.getExpression1(), op.getExpression2()};
        }
        return null;
    }
View Full Code Here

    }

    public Object getProperty(Object object, QName name)
        throws Exception {
        if (OGC.expression.equals(name)) {
            BinaryComparisonOperator op = (BinaryComparisonOperator) object;

            return new Expression[] { op.getExpression1(), op.getExpression2() };
        }

        //filter 1.1 only
        if ("matchCase".equals(name.getLocalPart())) {
            BinaryComparisonOperator op = (BinaryComparisonOperator) object;

            return Boolean.valueOf(op.isMatchingCase());
        }

        return null;
    }
View Full Code Here

                    "This method currently only supports logical filters with exactly 2 children.");
            }

            // we're expecting 2 compare subfilters
            PropertyIsGreaterThanOrEqualTo filter1 = (PropertyIsGreaterThanOrEqualTo) children.get(0);
            BinaryComparisonOperator filter2 = (BinaryComparisonOperator) children.get(1);

            //filter1 should be 1 <= x and filter2 should be x <(=) 5
            if (!(filter1.getExpression2().equals(filter2.getExpression1()))) {
                throw new IllegalArgumentException(
                    "Subfilters or subExpressions in incorrect order");
            }

            if (filter1.getExpression1().toString() != newValue[0]) {
                //lower bound value has changed, update
                filter1 = ff.greaterOrEqual(filter1.getExpression1(), ff.literal(newValue[0]));
            }

            if (filter2.getExpression2().toString() != newValue[1]) {
                //upper bound value has changed, update
                if(filter2 instanceof PropertyIsLessThan) {
                    filter2 = ff.less(filter1.getExpression1(), ff.literal(newValue[1]));
                } else if(filter2 instanceof PropertyIsLessThanOrEqualTo) {
                    filter2 = ff.lessOrEqual(filter1.getExpression1(), ff.literal(newValue[1]));
View Full Code Here

                try {
                    if(f == null) {
                        continue;
                    }
                    if (f instanceof PropertyIsLessThan) {
                        BinaryComparisonOperator cf =  (BinaryComparisonOperator) f;
                        if (cf.getExpression1() instanceof LengthFunction) {
                            filterLength = cf.getExpression2().evaluate(null, Integer.class) - 1;
                        }
                    } else if (f instanceof PropertyIsLessThanOrEqualTo) {
                        BinaryComparisonOperator cf =  (BinaryComparisonOperator) f;
                        if (cf.getExpression1() instanceof LengthFunction) {
                            filterLength = cf.getExpression2().evaluate(null, Integer.class);
                        }
                    } else if(f instanceof PropertyIsGreaterThan) {
                        BinaryComparisonOperator cf =  (BinaryComparisonOperator) f;
                        if (cf.getExpression2() instanceof LengthFunction) {
                            filterLength = cf.getExpression1().evaluate(null, Integer.class) - 1;
                        }
                    } else if (f instanceof PropertyIsGreaterThanOrEqualTo) {
                        BinaryComparisonOperator cf =  (BinaryComparisonOperator) f;
                        if (cf.getExpression2() instanceof LengthFunction) {
                            filterLength = cf.getExpression1().evaluate(null, Integer.class);
                        }
                    }
                } catch (NullPointerException e) {
                    // was not an integer eh? Continue, worst case we'll return ANY_LENGTH
                }
View Full Code Here

        assertTrue(f instanceof BinaryLogicOperator);
        assertEquals(FilterType.LOGIC_OR, Filters.getFilterType(f));
       
        int i = 0;
        for(Iterator<org.opengis.filter.Filter> filters = ((BinaryLogicOperator)f).getChildren().iterator(); filters.hasNext(); i++){
            BinaryComparisonOperator subFitler = (BinaryComparisonOperator) filters.next();
            StringBuffer attName = new StringBuffer();
            for(int repCount = 0; repCount <= i; repCount++){
                attName.append("eventtype-" + repCount + "_");
            }
            String parsedName = ((PropertyName)subFitler.getExpression1()).getPropertyName();
            try{
                assertEquals("at index " + i, attName.toString(), parsedName);
            }catch(AssertionFailedError e){
                Logging.getLogger("org.geotools.filter").warning("expected " + attName + ",\n but was " + parsedName);
                throw e;
            }
            assertEquals("literal-" + i, ((Literal)subFitler.getExpression2()).getValue());
        }
        assertEquals(filterCount, i);
    }
View Full Code Here

        // Extract the property name and the geometry literal
        //
        Literal geometry;
        PropertyName property;
        boolean swapped = false;
        BinaryComparisonOperator op = (BinaryComparisonOperator) filter;
        if (op.getExpression1() instanceof PropertyName && op.getExpression2() instanceof Literal) {
            property = (PropertyName) op.getExpression1();
            geometry = (Literal) op.getExpression2();
            swapped = true;
        } else if (op.getExpression2() instanceof PropertyName
                && op.getExpression1() instanceof Literal) {
            property = (PropertyName) op.getExpression2();
            geometry = (Literal) op.getExpression1();
        } else {
            throw new IllegalArgumentException("Can only encode spatial filters that do "
                    + "compare a property name and a geometry");
        }
View Full Code Here

                  continue;
             
                try{
                  if(f instanceof PropertyIsLessThan ||
                       f instanceof PropertyIsLessThanOrEqualTo ){
                    BinaryComparisonOperator cf = (BinaryComparisonOperator) f;
                    Expression e = cf.getExpression1();
                    if(e!= null && e instanceof LengthFunction){
                      length = Integer.parseInt(((Literal)cf.getExpression2()).getValue().toString());
                    }else{
                      if(cf.getExpression2() instanceof LengthFunction){
                        length = Integer.parseInt(((Literal)cf.getExpression1()).getValue().toString());
                      }
                    }
                  }
              }catch(Throwable t){
                length = Integer.MAX_VALUE;
View Full Code Here

TOP

Related Classes of org.opengis.filter.BinaryComparisonOperator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.