Package hec.map

Class WorldLine

java.lang.Object
hec.map.WorldLine
All Implemented Interfaces:
AsciiSerializable, FieldAccessor, Serializable, Cloneable
Direct Known Subclasses:
WorldLine3d

public class WorldLine extends Object implements Serializable, AsciiSerializable, Cloneable
A multi-point line in world coordinates.

See Also:
  • Field Details

    • RIGHTBANK

      public static final int RIGHTBANK
      See Also:
    • LEFTBANK

      public static final int LEFTBANK
      See Also:
    • pts

      public Vector pts
      Vector of interior points in line
    • _length

      protected transient double _length
    • _bounds

      protected transient WorldRect _bounds
    • _coordAtPt

      protected transient double[] _coordAtPt
    • _tmpSeg

      protected static transient WorldLineSeg _tmpSeg
  • Constructor Details

    • WorldLine

      public WorldLine()
  • Method Details

    • isEmpty

      public boolean isEmpty()
    • clone

      public Object clone()
      Overrides:
      clone in class Object
    • reverseDirection

      public void reverseDirection()
    • newPt

      public WorldPt newPt()
    • getFirstPt

      public WorldPt getFirstPt()
    • getLastPt

      public WorldPt getLastPt()
    • getCenterPt

      public WorldPt getCenterPt()
    • nearPt

      public boolean nearPt(WorldPt wpt, double tol)
    • getNearestLocationSigned

      public double getNearestLocationSigned(WorldPt wpt, WorldPt ptnbest)
      computes the shortest distance between the given point and the line, sign of returned value indicates which side of line the point is on
    • getNearestLocation

      public double getNearestLocation(WorldPt wpt, WorldPt ptnbest)
      Computes the shortest distance between the given point and the line

      Parameters:
      wpt - this is the point that we are testing to find the shortest distance to this line.
      ptnbest - this is an object if NOT null will hold the point on this line that is the closest to the test point.

    • getLength

      public double getLength()
      Computes the length of the line and the coordinate at each point
    • invalidate

      public void invalidate()
    • getPtIndexBeforeCoord

      public int getPtIndexBeforeCoord(double coord)
      returns the index of the point in the pts vector before the given coord
    • getPtIndexNearCoord

      public int getPtIndexNearCoord(double coord)
      returns the index of the point in the pts vector nearest the given coord
    • getCoordAtLocation

      public double getCoordAtLocation(WorldPt wpt)
      computes the stream coordinate nearest the given location
    • getLocationByCoord

      public WorldPt getLocationByCoord(double coord)
    • insertPt

      public boolean insertPt(WorldPt wpt, double tol)
      if the given point is within the given tolerance of the line, a new point is inserted at the location on the line nearest the given point.
    • removePt

      public boolean removePt(WorldPt wpt, double tol)
    • removePtsAfter

      public boolean removePtsAfter(WorldPt wpt)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • parseString

      public void parseString(String str)
    • createOffsetLine

      public WorldLine createOffsetLine(double coord0, double coord1, double offset, int bank)
      Creates a WorldLine offset from the current line between the given coordinates
    • intersects

      public boolean intersects(WorldLine wl, WorldPt intersectPt)
      check to see if WorldLine wl intersects this WorldLine
    • intersects

      public boolean intersects(WorldLineSeg l, WorldPt ptOfIntersect, WorldPt ptDist, int istart)
      tests for intersection with a world line segment starting from point istart
    • getLocalRegionArrays

      public int getLocalRegionArrays(MapScale scl, int[] xarray, int[] yarray)
      creates a set of local coordiates to draw a polygonal reach
    • getLocalRegionArrays

      public int getLocalRegionArrays(MapScale scl, int[] xarray, int[] yarray, double width)
    • getLocalRegionArrays

      public int getLocalRegionArrays(MapScale scl, int[] xarray, int[] yarray, double width, int start, int numPoints)
      creates a set of local coordiates to draw a polygonal reach
    • getLocalArrays

      public int getLocalArrays(MapScale scl, int[] xarray, int[] yarray, int start, int numPoints)
      creates a set of local coordinates to draw a polygonal reach

      Parameters:
      scl -
      xarray -
      yarray -
      start -
      numPoints -

      Returns:
    • getLocalArrays2d

      public int getLocalArrays2d(MapScale scl, int[] xarray, int[] yarray, int start, int numPoints)
      creates a set of local coordinates to draw a line using Graphics2d

      Parameters:
      scl -
      xarray -
      yarray -
      start -
      numPoints -

      Returns:
    • getSlopeAtCoord

      public boolean getSlopeAtCoord(double coord, WorldPt wpt, WorldPt slope)
      Compute the location and slope at the specified line coordinate. The line coordinate goes from 0 to 1.
    • setLinePoint

      public void setLinePoint(double coord, WorldPt wpt)
      reset the location of a point on the stream line
    • getBounds

      public WorldRect getBounds()
    • add

      public boolean add(WorldLine line)
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • equals

      public boolean equals(WorldLine that)
    • getFieldObject

      public Object getFieldObject(Field fld)
      Description copied from interface: FieldAccessor
      This method allows access to java.lang.reflect.Field objects within the implementing class.
      Specified by:
      getFieldObject in interface FieldAccessor
      Parameters:
      fld - The field to get.
      Returns:
      The data object that is stored in the given field
    • setFieldObject

      public boolean setFieldObject(Field fld, Object fobj)
      Description copied from interface: FieldAccessor
      This allows access to fields withing the implementing object to set there data.
      Specified by:
      setFieldObject in interface FieldAccessor
      Parameters:
      fld - The java field object representing the member field to be set
      fobj - The data to set in that field
      Returns:
      returns true if successful