Class LineStringCursor

Object
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 Details

    • LineStringCursor

      public LineStringCursor(LineString ls)
      Builds a new cursor
    • LineStringCursor

      public LineStringCursor(LineStringCursor cursor)
      Copy constructor
  • Method Details

    • 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 of getMaxAngleChange(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.