Package org.geotools.filter.function
Class ClassificationFunction
- Object
-
- ExpressionAbstract
-
- DefaultExpression
-
- ClassificationFunction
-
- All Implemented Interfaces:
Expression
,Function
,FunctionExpression
,Factory
- Direct Known Subclasses:
AbstractQuantityClassificationFunction
,EqualIntervalFunction
,JenksNaturalBreaksFunction
,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
Fields Modifier and Type Field Description protected static Logger
LOGGER
-
Fields inherited from interface Expression
NIL
-
-
Constructor Summary
Constructors Constructor Description ClassificationFunction(FunctionName name)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Object
accept(ExpressionVisitor visitor, Object extraData)
Accepts a visitor.protected double[]
computeGroupByPercentages(FeatureCollection collection, double[] percentages, int totalSize, double min, double classWidth)
This method return percentages by using a single groupBy query to retrieve class members.protected void
computePercentage(double[] percentages, double classMembers, double totalSize, int index)
Compute the percentage from the input parameters, setting in the percentages array at the specified indexprotected int
decimalPlaces(double slotWidth)
Determines the number of decimal places to truncate the interval at.abstract Object
evaluate(Object arg)
Subclass should override, default implementation returns null.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
getClasses()
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<RenderingHints.Key,?>
getImplementationHints()
Returns the implementation hints.String
getName()
Gets the name of this function.List<Expression>
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
setClasses(int classes)
void
setFallbackValue(Literal fallback)
Fallback value to use in the event the function is unavailable in the requested environment.void
setParameters(List<Expression> params)
Sets the function parameters.void
setProgressListener(ProgressListener progress)
String
toString()
Creates a String representation of this Function with the function name and the arguments.-
Methods inherited from class DefaultExpression
isAttributeExpression, isExpression, isFunctionExpression, isGeometryExpression, isLiteralExpression, isMathExpression
-
Methods inherited from class ExpressionAbstract
evaluate
-
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface Expression
evaluate
-
-
-
-
Field Detail
-
LOGGER
protected static final Logger LOGGER
-
-
Constructor Detail
-
ClassificationFunction
public ClassificationFunction(FunctionName name)
-
-
Method Detail
-
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 interfaceExpression
- See Also:
Expression.accept(ExpressionVisitor, Object)
-
evaluate
public abstract Object evaluate(Object arg)
Description copied from class:ExpressionAbstract
Subclass should override, default implementation returns null.- Specified by:
evaluate
in interfaceExpression
- Overrides:
evaluate
in classExpressionAbstract
- Returns:
- default implementation returns null
-
setFallbackValue
public void setFallbackValue(Literal fallback)
Description copied from interface:FunctionExpression
Fallback value to use in the event the function is unavailable in the requested environment.The fallback value is not provided as one of the arguments, as it is an advanced option used in style layer descriptor documents to facilitate interoperability. It allows a user to specify an SQL function, and provide a value to use when the documented is used with a WFS that does not support the provided function.
- Specified by:
setFallbackValue
in interfaceFunctionExpression
-
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 interfaceFunction
- Returns:
- Optional literal to use if an implementation for this function is not available.
-
getName
public String getName()
Gets the name of this 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 interfaceFunction
- Returns:
- FunctionName description, if available.
-
getParameters
public List<Expression> getParameters()
Returns the function parameters (the contents are Expressions, usually attribute expression and literal expression).- Specified by:
getParameters
in interfaceFunction
-
setParameters
public void setParameters(List<Expression> params)
Sets the function parameters.- Specified by:
setParameters
in interfaceFunctionExpression
-
getProgressListener
public ProgressListener getProgressListener()
-
setProgressListener
public void setProgressListener(ProgressListener progress)
-
getClasses
public int getClasses()
-
setClasses
public void setClasses(int classes)
-
getImplementationHints
public Map<RenderingHints.Key,?> getImplementationHints()
Returns the implementation hints. The default implementation returns an empty map.- Specified by:
getImplementationHints
in interfaceFactory
- Returns:
- The map of hints, or an {@linkplain java.util.Collections.emptyMap() empty map} if none.
-
decimalPlaces
protected int decimalPlaces(double slotWidth)
Determines the number of decimal places to truncate the interval at.
-
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-offdecimalPlaces
- 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
-
toString
public String toString()
Creates a String representation of this Function with the function name and the arguments.
-
computeGroupByPercentages
protected double[] computeGroupByPercentages(FeatureCollection collection, double[] percentages, int totalSize, double min, double classWidth) throws IOException
This method return percentages by using a single groupBy query to retrieve class members. Can be used if the class width is the same for all the classes.- Parameters:
collection
- the feature collection to classifypercentages
- the array of percentages to filltotalSize
- the totalSize of the collectionmin
- the min attribute value in the collectionclassWidth
- the classWidth- Returns:
- Throws:
IOException
-
computePercentage
protected void computePercentage(double[] percentages, double classMembers, double totalSize, int index)
Compute the percentage from the input parameters, setting in the percentages array at the specified index
-
-