Class AreaMeasurer
- java.lang.Object
-
- gov.nasa.worldwind.util.measure.LengthMeasurer
-
- gov.nasa.worldwind.util.measure.AreaMeasurer
-
- All Implemented Interfaces:
MeasurableArea
,MeasurableLength
public class AreaMeasurer extends LengthMeasurer implements MeasurableArea
Utility class to compute approximations of projected and surface (terrain following) area on a globe.To properly compute surface area the measurer must be provided with a list of positions that describe a closed path - one which last position is equal to the first.
Segments which are longer then the current maxSegmentLength will be subdivided along lines following the current pathType -
Polyline.LINEAR
,Polyline.RHUMB_LINE
orPolyline.GREAT_CIRCLE
.Projected or non terrain following area is computed in a sinusoidal projection which is equivalent or equal area. Surface or terrain following area is approximated by sampling the path bounding sector with square cells along a grid. Cells which center is inside the path have their area estimated and summed according to the overall slope at the cell south-west corner.
- See Also:
MeasureTool
,LengthMeasurer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
AreaMeasurer.Cell
-
Field Summary
Fields Modifier and Type Field Description protected double
projectedArea
protected double
surfaceArea
-
Fields inherited from class gov.nasa.worldwind.util.measure.LengthMeasurer
length
-
-
Constructor Summary
Constructors Constructor Description AreaMeasurer()
AreaMeasurer(java.util.ArrayList<? extends Position> positions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
clearCachedValues()
protected double
computeProjectedAreaGeometry(Globe globe)
protected double
computeSurfaceAreaSampling(Globe globe, double steps)
protected double
computeTriangleProjectedArea(Globe globe, float[] verts, int a, int b, int c)
double
getArea(Globe globe)
Get the surface area approximation for the current path or shape.double
getAreaTerrainSamplingSteps()
Get the sampling grid maximum number of rows or columns for terrain following surface area approximation.double
getHeight(Globe globe)
Returns the latitudanl length of the object in meters.double
getPerimeter(Globe globe)
Returns the length of the object's perimeter in meters.double
getProjectedArea(Globe globe)
double
getSurfaceArea(Globe globe)
double
getWidth(Globe globe)
Returns the longitudinal length of the object in meters.void
setAreaTerrainSamplingSteps(double steps)
Set the sampling grid maximum number of rows or columns for terrain following surface area approximation.void
setPositions(java.util.ArrayList<? extends Position> positions)
-
Methods inherited from class gov.nasa.worldwind.util.measure.LengthMeasurer
computeLength, getAVKeyPathType, getBoundingSector, getLength, getLengthTerrainSamplingSteps, getMaxSegmentLength, getPositions, isClosedShape, isFollowTerrain, setFollowTerrain, setLengthTerrainSamplingSteps, setMaxSegmentLength, setPathType, setPositions, setPositions, subdividePositions, subdividePositions
-
-
-
-
Constructor Detail
-
AreaMeasurer
public AreaMeasurer()
-
AreaMeasurer
public AreaMeasurer(java.util.ArrayList<? extends Position> positions)
-
-
Method Detail
-
clearCachedValues
protected void clearCachedValues()
- Overrides:
clearCachedValues
in classLengthMeasurer
-
setPositions
public void setPositions(java.util.ArrayList<? extends Position> positions)
- Overrides:
setPositions
in classLengthMeasurer
-
getAreaTerrainSamplingSteps
public double getAreaTerrainSamplingSteps()
Get the sampling grid maximum number of rows or columns for terrain following surface area approximation.- Returns:
- the sampling grid maximum number of rows or columns.
-
setAreaTerrainSamplingSteps
public void setAreaTerrainSamplingSteps(double steps)
Set the sampling grid maximum number of rows or columns for terrain following surface area approximation.- Parameters:
steps
- the sampling grid maximum number of rows or columns.- Throws:
java.lang.IllegalArgumentException
- if steps is less then one.
-
getArea
public double getArea(Globe globe)
Get the surface area approximation for the current path or shape.If the measurer is set to follow terrain, the computed area will account for terrain deformations. Otherwise the area is that of the path once projected at sea level - elevation zero.
- Specified by:
getArea
in interfaceMeasurableArea
- Parameters:
globe
- the globe to draw terrain information from.- Returns:
- the current shape surface area or -1 if the position list does not describe a closed path or is too short.
- Throws:
java.lang.IllegalArgumentException
- if globe isnull
.
-
getSurfaceArea
public double getSurfaceArea(Globe globe)
-
getProjectedArea
public double getProjectedArea(Globe globe)
-
getPerimeter
public double getPerimeter(Globe globe)
Description copied from interface:MeasurableArea
Returns the length of the object's perimeter in meters. If the object conforms to terrain, the perimeter is that along the terrain, including its hillsides and other undulations.- Specified by:
getPerimeter
in interfaceMeasurableArea
- Parameters:
globe
- The globe the object is related to.- Returns:
- the object's perimeter in meters. Returns -1 if the object does not form an area due to an insufficient number of vertices or any other condition.
-
getWidth
public double getWidth(Globe globe)
Description copied from interface:MeasurableArea
Returns the longitudinal length of the object in meters. The length is the distance from the object's west-most point to its east-most. If the object is terrain conforming then the- Specified by:
getWidth
in interfaceMeasurableArea
- Parameters:
globe
- The globe the object is related to.- Returns:
- the width of the object in meters.
-
getHeight
public double getHeight(Globe globe)
Description copied from interface:MeasurableArea
Returns the latitudanl length of the object in meters. The length is the distance from the objects south-most point to its east-most position.- Specified by:
getHeight
in interfaceMeasurableArea
- Parameters:
globe
- The globe the object is related to.- Returns:
- the height of the object in meters.
-
computeProjectedAreaGeometry
protected double computeProjectedAreaGeometry(Globe globe)
-
computeTriangleProjectedArea
protected double computeTriangleProjectedArea(Globe globe, float[] verts, int a, int b, int c)
-
computeSurfaceAreaSampling
protected double computeSurfaceAreaSampling(Globe globe, double steps)
-
-