gistoolkit.features
Class Shape

java.lang.Object
  extended bygistoolkit.features.Shape
Direct Known Subclasses:
LinearRing, LineString, MultiLineString, MultiPoint, MultiPolygon, Point, Polygon, RasterShape

public abstract class Shape
extends java.lang.Object

Represents the data associated with any shape.


Field Summary
static double EQUAL_LIMIT
          This is the number the shapes use to determine if one double is equal to another.
static java.lang.String LINEARRING
           
static java.lang.String LINESTRING
           
static java.lang.String MULTILINESTRING
           
static java.lang.String MULTIPOINT
           
static java.lang.String MULTIPOLYGON
           
protected  Envelope myEnvelope
          stores the bounding rectangle of this shape.
static java.lang.String NULLSHAPE
          There are set of valid shape types
static java.lang.String POINT
           
static java.lang.String POLYGON
           
static java.lang.String RASTER
           
 
Constructor Summary
Shape()
           
 
Method Summary
abstract  int add(double inX, double inY)
          Add the a point to this shape.
abstract  boolean add(int inIndex, double inX, double inY)
          Add the a point to this shape at this index.
 void calculateEnvelope()
          Recalculates the extents on the object, should be called if the object is changed.
abstract  java.lang.Object clone()
          Creates a copy of the shape
 boolean contains(Shape inShape)
          Determines if this shape contains the shape sent in; Since this is the super class, it always returns false.
static double distance(Point inPointA, Point inPointB)
          Distance from a point to another point.
abstract  int getClosestIndex(double inX, double inY)
          Get the index of the point within the shape nearest this location.
static double getDistance(double inX1, double inY1, double inX2, double inY2)
          Determine the distance between two points.
 double getDistanceToEnvelope(double inX, double inY)
          Determines the distance from the given point to the extents of this shape.
static double getDistanceToLine(double inP1X, double inP1Y, double inP2X, double inP2Y, double inX, double inY)
          Calculates the distance from the line defined by point 1 and 2 to the point defined by X and Y.
static double getDistanceToLine(Point inPoint1, Point inPoint2, double inX, double inY)
          Calculates the distance from the line defined by point 1 and 2 to the point defined by X and Y.
abstract  double getDistanceToPoint(double inX, double inY)
          Get the distance from this shape to the given point
abstract  Envelope getEnvelope()
          return the bounding rectangle of this shape.
static Point getLinesIntersect(Point inL1A, Point inL1B, Point inL2A, Point inL2B)
          Determines if the Two Lines intersect.
abstract  int getNumPoints()
          Returns the number of points in the shape.
abstract  Point getPoint(int inIndex)
          Returns the point at the given index.
abstract  Point[] getPoints()
          Returns the points that comprise the object.
abstract  java.lang.String getShapeType()
          Return the type of shape this is
abstract  java.lang.String getWKT()
          Returns the OGIS Well Know Text Representation of this shape
abstract  boolean intersects(Shape inShape)
          Determines if the two shapes intersect
static boolean linesIntersect(double inL1AX, double inL1AY, double inL1BX, double inL1BY, double inL2AX, double inL2AY, double inL2BX, double inL2BY)
          Determines if the Two Lines intersect.
static boolean linesIntersect(Point inL1A, Point inL1B, Point inL2A, Point inL2B)
          Determines if the Two Lines intersect.
static boolean pointOnLine(double inPointX, double inPointY, double inLAX, double inLAY, double inLBX, double inLBY)
          Determines if a point is exactly on a line.
static boolean pointOnLine(Point inPoint, Point inLA, Point inLB)
          Determines if a point is exactly on a line.
abstract  boolean remove(int inIndex)
          Remove this point from the Shape.
abstract  void setPoint(int inIndex, double inXCoordinate, double inYCoordinate)
          Sets the point at the given index to the given value.
abstract  void translate(double inXDistance, double inYDistance)
          Translate the shape the given distance in the X and Y directions
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULLSHAPE

public static final java.lang.String NULLSHAPE
There are set of valid shape types

See Also:
Constant Field Values

POINT

public static final java.lang.String POINT
See Also:
Constant Field Values

MULTIPOINT

public static final java.lang.String MULTIPOINT
See Also:
Constant Field Values

LINEARRING

public static final java.lang.String LINEARRING
See Also:
Constant Field Values

LINESTRING

public static final java.lang.String LINESTRING
See Also:
Constant Field Values

MULTILINESTRING

public static final java.lang.String MULTILINESTRING
See Also:
Constant Field Values

POLYGON

public static final java.lang.String POLYGON
See Also:
Constant Field Values

MULTIPOLYGON

public static final java.lang.String MULTIPOLYGON
See Also:
Constant Field Values

RASTER

public static final java.lang.String RASTER
See Also:
Constant Field Values

EQUAL_LIMIT

public static final double EQUAL_LIMIT
This is the number the shapes use to determine if one double is equal to another. If the absolute value of the difference of the numbers is less than this value, then the two numbers are equal.

See Also:
Constant Field Values

myEnvelope

protected Envelope myEnvelope
stores the bounding rectangle of this shape.

Constructor Detail

Shape

public Shape()
Method Detail

getShapeType

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


calculateEnvelope

public void calculateEnvelope()
Recalculates the extents on the object, should be called if the object is changed.


getEnvelope

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


clone

public abstract java.lang.Object clone()
Creates a copy of the shape


getNumPoints

public abstract int getNumPoints()
Returns the number of points in the shape.


getPoint

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


setPoint

public abstract void setPoint(int inIndex,
                              double inXCoordinate,
                              double inYCoordinate)
Sets the point at the given index to the given value.


add

public abstract int add(double inX,
                        double inY)
Add the a point to this shape. Returns the location where the point was added. Returns -1 if it could not be added.


add

public abstract boolean add(int inIndex,
                            double inX,
                            double inY)
Add the a point to this shape at this index. Returns true if the point was added. Returns false if it could not be added.


remove

public abstract boolean remove(int inIndex)
Remove this point from the Shape. Returns true if it removed the point, returns false if it cannot.


contains

public boolean contains(Shape inShape)
Determines if this shape contains the shape sent in; Since this is the super class, it always returns false.


linesIntersect

public static boolean linesIntersect(Point inL1A,
                                     Point inL1B,
                                     Point inL2A,
                                     Point inL2B)
Determines if the Two Lines intersect. The parameters inL1a is an end point of line 1, inl1b is the other end point of line 1. The parameters inL2a is an end point of line 2, inL2b is the other end point of line 2. The return will return true if the two lines intersect, and false if they do not.


linesIntersect

public static boolean linesIntersect(double inL1AX,
                                     double inL1AY,
                                     double inL1BX,
                                     double inL1BY,
                                     double inL2AX,
                                     double inL2AY,
                                     double inL2BX,
                                     double inL2BY)
Determines if the Two Lines intersect. The parameters inL1a is an end point of line 1, inl1b is the other end point of line 1. The parameters inL2a is an end point of line 2, inL2b is the other end point of line 2. The return will return true if the two lines intersect, and false if they do not.


getLinesIntersect

public static Point getLinesIntersect(Point inL1A,
                                      Point inL1B,
                                      Point inL2A,
                                      Point inL2B)
Determines if the Two Lines intersect. The parameters inL1a is an end point of line 1, inl1b is the other end point of line 1. The parameters inL2a is an end point of line 2, inL2b is the other end point of line 2. The return will return true if the two lines intersect, and false if they do not.


pointOnLine

public static boolean pointOnLine(Point inPoint,
                                  Point inLA,
                                  Point inLB)
Determines if a point is exactly on a line. The parameter inPoint is the point in question. The points inLA, and inLB are the end points of the line. If the point falls exactly on the line, then the method returns true. If the point is not on the line, then the method returns false.


pointOnLine

public static boolean pointOnLine(double inPointX,
                                  double inPointY,
                                  double inLAX,
                                  double inLAY,
                                  double inLBX,
                                  double inLBY)
Determines if a point is exactly on a line. The parameter inPoint is the point in question. The points inLA, and inLB are the end points of the line. If the point falls exactly on the line, then the method returns true. If the point is not on the line, then the method returns false.


getPoints

public abstract Point[] getPoints()
Returns the points that comprise the object. This is an expensive operation as all the points must be generated to be returned. As a result, the points returned are not owned by the shape. They are copies of the data contained in the shape.


getWKT

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


translate

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


distance

public static double distance(Point inPointA,
                              Point inPointB)
Distance from a point to another point. Implements the standard distance formula x^2 + y^2=d^2.


getDistance

public static double getDistance(double inX1,
                                 double inY1,
                                 double inX2,
                                 double inY2)
Determine the distance between two points. Implements the standard distance formula x^2 + y^2=d^2.


getDistanceToLine

public static double getDistanceToLine(Point inPoint1,
                                       Point inPoint2,
                                       double inX,
                                       double inY)
Calculates the distance from the line defined by point 1 and 2 to the point defined by X and Y.


getDistanceToLine

public static double getDistanceToLine(double inP1X,
                                       double inP1Y,
                                       double inP2X,
                                       double inP2Y,
                                       double inX,
                                       double inY)
Calculates the distance from the line defined by point 1 and 2 to the point defined by X and Y.


getDistanceToEnvelope

public double getDistanceToEnvelope(double inX,
                                    double inY)
Determines the distance from the given point to the extents of this shape. This method is meant to be a fast way to find the distance to the shape when close enough is close enough. The distance returned is the distance to any one of the lines, or the corners depending on which of the nine quadrants the point happens to land within. In the case of the point residing within the extents, a distance of zero 0 is returned.


getClosestIndex

public abstract int getClosestIndex(double inX,
                                    double inY)
Get the index of the point within the shape nearest this location.


getDistanceToPoint

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


intersects

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