public class LengthMeasurer extends java.lang.Object implements MeasurableLength
The measurer must be provided a list of at least two positions to be able to compute a distance.
Segments which are longer then the current maxSegmentLength will be subdivided along lines following the current pathType - Polyline.LINEAR, Polyline.RHUMB_LINE or Polyline.GREAT_CIRCLE.
If the measurer is set to follow terrain, the computed length will account for terrain deformations as if someone was walking along that path. Otherwise the length is the sum of the cartesian distance between the positions.
When following terrain the measurer will sample terrain elevations at regular intervals along the path. The minimum number of samples used for the whole length can be set with setLengthTerrainSamplingSteps(). However, the minimum sampling interval is 30 meters.
MeasureTool
Modifier and Type | Field and Description |
---|---|
protected double |
length |
Constructor and Description |
---|
LengthMeasurer() |
LengthMeasurer(java.util.ArrayList<? extends Position> positions) |
Modifier and Type | Method and Description |
---|---|
protected void |
clearCachedValues() |
protected double |
computeLength(Globe globe,
boolean followTerrain) |
Sector |
getBoundingSector() |
double |
getLength(Globe globe)
Get the path length in meter.
|
double |
getLengthTerrainSamplingSteps()
Get the number of terrain elevation samples used along the path to approximate it's terrain following length.
|
double |
getMaxSegmentLength()
Get the maximum length a segment can have before being subdivided along a line following the current pathType.
|
int |
getPathType() |
java.util.ArrayList<? extends Position> |
getPositions() |
boolean |
isClosedShape()
Returns true if the current position list describe a closed path - one which last position is equal to the
first.
|
boolean |
isFollowTerrain() |
void |
setFollowTerrain(boolean followTerrain)
Set whether measurements should account for terrain deformations.
|
void |
setLengthTerrainSamplingSteps(double steps)
Set the number of terrain elevation samples to be used along the path to approximate it's terrain following
length.
|
void |
setMaxSegmentLength(double length)
Set the maximum length a segment can have before being subdivided along a line following the current pathType.
|
void |
setPathType(int pathType)
Sets the type of path used when subdividing long segments, one of Polyline.GREAT_CIRCLE, which draws segments as
a great circle, Polyline.LINEAR, which determines the intermediate positions between segments by interpolating
the segment endpoints, or Polyline.RHUMB_LINE, which draws segments as a line of constant heading.
|
void |
setPositions(java.util.ArrayList<? extends LatLon> positions,
double elevation) |
void |
setPositions(java.util.ArrayList<? extends Position> positions) |
protected static java.util.ArrayList<? extends Position> |
subdividePositions(Globe globe,
java.util.ArrayList<? extends Position> positions,
double maxLength,
boolean followTerrain,
int pathType)
Subdivide a list of positions so that no segment is longer then the provided maxLength.
|
protected static java.util.ArrayList<? extends Position> |
subdividePositions(Globe globe,
java.util.ArrayList<? extends Position> positions,
double maxLength,
boolean followTerrain,
int pathType,
int start,
int count)
Subdivide a list of positions so that no segment is longer then the provided maxLength.
|
public LengthMeasurer()
public LengthMeasurer(java.util.ArrayList<? extends Position> positions)
protected void clearCachedValues()
protected double computeLength(Globe globe, boolean followTerrain)
public Sector getBoundingSector()
public double getLength(Globe globe)
If the measurer is set to follow terrain, the computed length will account for terrain deformations as if someone was walking along that path. Otherwise the length is the sum of the cartesian distance between each positions.
getLength
in interface MeasurableLength
globe
- the globe to draw terrain information from.public double getLengthTerrainSamplingSteps()
public double getMaxSegmentLength()
public int getPathType()
public java.util.ArrayList<? extends Position> getPositions()
public boolean isClosedShape()
public boolean isFollowTerrain()
public void setFollowTerrain(boolean followTerrain)
followTerrain
- set to true if measurements should account for terrain deformations.public void setLengthTerrainSamplingSteps(double steps)
steps
- the number of terrain elevation samples to be used.public void setMaxSegmentLength(double length)
length
- the maximum length a segment can have before being subdivided.public void setPathType(int pathType)
pathType
- the type of path to measure.public void setPositions(java.util.ArrayList<? extends LatLon> positions, double elevation)
public void setPositions(java.util.ArrayList<? extends Position> positions)
protected static java.util.ArrayList<? extends Position> subdividePositions(Globe globe, java.util.ArrayList<? extends Position> positions, double maxLength, boolean followTerrain, int pathType)
If needed, new intermediate positions will be created along lines that follow the given pathType - one of Polyline.LINEAR, Polyline.RHUMB_LINE or Polyline.GREAT_CIRCLE. All position elevations will be either at the terrain surface if followTerrain is true, or interpolated according to the original elevations.
globe
- the globe to draw elevations and points from.positions
- the original position listmaxLength
- the maximum length for one segment.followTerrain
- true if the positions should be on the terrain surface.pathType
- the type of path to use in between two positions.protected static java.util.ArrayList<? extends Position> subdividePositions(Globe globe, java.util.ArrayList<? extends Position> positions, double maxLength, boolean followTerrain, int pathType, int start, int count)
If needed, new intermediate positions will be created along lines that follow the given pathType - one of Polyline.LINEAR, Polyline.RHUMB_LINE or Polyline.GREAT_CIRCLE. All position elevations will be either at the terrain surface if followTerrain is true, or interpolated according to the original elevations.
globe
- the globe to draw elevations and points from.positions
- the original position listmaxLength
- the maximum length for one segment.followTerrain
- true if the positions should be on the terrain surface.pathType
- the type of path to use in between two positions.start
- the first position indice in the original list.count
- how many positions from the original list have to be processed and returned.