|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectAbstractDirectPosition
GeneralDirectPosition
public class GeneralDirectPosition
Holds the coordinates for a position within some coordinate reference system. Since
DirectPositions, as data types, will often be included in larger objects
(such as geometries) that have references
to CoordinateReferenceSystem, the getCoordinateReferenceSystem() method
may returns null if this particular DirectPosition is included in such
larger object. In this case, the coordinate reference system is implicitly assumed to take
on the value of the containing object's CoordinateReferenceSystem.
This particular implementation of DirectPosition is said "General" because it
uses an array of ordinates of an arbitrary length. If the direct
position is know to be always two-dimensional, then DirectPosition2D may provides
a more efficient implementation.
Most methods in this implementation are final for performance reason.
DirectPosition1D,
DirectPosition2D,
Point2D,
Serialized Form
| referencing/geotk-referencing (download) | View source code for this class |
| Field Summary | |
|---|---|
double[] |
ordinates
The ordinates of the direct position. |
| Constructor Summary | |
|---|---|
GeneralDirectPosition(CoordinateReferenceSystem crs)
Constructs a position using the specified coordinate reference system. |
|
GeneralDirectPosition(DirectPosition point)
Constructs a position initialized to the same values than the specified point. |
|
GeneralDirectPosition(double[] ordinates)
Constructs a position with the specified ordinates. |
|
GeneralDirectPosition(double x,
double y)
Constructs a 2D position from the specified ordinates. |
|
GeneralDirectPosition(double x,
double y,
double z)
Constructs a 3D position from the specified ordinates. |
|
GeneralDirectPosition(double x,
double y,
double z,
double t)
Constructs a 4D position from the specified ordinates. |
|
GeneralDirectPosition(int numDim)
Constructs a position with the specified number of dimensions. |
|
GeneralDirectPosition(Point2D point)
Constructs a position from the specified Point2D. |
|
GeneralDirectPosition(String wkt)
Constructs a position initialized to the values parsed from the given string in Well Known Text (WKT) format. |
|
| Method Summary | |
|---|---|
GeneralDirectPosition |
clone()
Returns a deep copy of this position. |
double[] |
getCoordinate()
Returns a sequence of numbers that hold the coordinate of this position in its reference system. |
CoordinateReferenceSystem |
getCoordinateReferenceSystem()
Returns the coordinate reference system in which the coordinate is given. |
int |
getDimension()
The length of coordinate sequence (the number of entries). |
double |
getOrdinate(int dimension)
Returns the ordinate at the specified dimension. |
int |
hashCode()
Returns a hash value for this coordinate. |
void |
setCoordinateReferenceSystem(CoordinateReferenceSystem crs)
Sets the coordinate reference system in which the coordinate is given. |
void |
setLocation(DirectPosition position)
Sets this coordinate to the specified direct position. |
void |
setLocation(double... ordinates)
Sets the ordinate values along all dimensions. |
void |
setLocation(GeneralDirectPosition position)
Sets this coordinate to the specified direct position. |
void |
setLocation(Point2D point)
Sets this coordinate to the specified Point2D. |
void |
setOrdinate(int dimension,
double value)
Sets the ordinate value along the specified dimension. |
Point2D |
toPoint2D()
Returns a Point2D with the same coordinate as this direct position. |
| Methods inherited from class AbstractDirectPosition |
|---|
equals, getDirectPosition, toString, toString |
| Methods inherited from class Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public final double[] ordinates
| Constructor Detail |
|---|
public GeneralDirectPosition(CoordinateReferenceSystem crs)
crs - The coordinate reference system to be given to this position.
public GeneralDirectPosition(int numDim)
throws NegativeArraySizeException
numDim - Number of dimensions.
NegativeArraySizeException - if numDim is negative.public GeneralDirectPosition(double[] ordinates)
ordinates array will be copied.
ordinates - The ordinate values to copy.
public GeneralDirectPosition(double x,
double y)
DirectPosition2D javadoc for details.
x - The first ordinate value.y - The second ordinate value.
public GeneralDirectPosition(double x,
double y,
double z)
x - The first ordinate value.y - The second ordinate value.z - The third ordinate value.
public GeneralDirectPosition(double x,
double y,
double z,
double t)
x - The first ordinate value.y - The second ordinate value.z - The third ordinate value.t - The fourth ordinate value.public GeneralDirectPosition(Point2D point)
Point2D.
point - The position to copy.public GeneralDirectPosition(DirectPosition point)
point - The position to copy.
public GeneralDirectPosition(String wkt)
throws NumberFormatException,
IllegalArgumentException
POINT
element like below:
However this constructor is lenient to other types likePOINT(6 10)
POINT ZM.
wkt - The POINT or other kind of element to parse.
NumberFormatException - If a number can not be parsed.
IllegalArgumentException - If the parenthesis are not balanced.AbstractDirectPosition.toString(DirectPosition),
CoordinateFormat| Method Detail |
|---|
public final CoordinateReferenceSystem getCoordinateReferenceSystem()
null if this particular DirectPosition is included
in a larger object with such a reference to a CRS.
getCoordinateReferenceSystem in interface DirectPositionnull.
public void setCoordinateReferenceSystem(CoordinateReferenceSystem crs)
throws MismatchedDimensionException
crs - The new coordinate reference system, or null.
MismatchedDimensionException - if the specified CRS doesn't have the expected
number of dimensions.public final int getDimension()
getDimension in interface DirectPositionpublic final double[] getCoordinate()
getCoordinate in interface DirectPositiongetCoordinate in class AbstractDirectPosition
public final double getOrdinate(int dimension)
throws IndexOutOfBoundsException
getOrdinate in interface DirectPositiondimension - The dimension in the range 0 to dimension-1.
IndexOutOfBoundsException - if the specified dimension is out of bounds.
public final void setOrdinate(int dimension,
double value)
throws IndexOutOfBoundsException
setOrdinate in interface DirectPositiondimension - the dimension for the ordinate of interest.value - the ordinate value of interest.
IndexOutOfBoundsException - if the specified dimension is out of bounds.
public final void setLocation(double... ordinates)
throws MismatchedDimensionException
ordinates - The new ordinates values. or a null array
for setting all ordinate values to NaN.
MismatchedDimensionException - If the length of the specified array is not
equals to the dimension of this position.
public final void setLocation(DirectPosition position)
throws MismatchedDimensionException
setLocation in class AbstractDirectPositionposition - The new position for this point, or null for setting all ordinate
values to NaN.
MismatchedDimensionException - if the given position doesn't have the expected dimension.
public final void setLocation(GeneralDirectPosition position)
throws MismatchedDimensionException
setLocation(DirectPosition), but is slightly faster in the special case
of an GeneralDirectPosition implementation.
position - The new position for this point, or null for setting all ordinate
values to NaN.
MismatchedDimensionException - if the given position doesn't have the expected dimension.
public final void setLocation(Point2D point)
throws MismatchedDimensionException
Point2D.
This coordinate must be two-dimensional.
point - The new coordinate for this point.
MismatchedDimensionException - if this coordinate point is not two-dimensional.
public Point2D toPoint2D()
throws IllegalStateException
Point2D with the same coordinate as this direct position.
This is a convenience method for inter-operability with Java2D.
IllegalStateException - if this coordinate point is not two-dimensional.public int hashCode()
hashCode in interface DirectPositionhashCode in class AbstractDirectPositionpublic GeneralDirectPosition clone()
clone in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||