org.geotools.filter
Class CartesianDistanceFilter

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
                  extended by org.geotools.filter.CartesianDistanceFilter
All Implemented Interfaces:
FilterType, GeometryDistanceFilter, GeometryFilter, org.opengis.filter.BinaryComparisonOperator, org.opengis.filter.Filter, org.opengis.filter.spatial.BinarySpatialOperator, org.opengis.filter.spatial.DistanceBufferOperator, org.opengis.filter.spatial.SpatialOperator
Direct Known Subclasses:
BeyondImpl, DWithinImpl

public abstract class CartesianDistanceFilter
extends GeometryFilterImpl
implements GeometryDistanceFilter

Defines geometry filters with a distance element.

These filters are defined in the filter spec by the DistanceBufferType, which contains an additioinal field for a distance. The two filters that use the distance buffer type are Beyond and DWithin.

From the spec: The spatial operators DWithin and Beyond test whether the value of a geometric property is within or beyond a specified distance of the specified literal geometric value. Distance values are expressed using the Distance element.

For now this code does not take into account the units of distance, we will assume that the filter units are the same as the geometry being filtered, and that they are cartesian.

Version:
$Id: CartesianDistanceFilter.java 31681 2008-10-18 19:02:26Z aaime $
Author:
Chris Holmes, 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 CartesianDistanceFilter(org.opengis.filter.FilterFactory factory)
           
protected CartesianDistanceFilter(org.opengis.filter.FilterFactory factory, org.opengis.filter.expression.Expression e1, org.opengis.filter.expression.Expression e2)
           
protected CartesianDistanceFilter(short filterType)
          Constructor which flags the operator as between.
 
Method Summary
 boolean equals(java.lang.Object oFilter)
          Returns true if the passed in object is the same as this filter.
 double getDistance()
          Gets the distance allowed by this filter.
 java.lang.String getDistanceUnits()
           
 int hashCode()
          Override of hashCode method.
 void setDistance(double distance)
          Sets the distance allowed by this filter.
 void setUnits(java.lang.String units)
           
 java.lang.String toString()
          Returns a string representation of this filter.
 
Methods inherited from class org.geotools.filter.GeometryFilterImpl
addLeftGeometry, addRightGeometry, evaluate, getLeftGeometry, getLeftGeometry, getRightGeometry, getRightGeometry, setExpression1, setExpression2, validate
 
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.GeometryDistanceFilter
contains
 
Methods inherited from interface org.geotools.filter.GeometryFilter
addLeftGeometry, addRightGeometry, getLeftGeometry, getRightGeometry
 
Methods inherited from interface org.geotools.filter.Filter
accept, and, evaluate, 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

CartesianDistanceFilter

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

CartesianDistanceFilter

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

CartesianDistanceFilter

protected CartesianDistanceFilter(short filterType)
                           throws IllegalFilterException
Constructor which flags the operator as between.

Parameters:
filterType - The type of filter to create - dwithin and beyond are allowed.
Throws:
IllegalFilterException - If a filter other than dwithin or beyond is attempted.
Method Detail

setDistance

public void setDistance(double distance)
Sets the distance allowed by this filter.

Specified by:
setDistance in interface GeometryDistanceFilter
Parameters:
distance - the length beyond which this filter is valid or not.

getDistance

public double getDistance()
Gets the distance allowed by this filter.

Specified by:
getDistance in interface GeometryDistanceFilter
Specified by:
getDistance in interface org.opengis.filter.spatial.DistanceBufferOperator
Returns:
distance the length beyond which this filter is valid or not.

getDistanceUnits

public java.lang.String getDistanceUnits()
Specified by:
getDistanceUnits in interface org.opengis.filter.spatial.DistanceBufferOperator

setUnits

public void setUnits(java.lang.String units)

toString

public java.lang.String toString()
Returns a string representation of this filter.

Overrides:
toString in class GeometryFilterImpl
Returns:
String representation of the between filter.

equals

public boolean equals(java.lang.Object oFilter)
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 all three of the values.

Specified by:
equals in interface GeometryDistanceFilter
Overrides:
equals in class GeometryFilterImpl
Parameters:
oFilter - The filter to test equality against.
Returns:
True if the objects are equal.

hashCode

public int hashCode()
Override of hashCode method.

Overrides:
hashCode in class GeometryFilterImpl
Returns:
a code to hash this object by.


Copyright © 1996-2010 Geotools. All Rights Reserved.