gistoolkit.features
Class LineString

java.lang.Object
  extended bygistoolkit.features.Shape
      extended bygistoolkit.features.LineString
Direct Known Subclasses:
LineStringM

public class LineString
extends Shape

A line string is a series of connected line segments.


Field Summary
 
Fields inherited from class gistoolkit.features.Shape
EQUAL_LIMIT, LINEARRING, LINESTRING, MULTILINESTRING, MULTIPOINT, MULTIPOLYGON, myEnvelope, NULLSHAPE, POINT, POLYGON, RASTER
 
Constructor Summary
LineString()
          Create a new empty Line String.
LineString(double[] inXs, double[] inYs)
          Create a new LineString from the points.
LineString(Point[] inPoints)
          Create a new LineString from the points.
 
Method Summary
 int add(double inX, double inY)
          Add a point to the LineString returns the index of the newly added point, or -1 if it failed to add the point.
 boolean add(int inIndex, double inX, double inY)
          Adds a point to the LineString at the given point index.
 void calculateEnvelope()
          Recalculates the envelope for the shape.
 java.lang.Object clone()
          Creates a copy of the Line String Creation date: (5/3/2001 8:45:46 AM)
 boolean contains(Shape inShape)
          For line strings, since the shape is a line, it can only contain points, and other line strings.
 boolean containsLine(LineString inLineString)
          For line strings, since the shape is a line, it can only contain points, and other line strings.
 boolean containsMultiLine(MultiLineString inMultiLineString)
          For line strings, since the shape is a line, it can only contain points, and other line strings.
 boolean containsPoint(Point inPoint)
          For line strings, since the shape is a line, it can only contain points, and other line strings.
 int getClosestIndex(double inX, double inY)
          Return the point in the LineString that is the closest to this point.
 Point getClosestPoint(double inX, double inY)
          Return the point in the LineString that is the closest to this point.
 double getDistanceToPoint(double inX, double inY)
          Get the distance from this shape to the given point
 Envelope getEnvelope()
          return the bounding rectangle of this shape.
 int getNumPoints()
          Return the number of points in this shape.
 Point getPoint(int inIndex)
          Get the point at the given index.
 Point[] getPoints()
          Returns the points representing this line string.
 java.lang.String getShapeType()
          Return the type of shape this is
 java.lang.String getWKT()
          Returns the OGIS Well Know Text Representation of this shape
 double[] getXCoordinates()
          Return the array of X Coordinates.
 double[] getYCoordinates()
          Return the array of Y Coordinates.
 boolean intersects(Shape inShape)
          Determines if the two shapes intersect
 boolean intersectsLinearRing(LinearRing inLinearRing)
          A LineString intersects a LinearRing if the LineString intersects the LinearRing, or if it is contained within the LinearRing.
 boolean intersectsLineString(LineString inLineString)
          A LineString will intersect another line string if the two LineStrings cross at some point
 boolean intersectsMultiLineString(MultiLineString inMultiLineString)
          A LineString intersects a MultiLineString if any of the constituent LineStrings intersect this LineString.
 boolean intersectsMultiPolygon(MultiPolygon inMultiPolygon)
          A LineString intersects a MultiPolygon if it intersects any of the constituent Polygons
 boolean intersectsPoint(double inX, double inY)
          A line string will intersect a point if the point falls on the line, or is the same as one of the verticies.
 boolean intersectsPoint(Point inPoint)
          A line string will intersect a point if the point falls on the line, or is the same as one of the verticies.
 boolean intersectsPolygon(Polygon inPolygon)
          A LineString intersects a Polygon if it intersects any of the rings of the polygon, or if it is contained within the Polygon.
 boolean intersectsRasterShape(RasterShape inRasterShape)
          A LineString intersects a RasterShape if it intersects the envelope of the raster, or if it is contained within the envelope of the raster.
 boolean remove(int inIndex)
          Removes the point at the given index from the LineString.
 void setPoint(int inIndex, double inXCoordinate, double inYCoordinate)
          Set the point at the given index.
 void translate(double inXDistance, double inYDistance)
          Translate the shape the given distance in the X and Y directions
 
Methods inherited from class gistoolkit.features.Shape
distance, getDistance, getDistanceToEnvelope, getDistanceToLine, getDistanceToLine, getLinesIntersect, linesIntersect, linesIntersect, pointOnLine, pointOnLine
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LineString

public LineString()
Create a new empty Line String.


LineString

public LineString(double[] inXs,
                  double[] inYs)
Create a new LineString from the points.


LineString

public LineString(Point[] inPoints)
Create a new LineString from the points.

Method Detail

getXCoordinates

public double[] getXCoordinates()
Return the array of X Coordinates. This is private data, and should be used carefully.


getYCoordinates

public double[] getYCoordinates()
Return the array of Y Coordinates. This is private data, and should be used carefully.


getShapeType

public java.lang.String getShapeType()
Return the type of shape this is

Specified by:
getShapeType in class Shape

clone

public java.lang.Object clone()
Creates a copy of the Line String Creation date: (5/3/2001 8:45:46 AM)

Specified by:
clone in class Shape
Returns:
gistoolkit.features.Shape

getNumPoints

public int getNumPoints()
Return the number of points in this shape.

Specified by:
getNumPoints in class Shape

getPoint

public Point getPoint(int inIndex)
Get the point at the given index.

Specified by:
getPoint in class Shape

setPoint

public void setPoint(int inIndex,
                     double inXCoordinate,
                     double inYCoordinate)
Set the point at the given index.

Specified by:
setPoint in class Shape

add

public int add(double inX,
               double inY)
Add a point to the LineString returns the index of the newly added point, or -1 if it failed to add the point.

Specified by:
add in class Shape

add

public boolean add(int inIndex,
                   double inX,
                   double inY)
Adds a point to the LineString at the given point index. Returns true if the add succeeded, and false if it failed.

Specified by:
add in class Shape

remove

public boolean remove(int inIndex)
Removes the point at the given index from the LineString.

Specified by:
remove in class Shape

getEnvelope

public Envelope getEnvelope()
return the bounding rectangle of this shape.

Specified by:
getEnvelope in class Shape

calculateEnvelope

public void calculateEnvelope()
Recalculates the envelope for the shape.

Overrides:
calculateEnvelope in class Shape

contains

public boolean contains(Shape inShape)
For line strings, since the shape is a line, it can only contain points, and other line strings. a point is contained within a line string if it falls on the line. A line is contained in the line string if it falls completely on the lines of the containing line string. Polygons, and rings can not be contained in a line.

Overrides:
contains in class Shape
Parameters:
inShape - features.Shape
Returns:
boolean

containsLine

public boolean containsLine(LineString inLineString)
For line strings, since the shape is a line, it can only contain points, and other line strings.

A point is contained within a line string if it falls on the line. A line is contained in the line string if it falls completely on the lines of the containing line string. Polygons, and rings can not be contained in a line.


containsMultiLine

public boolean containsMultiLine(MultiLineString inMultiLineString)
For line strings, since the shape is a line, it can only contain points, and other line strings. a point is contained within a line string if it falls on the line. A line is contained in the line string if it falls completely on the lines of the containing line string. Polygons, and rings can not be contained in a line.


containsPoint

public boolean containsPoint(Point inPoint)
For line strings, since the shape is a line, it can only contain points, and other line strings. a point is contained within a line string if it falls on the line. A line is contained in the line string if it falls completely on the lines of the containing line string. Polygons, and rings can not be contained in a line.


getPoints

public Point[] getPoints()
Returns the points representing this line string. Creates a new copy of all the points, so this is an expensive operation.

Specified by:
getPoints in class Shape

getWKT

public java.lang.String getWKT()
Returns the OGIS Well Know Text Representation of this shape

Specified by:
getWKT in class Shape

translate

public void translate(double inXDistance,
                      double inYDistance)
Translate the shape the given distance in the X and Y directions

Specified by:
translate in class Shape

getClosestPoint

public Point getClosestPoint(double inX,
                             double inY)
Return the point in the LineString that is the closest to this point.


getClosestIndex

public int getClosestIndex(double inX,
                           double inY)
Return the point in the LineString that is the closest to this point.

Specified by:
getClosestIndex in class Shape

getDistanceToPoint

public double getDistanceToPoint(double inX,
                                 double inY)
Get the distance from this shape to the given point

Specified by:
getDistanceToPoint in class Shape

intersects

public boolean intersects(Shape inShape)
Determines if the two shapes intersect

Specified by:
intersects in class Shape

intersectsPoint

public boolean intersectsPoint(Point inPoint)
A line string will intersect a point if the point falls on the line, or is the same as one of the verticies.


intersectsPoint

public boolean intersectsPoint(double inX,
                               double inY)
A line string will intersect a point if the point falls on the line, or is the same as one of the verticies.


intersectsLineString

public boolean intersectsLineString(LineString inLineString)
A LineString will intersect another line string if the two LineStrings cross at some point


intersectsMultiLineString

public boolean intersectsMultiLineString(MultiLineString inMultiLineString)
A LineString intersects a MultiLineString if any of the constituent LineStrings intersect this LineString.


intersectsLinearRing

public boolean intersectsLinearRing(LinearRing inLinearRing)
A LineString intersects a LinearRing if the LineString intersects the LinearRing, or if it is contained within the LinearRing.


intersectsPolygon

public boolean intersectsPolygon(Polygon inPolygon)
A LineString intersects a Polygon if it intersects any of the rings of the polygon, or if it is contained within the Polygon.


intersectsMultiPolygon

public boolean intersectsMultiPolygon(MultiPolygon inMultiPolygon)
A LineString intersects a MultiPolygon if it intersects any of the constituent Polygons


intersectsRasterShape

public boolean intersectsRasterShape(RasterShape inRasterShape)
A LineString intersects a RasterShape if it intersects the envelope of the raster, or if it is contained within the envelope of the raster.