Package org.geotools.geometry.jts
Class LineStringCursor
- Object
-
- LineStringCursor
-
- Direct Known Subclasses:
LineStringCursor
public class LineStringCursor extends Object
Allows to move a point cursor along the path of a LineString using a curvilinear coordinate system and either absolute distances (from the start of the line) or offsets relative to the current position, to return the absolute position of the cursor as a Point, and to get the orientation of the current segment.- Author:
- Andrea Aime
-
-
Constructor Summary
Constructors Constructor Description LineStringCursor(LineStringCursor cursor)Copy constructorLineStringCursor(LineString ls)Builds a new cursor
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description doublegetCurrentAngle()Returns the current segment direction as an angle expressed in radiansdoublegetCurrentOrdinate()CoordinategetCurrentPosition()Returns the Point representing the current position along the LineStringCoordinategetCurrentPosition(Coordinate c)Returns the Point representing the current position along the LineStringdoublegetLabelOrientation()Returns the current segment direction as an angle expressed in radiansLineStringgetLineString()The linestrings wrapped by this cursordoublegetLineStringLength()Returns the line string lengthdoublegetMaxAngleChange(double startOrdinate, double endOrdinate)Returns the maximum angle change (in radians) between two subsequent segments between the specified curvilinear coordinates.doublegetMaxAngleChange(double startOrdinate, double endOrdinate, double step)Deprecated.Does not work correctly, will be removed (tried too many times to fix it)doublegetMaxDistanceFromStraightLine(double startOrdinate, double endOrdinate)Returns the maximum distance between the curve and a straight line connecting the start and end ordinates.protected doublegetSegmentAngle(int segmentIdx)LineStringgetSubLineString(double startOrdinate, double endOrdinate)Returns the linestring that starts and ends at the specified curvilinear coordinates.booleanmoveRelative(double offset)Moves of the specified distance from the current position.voidmoveTo(double ordinate)Moves the current position to theLineStringCursorreverse()Returns a line string cursor based on the opposite walking direction.
-
-
-
Constructor Detail
-
LineStringCursor
public LineStringCursor(LineString ls)
Builds a new cursor
-
LineStringCursor
public LineStringCursor(LineStringCursor cursor)
Copy constructor
-
-
Method Detail
-
getLineStringLength
public double getLineStringLength()
Returns the line string length
-
moveTo
public void moveTo(double ordinate)
Moves the current position to the
-
moveRelative
public boolean moveRelative(double offset)
Moves of the specified distance from the current position.- Returns:
- true if it was possible to move to the desired offset, false if the movement stopped because the start or end of the LineString was reached
-
getCurrentPosition
public Coordinate getCurrentPosition()
Returns the Point representing the current position along the LineString
-
getCurrentPosition
public Coordinate getCurrentPosition(Coordinate c)
Returns the Point representing the current position along the LineString
-
getCurrentOrdinate
public double getCurrentOrdinate()
-
getCurrentAngle
public double getCurrentAngle()
Returns the current segment direction as an angle expressed in radians
-
getSegmentAngle
protected double getSegmentAngle(int segmentIdx)
-
getLabelOrientation
public double getLabelOrientation()
Returns the current segment direction as an angle expressed in radians
-
getMaxAngleChange
public double getMaxAngleChange(double startOrdinate, double endOrdinate)Returns the maximum angle change (in radians) between two subsequent segments between the specified curvilinear coordinates.
-
getMaxAngleChange
@Deprecated public double getMaxAngleChange(double startOrdinate, double endOrdinate, double step)
Deprecated.Does not work correctly, will be removed (tried too many times to fix it)A variant ofgetMaxAngleChange(double, double)taking a step and evaluating angle differences at such step. This helps when a line has many little segments and chars would end up showing several segments apart (so the full angle change needs to be considered)
-
getMaxDistanceFromStraightLine
public double getMaxDistanceFromStraightLine(double startOrdinate, double endOrdinate)Returns the maximum distance between the curve and a straight line connecting the start and end ordinates.
-
reverse
public LineStringCursor reverse()
Returns a line string cursor based on the opposite walking direction.
-
getLineString
public LineString getLineString()
The linestrings wrapped by this cursor
-
getSubLineString
public LineString getSubLineString(double startOrdinate, double endOrdinate)
Returns the linestring that starts and ends at the specified curvilinear coordinates.
-
-