Package org.opengis.filter

Examples of org.opengis.filter.BinaryLogicOperator


        return new Data(compressFilter(filterType, (BinaryLogicOperator) f));
    }
   
    private org.opengis.filter.Filter compressFilter(short filterType, BinaryLogicOperator f)
        throws IllegalFilterException {
        BinaryLogicOperator result;
        int added = 0;
        List<org.opengis.filter.Filter> resultList = new ArrayList<org.opengis.filter.Filter>();
       
        switch (filterType) {
        case FilterType.LOGIC_AND:
           
            if (contains(f, Filter.EXCLUDE)) {
                return Filter.EXCLUDE;
            }

            for (org.opengis.filter.Filter filter : f.getChildren() ) {
                if (filter == org.opengis.filter.Filter.INCLUDE) {
                    continue;
                }
                added++;
                resultList.add( filter );
            }

            if (resultList.isEmpty()) {
                return Filter.EXCLUDE;
            }

            result = ff.and(resultList);
            break;

        case FilterType.LOGIC_OR:

            if (contains(f, Filter.INCLUDE)) {
                return Filter.INCLUDE;
            }

            for (Object item : f.getChildren() ) {
                org.opengis.filter.Filter filter = (org.opengis.filter.Filter) item;
                if (filter == Filter.EXCLUDE) {
                    continue;
                }
                added++;
                resultList.add( filter );
            }

            if (resultList.isEmpty()) {
                return Filter.EXCLUDE;
            }

            result = ff.or(resultList);
           
            break;

        default:
            return Filter.EXCLUDE;
        }

        switch (added) {
        case 0:
            return Filter.EXCLUDE;

        case 1:
            return (Filter) result.getChildren().iterator().next();

        default:
            return result;
        }
    }
View Full Code Here


            Map hints) throws IOException, OperationNotSupportedException {
            if (!canEncode(element, value, hints)) {
                return;
            }
            if( value instanceof BinaryLogicOperator){
                BinaryLogicOperator lf = (BinaryLogicOperator) value;
   
                switch ( Filters.getFilterType( lf )) {
                case LOGIC_AND:
                    BinaryLogicOpType.getInstance().encode(new FilterElement(
                            "And", BinaryLogicOpType.getInstance(), element),
View Full Code Here

        public void encode(Element element, Object value, PrintHandler output,
            Map hints) throws IOException, OperationNotSupportedException {
            if (!canEncode(element, value, hints)) {
                return;
            }
            BinaryLogicOperator lf = (BinaryLogicOperator) value;
            output.startElement(element.getNamespace(), element.getName(), null);
            for( org.opengis.filter.Filter f : lf.getChildren() ){
                encodeFilter(f, output, hints);
            }
            output.endElement(element.getNamespace(), element.getName());
        }
View Full Code Here

        testLogicFilter(And.class);
        testLogicFilter(Or.class);
    }

    private void testLogicFilter(Class<?> filterType) throws Exception {
        BinaryLogicOperator complexLogicFilter;
        PropertyIsGreaterThan resultFilter = ff.greater(ff.property("measurement/result"), ff
                .literal(new Integer(5)));

        PropertyIsBetween determFilter = ff.between(ff
                .property("measurement/determinand_description"), ff
                .literal("determinand_description_1_1"), ff.literal("determinand_description_3_3"));

        if (And.class.equals(filterType)) {
            complexLogicFilter = ff.and(resultFilter, determFilter);
        } else if (Or.class.equals(filterType)) {
            complexLogicFilter = ff.or(resultFilter, determFilter);
        } else {
            throw new IllegalArgumentException();
        }

        Filter unmapped = (Filter) complexLogicFilter.accept(visitor, null);
        assertNotNull(unmapped);
        assertTrue(unmapped instanceof BinaryLogicOperator);
        assertNotSame(complexLogicFilter, unmapped);

        BinaryLogicOperator logicUnmapped = (BinaryLogicOperator) unmapped;

        List children = logicUnmapped.getChildren();
        assertEquals(2, children.size());

        PropertyIsGreaterThan unmappedResult = (PropertyIsGreaterThan) children.get(0);
        PropertyIsBetween unmappedDeterm = (PropertyIsBetween) children.get(1);
View Full Code Here

     * @param filter A LOGIC_AND filter containing 2 CompareFilters or a single CompareFilter.
     * @return a styleExpression of the syntax "min..max"
     */
    private static String toRangedStyleExpression(Filter filter) {
        if (filter instanceof BinaryLogicOperator) {
            BinaryLogicOperator lFilter = (BinaryLogicOperator) filter;

            if (!(filter instanceof And)) {
                throw new IllegalArgumentException(
                    "Only logic filters constructed using the LOGIC_AND filterType are currently supported by this method.");
            }

            List<Filter> children = lFilter.getChildren();

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

View Full Code Here

        //        }
    }

    public Object getProperty(Object object, QName qName)
        throws Exception {
        BinaryLogicOperator operator = (BinaryLogicOperator) object;

        // this method is acutally used by later version of the filter spec, so it handles
        // everything
       
        //use the local part to handle both OGC and FES namespaces
        String name = qName.getLocalPart();

        if ("comparisonOps".equals(name)) {
            List comparison = new ArrayList();

            for (Iterator f = operator.getChildren().iterator(); f.hasNext();) {
                Filter filter = (Filter) f.next();

                if (!(filter instanceof BinarySpatialOperator || filter instanceof BinaryTemporalOperator) &&
                     (filter instanceof BinaryComparisonOperator ||
                      filter instanceof PropertyIsLike ||
                      filter instanceof PropertyIsNull ||
                      filter instanceof PropertyIsNil ||
                      filter instanceof PropertyIsBetween) ) {
                   
                    comparison.add(filter);
                }
            }

            if (!comparison.isEmpty()) {
                return comparison;
            }
        }

        if ("spatialOps".equals(name)) {
            List spatial = new ArrayList();

            for (Iterator f = operator.getChildren().iterator(); f.hasNext();) {
                Filter filter = (Filter) f.next();

                if (filter instanceof BinarySpatialOperator) {
                    spatial.add(filter);
                }
            }

            if (!spatial.isEmpty()) {
                return spatial;
            }
        }
       
        if ("temporalOps".equals(name)) {
            List temporal = new ArrayList();

            for (Iterator f = operator.getChildren().iterator(); f.hasNext();) {
                Filter filter = (Filter) f.next();

                if (filter instanceof BinaryTemporalOperator) {
                    temporal.add(filter);
                }
            }

            if (!temporal.isEmpty()) {
                return temporal;
            }
        }

        if ("logicOps".equals(name)) {
            List logic = new ArrayList();

            for (Iterator f = operator.getChildren().iterator(); f.hasNext();) {
                Filter filter = (Filter) f.next();

                if (filter instanceof BinaryLogicOperator || filter instanceof Not) {
                    logic.add(filter);
                }
            }

            if (!logic.isEmpty()) {
                return logic;
            }
        }

        if ("_Id".equals(name)) {
            List ids = new ArrayList();
            for (Filter filter : operator.getChildren()) {
                if (filter instanceof Id) {
                    ids.add(filter);
                }
            }
            if (!ids.isEmpty()) {
                return ids;
            }
        }
       
        if ("Function".equals(name)) {
            List functions = new ArrayList();
            for (Filter filter : operator.getChildren()) {
                if (filter instanceof Function) {
                    functions.add(filter);
                }
            }
            if (!functions.isEmpty()) {
View Full Code Here

        assertEquals("#0000ff", Filters.puts(Color.BLUE));
    }
   
    private int count( Filter filter ){
        if( filter instanceof BinaryLogicOperator ){
            BinaryLogicOperator logic = (BinaryLogicOperator) filter;
            return logic.getChildren() != null ? logic.getChildren().size() : -1;
        }
        return -1;
    }
View Full Code Here

        }

        short filterType = Filters.getFilterType(filter);

        if (filter instanceof BinaryLogicOperator) {
            BinaryLogicOperator lf = (BinaryLogicOperator) filter;
            for( Filter testFilter : lf.getChildren() ){
                if (!(this.fullySupports(testFilter))) {
                    supports = false;
                    break;
                }
            }
        }
        else if (filter instanceof Not) {
            Not lf = (Not) filter;
            if (!(this.fullySupports(lf.getFilter()))) {
                supports = false;
            }
        } else {
            supports = this.supports(filter);
        }
View Full Code Here

        assertEquals(3, mixed.getPropertyNames().length);

        Filter mixedFilter = mixed.getFilter();
        assertNotNull(mixedFilter);
        assertTrue(mixedFilter instanceof BinaryLogicOperator);
        BinaryLogicOperator f = (BinaryLogicOperator) mixedFilter;

        assertTrue(f instanceof And);
        for (Iterator fit = f.getChildren().iterator(); fit.hasNext();) {
            Filter subFilter = (Filter) fit.next();
            assertTrue(filter1.equals(subFilter) || filter2.equals(subFilter));
        }
       
        // check mixing hints too
View Full Code Here

                }
            };
            return (Filter) baseFilter.accept(remove, ff);
        }
        else {
            BinaryLogicOperator blo = (BinaryLogicOperator) baseFilter;
            List<Filter> children = blo.getChildren();
            if (children == null ){
                children = Collections.emptyList();
            }
           
            List<Filter> copy = new ArrayList<Filter>( children.size() );
View Full Code Here

TOP

Related Classes of org.opengis.filter.BinaryLogicOperator

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.