org.geotools.filter
Class GeometryFilterImpl

java.lang.Object
  extended by org.geotools.filter.FilterAbstract
      extended by org.geotools.filter.AbstractFilter
          extended by org.geotools.filter.BinaryComparisonAbstract
              extended by org.geotools.filter.GeometryFilterImpl
All Implemented Interfaces:
FilterType, GeometryFilter, org.opengis.filter.BinaryComparisonOperator, org.opengis.filter.Filter, org.opengis.filter.spatial.BinarySpatialOperator, org.opengis.filter.spatial.SpatialOperator
Direct Known Subclasses:
AbstractPreparedGeometryFilter, CartesianDistanceFilter, CrossesImpl, EqualsImpl, OverlapsImpl, TouchesImpl

public abstract class GeometryFilterImpl
extends BinaryComparisonAbstract
implements GeometryFilter

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.

Version:
$Id: GeometryFilterImpl.java 32201 2009-01-12 10:20:34Z jesseeichar $
Author:
Rob Hranac, TOPP

Field Summary
 
Fields inherited from class org.geotools.filter.BinaryComparisonAbstract
expression1, expression2
 
Fields inherited from class org.geotools.filter.AbstractFilter
filterType, permissiveConstruction
 
Fields inherited from class org.geotools.filter.FilterAbstract
factory
 
Fields inherited from interface org.geotools.filter.Filter
ALL, NONE
 
Fields inherited from interface org.geotools.filter.FilterType
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, NULL
 
Fields inherited from interface org.opengis.filter.Filter
EXCLUDE, INCLUDE
 
Constructor Summary
protected GeometryFilterImpl(org.opengis.filter.FilterFactory factory)
           
protected GeometryFilterImpl(org.opengis.filter.FilterFactory factory, org.opengis.filter.expression.Expression e1, org.opengis.filter.expression.Expression e2)
           
protected GeometryFilterImpl(short filterType)
          Constructor with filter type.
 
Method Summary
 void addLeftGeometry(Expression leftGeometry)
          Deprecated. use setExpression1(org.opengis.filter.expression.Expression)
 void addRightGeometry(Expression rightGeometry)
          Deprecated. use #set
 boolean equals(java.lang.Object obj)
          Compares this filter to the specified object.
 boolean evaluate(org.opengis.feature.simple.SimpleFeature feature)
          Determines whether or not a given feature is 'inside' this filter.
 Expression getLeftGeometry()
          Deprecated. use BinarySpatialOperator.getExpression1()
protected  com.vividsolutions.jts.geom.Geometry getLeftGeometry(java.lang.Object feature)
          Subclass convenience method for returning left expression as a JTS geometry.
 Expression getRightGeometry()
          Deprecated. use BinarySpatialOperator.getExpression2()
protected  com.vividsolutions.jts.geom.Geometry getRightGeometry(java.lang.Object feature)
          Subclass convenience method for returning right expression as a JTS geometry.
 int hashCode()
          Override of hashCode method.
 void setExpression1(org.opengis.filter.expression.Expression expression)
           
 void setExpression2(org.opengis.filter.expression.Expression expression)
           
 java.lang.String toString()
          Return this filter as a string.
protected  boolean validate(org.opengis.feature.simple.SimpleFeature feature)
          Subclass convenience method to make sure we have geometry instances on both the left and right hand sides.
 
Methods inherited from class org.geotools.filter.BinaryComparisonAbstract
and, comparable, eval, getExpression1, getExpression2, isMatchingCase, not, or
 
Methods inherited from class org.geotools.filter.AbstractFilter
accept, contains, getFilterType, isCompareFilter, isGeometryDistanceFilter, isGeometryFilter, isLogicFilter, isMathFilter, isSimpleFilter
 
Methods inherited from class org.geotools.filter.FilterAbstract
accept, accepts, eval, eval, eval
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.geotools.filter.GeometryFilter
contains
 
Methods inherited from interface org.geotools.filter.Filter
accept, and, getFilterType, not, or
 
Methods inherited from interface org.opengis.filter.spatial.BinarySpatialOperator
getExpression1, getExpression2
 
Methods inherited from interface org.opengis.filter.Filter
accept, evaluate
 

Constructor Detail

GeometryFilterImpl

protected GeometryFilterImpl(org.opengis.filter.FilterFactory factory)

GeometryFilterImpl

protected GeometryFilterImpl(org.opengis.filter.FilterFactory factory,
                             org.opengis.filter.expression.Expression e1,
                             org.opengis.filter.expression.Expression e2)

GeometryFilterImpl

protected GeometryFilterImpl(short filterType)
                      throws IllegalFilterException
Constructor with filter type.

Parameters:
filterType - The type of comparison.
Throws:
IllegalFilterException - Non-geometry type.
Method Detail

addLeftGeometry

public final void addLeftGeometry(Expression leftGeometry)
                           throws IllegalFilterException
Deprecated. use setExpression1(org.opengis.filter.expression.Expression)

Adds the 'left' value to this filter.

Specified by:
addLeftGeometry in interface GeometryFilter
Parameters:
leftGeometry - Expression for 'left' value.
Throws:
IllegalFilterException - Filter is not internally consistent.

setExpression1

public void setExpression1(org.opengis.filter.expression.Expression expression)
Overrides:
setExpression1 in class BinaryComparisonAbstract

addRightGeometry

public final void addRightGeometry(Expression rightGeometry)
                            throws IllegalFilterException
Deprecated. use #set

Adds the 'right' value to this filter.

Specified by:
addRightGeometry in interface GeometryFilter
Parameters:
rightGeometry - Expression for 'right' value.
Throws:
IllegalFilterException - Filter is not internally consistent.

setExpression2

public void setExpression2(org.opengis.filter.expression.Expression expression)
Overrides:
setExpression2 in class BinaryComparisonAbstract

getLeftGeometry

public final Expression getLeftGeometry()
Deprecated. use BinarySpatialOperator.getExpression1()

Retrieves the expression on the left side of the comparison.

Specified by:
getLeftGeometry in interface GeometryFilter
Returns:
the expression on the left.

getRightGeometry

public final Expression getRightGeometry()
Deprecated. use BinarySpatialOperator.getExpression2()

Retrieves the expression on the right side of the comparison.

Specified by:
getRightGeometry in interface GeometryFilter
Returns:
the expression on the right.

getLeftGeometry

protected com.vividsolutions.jts.geom.Geometry getLeftGeometry(java.lang.Object feature)
Subclass convenience method for returning left expression as a JTS geometry.


getRightGeometry

protected com.vividsolutions.jts.geom.Geometry getRightGeometry(java.lang.Object feature)
Subclass convenience method for returning right expression as a JTS geometry.


validate

protected boolean validate(org.opengis.feature.simple.SimpleFeature feature)
Subclass convenience method to make sure we have geometry instances on both the left and right hand sides.

Returns:
true iff we can perform a geometry operation

evaluate

public boolean evaluate(org.opengis.feature.simple.SimpleFeature feature)
Determines whether or not a given feature is 'inside' this filter.

Overrides:
evaluate in class FilterAbstract
Parameters:
feature - Specified feature to examine.
Returns:
Flag confirming whether or not this feature is inside filter.

toString

public java.lang.String toString()
Return this filter as a string.

Overrides:
toString in class java.lang.Object
Returns:
String representation of this geometry filter.

equals

public boolean equals(java.lang.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.

Overrides:
equals in class java.lang.Object
Parameters:
obj - - the object to compare this GeometryFilter against.
Returns:
true if specified object is equal to this filter; else false

hashCode

public int hashCode()
Override of hashCode method.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this geometry filter.


Copyright © 1996-2010 Geotools. All Rights Reserved.