org.hibernate.spatial.jts.mgeom
Class MLineString

java.lang.Object
  extended by com.vividsolutions.jts.geom.Geometry
      extended by com.vividsolutions.jts.geom.LineString
          extended by org.hibernate.spatial.jts.mgeom.MLineString
All Implemented Interfaces:
com.vividsolutions.jts.geom.Lineal, java.io.Serializable, java.lang.Cloneable, java.lang.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.

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.hibernate.spatial.jts.mgeom.MGeometry
CONSTANT, DECREASING, INCREASING, NON_MONOTONE
 
Constructor Summary
MLineString(com.vividsolutions.jts.geom.CoordinateSequence points, com.vividsolutions.jts.geom.GeometryFactory factory)
           
 
Method Summary
 com.vividsolutions.jts.geom.Geometry asGeometry()
          Returns this MGeometry as a Geometry.
 java.lang.Object clone()
           
 MCoordinate 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.
 java.lang.String getGeometryType()
           
 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 getMaxM()
          Returns the maximum M-value of the MGeometry
 int getMeasureDirection()
          determine the direction of the measures w.r.t.
 double[] getMeasures()
           
 double getMinM()
          Returns the minimum M-value of the MGeometry
 double getMLength()
          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 reverseMeasures()
          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.
 java.lang.String toString()
           
 MLineString unionM(MLineString l)
           
 
Methods inherited from class com.vividsolutions.jts.geom.LineString
apply, apply, apply, apply, equalsExact, getBoundary, getBoundaryDimension, getCoordinate, getCoordinateN, getCoordinates, getCoordinateSequence, getDimension, getEndPoint, getLength, getNumPoints, getPointN, getStartPoint, isClosed, isCoordinate, isEmpty, isRing, normalize, reverse
 
Methods inherited from class com.vividsolutions.jts.geom.Geometry
buffer, buffer, buffer, compareTo, compareTo, contains, convexHull, coveredBy, covers, crosses, difference, disjoint, distance, equals, equals, equalsExact, equalsNorm, equalsTopo, geometryChanged, getArea, getCentroid, getEnvelope, getEnvelopeInternal, getFactory, getGeometryN, getInteriorPoint, getNumGeometries, getPrecisionModel, getSRID, getUserData, hashCode, intersection, intersects, isRectangle, isSimple, isValid, isWithinDistance, norm, overlaps, relate, relate, setSRID, setUserData, symDifference, toText, touches, union, union, within
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.hibernate.spatial.jts.mgeom.MGeometry
getFactory
 

Constructor Detail

MLineString

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

clone

public java.lang.Object clone()
Overrides:
clone in class com.vividsolutions.jts.geom.LineString

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 java.lang.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 java.lang.String toString()
Overrides:
toString in class com.vividsolutions.jts.geom.Geometry

unionM

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