skrueger.geotools
Class GeomFilterGenerator

java.lang.Object
  extended by skrueger.geotools.GeomFilterGenerator
Direct Known Subclasses:
GeomFilterGenerator.BoundingBoxFilterGenerator, GeomFilterGenerator.PointFilterGenerator

public abstract class GeomFilterGenerator
extends Object

The GeomFilterGenerator prepares a BinarySpatialOperator filter for multiple use. Only the "right" argument is prepared. The "left" argument (the geometry attribute of the FeatureSource to filter) is first set on calling #adaptFilter(FeatureSource) for a specific FeatureSource. This method also takes care to recreate the filter (or its "right" argument) if the given FeatureSource has another CoordinateReferenceSystem than the base constraint.
The type of filter (e.g. distance or bounding box) is specified by the subclass implemenation of #prepareFilter(CoordinateReferenceSystem) .

Author:
Martin Schmitz

Nested Class Summary
static class GeomFilterGenerator.BoundingBoxFilterGenerator
          GeomFilterGenerator for a bounding box constraint.
static class GeomFilterGenerator.PointFilterGenerator
          GeomFilterGenerator for a "near distance" constraint.
 
Field Summary
protected  CoordinateReferenceSystem baseCRS
          Holds the CoordinateReferenceSystem the filter constraint bases on.
 
Constructor Summary
GeomFilterGenerator(CoordinateReferenceSystem crs)
          Creates a new filter generator
 
Method Summary
 GeometryFilterImpl adaptFilter( fs)
          Completes the filter with its "left" argument for a concrete FeatureSource.
protected abstract  GeometryFilterImpl prepareFilter(CoordinateReferenceSystem crs, Class<?> geomClass)
          Creates a filter containing the base constraint ("right" argument) transformed to the given CoordinateReferenceSystem.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

baseCRS

protected CoordinateReferenceSystem baseCRS
Holds the CoordinateReferenceSystem the filter constraint bases on.

Constructor Detail

GeomFilterGenerator

public GeomFilterGenerator(CoordinateReferenceSystem crs)
Creates a new filter generator

Parameters:
crs - CoordinateReferenceSystem the base constraint ("right" filter argument is relative to)
Method Detail

prepareFilter

protected abstract GeometryFilterImpl prepareFilter(CoordinateReferenceSystem crs,
                                                    Class<?> geomClass)
Creates a filter containing the base constraint ("right" argument) transformed to the given CoordinateReferenceSystem.
Depending on the Geometry type of the targeted layer, the filter may look different. For example checking POINT INTERSECTS POLYGON is easy, where POINT INTERSECTS LINE will hardly ever hit, so we do SMALLBBOXARROUND(POINT) INTERSECTS POLYGON.

Parameters:
crs - the CoordinateReferenceSystem the base constraint is transformed to
Geometry - class of the features we want to filter against.
Class - the geometry class we are testing against. For point against polygon for example, an intersects is much faster that the bbox filter

adaptFilter

public GeometryFilterImpl adaptFilter( fs)
Completes the filter with its "left" argument for a concrete FeatureSource. If the FeatureSource's CRS differs from the CRS the base constraint is specified in, first a new filter is created by calling #prepareFilter(CoordinateReferenceSystem).

Parameters:
fs - FeatureSource the filter is adaped to
Returns: