Package org.gvsig.fmap.geom.jts.mgeom
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
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
pointsFields inherited from class com.vividsolutions.jts.geom.Geometry
envelope, factory, SRIDFields inherited from interface org.gvsig.fmap.geom.jts.mgeom.MGeometry
CONSTANT, DECREASING, INCREASING, NON_MONOTONE -
Constructor Summary
ConstructorsConstructorDescriptionMLineString(com.vividsolutions.jts.geom.CoordinateSequence points, com.vividsolutions.jts.geom.GeometryFactory factory) -
Method Summary
Modifier and TypeMethodDescriptioncom.vividsolutions.jts.geom.GeometryReturns thisMGeometryas aGeometry.clone()protected voidgetClosestPoint(com.vividsolutions.jts.geom.Coordinate co, double tolerance) com.vividsolutions.jts.geom.CoordinategetCoordinateAtM(double m) Returns the Coordinate along the Geometry at the measure valuecom.vividsolutions.jts.geom.CoordinateSequence[]getCoordinatesBetween(double fromM, double toM) Returns the coordinatesequence(s) containing all coordinates between the begin and end measures.doublegetMatCoordinate(com.vividsolutions.jts.geom.Coordinate c, double tolerance) Returns the measure value at the CoordinatedoublegetMatN(int n) get the measure of the specified coordinatedoublegetMaxM()Returns the maximum M-value of the MGeometryintdetermine the direction of the measures w.r.t. the direction of the linedouble[]doublegetMinM()Returns the minimum M-value of the MGeometrydoubleReturns the measure length of the segment.voidinterpolate(double beginMeasure, double endMeasure) Assigns the first coordinate in the CoordinateSequence to thebeginMeasureand the last coordinate in the CoordinateSequence to theendMeasure.booleanisMonotone(boolean strict) Indicates whether the MLineString has monotone increasing or decreasing M-valuesvoidmeasureOnLength(boolean keepBeginMeasure) Builds measures along the Geometry based on the length from the beginning (first coordinate) of the Geometry.voidThis method reverses the measures assigned to the Coordinates in the CoordinateSequence without modifying the positional (x,y,z) values.voidsetMeasureAtIndex(int index, double m) voidshiftMeasure(double amount) Shift all measures by the amount parameter.toString()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, reverseMethods 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, withinMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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
- Overrides:
clonein classcom.vividsolutions.jts.geom.LineString
-
geometryChangedAction
protected void geometryChangedAction()- Overrides:
geometryChangedActionin classcom.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 MLineStringtolerance- max. distance that co may be from this MLineString- Returns:
- an MCoordinate on this MLineString with appropriate M-value
- Throws:
MGeometryException
-
getCoordinateAtM
Description copied from interface:MGeometryReturns the Coordinate along the Geometry at the measure value- Specified by:
getCoordinateAtMin interfaceMGeometry- Parameters:
m- measure value- Returns:
- the Coordinate if m is on the MGeometry otherwise null
- Throws:
MGeometryException- when MGeometry is not monotone
-
getGeometryType
- Overrides:
getGeometryTypein classcom.vividsolutions.jts.geom.LineString
-
getMatCoordinate
public double getMatCoordinate(com.vividsolutions.jts.geom.Coordinate c, double tolerance) throws MGeometryException Description copied from interface:MGeometryReturns the measure value at the Coordinate- Specified by:
getMatCoordinatein interfaceMGeometry- Parameters:
c- the Coordinate for which the measure value is soughttolerance- 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:MGeometryReturns the maximum M-value of the MGeometry -
getCoordinatesBetween
public com.vividsolutions.jts.geom.CoordinateSequence[] getCoordinatesBetween(double fromM, double toM) throws MGeometryException Description copied from interface:MGeometryReturns the coordinatesequence(s) containing all coordinates between the begin and end measures.- Specified by:
getCoordinatesBetweenin interfaceMGeometry- Parameters:
fromM- begin measuretoM- 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:MGeometryReturns the minimum M-value of the MGeometry -
interpolate
public void interpolate(double beginMeasure, double endMeasure) Assigns the first coordinate in the CoordinateSequence to thebeginMeasureand the last coordinate in the CoordinateSequence to theendMeasure. 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 coordinateendMeasure- 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:
isMonotonein interfaceMGeometry- 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:MGeometryReturns thisMGeometryas aGeometry. Modifying the returnedGeometrywill result in internal state changes.- Specified by:
asGeometryin interfaceMGeometry- Returns:
- this object as a Geometry.
-
measureOnLength
public void measureOnLength(boolean keepBeginMeasure) Description copied from interface:MGeometryBuilds measures along the Geometry based on the length from the beginning (first coordinate) of the Geometry.- Specified by:
measureOnLengthin interfaceMGeometry- 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
- Overrides:
toStringin classcom.vividsolutions.jts.geom.Geometry
-
unionM
- Throws:
MGeometryException
-