Class MLineString

java.lang.Object
com.vividsolutions.jts.geom.Geometry
com.vividsolutions.jts.geom.LineString
org.gvsig.fmap.geom.jts.mgeom.MLineString
All Implemented Interfaces:
com.vividsolutions.jts.geom.Lineal, Serializable, Cloneable, Comparable, MGeometry

public class MLineString extends com.vividsolutions.jts.geom.LineString implements MGeometry
An implementation of the LineString class with the addition that the containing CoordinateSequence can carry measure. Note that this is not a strict requirement of the class, and can interact with non-measure geometries for JTS topological comparisons regardless.
Author:
Karel Maesen
See Also:
  • Field Summary

    Fields inherited from class com.vividsolutions.jts.geom.LineString

    points

    Fields inherited from class com.vividsolutions.jts.geom.Geometry

    envelope, factory, SRID

    Fields inherited from interface org.gvsig.fmap.geom.jts.mgeom.MGeometry

    CONSTANT, DECREASING, INCREASING, NON_MONOTONE
  • Constructor Summary

    Constructors
    Constructor
    Description
    MLineString(com.vividsolutions.jts.geom.CoordinateSequence points, com.vividsolutions.jts.geom.GeometryFactory factory)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.vividsolutions.jts.geom.Geometry
    Returns this MGeometry as a Geometry.
     
    protected void
     
    getClosestPoint(com.vividsolutions.jts.geom.Coordinate co, double tolerance)
     
    com.vividsolutions.jts.geom.Coordinate
    getCoordinateAtM(double m)
    Returns the Coordinate along the Geometry at the measure value
    com.vividsolutions.jts.geom.CoordinateSequence[]
    getCoordinatesBetween(double fromM, double toM)
    Returns the coordinatesequence(s) containing all coordinates between the begin and end measures.
     
    double
    getMatCoordinate(com.vividsolutions.jts.geom.Coordinate c, double tolerance)
    Returns the measure value at the Coordinate
    double
    getMatN(int n)
    get the measure of the specified coordinate
    double
    Returns the maximum M-value of the MGeometry
    int
    determine the direction of the measures w.r.t. the direction of the line
    double[]
     
    double
    Returns the minimum M-value of the MGeometry
    double
    Returns the measure length of the segment.
    void
    interpolate(double beginMeasure, double endMeasure)
    Assigns the first coordinate in the CoordinateSequence to the beginMeasure and the last coordinate in the CoordinateSequence to the endMeasure.
    boolean
    isMonotone(boolean strict)
    Indicates whether the MLineString has monotone increasing or decreasing M-values
    void
    measureOnLength(boolean keepBeginMeasure)
    Builds measures along the Geometry based on the length from the beginning (first coordinate) of the Geometry.
    void
    This method reverses the measures assigned to the Coordinates in the CoordinateSequence without modifying the positional (x,y,z) values.
    void
    setMeasureAtIndex(int index, double m)
     
    void
    shiftMeasure(double amount)
    Shift all measures by the amount parameter.
     
     

    Methods inherited from class com.vividsolutions.jts.geom.LineString

    apply, apply, apply, apply, compareToSameClass, compareToSameClass, computeEnvelopeInternal, equalsExact, getBoundary, getBoundaryDimension, getCoordinate, getCoordinateN, getCoordinates, getCoordinateSequence, getDimension, getEndPoint, getLength, getNumPoints, getPointN, getStartPoint, isClosed, isCoordinate, isEmpty, isEquivalentClass, isRing, normalize, reverse

    Methods inherited from class com.vividsolutions.jts.geom.Geometry

    buffer, buffer, buffer, checkNotGeometryCollection, compare, compareTo, compareTo, contains, convexHull, coveredBy, covers, crosses, difference, disjoint, distance, equal, equals, equals, equalsExact, equalsNorm, equalsTopo, geometryChanged, getArea, getCentroid, getEnvelope, getEnvelopeInternal, getFactory, getGeometryN, getInteriorPoint, getNumGeometries, getPrecisionModel, getSRID, getUserData, hashCode, hasNonEmptyElements, hasNullElements, intersection, intersects, isGeometryCollection, isRectangle, isSimple, isValid, isWithinDistance, norm, overlaps, relate, relate, setSRID, setUserData, symDifference, toText, touches, union, union, within

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.gvsig.fmap.geom.jts.mgeom.MGeometry

    getFactory
  • Constructor Details

    • MLineString

      public MLineString(com.vividsolutions.jts.geom.CoordinateSequence points, com.vividsolutions.jts.geom.GeometryFactory factory)
  • Method Details

    • clone

      public Object clone()
      Overrides:
      clone in class com.vividsolutions.jts.geom.LineString
    • geometryChangedAction

      protected void geometryChangedAction()
      Overrides:
      geometryChangedAction in class com.vividsolutions.jts.geom.Geometry
    • getClosestPoint

      public MCoordinate getClosestPoint(com.vividsolutions.jts.geom.Coordinate co, double tolerance) throws MGeometryException
      Parameters:
      co - input coordinate in the neighbourhood of the MLineString
      tolerance - max. distance that co may be from this MLineString
      Returns:
      an MCoordinate on this MLineString with appropriate M-value
      Throws:
      MGeometryException
    • getCoordinateAtM

      public com.vividsolutions.jts.geom.Coordinate getCoordinateAtM(double m) throws MGeometryException
      Description copied from interface: MGeometry
      Returns the Coordinate along the Geometry at the measure value
      Specified by:
      getCoordinateAtM in interface MGeometry
      Parameters:
      m - measure value
      Returns:
      the Coordinate if m is on the MGeometry otherwise null
      Throws:
      MGeometryException - when MGeometry is not monotone
    • getGeometryType

      public String getGeometryType()
      Overrides:
      getGeometryType in class com.vividsolutions.jts.geom.LineString
    • getMatCoordinate

      public double getMatCoordinate(com.vividsolutions.jts.geom.Coordinate c, double tolerance) throws MGeometryException
      Description copied from interface: MGeometry
      Returns the measure value at the Coordinate
      Specified by:
      getMatCoordinate in interface MGeometry
      Parameters:
      c - the Coordinate for which the measure value is sought
      tolerance - distance to the MGeometry within which Coordinate c has to lie
      Returns:
      the measure value if Coordinate c is within tolerance of the Geometry, else Double.NaN

      When the geometry is a ring or is self-intersecting more coordinates may be determined by one coordinate. In that case, the lowest measure is returned.

      Throws:
      MGeometryException - when this MGeometry is not monotone
    • getMatN

      public double getMatN(int n)
      get the measure of the specified coordinate
      Parameters:
      n - index of the coordinate
      Returns:
      The measure of the coordinate. If the coordinate does not exists it returns Double.NaN
    • getMaxM

      public double getMaxM()
      Description copied from interface: MGeometry
      Returns the maximum M-value of the MGeometry
      Specified by:
      getMaxM in interface MGeometry
      Returns:
      the maximum M-value
    • getCoordinatesBetween

      public com.vividsolutions.jts.geom.CoordinateSequence[] getCoordinatesBetween(double fromM, double toM) throws MGeometryException
      Description copied from interface: MGeometry
      Returns the coordinatesequence(s) containing all coordinates between the begin and end measures.
      Specified by:
      getCoordinatesBetween in interface MGeometry
      Parameters:
      fromM - begin measure
      toM - end measure
      Returns:
      an array containing all coordinatesequences in order between begin and end. Each CoordinateSequence covers a contiguous stretch of the MGeometry.
      Throws:
      MGeometryException - when this MGeometry is not monotone
    • getMeasureDirection

      public int getMeasureDirection()
      determine the direction of the measures w.r.t. the direction of the line
      Returns:
      MGeometry.NON_MONOTONE
      MGeometry.INCREASING
      MGeometry.DECREASING
      MGeometry.CONSTANT
    • getMeasures

      public double[] getMeasures()
      Returns:
      the array with measure-values of the vertices
    • getMinM

      public double getMinM()
      Description copied from interface: MGeometry
      Returns the minimum M-value of the MGeometry
      Specified by:
      getMinM in interface MGeometry
      Returns:
      the minimum M-value
    • interpolate

      public void interpolate(double beginMeasure, double endMeasure)
      Assigns the first coordinate in the CoordinateSequence to the beginMeasure and the last coordinate in the CoordinateSequence to the endMeasure. Measure values for intermediate coordinates are then interpolated proportionally based on their 2d offset of the overall 2d length of the LineString.

      If the beginMeasure and endMeasure values are equal it is assumed that all intermediate coordinates shall be the same value.

      Parameters:
      beginMeasure - Measure value for first coordinate
      endMeasure - Measure value for last coordinate
    • getMLength

      public double getMLength()
      Returns the measure length of the segment. This method assumes that the length of the LineString is defined by the absolute value of (last coordinate - first coordinate) in the CoordinateSequence. If either measure is not defined or the CoordinateSequence contains no coordinates, then Double.NaN is returned. If there is only 1 element in the CoordinateSequence, then 0 is returned.
      Returns:
      The measure length of the LineString
    • isMonotone

      public boolean isMonotone(boolean strict)
      Indicates whether the MLineString has monotone increasing or decreasing M-values
      Specified by:
      isMonotone in interface MGeometry
      Returns:
      true if MLineString is empty or M-values are increasing (NaN) values, false otherwise
    • asGeometry

      public com.vividsolutions.jts.geom.Geometry asGeometry()
      Description copied from interface: MGeometry
      Returns this MGeometry as a Geometry.

      Modifying the returned Geometry will result in internal state changes.

      Specified by:
      asGeometry in interface MGeometry
      Returns:
      this object as a Geometry.
    • measureOnLength

      public void measureOnLength(boolean keepBeginMeasure)
      Description copied from interface: MGeometry
      Builds measures along the Geometry based on the length from the beginning (first coordinate) of the Geometry.
      Specified by:
      measureOnLength in interface MGeometry
      Parameters:
      keepBeginMeasure - - if true, the measure of the first coordinate is maintained and used as start value, unless this measure is Double.NaN
    • reverseMeasures

      public void reverseMeasures()
      This method reverses the measures assigned to the Coordinates in the CoordinateSequence without modifying the positional (x,y,z) values.
    • setMeasureAtIndex

      public void setMeasureAtIndex(int index, double m)
    • shiftMeasure

      public void shiftMeasure(double amount)
      Shift all measures by the amount parameter. A negative amount shall subtract the amount from the measure. Note that this can make for negative measures.
      Parameters:
      amount - the positive or negative amount by which to shift the measures in the CoordinateSequence.
    • toString

      public String toString()
      Overrides:
      toString in class com.vividsolutions.jts.geom.Geometry
    • unionM

      public MLineString unionM(MLineString l) throws MGeometryException
      Throws:
      MGeometryException