| java.lang.Object java.awt.geom.Point2D org.geotools.geometry.DirectPosition2D
All known Subclasses: org.geotools.referencing.operation.builder.ExtendedPosition,
DirectPosition2D | public class DirectPosition2D extends Point2D.Double implements DirectPosition,Serializable(Code) | | Holds the coordinates for a two-dimensional position within some coordinate reference system.
Note 1: This class inherits
and
fields. But
despite their names, they don't need to be oriented toward
and
respectively. The (x,y) axis
can have any orientation and should be understood as "ordinate 0" and "ordinate 1" values
instead. This is not specific to this implementation; in Java2D too, the visual axis orientation
depend on the
.
The rational for avoiding axis orientation restriction is that other
DirectPosition implementation do not have such restriction, and anyway it would be hard to generalize (what
to do with
direction?).
Note 2:
Do not mix instances of this class with ordinary
Point2D instances in a
java.util.HashSet or as
java.util.HashMap keys. It is not possible to
meet both
Point2D.hashCode and
DirectPosition.hashCode contract, and this class
choose to implements the later. Concequently,
DirectPosition2D.hashCode is inconsistent with
Point2D.equals (but is consistent with
DirectPosition.equals ).
In other words, it is safe to add instances of
DirectPosition2D in a
HashSet , but it is unsafe to add them in a
HashSet .
Collections that do not rely on
Object.hashCode , like
java.util.ArrayList ,
are safe in all cases.
since: 2.0 version: $Id: DirectPosition2D.java 28788 2008-01-16 18:18:22Z desruisseaux $ author: Martin Desruisseaux See Also: DirectPosition1D See Also: GeneralPosition See Also: java.awt.geom.Point2D |
Constructor Summary | |
public | DirectPosition2D() Constructs a position initialized to (0,0) with a
null coordinate reference system. | public | DirectPosition2D(CoordinateReferenceSystem crs) Constructs a position with the specified coordinate reference system. | public | DirectPosition2D(double x, double y) Constructs a 2D position from the specified ordinates. | public | DirectPosition2D(CoordinateReferenceSystem crs, double x, double y) Constructs a 2D position from the specified ordinates in the specified CRS. | public | DirectPosition2D(Point2D point) Constructs a position from the specified
Point2D . | public | DirectPosition2D(DirectPosition point) Constructs a position initialized to the same values than the specified point. |
Method Summary | |
public boolean | equals(Object object) Compares this point with the specified object for equality. | final public CoordinateReferenceSystem | getCoordinateReferenceSystem() Returns the coordinate reference system in which the coordinate is given. | public double[] | getCoordinates() Returns a sequence of numbers that hold the coordinate of this position in its
reference system. | final public int | getDimension() The length of coordinate sequence (the number of entries). | final public double | getOrdinate(int dimension) Returns the ordinate at the specified dimension.
Parameters: dimension - The dimension in the range 0 to 1 inclusive. | public DirectPosition | getPosition() Returns always this , the direct position for this
. | public int | hashCode() Returns a hash value for this coordinate. | public void | setCoordinateReferenceSystem(CoordinateReferenceSystem crs) Set the coordinate reference system in which the coordinate is given. | public void | setLocation(DirectPosition position) Set this coordinate to the specified direct position. | final public void | setOrdinate(int dimension, double value) Sets the ordinate value along the specified dimension. | public Point2D | toPoint2D() Returns a
Point2D with the same coordinate as this direct position. | public String | toString() Returns a string representation of this coordinate. |
DirectPosition2D | public DirectPosition2D()(Code) | | Constructs a position initialized to (0,0) with a
null coordinate reference system.
|
DirectPosition2D | public DirectPosition2D(CoordinateReferenceSystem crs)(Code) | | Constructs a position with the specified coordinate reference system.
|
DirectPosition2D | public DirectPosition2D(double x, double y)(Code) | | Constructs a 2D position from the specified ordinates. Despite their name,
the (x,y) coordinates don't need to be oriented toward
(
,
).
Those parameter names simply match the
and
fields. See the
for details.
|
DirectPosition2D | public DirectPosition2D(CoordinateReferenceSystem crs, double x, double y)(Code) | | Constructs a 2D position from the specified ordinates in the specified CRS. Despite
their name, the (x,y) coordinates don't need to be oriented toward
(
,
).
Those parameter names simply match the
and
fields. The actual axis orientations are determined by the specified CRS.
See the
for details.
|
DirectPosition2D | public DirectPosition2D(Point2D point)(Code) | | Constructs a position from the specified
Point2D .
|
DirectPosition2D | public DirectPosition2D(DirectPosition point)(Code) | | Constructs a position initialized to the same values than the specified point.
|
equals | public boolean equals(Object object)(Code) | | Compares this point with the specified object for equality. If the given object implements
the
DirectPosition interface, then the comparaison is performed as specified in its
DirectPosition.equals contract. Otherwise the comparaison is performed as specified
in
Point2D.equals .
|
getCoordinateReferenceSystem | final public CoordinateReferenceSystem getCoordinateReferenceSystem()(Code) | | Returns the coordinate reference system in which the coordinate is given.
May be
null if this particular
DirectPosition is included
in a larger object with such a reference to a
.
The coordinate reference system, or null . |
getCoordinates | public double[] getCoordinates()(Code) | | Returns a sequence of numbers that hold the coordinate of this position in its
reference system.
The coordinates |
getDimension | final public int getDimension()(Code) | | The length of coordinate sequence (the number of entries).
This is always 2 for DirectPosition2D objects.
The dimensionality of this position. |
getOrdinate | final public double getOrdinate(int dimension) throws IndexOutOfBoundsException(Code) | | Returns the ordinate at the specified dimension.
Parameters: dimension - The dimension in the range 0 to 1 inclusive. The coordinate at the specified dimension. throws: IndexOutOfBoundsException - if the specified dimension is out of bounds. |
getPosition | public DirectPosition getPosition()(Code) | | Returns always this , the direct position for this
.
|
hashCode | public int hashCode()(Code) | | Returns a hash value for this coordinate. This method implements the
DirectPosition.hashCode contract, not the
Point2D.hashCode contract.
|
setCoordinateReferenceSystem | public void setCoordinateReferenceSystem(CoordinateReferenceSystem crs)(Code) | | Set the coordinate reference system in which the coordinate is given.
Parameters: crs - The new coordinate reference system, or null . |
setLocation | public void setLocation(DirectPosition position) throws MismatchedDimensionException(Code) | | Set this coordinate to the specified direct position. If the specified position
contains a
,
then the CRS for this position will be set to the CRS of the specified position.
Parameters: position - The new position for this point. throws: MismatchedDimensionException - if this point doesn't have the expected dimension. |
setOrdinate | final public void setOrdinate(int dimension, double value) throws IndexOutOfBoundsException(Code) | | Sets the ordinate value along the specified dimension.
Parameters: dimension - the dimension for the ordinate of interest. Parameters: value - the ordinate value of interest. throws: IndexOutOfBoundsException - if the specified dimension is out of bounds. |
toPoint2D | public Point2D toPoint2D()(Code) | | Returns a
Point2D with the same coordinate as this direct position.
|
toString | public String toString()(Code) | | Returns a string representation of this coordinate. The default implementation formats
this coordinate using a shared instance of
org.geotools.measure.CoordinateFormat .
This is okay for occasional formatting (for example for debugging purpose). But if there
is a lot of positions to format, users will get better performance and more control by
using their own instance of
org.geotools.measure.CoordinateFormat .
|
|
|