public abstract class AbstractPreparedGeometryFilter extends GeometryFilterImpl
This class determines when the expressions are set which expressions are literals. The protected
field literals
contains the AbstractPreparedGeometryFilter.Literals
enumerated value that indicates if:
If BOTH of the expressions are literals then a cached value is generated by calling {@link #basicEvaluate(Geometry, Geometry)}.
The method {@link #basicEvaluate(Geometry, Geometry)} is required to be implemented so that a cached value can be generated in the case that both expressions are literals
public boolean evaluate(Object feature) {
if (feature instanceof SimpleFeature
&& !validate((SimpleFeature) feature)) {
// we could not obtain a geometry for both left and right hand sides
// so default to false
return false;
}
Geometry left;
Geometry right;
switch (literals) {
case BOTH:
return cacheValue;
case RIGHT: {
return rightPreppedGeom.intersects(getLeftGeometry(feature));
}
case LEFT: {
return leftPreppedGeom.intersects(getRightGeometry(feature));
}
default: {
left = getLeftGeometry(feature);
right = getRightGeometry(feature);
return basicEvaluate(left, right);
}
}
}
protected final boolean basicEvaluate(Geometry left, Geometry right) {
Envelope envLeft = left.getEnvelopeInternal();
Envelope envRight = right.getEnvelopeInternal();
return envRight.intersects(envLeft) && left.intersects(right);
}
Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractPreparedGeometryFilter.Literals
Constant that identifies which expressions are Literal and JTS Geometries
|
MultiValuedFilter.MatchAction
Modifier and Type | Field and Description |
---|---|
protected boolean |
cacheValue
If both expressions are literals the value will never change.
|
protected PreparedGeometry |
leftPreppedGeom
The PreparedGeometry for the left Geometry.
|
protected AbstractPreparedGeometryFilter.Literals |
literals
Indicates which expressions are
Literal s |
protected PreparedGeometry |
rightPreppedGeom
The PreparedGeometry for the right Geometry.
|
matchAction
expression1, expression2
ALL, BETWEEN, COMPARE_EQUALS, COMPARE_GREATER_THAN, COMPARE_GREATER_THAN_EQUAL, COMPARE_LESS_THAN, COMPARE_LESS_THAN_EQUAL, COMPARE_NOT_EQUALS, FID, GEOMETRY_BBOX, GEOMETRY_BEYOND, GEOMETRY_CONTAINS, GEOMETRY_CROSSES, GEOMETRY_DISJOINT, GEOMETRY_DWITHIN, GEOMETRY_EQUALS, GEOMETRY_INTERSECTS, GEOMETRY_OVERLAPS, GEOMETRY_TOUCHES, GEOMETRY_WITHIN, LIKE, LOGIC_AND, LOGIC_NOT, LOGIC_OR, NONE, NULL
Modifier | Constructor and Description |
---|---|
protected |
AbstractPreparedGeometryFilter(Expression e1,
Expression e2) |
protected |
AbstractPreparedGeometryFilter(Expression e1,
Expression e2,
MultiValuedFilter.MatchAction matchAction) |
Modifier and Type | Method and Description |
---|---|
protected abstract boolean |
basicEvaluate(Geometry left,
Geometry right)
Performs the calculation on the two geometries.
|
void |
setExpression1(Expression expression) |
void |
setExpression2(Expression expression) |
equals, evaluate, evaluateInternal, getGeometries, getMatchAction, hashCode, toString
comparable, eval, eval, getExpression1, getExpression2, isMatchingCase
isCompareFilter, isGeometryDistanceFilter, isGeometryFilter, isLogicFilter, isMathFilter, isSimpleFilter
accepts, eval, eval
getExpression1, getExpression2
protected AbstractPreparedGeometryFilter.Literals literals
Literal
sprotected PreparedGeometry leftPreppedGeom
Literal
protected PreparedGeometry rightPreppedGeom
Literal
protected boolean cacheValue
protected AbstractPreparedGeometryFilter(Expression e1, Expression e2)
protected AbstractPreparedGeometryFilter(Expression e1, Expression e2, MultiValuedFilter.MatchAction matchAction)
public void setExpression1(Expression expression)
setExpression1
in class BinaryComparisonAbstract
public void setExpression2(Expression expression)
setExpression2
in class BinaryComparisonAbstract
protected abstract boolean basicEvaluate(Geometry left, Geometry right)
left
- the geometry on the left of the equations (the geometry obtained from evaluating
Expression1)right
- the geometry on the right of the equations (the geometry obtained from
evaluating Expression2)Copyright © 1996–2019 Geotools. All rights reserved.