org.geotools.filter
Class AreaFunction

java.lang.Object
  extended byorg.geotools.filter.expression.ExpressionAbstract
      extended byorg.geotools.filter.DefaultExpression
          extended byorg.geotools.filter.FunctionExpressionImpl
              extended byorg.geotools.filter.AreaFunction
All Implemented Interfaces:
org.opengis.filter.expression.Expression, Expression, ExpressionType, Factory, org.opengis.filter.expression.Function, FunctionExpression

public class AreaFunction
extends FunctionExpressionImpl
implements FunctionExpression

Author:
James

Field Summary
 
Fields inherited from class org.geotools.filter.DefaultExpression
expressionType, permissiveConstruction
 
Fields inherited from interface org.geotools.filter.expression.ExpressionType
ATTRIBUTE, ATTRIBUTE_DOUBLE, ATTRIBUTE_GEOMETRY, ATTRIBUTE_INTEGER, ATTRIBUTE_STRING, ATTRIBUTE_UNDECLARED, FUNCTION, LITERAL_DOUBLE, LITERAL_GEOMETRY, LITERAL_INTEGER, LITERAL_STRING, MATH_ADD, MATH_DIVIDE, MATH_MULTIPLY, MATH_SUBTRACT
 
Constructor Summary
AreaFunction()
          Creates a new instance of AreaFunction
 
Method Summary
 java.lang.Object evaluate(Feature feature)
          Evaluates the expression against an instance of Feature.
 double getArea(com.vividsolutions.jts.geom.Geometry geometry)
          Calculates and returns the area of the specified geometry.
protected  double getArea(com.vividsolutions.jts.geom.GeometryCollection geometryCollection1)
          Returns the area of a GeometryCollection.
protected  double getArea(com.vividsolutions.jts.geom.MultiPolygon multiPolygon)
          Returns the area of a MultiPolygon.
protected  double getArea(com.vividsolutions.jts.geom.Polygon polygon)
          Returns the area of a Polygon.
 int getArgCount()
          Returns the number of arguments this requires.
 Expression[] getArgs()
          Used by FilterVisitors to perform some action on this filter instance.
 java.util.Map getImplementationHints()
          Returns the implementation hints.
 java.lang.String getName()
          Gets the name of this function.
 double getPerimeter(com.vividsolutions.jts.geom.Geometry geometry)
          Calculates and returns the perimeter of the specified geometry.
protected  double getPerimeter(com.vividsolutions.jts.geom.GeometryCollection geometryCollection)
          Returns.
protected  double getPerimeter(com.vividsolutions.jts.geom.LineString lineString)
          Returns the perimeter of a LineString.
protected  double getPerimeter(com.vividsolutions.jts.geom.MultiLineString multiLineString)
          Returns the perimeter of a MultiLineString.
protected  double getperimeter(com.vividsolutions.jts.geom.MultiPolygon multiPolygon)
          Returns the perimeter of a MultiPolygon.
protected  double getPerimeter(com.vividsolutions.jts.geom.Polygon polygon)
          Returns the perimeter of a Polygon.
 short getType()
          Gets the type of this expression.
 void setArgs(Expression[] args)
          Sets the arguments to be evaluated by this function.
 
Methods inherited from class org.geotools.filter.FunctionExpressionImpl
accept, getParameters, setName, setParameters
 
Methods inherited from class org.geotools.filter.DefaultExpression
accept, evaluate, getValue, isAttributeExpression, isExpression, isGeometryExpression, isLiteralExpression, isMathExpression, isMathExpression
 
Methods inherited from class org.geotools.filter.expression.ExpressionAbstract
eval
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.geotools.filter.expression.Expression
accept, getValue
 
Methods inherited from interface org.opengis.filter.expression.Expression
accept, evaluate
 
Methods inherited from interface org.opengis.filter.expression.Function
getParameters, setName, setParameters
 

Constructor Detail

AreaFunction

public AreaFunction()
Creates a new instance of AreaFunction

Method Detail

getType

public short getType()
Description copied from interface: FunctionExpression
Gets the type of this expression.

Specified by:
getType in interface FunctionExpression
Overrides:
getType in class FunctionExpressionImpl
Returns:
the short representation of a function expression.

evaluate

public java.lang.Object evaluate(Feature feature)
Description copied from interface: Expression
Evaluates the expression against an instance of Feature.

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

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
Specified by:
getArgCount in class FunctionExpressionImpl
Returns:
the number of args.

getName

public java.lang.String getName()
Description copied from interface: FunctionExpression
Gets the name of this function.

Specified by:
getName in interface FunctionExpression
Overrides:
getName in class FunctionExpressionImpl
Returns:
the name of the function.

setArgs

public void setArgs(Expression[] args)
Description copied from interface: FunctionExpression
Sets the arguments to be evaluated by this function.

Specified by:
setArgs in interface FunctionExpression
Overrides:
setArgs in class FunctionExpressionImpl

getArgs

public Expression[] getArgs()
Used by FilterVisitors to perform some action on this filter instance. Typicaly used by Filter decoders, but may also be used by any thing which needs infomration from filter structure. Implementations should always call: visitor.visit(this); It is importatant that this is not left to a parent class unless the parents API is identical.

Specified by:
getArgs in interface FunctionExpression
Overrides:
getArgs in class FunctionExpressionImpl

getImplementationHints

public java.util.Map getImplementationHints()
Returns the implementation hints. The default implementation returns en empty map.

Specified by:
getImplementationHints in interface Factory
Overrides:
getImplementationHints in class FunctionExpressionImpl

getArea

protected double getArea(com.vividsolutions.jts.geom.GeometryCollection geometryCollection1)
Returns the area of a GeometryCollection.

Parameters:
geometryCollection1 - The GeometryCollection for which the area is calulated.
Returns:
The total area of all geometries in the collection.

getPerimeter

protected double getPerimeter(com.vividsolutions.jts.geom.GeometryCollection geometryCollection)
Returns.

Parameters:
geometryCollection - The GeometryCollection for which the perimeter is calulated.
Returns:
the perimeter of a GeometryCollection.

getArea

public double getArea(com.vividsolutions.jts.geom.Geometry geometry)
Calculates and returns the area of the specified geometry.
For Polygons, this is the total area inside the external ring less the total of any contained by interior rings. GeometryCollections (including MultiPolygons) are iterated through so the result is the sum of all polygons anywhere within the collection. Any geometry other than Polgyon or a collection returns 0;

Parameters:
geometry - The Geometry to calculate the area of.
Returns:
The total area of the Geometry.

getPerimeter

public double getPerimeter(com.vividsolutions.jts.geom.Geometry geometry)
Calculates and returns the perimeter of the specified geometry.
For Polygons, this is the total length of the exterior ring and all internal rings. For LineStrings the total line length is returned. GeometryCollections are iterated through so the result is the sum of all Polygon and Line geometries anywhere within the collection. Any point geometries return a value of 0;

Parameters:
geometry - The Geometry to calculate the area of.
Returns:
The total area of the Geometry.

getArea

protected double getArea(com.vividsolutions.jts.geom.MultiPolygon multiPolygon)
Returns the area of a MultiPolygon.

Parameters:
multiPolygon - the MultiPolygon for which the area is calculated.
Returns:
Total area of all polygons in multiPolygon.

getperimeter

protected double getperimeter(com.vividsolutions.jts.geom.MultiPolygon multiPolygon)
Returns the perimeter of a MultiPolygon.

Parameters:
multiPolygon - the MultiPolygon for which the perimeter is calculated.
Returns:
Total perimeter of all polygons in the multiPolygon.

getArea

protected double getArea(com.vividsolutions.jts.geom.Polygon polygon)
Returns the area of a Polygon.

Parameters:
polygon - the Polygon for which the area is calculated.
Returns:
The area of the polygon.

getPerimeter

protected double getPerimeter(com.vividsolutions.jts.geom.Polygon polygon)
Returns the perimeter of a Polygon.

Parameters:
polygon - the Polygon for which the perimeter is calculated.
Returns:
The perimeter of the polygon.

getPerimeter

protected double getPerimeter(com.vividsolutions.jts.geom.MultiLineString multiLineString)
Returns the perimeter of a MultiLineString.

Parameters:
multiLineString - the MultiLineString for which the perimeter is calculated.
Returns:
the total perimter (length) of the lines in multiLineString.

getPerimeter

protected double getPerimeter(com.vividsolutions.jts.geom.LineString lineString)
Returns the perimeter of a LineString.

Parameters:
lineString - the LineString for which the perimeter is calculated.
Returns:
the perimeter (length) of the lineString.


Copyright © GeoTools. All Rights Reserved.