com.vividsolutions.jts.geom
Class LineString

java.lang.Object
  extended bycom.vividsolutions.jts.geom.Geometry
      extended bycom.vividsolutions.jts.geom.LineString
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable, java.io.Serializable
Direct Known Subclasses:
LinearRing

public class LineString
extends Geometry

Basic implementation of LineString.

Version:
1.7
See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.vividsolutions.jts.geom.Geometry
envelope, factory, SRID
 
Constructor Summary
LineString(Coordinate[] points, PrecisionModel precisionModel, int SRID)
          Deprecated. Use GeometryFactory instead
LineString(CoordinateSequence points, GeometryFactory factory)
           
 
Method Summary
 void apply(CoordinateFilter filter)
          Performs an operation with or on this Geometry's coordinates.
 void apply(CoordinateSequenceFilter filter)
          Performs an operation on the coordinates in this Geometry's CoordinateSequences.
 void apply(GeometryComponentFilter filter)
          Performs an operation with or on this Geometry and its component Geometry's.
 void apply(GeometryFilter filter)
          Performs an operation with or on this Geometry and its subelement Geometrys (if any).
 java.lang.Object clone()
          Creates and returns a full copy of this LineString object.
protected  int compareToSameClass(java.lang.Object o)
          Returns whether this Geometry is greater than, equal to, or less than another Geometry having the same class.
protected  int compareToSameClass(java.lang.Object o, CoordinateSequenceComparator comp)
          Returns whether this Geometry is greater than, equal to, or less than another Geometry of the same class.
protected  Envelope computeEnvelopeInternal()
          Returns the minimum and maximum x and y values in this Geometry , or a null Envelope if this Geometry is empty.
 boolean equalsExact(Geometry other, double tolerance)
          Returns true if the two Geometrys are exactly equal, up to a specified distance tolerance.
 Geometry getBoundary()
          Gets the boundary of this geometry.
 int getBoundaryDimension()
          Returns the dimension of this Geometrys inherent boundary.
 Coordinate getCoordinate()
          Returns a vertex of this Geometry.
 Coordinate getCoordinateN(int n)
           
 Coordinate[] getCoordinates()
          Returns this Geometry s vertices.
 CoordinateSequence getCoordinateSequence()
           
 int getDimension()
          Returns the dimension of this Geometry.
 Point getEndPoint()
           
 java.lang.String getGeometryType()
          Returns the name of this object's com.vivid.jts.geom interface.
 double getLength()
          Returns the length of this LineString
 int getNumPoints()
          Returns the count of this Geometrys vertices.
 Point getPointN(int n)
           
 Point getStartPoint()
           
 boolean isClosed()
           
 boolean isCoordinate(Coordinate pt)
          Returns true if the given point is a vertex of this LineString.
 boolean isEmpty()
          Returns whether or not the set of points in this Geometry is empty.
protected  boolean isEquivalentClass(Geometry other)
          Returns whether the two Geometrys are equal, from the point of view of the equalsExact method.
 boolean isRing()
           
 void normalize()
          Normalizes a LineString.
 LineString reverse()
          Creates a LineString whose coordinates are in the reverse order of this objects
 
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, equalsExact, geometryChanged, geometryChangedAction, getArea, getCentroid, getEnvelope, getEnvelopeInternal, getFactory, getGeometryN, getInteriorPoint, getNumGeometries, getPrecisionModel, getSRID, getUserData, hasNonEmptyElements, hasNullElements, intersection, intersects, isRectangle, isSimple, isValid, isWithinDistance, overlaps, relate, relate, setSRID, setUserData, symDifference, toString, toText, touches, union, within
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LineString

public LineString(Coordinate[] points,
                  PrecisionModel precisionModel,
                  int SRID)
Deprecated. Use GeometryFactory instead


LineString

public LineString(CoordinateSequence points,
                  GeometryFactory factory)
Parameters:
points - the points of the linestring, or null to create the empty geometry. Consecutive points may not be equal.
Method Detail

getCoordinates

public Coordinate[] getCoordinates()
Description copied from class: Geometry
Returns this Geometry s vertices. If you modify the coordinates in this array, be sure to call #geometryChanged afterwards. The Geometrys contained by composite Geometrys must be Geometry's; that is, they must implement getCoordinates.

Specified by:
getCoordinates in class Geometry
Returns:
the vertices of this Geometry

getCoordinateSequence

public CoordinateSequence getCoordinateSequence()

getCoordinateN

public Coordinate getCoordinateN(int n)

getCoordinate

public Coordinate getCoordinate()
Description copied from class: Geometry
Returns a vertex of this Geometry.

Specified by:
getCoordinate in class Geometry
Returns:
a Coordinate which is a vertex of this Geometry. Returns null if this Geometry is empty

getDimension

public int getDimension()
Description copied from class: Geometry
Returns the dimension of this Geometry.

Specified by:
getDimension in class Geometry
Returns:
the dimension of the class implementing this interface, whether or not this object is the empty geometry

getBoundaryDimension

public int getBoundaryDimension()
Description copied from class: Geometry
Returns the dimension of this Geometrys inherent boundary.

Specified by:
getBoundaryDimension in class Geometry
Returns:
the dimension of the boundary of the class implementing this interface, whether or not this object is the empty geometry. Returns Dimension.FALSE if the boundary is the empty geometry.

isEmpty

public boolean isEmpty()
Description copied from class: Geometry
Returns whether or not the set of points in this Geometry is empty.

Specified by:
isEmpty in class Geometry
Returns:
true if this Geometry equals the empty geometry

getNumPoints

public int getNumPoints()
Description copied from class: Geometry
Returns the count of this Geometrys vertices. The Geometry s contained by composite Geometrys must be Geometry's; that is, they must implement getNumPoints

Specified by:
getNumPoints in class Geometry
Returns:
the number of vertices in this Geometry

getPointN

public Point getPointN(int n)

getStartPoint

public Point getStartPoint()

getEndPoint

public Point getEndPoint()

isClosed

public boolean isClosed()

isRing

public boolean isRing()

getGeometryType

public java.lang.String getGeometryType()
Description copied from class: Geometry
Returns the name of this object's com.vivid.jts.geom interface.

Specified by:
getGeometryType in class Geometry
Returns:
the name of this Geometrys most specific com.vividsolutions.jts.geom interface

getLength

public double getLength()
Returns the length of this LineString

Overrides:
getLength in class Geometry
Returns:
the area of the polygon

getBoundary

public Geometry getBoundary()
Gets the boundary of this geometry. The boundary of a lineal geometry is always a zero-dimensional geometry (which may be empty).

Specified by:
getBoundary in class Geometry
Returns:
the boundary geometry
See Also:
Geometry.getBoundary()

reverse

public LineString reverse()
Creates a LineString whose coordinates are in the reverse order of this objects

Returns:
a LineString with coordinates in the reverse order

isCoordinate

public boolean isCoordinate(Coordinate pt)
Returns true if the given point is a vertex of this LineString.

Parameters:
pt - the Coordinate to check
Returns:
true if pt is one of this LineString 's vertices

computeEnvelopeInternal

protected Envelope computeEnvelopeInternal()
Description copied from class: Geometry
Returns the minimum and maximum x and y values in this Geometry , or a null Envelope if this Geometry is empty. Unlike getEnvelopeInternal, this method calculates the Envelope each time it is called; getEnvelopeInternal caches the result of this method.

Specified by:
computeEnvelopeInternal in class Geometry
Returns:
this Geometrys bounding box; if the Geometry is empty, Envelope#isNull will return true

equalsExact

public boolean equalsExact(Geometry other,
                           double tolerance)
Description copied from class: Geometry
Returns true if the two Geometrys are exactly equal, up to a specified distance tolerance. Two Geometries are exactly equal within a distance tolerance if and only if: If this and the other Geometrys are composites and any children are not Geometrys, returns false.

Specified by:
equalsExact in class Geometry
Parameters:
other - the Geometry with which to compare this Geometry
Returns:
true if this and the other Geometry are of the same class and have equal internal data.

apply

public void apply(CoordinateFilter filter)
Description copied from class: Geometry
Performs an operation with or on this Geometry's coordinates. If this method modifies any coordinate values, #geometryChanged() must be called to update the geometry state. Note that you cannot use this method to modify this Geometry if its underlying CoordinateSequence's #get method returns a copy of the Coordinate, rather than the actual Coordinate stored (if it even stores Coordinates at all).

Specified by:
apply in class Geometry
Parameters:
filter - the filter to apply to this Geometry's coordinates

apply

public void apply(CoordinateSequenceFilter filter)
Description copied from class: Geometry
Performs an operation on the coordinates in this Geometry's CoordinateSequences. If this method modifies any coordinate values, #geometryChanged() must be called to update the geometry state.

Specified by:
apply in class Geometry
Parameters:
filter - the filter to apply

apply

public void apply(GeometryFilter filter)
Description copied from class: Geometry
Performs an operation with or on this Geometry and its subelement Geometrys (if any). Only GeometryCollections and subclasses have subelement Geometry's.

Specified by:
apply in class Geometry
Parameters:
filter - the filter to apply to this Geometry (and its children, if it is a GeometryCollection).

apply

public void apply(GeometryComponentFilter filter)
Description copied from class: Geometry
Performs an operation with or on this Geometry and its component Geometry's. Only GeometryCollections and Polygons have component Geometry's; for Polygons they are the LinearRings of the shell and holes.

Specified by:
apply in class Geometry
Parameters:
filter - the filter to apply to this Geometry.

clone

public java.lang.Object clone()
Creates and returns a full copy of this LineString object. (including all coordinates contained by it).

Overrides:
clone in class Geometry
Returns:
a clone of this instance

normalize

public void normalize()
Normalizes a LineString. A normalized linestring has the first point which is not equal to it's reflected point less than the reflected point.

Specified by:
normalize in class Geometry

isEquivalentClass

protected boolean isEquivalentClass(Geometry other)
Description copied from class: Geometry
Returns whether the two Geometrys are equal, from the point of view of the equalsExact method. Called by equalsExact . In general, two Geometry classes are considered to be "equivalent" only if they are the same class. An exception is LineString , which is considered to be equivalent to its subclasses.

Overrides:
isEquivalentClass in class Geometry
Parameters:
other - the Geometry with which to compare this Geometry for equality
Returns:
true if the classes of the two Geometry s are considered to be equal by the equalsExact method.

compareToSameClass

protected int compareToSameClass(java.lang.Object o)
Description copied from class: Geometry
Returns whether this Geometry is greater than, equal to, or less than another Geometry having the same class.

Specified by:
compareToSameClass in class Geometry
Parameters:
o - a Geometry having the same class as this Geometry
Returns:
a positive number, 0, or a negative number, depending on whether this object is greater than, equal to, or less than o, as defined in "Normal Form For Geometry" in the JTS Technical Specifications

compareToSameClass

protected int compareToSameClass(java.lang.Object o,
                                 CoordinateSequenceComparator comp)
Description copied from class: Geometry
Returns whether this Geometry is greater than, equal to, or less than another Geometry of the same class. using the given CoordinateSequenceComparator.

Specified by:
compareToSameClass in class Geometry
Parameters:
o - a Geometry having the same class as this Geometry
comp - a CoordinateSequenceComparator
Returns:
a positive number, 0, or a negative number, depending on whether this object is greater than, equal to, or less than o, as defined in "Normal Form For Geometry" in the JTS Technical Specifications