@Override public Expression getExpression2(BinarySpatialOperator filter) { return filter.getExpression2(); }
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); } }
public Object getProperty(Object object, QName name) throws Exception { BinarySpatialOperator operator = (BinarySpatialOperator) object; return OGCUtils.property(operator.getExpression1(), operator.getExpression2(), name); }
public SpatialOperation(BinarySpatialOperator op) { this.op = op; for (Class<?> iface : op.getClass().getInterfaces()) { if (SPATIAL_OPERATIONS.contains(iface)) { operation = iface; break; } } if (op.getExpression1() instanceof Literal) { geometry = op.getExpression1().evaluate(null, Geometry.class); } else if (op.getExpression2() instanceof Literal) { geometry = op.getExpression2().evaluate(null, Geometry.class); } else { throw new IllegalArgumentException( "Cannot find literal geometry in the spatial filter"); } } }
protected Object visitBinarySpatialOperator(BinarySpatialOperator filter, Object extraData) { Expression ex1 = filter.getExpression1(); Expression ex2 = filter.getExpression2(); PropertyName pn = null; if (ex1 instanceof PropertyName && ex2 instanceof Literal) { pn = (PropertyName) ex1; } else if (ex1 instanceof Literal && ex2 instanceof PropertyName) { pn = (PropertyName) ex2; } if (pn != null) { String name = pn.getPropertyName(); if (spatialProperties.containsKey(name)) { Integer count = spatialProperties.get(name); spatialProperties.put(name, count + 1); } else { spatialProperties.put(name, 1); } } return null; } }
/** * Visits filter.getExpression1(),filter.getExpression2() if an expression visitor has been set. */ protected Object visit(BinarySpatialOperator filter, Object data) { if (expressionVisitor != null) { if (filter.getExpression1() != null) { filter.getExpression1().accept(expressionVisitor, data); } if (filter.getExpression2() != null) { filter.getExpression2().accept(expressionVisitor, data); } } return filter; }
public Expression[][] visitBinarySpatialOp(BinarySpatialOperator filter) { Expression left = filter.getExpression1(); Expression right = filter.getExpression2(); List leftExpressions = (List) left.accept(this, null); List rightExpressions = (List) right.accept(this, null); if (leftExpressions.size() == 0) { throw new IllegalStateException(left + " mapping not found"); } if (rightExpressions.size() == 0) { throw new IllegalStateException(right + " mapping not found"); } Expression[][] product = buildExpressionsMatrix(leftExpressions, rightExpressions); return product; }
static Expression getProperty(BinarySpatialOperator op, QName name) { return getProperty(op.getExpression1(), op.getExpression2(), name); }
public static Object buildBinarySpatialOperator( String spatialOperator, BinarySpatialOperator filter, Object extraData, ExpressionToText visitor) { LOGGER.finer("exporting " + spatialOperator); StringBuilder output = asStringBuilder(extraData); output.append(spatialOperator).append("("); Expression expr = filter.getExpression1(); expr.accept(visitor, output); output.append(", "); filter.getExpression2().accept(visitor, output); output.append(")"); return output; }
rightGeometry = ((BinarySpatialOperator) filter).getExpression2();
rightGeometry = ((BinarySpatialOperator) filter).getExpression2();
protected Envelope extractBboxForSpatialIndexQuery(BinarySpatialOperator filter) { org.opengis.filter.expression.Expression leftGeom = filter.getExpression1(); org.opengis.filter.expression.Expression rightGeom = filter.getExpression2(); Geometry g; if (leftGeom instanceof org.opengis.filter.expression.Literal) { g = (Geometry) ((org.opengis.filter.expression.Literal) leftGeom).getValue(); } else { g = (Geometry) ((org.opengis.filter.expression.Literal) rightGeom).getValue(); } return g.getEnvelopeInternal(); }
SpatialOperation so = null; if (bso.getExpression1() instanceof PropertyName && bso.getExpression2() instanceof Literal) { name = ((PropertyName) bso.getExpression1()).getPropertyName(); so = new SpatialOperation(bso); } else if (bso.getExpression2() instanceof PropertyName && bso.getExpression1() instanceof Literal) { name = ((PropertyName) bso.getExpression2()).getPropertyName(); so = new SpatialOperation(bso);
Expression e2 = op.getExpression2(); e1 = (PropertyName) op.getExpression2(); e2 = (Literal) op.getExpression1();
Envelope getEnvelope(Filter filter) { Envelope result = originalBounds; if (filter instanceof And) { Envelope bounds = new Envelope(); for (Iterator iter = ((And) filter).getChildren().iterator(); iter.hasNext(); ) { Filter f = (Filter) iter.next(); Envelope e = getEnvelope(f); if (e == null) return null; 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) { Geometry g = (Geometry) ((Literal) rg).getValue(); if (lg instanceof PropertyName) result = g.getEnvelopeInternal(); } } } return result.intersection(originalBounds); }
if (supportedFilterTypes.contains(gf.getClass())) { Expression lg = gf.getExpression1(); Expression rg = gf.getExpression2(); if (lg instanceof Literal) { Geometry g = (Geometry) ((Literal) lg).getValue();
Object transform(final BinarySpatialOperator filter, Object extraData) { // check working assumptions, first expression is a property final CoordinateReferenceSystem propertyCrs; if (filter.getExpression1() instanceof BoundedByFunction) { propertyCrs = featureType.getCoordinateReferenceSystem(); } else { if (!(filter.getExpression1() instanceof PropertyName)) { throw new IllegalArgumentException( "Binary geometry filter, but first expression " + "is not a property name? (it's a " + filter.getExpression1().getClass() + ")"); } propertyCrs = findPropertyCRS((PropertyName) filter.getExpression1()); } if (propertyCrs == null) return cloneFilter(filter, extraData); // "transformed" expressions Expression ex1 = (Expression) filter.getExpression1() .accept(ReprojectingFilterVisitor.this, extraData); Expression ex2 = reproject(filter.getExpression2(), propertyCrs, true); return cloneFilter(filter, extraData, ex1, ex2); }
right = filter.getExpression2(); if (left instanceof PropertyName && right instanceof Literal) { propertyExpr = (PropertyName) left;
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) ((Literal) lf.getExpression2()).getValue()).getEnvelope(); elems[1].getType().encode(elems[1], g, output, hints); // geom } else {
short type2 = Filters.getExpressionType(lf.getExpression2()); if ((type1 == org.geotools.filter.ExpressionType.LITERAL_STRING) || (type1 == org.geotools.filter.ExpressionType.ATTRIBUTE_STRING) .encode( elems[1], ((Literal) lf.getExpression2()).getValue(), output, .encode( elems[2], ((Literal) lf.getExpression2()).getValue(), output, || (type2 == org.geotools.filter.ExpressionType.ATTRIBUTE)) { elems[0].getType() .encode(elems[0], lf.getExpression2(), output, hints); // prop name