Class TLcdDiscretizedLonLatGeoPath

All Implemented Interfaces:
ILcdEditableGeoPath, ILcdGeoPath, ILcdBounded, ILcdCurve, ILcdPointList, ILcdPolygon, ILcdRing, ILcdShape, ILcdCloneable, ILcdInvalidateable, Serializable, Cloneable

public class TLcdDiscretizedLonLatGeoPath extends ALcdDiscretizedGeoPath implements ILcdInvalidateable
An implementation of ALcdDiscretizedGeoPath which performs the discretization in geodetic coordinates.

The discretization procedure tries to create an ILcdPolygon that is not self-intersecting, as this can cause problems when it is used for certain algorithms in computational geometry, like boolean operations or triangulation. More concretely, it contains a number of techniques to resolve some self-intersection problems that occur frequently in a GeoPath model (most of the time on a very small scale):

  • self-intersections between two succeeding GeoPath legs, of which at least one is of the type ILcdGeoPathLeg.SUB_POINT_LIST.
  • self-intersections at the edges of a leg of type ILcdGeoPathLeg.ARC, caused by an incorrect arc center/radius.
These techniques basically come down to the replacement of (potential) problem points. To allow the user to control this procedure, the method acceptCorrection(ILcdGeoPathLeg, int, ILcdPoint, ILcdPoint) is called for each point replacement. This method returns a boolean value, indicating whether the proposed data correction should be carried out or not. By default, this method returns true in all cases.

It is important to note that these mechanisms do not resolve all possible self-intersections, as it is by no means the intention to perform a full validation of the GeoPath model. This class assumes that the source data of the GeoPath model is correct and only contains some small inaccuracies at most.
See Also:
  • Field Details

    • SUBPOINTLIST_INTERSECTION_CORRECTION

      public static final int SUBPOINTLIST_INTERSECTION_CORRECTION
      Identifies a data correction to prevent a self-intersection at/near a leg of type ILcdGeoPathLeg.SUB_POINT_LIST.
      See Also:
    • ARC_CENTER_CORRECTION

      public static final int ARC_CENTER_CORRECTION
      Identifies a data correction to prevent a self-intersection at a leg of type ILcdGeoPathLeg.ARC.
      See Also:
  • Constructor Details

    • TLcdDiscretizedLonLatGeoPath

      public TLcdDiscretizedLonLatGeoPath()
      Default constructor.
    • TLcdDiscretizedLonLatGeoPath

      public TLcdDiscretizedLonLatGeoPath(TLcdDiscretizedLonLatGeoPath aDiscretizedGeoPath)
      Copy constructor.
      Parameters:
      aDiscretizedGeoPath - the object to be copied
  • Method Details

    • getBounds

      public ILcdBounds getBounds()
      Returns the bounds of the discretized GeoPath.
      Specified by:
      getBounds in interface ILcdBounded
      Returns:
      an ILcdBounds
    • clone

      public Object clone()
      Creates and returns a copy of this object.

      The discretization is not copied or cloned at all, but recalculated when needed.

      Specified by:
      clone in interface ILcdCloneable
      Overrides:
      clone in class ALcdDiscretizedGeoPath
      See Also:
    • getFocusPoint

      public ILcdPoint getFocusPoint()
      Description copied from interface: ILcdShape
      Returns the focus point of this ILcdShape.
      Specified by:
      getFocusPoint in interface ILcdShape
      Returns:
      the focus point of this ILcdShape.
    • contains2D

      public boolean contains2D(ILcdPoint aPoint)
      Description copied from interface: ILcdShape
      Checks whether this ILcdShape contains the given ILcdPoint in the 2D space. Only the first two dimensions of the ILcdShape and the ILcdPoint are considered.
      Specified by:
      contains2D in interface ILcdShape
      Parameters:
      aPoint - the ILcdPoint to test.
      Returns:
      the boolean result of the containment test.
      See Also:
    • contains2D

      public boolean contains2D(double v, double v1)
      Description copied from interface: ILcdShape
      Checks whether this ILcdShape contains the given point in the 2D space. Only the first two dimensions of the ILcdShape are considered.
      Specified by:
      contains2D in interface ILcdShape
      Parameters:
      v - the x coordinate of the point.
      v1 - the y coordinate of the point.
      Returns:
      the boolean result of the containment test.
    • contains3D

      public boolean contains3D(ILcdPoint aPoint)
      Description copied from interface: ILcdShape
      Checks whether this ILcdShape contains the given ILcdPoint in the 3D space.
      Specified by:
      contains3D in interface ILcdShape
      Parameters:
      aPoint - the ILcdPoint to test.
      Returns:
      the boolean result of the containment test.
      See Also:
    • contains3D

      public boolean contains3D(double v, double v1, double v2)
      Description copied from interface: ILcdShape
      Checks whether this ILcdShape contains the given point in the 3D space.
      Specified by:
      contains3D in interface ILcdShape
      Parameters:
      v - the x coordinate of the point.
      v1 - the y coordinate of the point.
      v2 - the z coordinate of the point.
      Returns:
      the boolean result of the containment test.
    • getOrientation

      public int getOrientation()
      Description copied from interface: ILcdPolygon
      Returns the orientation of this ILcdPolygon: ILcdPolygon.CLOCKWISE or ILcdPolygon.COUNTERCLOCKWISE.
      Specified by:
      getOrientation in interface ILcdPolygon
      Returns:
      the orientation of this ILcdPolygon: ILcdPolygon.CLOCKWISE or ILcdPolygon.COUNTERCLOCKWISE. This method should not return INVALID_ORIENTATION, which is only to be used for resetting the orientation so that it can be recalculated.
    • getPointCount

      public int getPointCount()
      Description copied from interface: ILcdPointList
      Returns the number of ILcdPoint objects in the list.
      Specified by:
      getPointCount in interface ILcdPointList
      Returns:
      the number of ILcdPoint objects in the list.
    • getPoint

      public ILcdPoint getPoint(int aIndex) throws IndexOutOfBoundsException
      Description copied from interface: ILcdPointList
      Returns the ILcdPoint at a given index.
      Specified by:
      getPoint in interface ILcdPointList
      Parameters:
      aIndex - a valid index in the list of ILcdPoint objects.
      Returns:
      the ILcdPoint at the given index.
      Throws:
      IndexOutOfBoundsException - if the given index is out of bounds.
    • addLeg

      public void addLeg(ILcdGeoPathLeg aGeoPathLeg)
      Add aGeoPathLeg to this GeoPath.
      Specified by:
      addLeg in interface ILcdEditableGeoPath
      Overrides:
      addLeg in class TLcdGeoPath
      Parameters:
      aGeoPathLeg - the ILcdGeoPathLeg to be added
    • removeLeg

      public boolean removeLeg(ILcdGeoPathLeg aGeoPathLeg)
      Remove aGeoPathLeg from this GeoPath.
      Overrides:
      removeLeg in class TLcdGeoPath
      Parameters:
      aGeoPathLeg - the ILcdGeoPathLeg to be removed
      Returns:
      true if the leg was successfully removed
    • insertLegAt

      public void insertLegAt(ILcdGeoPathLeg aLeg, int anIndex)
      Description copied from interface: ILcdEditableGeoPath
      Adds a ILcdGeoPathLeg object to the ILcdEditableGeoPath on the specified index.
      Specified by:
      insertLegAt in interface ILcdEditableGeoPath
      Overrides:
      insertLegAt in class TLcdGeoPath
      Parameters:
      aLeg - the ILcdGeoPathLeg object to be added to the ILcdEditableGeoPath.
      anIndex - the index in the ILcdEditableAirspace where the ILcdAirspaceSegment object must be added.
    • removeLegAt

      public void removeLegAt(int anIndex)
      Description copied from interface: ILcdEditableGeoPath
      Removes the ILcdGeoPathLeg object on the specified index from the from ILcdEditableGeoPath.
      Specified by:
      removeLegAt in interface ILcdEditableGeoPath
      Overrides:
      removeLegAt in class TLcdGeoPath
      Parameters:
      anIndex - the index in the ILcdEditableGeoPath where the ILcdGeoPathLeg object must be removed.
    • invalidate

      public void invalidate()
      Discards the geometry cached with this GeoPath and recalculates it. Whenever this is done, the ILcdModel containing this GeoPath should be notified by means of a call to elementChanged()!
    • invalidateObject

      public void invalidateObject()
      Delegates to invalidate().
      Specified by:
      invalidateObject in interface ILcdInvalidateable
      See Also:
    • getLegForPoint

      public ILcdGeoPathLeg getLegForPoint(int aPointIndex)
      Returns the ILcdGeoPathLeg that contains the discretized point at the given index.
      Parameters:
      aPointIndex - the index of a discretized point in this GeoPath
      Returns:
      the corresponding ILcdGeoPathLeg.
      Throws:
      ArrayIndexOutOfBoundsException - if the index is out of range (index < 0 || index >= getPointCount()).
    • getLegIndexForPoint

      public int getLegIndexForPoint(int aPointIndex) throws ArrayIndexOutOfBoundsException
      Identical to getLegForPoint(), but returns the index of the ILcdGeoPathLeg rather than the leg itself.
      Parameters:
      aPointIndex - the index of a discretized point in this GeoPath
      Returns:
      the index of the corresponding ILcdGeoPathLeg.
      Throws:
      ArrayIndexOutOfBoundsException - if the index is out of range (index < 0 || index >= getPointCount()).
    • setEllipsoid

      public void setEllipsoid(ILcdEllipsoid aEllipsoid)
      Sets the ellipsoid on which the discretization calculations are to be performed. Defaults to the WGS84 ellipsoid.
      Parameters:
      aEllipsoid - an ILcdEllipsoid
    • getDiscretisationResolutionDistance

      public double getDiscretisationResolutionDistance()
      Returns the distance between discretized points in meters.
      Returns:
      the distance between discretized points in meters.
    • setDiscretisationResolutionDistance

      public void setDiscretisationResolutionDistance(double aDiscretisationResolutionDistance)
      Sets the distance between discretized points in meters.
      Parameters:
      aDiscretisationResolutionDistance - the distance between discretized points in meters.
    • getDiscretisationResolutionAngle

      public double getDiscretisationResolutionAngle()
      Return the distance between discrete points on an arc in degrees.
      Returns:
      the distance between discrete points on an arc in degrees.
    • setDiscretisationResolutionAngle

      public void setDiscretisationResolutionAngle(double aDiscretisationResolutionAngle)
      Sets the distance between discrete points on an arc in degrees.
      Parameters:
      aDiscretisationResolutionAngle - the distance between discrete points on an arc in degrees.
    • computePointSFCT

      public void computePointSFCT(double aParam, ILcd3DEditablePoint aPointSFCT)
      Description copied from interface: ILcdCurve
      Computes a point of the curve, defined by the given parameter.
      Specified by:
      computePointSFCT in interface ILcdCurve
      Parameters:
      aParam - a value of the closed interval [0,1]
      aPointSFCT - the point to store the computed curve point in
    • getEndPoint

      public ILcdPoint getEndPoint()
      Description copied from interface: ILcdCurve
      Retrieves the end point of the curve.

      This is equivalent to computePointSFCT(1).

      Specified by:
      getEndPoint in interface ILcdCurve
      Returns:
      the end point of the curve
    • getEndTangent2D

      public double getEndTangent2D()
      Description copied from interface: ILcdCurve
      Returns the angle of the curve's tangent at the end point, in degrees counterclockwise from the direction at 3 o'clock.

      The tangent orientation is from the end point, away from the curve before it.

      This is the same as getTangent2D(1).

      Specified by:
      getEndTangent2D in interface ILcdCurve
      Returns:
      the curve's angle in the end point
    • getInterpolation

      public String getInterpolation()
      Description copied from interface: ILcdCurve
      Returns the interpolation method used by this curve.

      A set of predefined constants are defined in this interface, which are used by the default ILcdCurve implementations provided by LuciadLightspeed.

      Custom implementations can define their own constants, and use them to interpret the interpolation of the curve.

      Specified by:
      getInterpolation in interface ILcdCurve
      Returns:
      the interpolation method used by this curve.
    • getLength2D

      public double getLength2D(double aParam1, double aParam2)
      Description copied from interface: ILcdCurve
      Returns the length between two points of the curve, defined by the given parameters.
      • When aParam1 == aParam2, the length is 0.
      • When aParam1 == 0 and aParam2 == 1, the length is the whole length of the curve.
      • When aParam1 > aParam2, the length is (aParam1 to 1) + (0 to aParam2).
      Specified by:
      getLength2D in interface ILcdCurve
      Parameters:
      aParam1 - a value of the closed interval [0,1]
      aParam2 - a value of the closed interval [0,1]
      Returns:
      the length of the curve.
    • getLineSegmentIntersectionCount

      public int getLineSegmentIntersectionCount(ILcdPoint aP1, ILcdPoint aP2)
      Description copied from interface: ILcdCurve
      Returns the number of intersections between this curve and a line segment defined by the two specified points.

      This information can be used to perform containment calculations, if this curve is closed or if this curve is part of a composite closed curve. By determining the number of intersections between this curve and a line segment starting from a given point in a fixed direction, one can determine whether a point is located within the closed curve by using the even-odd rule.

      Specified by:
      getLineSegmentIntersectionCount in interface ILcdCurve
      Parameters:
      aP1 - the first point of the line segment
      aP2 - the second point of the line segment
      Returns:
      the number of intersections between the curve and the line segment
    • getStartPoint

      public ILcdPoint getStartPoint()
      Description copied from interface: ILcdCurve
      Retrieves the start point of the curve.

      This is equivalent to computePointSFCT(0).

      Specified by:
      getStartPoint in interface ILcdCurve
      Returns:
      the start point of the curve
    • getStartTangent2D

      public double getStartTangent2D()
      Description copied from interface: ILcdCurve
      Returns the angle of the curve's tangent at the start point, in degrees counterclockwise from the direction at 3 o'clock.

      The tangent orientation is from the start point towards the rest of the shape.

      This is the same as getTangent2D(0).

      Specified by:
      getStartTangent2D in interface ILcdCurve
      Returns:
      the curve's angle in the start point
    • getTangent2D

      public double getTangent2D(double aParam)
      Description copied from interface: ILcdCurve
      Returns the angle of the curve's tangent in the point defined by the given parameter, in degrees counterclockwise from the direction at 3 o'clock.

      The tangent orientation is from the point at parameter aParam towards the rest of the shape.

      Specified by:
      getTangent2D in interface ILcdCurve
      Parameters:
      aParam - a value of the closed interval [0,1]
      Returns:
      the curve's angle in the point defined by the given parameter
    • acceptCorrection

      protected boolean acceptCorrection(ILcdGeoPathLeg aLeg, int aType, ILcdPoint aOriginalPoint, ILcdPoint aNewPoint)
      Checks whether the proposed data correction is accepted or not, to prevent self-intersections in the discretized pointlists. The data correction implies a replacement of one point by another, in the supplied GeoPath leg. By default, this method returns true in all cases.
      Parameters:
      aLeg - The ILcdGeoPathLeg object for which a data correction is proposed.
      aType - An identification of the data correction, which is either SUBPOINTLIST_INTERSECTION_CORRECTION or ARC_CENTER_CORRECTION.
      aOriginalPoint - A point in the geopath leg that is to be replaced. This point can be the location of the GeoPath leg itself (ILcdGeoPathLeg is also a ILcdPoint), or a point in its data array (ILcdGeoPathLeg.getDataSFCT())
      aNewPoint - The new point to be used instead of the original point.
      Returns:
      True if the proposed data correction is accepted.