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
FieldsFields inherited from interface Expression
NIL -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaccept(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 voidcomputePercentage(double[] percentages, double classMembers, double totalSize, int index) Compute the percentage from the input parameters, setting in the percentages array at the specified indexprotected intdecimalPlaces(double slotWidth) Determines the number of decimal places to truncate the interval at.abstract ObjectSubclass should override, default implementation returns null.protected doublefixRound(double value, int decimalPlaces, boolean up) Corrects a round off operation by incrementing or decrementing the decimal place (preferably the smallest one).intThe value of the fallbackValue attribute is used as a default value, if the SE implementation does not support the function.Access to the FunctionName description as used in a FilterCapabilities document.Returns the implementation hints.getName()Gets the name of this function.Returns the function parameters (the contents are Expressions, usually attribute expression and literal expression).protected doubleround(double value, int decimalPlaces) Truncates a double to a certain number of decimals places.voidsetClasses(int classes) voidsetFallbackValue(Literal fallback) Fallback value to use in the event the function is unavailable in the requested environment.voidsetParameters(List<Expression> params) Sets the function parameters.voidsetProgressListener(ProgressListener progress) 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, isMathExpressionMethods inherited from class ExpressionAbstract
evaluateMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Expression
evaluate
-
Field Details
-
LOGGER
-
-
Constructor Details
-
ClassificationFunction
-
-
Method Details
-
accept
Description copied from interface:ExpressionAccepts a visitor. Subclasses must implement with a method whose content is the following:return visitor.visit(this, extraData);
- Specified by:
acceptin interfaceExpression- See Also:
-
evaluate
Description copied from class:ExpressionAbstractSubclass should override, default implementation returns null.- Specified by:
evaluatein interfaceExpression- Overrides:
evaluatein classExpressionAbstract- Returns:
- default implementation returns null
-
setFallbackValue
Description copied from interface:FunctionExpressionFallback 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:
setFallbackValuein interfaceFunctionExpression
-
getFallbackValue
Description copied from interface:FunctionThe 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:
getFallbackValuein interfaceFunction- Returns:
- Optional literal to use if an implementation for this function is not available.
-
getName
Gets the name of this function. -
getFunctionName
Description copied from interface:FunctionAccess to the FunctionName description as used in a FilterCapabilities document.- Specified by:
getFunctionNamein interfaceFunction- Returns:
- FunctionName description, if available.
-
getParameters
Returns the function parameters (the contents are Expressions, usually attribute expression and literal expression).- Specified by:
getParametersin interfaceFunction
-
setParameters
Sets the function parameters.- Specified by:
setParametersin interfaceFunctionExpression
-
getProgressListener
-
setProgressListener
-
getClasses
public int getClasses() -
setClasses
public void setClasses(int classes) -
getImplementationHints
Returns the implementation hints. The default implementation returns an empty map.- Specified by:
getImplementationHintsin 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
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
-