Class 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.

    Rob Hranac, TOPP
    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.
    • 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.
        toString in class Object
        String representation of this geometry filter.
      • 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.
        equals in class Object
        obj - - the object to compare this GeometryFilter against.
        true if specified object is equal to this filter; else false
      • hashCode

        public int hashCode()
        Override of hashCode method.
        hashCode in class Object
        a hash code value for this geometry filter.
      • 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 interface MultiValuedFilter
        getMatchAction in class BinaryComparisonAbstract
        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.

        Specified by:
        evaluate in interface Filter
        true if the test(s) are passed for the provided object
      • evaluateInternal

        protected abstract boolean evaluateInternal​(Geometry left,
                                                    Geometry right)
        Performs the calculation on the two geometries.
        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)
        true if the filter evaluates to true for the two geometries