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 Expression
getExpression()
Expression used to access collection content.List<Expression>
getExpressions()
List of expressions used by visitor.Object
getNearestMatch()
Returns the match aftervisit(org.geotools.api.feature.Feature)
.CalcResult
getResult()
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.Object
getValueToMatch()
Provided value to match against.void
reset()
void
setValue(Comparable nearest)
void
setValue(Comparable maxBelow, Comparable minAbove)
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.
-
-
-
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:
visit
in 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:FeatureCalc
Returns the result of the calculation as a handy object which can be merged and modified.- Specified by:
getResult
in 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:FeatureAttributeVisitor
List of expressions used by visitor.- Specified by:
getExpressions
in interfaceFeatureAttributeVisitor
-
getResultType
public Optional<List<Class>> getResultType(List<Class> inputTypes)
Description copied from interface:FeatureAttributeVisitor
Returns the expected output type given the input type.- Specified by:
getResultType
in interfaceFeatureAttributeVisitor
- Parameters:
inputTypes
- The type of the input expressions
-
-