org.geotools.filter.function
Class ClassificationFunction

java.lang.Object
  extended byorg.geotools.filter.expression.ExpressionAbstract
      extended byorg.geotools.filter.DefaultExpression
          extended byorg.geotools.filter.FunctionExpressionImpl
              extended byorg.geotools.filter.function.ClassificationFunction
All Implemented Interfaces:
org.opengis.filter.expression.Expression, Expression, ExpressionType, Factory, org.opengis.filter.expression.Function, FunctionExpression
Direct Known Subclasses:
CustomClassifierFunction, ExplicitClassificationFunction, RangedClassificationFunction

public abstract class ClassificationFunction
extends FunctionExpressionImpl
implements FunctionExpression

Parent for classifiers which break a feature collection into the specified number of classes.

Author:
James Macgill, Cory Horner, Refractions Research Inc.

Field Summary
 
Fields inherited from class org.geotools.filter.DefaultExpression
expressionType, permissiveConstruction
 
Fields inherited from interface org.geotools.filter.expression.ExpressionType
ATTRIBUTE, ATTRIBUTE_DOUBLE, ATTRIBUTE_GEOMETRY, ATTRIBUTE_INTEGER, ATTRIBUTE_STRING, ATTRIBUTE_UNDECLARED, FUNCTION, LITERAL_DOUBLE, LITERAL_GEOMETRY, LITERAL_INTEGER, LITERAL_STRING, MATH_ADD, MATH_DIVIDE, MATH_MULTIPLY, MATH_SUBTRACT
 
Constructor Summary
ClassificationFunction()
          Creates a new instance of ClassificationFunction
 
Method Summary
protected  int decimalPlaces(double slotWidth)
          Determines the number of decimal places to truncate the interval at (public for testing purposes only).
abstract  java.lang.Object evaluate(Feature feature)
          Evaluates the expression against an instance of Feature.
protected  double fixRound(double value, int decimalPlaces, boolean up)
          Corrects a round off operation by incrementing or decrementing the decimal place (preferably the smallest one).
 int getArgCount()
          Returns the number of arguments this requires.
 Expression[] getArgs()
          Gets the arguments to be evaluated by this function.
 FeatureCollection getCollection()
           
 Expression getExpression()
           
abstract  java.lang.String getName()
          Gets the name of this function.
 int getNumberOfClasses()
           
 ProgressListener getProgressListener()
           
 java.lang.Object getValue(int index)
           
protected  double round(double value, int decimalPlaces)
          Truncates a double to a certain number of decimals places.
 void setArgs(Expression[] args)
          Sets the arguments to be evaluated by this function.
 void setCollection(FeatureCollection fc)
           
 void setExpression(Expression e)
           
 void setNumberOfClasses(int i)
           
 void setProgressListener(ProgressListener progress)
           
 
Methods inherited from class org.geotools.filter.FunctionExpressionImpl
accept, getImplementationHints, getParameters, getType, setName, setParameters
 
Methods inherited from class org.geotools.filter.DefaultExpression
accept, evaluate, getValue, isAttributeExpression, isExpression, isGeometryExpression, isLiteralExpression, isMathExpression, isMathExpression
 
Methods inherited from class org.geotools.filter.expression.ExpressionAbstract
eval
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.geotools.filter.expression.FunctionExpression
getType
 
Methods inherited from interface org.geotools.filter.expression.Expression
accept, getValue
 
Methods inherited from interface org.opengis.filter.expression.Expression
accept, evaluate
 
Methods inherited from interface org.geotools.factory.Factory
getImplementationHints
 
Methods inherited from interface org.opengis.filter.expression.Function
getParameters, setName, setParameters
 

Constructor Detail

ClassificationFunction

public ClassificationFunction()
Creates a new instance of ClassificationFunction

Method Detail

getArgCount

public int getArgCount()
Description copied from interface: FunctionExpression
Returns the number of arguments this requires. For example [arg1][arg2]. This function must have EXACTLY 2 arguments, so this function would return 2. The parser might use this information to ensure validity, and its also for reporting capabilities. NOTE: this was previously javadoc-ed incorrectly, please note the new definition. NOTE: you cannot have a function with a variable number of arguments.

Specified by:
getArgCount in interface FunctionExpression
Specified by:
getArgCount in class FunctionExpressionImpl
Returns:
the number of args.

getNumberOfClasses

public int getNumberOfClasses()

setNumberOfClasses

public void setNumberOfClasses(int i)

getCollection

public FeatureCollection getCollection()

setCollection

public void setCollection(FeatureCollection fc)

getExpression

public Expression getExpression()

setExpression

public void setExpression(Expression e)

getProgressListener

public ProgressListener getProgressListener()

setProgressListener

public void setProgressListener(ProgressListener progress)

getArgs

public Expression[] getArgs()
Description copied from interface: FunctionExpression
Gets the arguments to be evaluated by this function.

Specified by:
getArgs in interface FunctionExpression
Overrides:
getArgs in class FunctionExpressionImpl

getName

public abstract java.lang.String getName()
Description copied from interface: FunctionExpression
Gets the name of this function.

Specified by:
getName in interface FunctionExpression
Overrides:
getName in class FunctionExpressionImpl
Returns:
the name of the function.

setArgs

public void setArgs(Expression[] args)
Description copied from interface: FunctionExpression
Sets the arguments to be evaluated by this function.

Specified by:
setArgs in interface FunctionExpression
Overrides:
setArgs in class FunctionExpressionImpl

evaluate

public abstract java.lang.Object evaluate(Feature feature)
Description copied from interface: Expression
Evaluates the expression against an instance of Feature.

Specified by:
evaluate in interface Expression
Overrides:
evaluate in class DefaultExpression
Parameters:
feature - Specified feature to use when returning value.
Returns:
The value of this expression based on the feature.

getValue

public java.lang.Object getValue(int index)

decimalPlaces

protected int decimalPlaces(double slotWidth)
Determines the number of decimal places to truncate the interval at (public for testing purposes only).

Parameters:
slotWidth -
Returns:

round

protected double round(double value,
                       int decimalPlaces)
Truncates a double to a certain number of decimals places. Note: truncation at zero decimal places will still show up as x.0, since we're using the double type.

Parameters:
value - number to round-off
decimalPlaces - number of decimal places to leave
Returns:
the rounded value

fixRound

protected double fixRound(double value,
                          int decimalPlaces,
                          boolean up)
Corrects a round off operation by incrementing or decrementing the decimal place (preferably the smallest one). This should usually be used to adjust the bounds to include a value. Example: 0.31-->0.44 where 0.44 is the maximum value and end of the range. We could just make the , round(0.31, 1)=0.3; round(0.44 max value = 0.49

Parameters:
value -
decimalPlaces -
up -
Returns:


Copyright © GeoTools. All Rights Reserved.