Class GeometryFilterImpl
- Object
-
- FilterAbstract
-
- AbstractFilter
-
- BinaryComparisonAbstract
-
- GeometryFilterImpl
-
- All Implemented Interfaces:
Filter
,MultiValuedFilter
,BinarySpatialOperator
,SpatialOperator
,FilterType
- Direct Known Subclasses:
AbstractPreparedGeometryFilter
,CartesianDistanceFilter
,CrossesImpl
,EqualsImpl
,OverlapsImpl
,TouchesImpl
public abstract class GeometryFilterImpl extends BinaryComparisonAbstract implements BinarySpatialOperator
Implements a geometry filter.This filter implements a relationship - of some sort - between two geometry expressions. Note that this comparison does not attempt to restict its expressions to be meaningful. This means that it considers itself a valid filter as long as it contains two geometry sub-expressions. It is also slightly less restrictive than the OGC Filter specification because it does not require that one sub-expression be an geometry attribute and the other be a geometry literal.
In other words, you may use this filter to compare two geometries in the same feature, such as: attributeA inside attributeB? You may also compare two literal geometries, although this is fairly meaningless, since it could be reduced (ie. it is always either true or false). This approach is very similar to that taken in the FilterCompare class.
- Author:
- Rob Hranac, TOPP
- TODO:
- REVISIT: make this class (and all filters) immutable, implement cloneable and return new filters when calling addLeftGeometry and addRightG Issues to think through: would be cleaner immutability to have constructor called with left and right Geometries, but this does not jive with SAX parsing, which is one of the biggest uses of filters. But the alternative is not incredibly efficient either, as there will be two filters that are just thrown away every time we make a full geometry filter. These issues extend to most filters, as just about all of them are mutable when creating them. Other issue is that lots of code will need to be changed for immutability. (comments by cholmes) - MUTABLE FACTORIES! Sax and immutability.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface MultiValuedFilter
MultiValuedFilter.MatchAction
-
-
Field Summary
Fields Modifier and Type Field Description protected MultiValuedFilter.MatchAction
matchAction
-
Fields inherited from class BinaryComparisonAbstract
expression1, expression2
-
Fields inherited from class AbstractFilter
LOGGER
-
Fields inherited from interface FilterType
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
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
GeometryFilterImpl(Expression e1, Expression e2)
protected
GeometryFilterImpl(Expression e1, Expression e2, MultiValuedFilter.MatchAction matchAction)
protected
GeometryFilterImpl(FilterFactory factory)
protected
GeometryFilterImpl(MultiValuedFilter.MatchAction matchAction)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
Compares this filter to the specified object.boolean
evaluate(Object feature)
Give an object, this method determines if the test(s) represented by this filter object are passed.protected abstract boolean
evaluateInternal(Geometry left, Geometry right)
Performs the calculation on the two geometries.protected static Object
getGeometries(Expression expr, Object feature)
NC - support for multiple values Convenience method for returning expression as either a geometry or a list of geometries.MultiValuedFilter.MatchAction
getMatchAction()
* Flag Controlling MatchAction property When one or more of the operands evaluates to multiple values rather than a single value, which action should be taken?int
hashCode()
Override of hashCode method.String
toString()
Return this filter as a string.-
Methods inherited from class BinaryComparisonAbstract
comparable, eval, eval, getExpression1, getExpression2, isMatchingCase, setExpression1, setExpression2
-
Methods inherited from class AbstractFilter
isCompareFilter, isGeometryDistanceFilter, isGeometryFilter, isLogicFilter, isMathFilter, isSimpleFilter
-
Methods inherited from class FilterAbstract
accepts, eval, eval
-
Methods inherited from interface BinarySpatialOperator
getExpression1, getExpression2
-
-
-
-
Field Detail
-
matchAction
protected MultiValuedFilter.MatchAction matchAction
-
-
Constructor Detail
-
GeometryFilterImpl
protected GeometryFilterImpl(MultiValuedFilter.MatchAction matchAction)
-
GeometryFilterImpl
protected GeometryFilterImpl(Expression e1, Expression e2, MultiValuedFilter.MatchAction matchAction)
-
GeometryFilterImpl
protected GeometryFilterImpl(FilterFactory factory)
-
GeometryFilterImpl
protected GeometryFilterImpl(Expression e1, Expression e2)
-
-
Method Detail
-
getGeometries
protected static Object getGeometries(Expression expr, Object feature)
NC - support for multiple values Convenience method for returning expression as either a geometry or a list of geometries.
-
toString
public String toString()
Return this filter as a string.
-
equals
public boolean equals(Object obj)
Compares this filter to the specified object. Returns true if the passed in object is the same as this filter. Checks to make sure the filter types are the same as well as the left and right geometries.
-
hashCode
public int hashCode()
Override of hashCode method.
-
getMatchAction
public MultiValuedFilter.MatchAction getMatchAction()
Description copied from interface:MultiValuedFilter
* Flag Controlling MatchAction property When one or more of the operands evaluates to multiple values rather than a single value, which action should be taken? If there are n values for the left operand and m values for the right operand, there are n * m possible combinations that can be compared,ANY - if any of the possible combinations match, the result is true (aggregated OR) ALL - only if all of the possible combinations match, the result is true (aggregated AND) ONE - only if exactly one of the possible combinations match, the result is true (aggregated XOR)
- Specified by:
getMatchAction
in interfaceMultiValuedFilter
- Overrides:
getMatchAction
in classBinaryComparisonAbstract
- Returns:
- MatchAction flag
-
evaluate
public final boolean evaluate(Object feature)
Description copied from interface:Filter
Give an object, this method determines if the test(s) represented by this filter object are passed.This ability is used to allow Queries against both Features and and non spatial data (such as Record) and to express constraints on permissable data values.
-
evaluateInternal
protected abstract boolean evaluateInternal(Geometry left, Geometry right)
Performs the calculation on the two geometries.- Parameters:
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)- Returns:
- true if the filter evaluates to true for the two geometries
-
-