Class DB2FilterToSQL

All Implemented Interfaces:
ExpressionVisitor, FilterVisitor

public class DB2FilterToSQL extends PreparedFilterToSQL
Generate a WHERE clause for DB2 Spatial Extender based on a spatial filter.

The following spatial filter operations are supported:

  • GEOMETRY_BBOX
  • GEOMETRY_CONTAINS
  • GEOMETRY_CROSSES
  • GEOMETRY_DISJOINT
  • GEOMETRY_EQUALS
  • GEOMETRY_INTERSECTS
  • GEOMETRY_OVERLAPS
  • GEOMETRY_TOUCHES
  • GEOMETRY_WITHIN
  • GEOMETRY_DWITHIN
Author:
Mueller Christian
  • Constructor Details

  • Method Details

    • getPredicateMap

      public HashMap<Class<?>,String> getPredicateMap()
    • db2Geom

      public String db2Geom(Geometry geom)
      Construct a geometry from the WKT representation of a geometry
      Parameters:
      geom - the constructor for the geometry.
    • createFilterCapabilities

      protected FilterCapabilities createFilterCapabilities()
      Sets the DB2 filter capabilities.
      Overrides:
      createFilterCapabilities in class FilterToSQL
      Returns:
      FilterCapabilities for DB2
    • setSelectivityClause

      public void setSelectivityClause(String string)
      Sets a SELECTIVITY clause that can be included with the spatial predicate to influence the query optimizer to exploit a spatial index if it exists.

      The parameter should be of the form:
      "SELECTIVITY 0.001"
      where the numeric value is the fraction of rows that will be returned by using the index scan. This doesn't have to be true. The value 0.001 is typically used to force the use of the spatial in all cases if the spatial index exists.

      Parameters:
      string - a selectivity clause
    • visitBinarySpatialOperator

      protected Object visitBinarySpatialOperator(BinarySpatialOperator filter, PropertyName property, Literal geometry, boolean swapped, Object extraData)
      Description copied from class: FilterToSQL
      Handles the common case of a PropertyName,Literal geometry binary spatial operator.
      Overrides:
      visitBinarySpatialOperator in class FilterToSQL
    • visitBinarySpatialOperator

      protected Object visitBinarySpatialOperator(BinarySpatialOperator filter, Expression e1, Expression e2, Object extraData)
      Description copied from class: FilterToSQL
      Handles the more general case of two generic expressions.

      The most common case is two PropertyName expressions, which happens during a spatial join.

      Overrides:
      visitBinarySpatialOperator in class FilterToSQL
    • visitBinarySpatialOperator

      protected Object visitBinarySpatialOperator(BinarySpatialOperator filter, Expression e1, Expression e2, boolean swapped, Object extraData)
    • visitLiteralGeometry

      public void visitLiteralGeometry(Literal expression) throws IOException
      Construct the appropriate geometry type from the WKT representation of a literal expression
      Overrides:
      visitLiteralGeometry in class FilterToSQL
      Parameters:
      expression - the expression turn into a geometry constructor.
      Throws:
      IOException - Passes back exception if generated by this.out.write()
    • addSelectivity

      protected void addSelectivity() throws IOException
      Throws:
      IOException
    • visit

      public Object visit(ExcludeFilter filter, Object extraData)
      Description copied from interface: FilterVisitor
      Visit Filter.EXCLUDE (often used during data structure transformations).
      Specified by:
      visit in interface FilterVisitor
      Overrides:
      visit in class FilterToSQL
      Parameters:
      filter - the filter to be visited
      extraData - Value object provided to visitor
      Returns:
      subclass supplied
    • visit

      public Object visit(IncludeFilter filter, Object extraData)
      Description copied from interface: FilterVisitor
      Visit Filter.INCLUDE (often used during data structure transformations).
      Specified by:
      visit in interface FilterVisitor
      Overrides:
      visit in class FilterToSQL
      Parameters:
      filter - the filter to be visited
      extraData - Value object provided to visitor
      Returns:
      subclass supplied
    • isLooseBBOXEnabled

      public boolean isLooseBBOXEnabled()
    • setLooseBBOXEnabled

      public void setLooseBBOXEnabled(boolean looseBBOXEnabled)
    • writeLiteral

      protected void writeLiteral(Object literal) throws IOException
      Description copied from class: FilterToSQL
      Writes out a non null, non geometry literal. The base class properly handles null, numeric and booleans (true|false), and turns everything else into a string. Subclasses are expected to override this shall they need a different treatment (e.g. for dates)
      Overrides:
      writeLiteral in class FilterToSQL
      Throws:
      IOException
    • isFunctionEncodingEnabled

      public boolean isFunctionEncodingEnabled()
    • setFunctionEncodingEnabled

      public void setFunctionEncodingEnabled(boolean functionEncodingEnabled)
    • visitFunction

      public boolean visitFunction(Function function, Object extraData) throws IOException
      Performs custom visits for functions that cannot be encoded as functionName(p1, p2, ... pN).
      Throws:
      IOException
    • visit

      public Object visit(Function function, Object extraData) throws RuntimeException
      Description copied from class: FilterToSQL
      Writes sql for a function expression. By default it will write the call by using the same arguments provided to the GeoTools function, subclasses should override on a case by case basis if this behavior is not the desired one.
      Specified by:
      visit in interface ExpressionVisitor
      Overrides:
      visit in class FilterToSQL
      Parameters:
      function - a function expression
      Throws:
      RuntimeException - If an IO error occurs.
      See Also: