Package org.geotools.feature.visitor
Class NearestVisitor
- Object
-
- NearestVisitor
-
- Type Parameters:
T-
- All Implemented Interfaces:
FeatureVisitor,FeatureAttributeVisitor,FeatureCalc
public class NearestVisitor extends Object implements FeatureCalc, FeatureAttributeVisitor
Finds the nearest value to the provided one in the attribute domain.- Author:
- Andrea Aime - GeoSolutions, Ilkka Rinne / Spatineo Inc for the Finnish Meteorological Institute
-
-
Constructor Summary
Constructors Constructor Description NearestVisitor(Expression expression, Object valueToMatch)Creates a NearestVisitor instance for the given attribute and a value to match.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ExpressiongetExpression()Expression used to access collection content.List<Expression>getExpressions()List of expressions used by visitor.ObjectgetNearestMatch()Returns the match aftervisit(org.geotools.api.feature.Feature).CalcResultgetResult()Returns the result of the calculation as a handy object which can be merged and modified.Optional<List<Class>>getResultType(List<Class> inputTypes)Returns the expected output type given the input type.ObjectgetValueToMatch()Provided value to match against.voidreset()voidsetValue(Comparable nearest)voidsetValue(Comparable maxBelow, Comparable minAbove)voidvisit(Feature feature)Visitor function, which looks at each feature and finds the value of the attribute given attribute nearest to the given comparison value.
-
-
-
Constructor Detail
-
NearestVisitor
public NearestVisitor(Expression expression, Object valueToMatch)
Creates a NearestVisitor instance for the given attribute and a value to match.- Parameters:
valueToMatch- The target value to match
-
-
Method Detail
-
visit
public void visit(Feature feature)
Visitor function, which looks at each feature and finds the value of the attribute given attribute nearest to the given comparison value.- Specified by:
visitin interfaceFeatureVisitor- Parameters:
feature- the feature to be visited
-
reset
public void reset()
-
setValue
public void setValue(Comparable nearest)
-
setValue
public void setValue(Comparable maxBelow, Comparable minAbove)
-
getNearestMatch
public Object getNearestMatch() throws IllegalStateException
Returns the match aftervisit(org.geotools.api.feature.Feature).- Throws:
IllegalStateException
-
getResult
public CalcResult getResult()
Description copied from interface:FeatureCalcReturns the result of the calculation as a handy object which can be merged and modified.- Specified by:
getResultin interfaceFeatureCalc- Returns:
- the results of the calculation
-
getExpression
public Expression getExpression()
Expression used to access collection content.- Returns:
- expr used to access collection
-
getValueToMatch
public Object getValueToMatch()
Provided value to match against.- Returns:
- value to match against.
-
getExpressions
public List<Expression> getExpressions()
Description copied from interface:FeatureAttributeVisitorList of expressions used by visitor.- Specified by:
getExpressionsin interfaceFeatureAttributeVisitor
-
getResultType
public Optional<List<Class>> getResultType(List<Class> inputTypes)
Description copied from interface:FeatureAttributeVisitorReturns the expected output type given the input type.- Specified by:
getResultTypein interfaceFeatureAttributeVisitor- Parameters:
inputTypes- The type of the input expressions
-
-