Examples of BinarySpatialOperator


Examples of org.opengis.filter.spatial.BinarySpatialOperator

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

            BinarySpatialOperator lf = (BinarySpatialOperator) value;

            switch ( Filters.getFilterType( lf )) {
            case GEOMETRY_BBOX:
                BBOXType.getInstance().encode(new FilterElement("BBOX",
                        BBOXType.getInstance(), element), value, output, hints);

                return;

            case GEOMETRY_BEYOND:
                DistanceBufferType.getInstance().encode(new FilterElement(
                        "Beyond", DistanceBufferType.getInstance(), element),
                    value, output, hints);

                return;

            case GEOMETRY_CONTAINS:
                BinarySpatialOpType.getInstance().encode(new FilterElement(
                        "Contains", BinarySpatialOpType.getInstance(), element),
                    value, output, hints);

                return;

            case GEOMETRY_CROSSES:
                BinarySpatialOpType.getInstance().encode(new FilterElement(
                        "Crosses", BinarySpatialOpType.getInstance(), element),
                    value, output, hints);

                return;

            case GEOMETRY_DISJOINT:
                BinarySpatialOpType.getInstance().encode(new FilterElement(
                        "Disjoint", BinarySpatialOpType.getInstance(), element),
                    value, output, hints);

                return;

            case GEOMETRY_DWITHIN:
                DistanceBufferType.getInstance().encode(new FilterElement(
                        "DWithin", DistanceBufferType.getInstance(), element),
                    value, output, hints);

                return;

            case GEOMETRY_EQUALS:
                BinarySpatialOpType.getInstance().encode(new FilterElement(
                        "Equals", BinarySpatialOpType.getInstance(), element),
                    value, output, hints);

                return;

            case GEOMETRY_INTERSECTS:
                BinarySpatialOpType.getInstance().encode(new FilterElement(
                        "Intersects", BinarySpatialOpType.getInstance(), element),
                    value, output, hints);

                return;

            case GEOMETRY_OVERLAPS:
                BinarySpatialOpType.getInstance().encode(new FilterElement(
                        "Overlaps", BinarySpatialOpType.getInstance(), element),
                    value, output, hints);

                return;

            case GEOMETRY_TOUCHES:
                BinarySpatialOpType.getInstance().encode(new FilterElement(
                        "Touches", BinarySpatialOpType.getInstance(), element),
                    value, output, hints);

                return;

            case GEOMETRY_WITHIN:
                BinarySpatialOpType.getInstance().encode(new FilterElement(
                        "Within", BinarySpatialOpType.getInstance(), element),
                    value, output, hints);

                return;
            }

            throw new OperationNotSupportedException(
                "Unknown filter type in ComparisonFilter: "
                + lf.getClass().getName());
        }
View Full Code Here

Examples of org.opengis.filter.spatial.BinarySpatialOperator

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

            BinarySpatialOperator lf = (BinarySpatialOperator) value;

            output.startElement(element.getNamespace(), element.getName(), null);
            short type1 = Filters.getExpressionType(lf.getExpression1());
            short type2 = Filters.getExpressionType(lf.getExpression2());
            if ((type1 == org.geotools.filter.ExpressionType.LITERAL_STRING)
                    || (type1 == org.geotools.filter.ExpressionType.ATTRIBUTE_STRING)
                    || (type1 == org.geotools.filter.ExpressionType.ATTRIBUTE)) {
                elems[0].getType().encode(elems[0], lf.getExpression1(),
                    output, hints); // prop name

                if (type2 == org.geotools.filter.ExpressionType.LITERAL_GEOMETRY) {
                    elems[1].getType().encode(elems[1],
                        ((Literal) lf.getExpression2()).getValue(),
                        output, hints); // geom
                } else {
                    elems[2].getType().encode(elems[2],
                        ((Literal) lf.getExpression2()).getValue(),
                        output, hints); // geom
                }
            } else {
               
                if ((type2 == org.geotools.filter.ExpressionType.LITERAL_STRING)
                        || (type2 == org.geotools.filter.ExpressionType.ATTRIBUTE_STRING)
                        || (type2 == org.geotools.filter.ExpressionType.ATTRIBUTE)) {
                    elems[0].getType().encode(elems[0], lf.getExpression2(),
                        output, hints); // prop name

                    if (type1 == org.geotools.filter.ExpressionType.LITERAL_GEOMETRY) {
                        elems[1].getType().encode(elems[1],
                            ((Literal) lf.getExpression1())
                            .getValue(), output, hints); // geom
                    } else {
                        elems[2].getType().encode(elems[2],
                            ((Literal) lf.getExpression1())
                            .getValue(), output, hints); // geom
                    }
                } else {
                    throw new OperationNotSupportedException(
                            "Either the left or right expr must be a literal for the property name l="
View Full Code Here

Examples of org.opengis.filter.spatial.BinarySpatialOperator

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

            BinarySpatialOperator lf = (BinarySpatialOperator) value;

            output.startElement(element.getNamespace(), element.getName(), null);
            short TYPE1 = Filters.getExpressionType(lf.getExpression1());
            short TYPE2 = Filters.getExpressionType(lf.getExpression2());
            if (TYPE1 == org.geotools.filter.ExpressionType.LITERAL_GEOMETRY) {
                elems[0].getType().encode(elems[0], lf.getExpression2(),
                    output, hints); // prop name

                Geometry g = ((Geometry) ((Literal) lf
                    .getExpression1()).getValue()).getEnvelope();
                elems[1].getType().encode(elems[1], g, output, hints); // geom
            } else {
                if (TYPE2 == org.geotools.filter.ExpressionType.LITERAL_GEOMETRY) {
                    elems[0].getType().encode(elems[0], lf.getExpression1(),
                        output, hints); // prop name

                    Geometry g = ((Geometry) ((Literal) lf
                        .getExpression2()).getValue()).getEnvelope();
                    elems[1].getType().encode(elems[1], g, output, hints); // geom
                } else {
                    throw new OperationNotSupportedException(
                        "Either the left or right expr must be a literal for the property name : BBOXType");
View Full Code Here

Examples of org.opengis.filter.spatial.BinarySpatialOperator

        //        }
    }

    public Object getProperty(Object object, QName name)
        throws Exception {
        BinarySpatialOperator operator = (BinarySpatialOperator) object;

        return OGCUtils.property(operator.getExpression1(), operator.getExpression2(), name);
    }
View Full Code Here

Examples of org.opengis.filter.spatial.BinarySpatialOperator

    }
   
    public List getProperties(Object object) throws Exception {
        //special hack for Functions, while not mandated by the spec we handle it
        // here
        BinarySpatialOperator operator = (BinarySpatialOperator) object;
        if ( operator.getExpression2() instanceof Function ) {
            ArrayList props = new ArrayList();
            props.add( new Object[]{ OGC.Function, operator.getExpression2() } );
            return props;
        }
       
        return super.getProperties(object);
    }
View Full Code Here

Examples of org.opengis.filter.spatial.BinarySpatialOperator

                    bounds.expandToInclude(e);
                }
            }
            result = bounds;
        } else if (filter instanceof BinarySpatialOperator) {
            BinarySpatialOperator gf = (BinarySpatialOperator) filter;
            if (supportedFilterTypes.contains(gf.getClass())) {
                Expression lg = gf.getExpression1();
                Expression rg = gf.getExpression2();
                if (lg instanceof Literal) {
                    Geometry g = (Geometry) ((Literal) lg).getValue();
                    if (rg instanceof PropertyName) {
                        result = g.getEnvelopeInternal();
                    }
View Full Code Here

Examples of org.opengis.filter.spatial.BinarySpatialOperator

     *
     * </p>
     */
    @Test
    public void geometryLiterals() throws Exception {
        BinarySpatialOperator result;
        Literal geom;

        // Point":" <time-second> "Z"
        result = (BinarySpatialOperator) CompilerUtil.parseFilter(this.language, "WITHIN(ATTR1, POINT(1 2))");

        geom = (Literal) result.getExpression2();

        Assert.assertNotNull(geom.getValue());
        Assert.assertTrue(geom.getValue() instanceof com.vividsolutions.jts.geom.Point);

        // LineString
        result = (BinarySpatialOperator) CompilerUtil.parseFilter(this.language,"WITHIN(ATTR1, LINESTRING(1 2, 10 15))");

        geom = (Literal) result.getExpression2();

        Assert.assertNotNull(geom.getValue());
        Assert.assertTrue(geom.getValue() instanceof com.vividsolutions.jts.geom.LineString);

        // Polygon
        result = (BinarySpatialOperator) CompilerUtil.parseFilter(this.language,
                "WITHIN(ATTR1, POLYGON((1 2, 15 2, 15 20, 15 21, 1 2)))");

        geom = (Literal) result.getExpression2();

        Assert.assertNotNull(geom.getValue());
        Assert.assertTrue(geom.getValue() instanceof com.vividsolutions.jts.geom.Polygon);

        // MultiPoint
        result = (BinarySpatialOperator) CompilerUtil.parseFilter(this.language,
                "WITHIN(ATTR1, MULTIPOINT( (1 2), (15 2), (15 20), (15 21), (1 2) ))");

        geom = (Literal) result.getExpression2();

        Assert.assertNotNull(geom.getValue());
        Assert.assertTrue(geom.getValue() instanceof com.vividsolutions.jts.geom.MultiPoint);

        // MultiLineString
        result = (BinarySpatialOperator) CompilerUtil.parseFilter(this.language,
                "WITHIN(ATTR1, MULTILINESTRING((10 10, 20 20),(15 15,30 15)) )");

        geom = (Literal) result.getExpression2();

        Assert.assertNotNull(geom.getValue());
        Assert.assertTrue(geom.getValue() instanceof com.vividsolutions.jts.geom.MultiLineString);

        // MultiPolygon
        result = (BinarySpatialOperator) CompilerUtil.parseFilter(this.language,
                "WITHIN(ATTR1, MULTIPOLYGON( ((10 10, 10 20, 20 20, 20 15, 10 10)),((60 60, 70 70, 80 60, 60 60 )) ) )");

        geom = (Literal) result.getExpression2();

        Assert.assertNotNull(geom.getValue());
        Assert.assertTrue(geom.getValue() instanceof com.vividsolutions.jts.geom.MultiPolygon);

        // ENVELOPE
        result = (BinarySpatialOperator) CompilerUtil.parseFilter(this.language,
                "WITHIN(ATTR1, ENVELOPE( 10, 20, 30, 40) )");

        geom = (Literal) result.getExpression2();

        Assert.assertNotNull(geom.getValue());
        Assert.assertTrue(geom.getValue() instanceof com.vividsolutions.jts.geom.Polygon);
    }
View Full Code Here

Examples of org.opengis.filter.spatial.BinarySpatialOperator

     * @throws CQLException
     */
    private BinarySpatialOperator buildBinarySpatialOperator(final int nodeType)
            throws CQLException {

        BinarySpatialOperator filter = null;

        switch (nodeType) {
        case JJTROUTINEINVOCATION_GEOOP_EQUAL_NODE:
            filter = this.builder.buildSpatialEqualFilter();
            break;
View Full Code Here

Examples of org.opengis.filter.spatial.BinarySpatialOperator

                else
                    bounds.expandToInclude(e);
            }
            result = bounds;
        } else if (filter instanceof BinarySpatialOperator) {
            BinarySpatialOperator gf = (BinarySpatialOperator) filter;
            if (supportedFilterTypes.contains(gf.getClass())) {
                Expression lg = gf.getExpression1();
                Expression rg = gf.getExpression2();
                if (lg instanceof Literal) {
                    Geometry g = (Geometry) ((Literal) lg).getValue();
                    if (rg instanceof PropertyName)
                        result = g.getEnvelopeInternal();
                } else if (rg instanceof Literal) {
View Full Code Here

Examples of org.opengis.filter.spatial.BinarySpatialOperator

        PostPreProcessFilterSplittingVisitor visitor = new PostPreProcessFilterSplittingVisitor(
                GEOMETRY_FILTER_CAPABILITIES, schema, null);
        filter.accept(visitor, null);
        Filter preFilter = visitor.getFilterPre();
        if (preFilter instanceof BinarySpatialOperator) {
            BinarySpatialOperator bso = ((BinarySpatialOperator) preFilter);
            Expression geomExpression = null;
            if (bso.getExpression1() instanceof PropertyName
                    && bso.getExpression2() instanceof Literal) {
                geomExpression = bso.getExpression2();
            } else if (bso.getExpression1() instanceof Literal
                    && bso.getExpression2() instanceof PropertyName) {
                geomExpression = bso.getExpression1();
            }
            if (geomExpression != null) {
                Geometry geom = geomExpression.evaluate(null, Geometry.class);
                return geom;
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.