org.geotools.filter.function
Class ClassificationFunction

Object
  extended by ExpressionAbstract
      extended by DefaultExpression
          extended by ClassificationFunction
All Implemented Interfaces:
Factory, ExpressionType, FunctionExpression, Expression, Function
Direct Known Subclasses:
EqualIntervalFunction, JenksNaturalBreaksFunction, QuantileFunction, StandardDeviationFunction, UniqueIntervalFunction

public abstract class ClassificationFunction
extends DefaultExpression
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
protected static Logger LOGGER
           
 
Fields inherited from class DefaultExpression
expressionType, permissiveConstruction
 
Fields inherited from interface ExpressionType
ATTRIBUTE, ATTRIBUTE_DOUBLE, ATTRIBUTE_GEOMETRY, ATTRIBUTE_INTEGER, ATTRIBUTE_STRING, ATTRIBUTE_UNDECLARED, FUNCTION, LITERAL_DOUBLE, LITERAL_GEOMETRY, LITERAL_INTEGER, LITERAL_LONG, LITERAL_STRING, LITERAL_UNDECLARED, MATH_ADD, MATH_DIVIDE, MATH_MULTIPLY, MATH_SUBTRACT
 
Fields inherited from interface Expression
NIL
 
Constructor Summary
ClassificationFunction(FunctionName name)
           
 
Method Summary
 Object accept(ExpressionVisitor visitor, Object extraData)
          Accepts a visitor.
protected  int decimalPlaces(double slotWidth)
          Determines the number of decimal places to truncate the interval at.
abstract  Object evaluate(Object arg)
          This method checks if the object is an instance of Feature and if so, calls through to #evaluate(Feature).
 Object evaluate(SimpleFeature feature)
          Returns a value for this expression.
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()
          Deprecated. please use getParameters
 int getClasses()
           
 Expression getExpression()
           
 Literal getFallbackValue()
          The value of the fallbackValue attribute is used as a default value, if the SE implementation does not support the function.
 FunctionName getFunctionName()
          Access to the FunctionName description as used in a FilterCapabilities document.
 Map getImplementationHints()
          Returns the implementation hints.
 String getName()
          Gets the name of this function.
 int getNumberOfClasses()
          Deprecated. use getClasses()
 List getParameters()
          Returns the function parameters (the contents are Expressions, usually attribute expression and literal expression).
 ProgressListener getProgressListener()
           
protected  double round(double value, int decimalPlaces)
          Truncates a double to a certain number of decimals places.
 void setArgs(Expression[] args)
          Deprecated. please use setParameters
 void setClasses(int classes)
           
 void setExpression(Expression e)
           
 void setFallbackValue(Literal fallback)
           
 void setNumberOfClasses(int classes)
          Deprecated. use setClasses()
 void setParameters(List params)
          Sets the function parameters.
 void setProgressListener(ProgressListener progress)
           
 
Methods inherited from class DefaultExpression
accept, getType, getValue, isAttributeExpression, isExpression, isFunctionExpression, isGeometryExpression, isLiteralExpression, isMathExpression, isMathExpression
 
Methods inherited from class ExpressionAbstract
eval, eval, evaluate
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface FunctionExpression
getType
 
Methods inherited from interface Expression
accept, getValue
 
Methods inherited from interface Expression
evaluate
 

Field Detail

LOGGER

protected static final Logger LOGGER
Constructor Detail

ClassificationFunction

public ClassificationFunction(FunctionName name)
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
Returns:
the number of args required by this function.

accept

public Object accept(ExpressionVisitor visitor,
                     Object extraData)
Description copied from interface: Expression
Accepts a visitor. Subclasses must implement with a method whose content is the following:
return visitor.visit(this, extraData);

Specified by:
accept in interface Expression
See Also:
Expression.accept(ExpressionVisitor, Object)

evaluate

public Object evaluate(SimpleFeature feature)
Description copied from class: DefaultExpression
Returns a value for this expression. If the expression is an attribute expression then the attribute of the feature should be returned. If a literal then the feature is ignored, the literal is returned as it has no relation to the feature.

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

evaluate

public abstract Object evaluate(Object arg)
Description copied from class: DefaultExpression
This method checks if the object is an instance of Feature and if so, calls through to #evaluate(Feature). This is done to maintain backwards compatability with previous version of Expression api which depended on Feature. If the object is not an instance of feature the super implementation is called.

Specified by:
evaluate in interface Expression
Overrides:
evaluate in class DefaultExpression

setFallbackValue

public void setFallbackValue(Literal fallback)

getFallbackValue

public Literal getFallbackValue()
Description copied from interface: Function
The value of the fallbackValue attribute is used as a default value, if the SE implementation does not support the function. If the implementation supports the function, then the result value is determined by executing the function.

Specified by:
getFallbackValue in interface Function
Returns:
Optional literal to use if an implementation for this function is not available.

getArgs

public Expression[] getArgs()
Deprecated. please use getParameters

Description copied from interface: FunctionExpression
Gets the arguments to be evaluated by this function.

Specified by:
getArgs in interface FunctionExpression
Returns:
an array of the args to be evaluated.

setArgs

public void setArgs(Expression[] args)
Deprecated. please use setParameters

Description copied from interface: FunctionExpression
Sets the arguments to be evaluated by this function.

Specified by:
setArgs in interface FunctionExpression
Parameters:
args - an array of expressions to be evaluated.

getName

public String getName()
Gets the name of this function.

Specified by:
getName in interface FunctionExpression
Specified by:
getName in interface Function
Returns:
the name of the function.

getFunctionName

public FunctionName getFunctionName()
Description copied from interface: Function
Access to the FunctionName description as used in a FilterCapabilities document.

Specified by:
getFunctionName in interface Function
Returns:
FunctionName description, if available.

getParameters

public List getParameters()
Returns the function parameters (the contents are Expressions, usually attribute expression and literal expression).

Specified by:
getParameters in interface Function

setParameters

public void setParameters(List params)
Sets the function parameters.

Specified by:
setParameters in interface FunctionExpression

getProgressListener

public ProgressListener getProgressListener()

setProgressListener

public void setProgressListener(ProgressListener progress)

getNumberOfClasses

public int getNumberOfClasses()
Deprecated. use getClasses()


getClasses

public int getClasses()

setNumberOfClasses

public void setNumberOfClasses(int classes)
Deprecated. use setClasses()


setClasses

public void setClasses(int classes)

getExpression

public Expression getExpression()

setExpression

public void setExpression(Expression e)

getImplementationHints

public Map getImplementationHints()
Returns the implementation hints. The default implementation returns an empty map.

Specified by:
getImplementationHints in interface Factory
Returns:
The map of hints, or an empty map if none.

decimalPlaces

protected int decimalPlaces(double slotWidth)
Determines the number of decimal places to truncate the interval at.

Parameters:
slotWidth -

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 -


Copyright © 1996-2014 Geotools. All Rights Reserved.