|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.geom.Point2D
java.awt.geom.Point2D.Double
org.geotools.geometry.DirectPosition2D
public class DirectPosition2D
Holds the coordinates for a two-dimensional position within some coordinate reference system.
Note 1:
This class inherits x and y fields. But despite their names, they don't need to be oriented toward East and North. 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 affine transform in the graphics context.The rational for avoiding axis orientation restriction is that other
DirectPosition
implementation do not have such restriction, and it would be hard to generalize (what to do with North-East direction?).
Note 2:
Do not mix instances of this class with ordinaryPoint2D
instances in aHashSet
or asHashMap
keys. It is not possible to meet bothPoint2D.hashCode()
andDirectPosition.hashCode()
contract, and this class choose to implements the later. Concequently,hashCode()
is inconsistent withPoint2D.equals(java.lang.Object)
(but is consistent withDirectPosition.equals(java.lang.Object)
).In other words, it is safe to add instances of
DirectPosition2D
in aHashSet<DirectPosition>
, but it is unsafe to add them in aHashSet<Point2D>
. Collections that do not rely onObject.hashCode()
, likeArrayList
, are safe in all cases.
DirectPosition1D
,
GeneralDirectPosition
,
Point2D
,
Serialized FormNested Class Summary |
---|
Nested classes/interfaces inherited from class java.awt.geom.Point2D |
---|
java.awt.geom.Point2D.Double, java.awt.geom.Point2D.Float |
Field Summary |
---|
Fields inherited from class java.awt.geom.Point2D.Double |
---|
x, y |
Constructor Summary | |
---|---|
DirectPosition2D()
Constructs a position initialized to (0,0) with a null
coordinate reference system. |
|
DirectPosition2D(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
Constructs a position with the specified coordinate reference system. |
|
DirectPosition2D(org.opengis.referencing.crs.CoordinateReferenceSystem crs,
double x,
double y)
Constructs a 2D position from the specified ordinates in the specified CRS. |
|
DirectPosition2D(org.opengis.geometry.DirectPosition point)
Constructs a position initialized to the same values than the specified point. |
|
DirectPosition2D(double x,
double y)
Constructs a 2D position from the specified ordinates. |
|
DirectPosition2D(java.awt.geom.Point2D point)
Constructs a position from the specified Point2D . |
Method Summary | |
---|---|
DirectPosition2D |
clone()
Returns a clone of this point. |
boolean |
equals(java.lang.Object object)
Compares this point with the specified object for equality. |
double[] |
getCoordinate()
Returns a sequence of numbers that hold the coordinate of this position in its reference system. |
org.opengis.referencing.crs.CoordinateReferenceSystem |
getCoordinateReferenceSystem()
Returns the coordinate reference system in which the coordinate is given. |
double[] |
getCoordinates()
Deprecated. Renamed as getCoordinate() for consistency with ISO 19107. |
int |
getDimension()
The length of coordinate sequence (the number of entries). |
org.opengis.geometry.DirectPosition |
getDirectPosition()
Returns always this , the direct position for this
position. |
double |
getOrdinate(int dimension)
Returns the ordinate at the specified dimension. |
org.opengis.geometry.DirectPosition |
getPosition()
Deprecated. Renamed as getDirectPosition() . |
int |
hashCode()
Returns a hash value for this coordinate. |
void |
setCoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
Set the coordinate reference system in which the coordinate is given. |
void |
setLocation(org.opengis.geometry.DirectPosition position)
Set this coordinate to the specified direct position. |
void |
setOrdinate(int dimension,
double value)
Sets the ordinate value along the specified dimension. |
java.awt.geom.Point2D |
toPoint2D()
Returns a Point2D with the same coordinate as this direct position. |
java.lang.String |
toString()
Returns a string representation of this coordinate. |
Methods inherited from class java.awt.geom.Point2D.Double |
---|
getX, getY, setLocation |
Methods inherited from class java.awt.geom.Point2D |
---|
distance, distance, distance, distanceSq, distanceSq, distanceSq, setLocation |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public DirectPosition2D()
null
coordinate reference system.
public DirectPosition2D(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
crs
- The coordinate reference system, or null
.public DirectPosition2D(double x, double y)
x
- The x value.y
- The y value.public DirectPosition2D(org.opengis.referencing.crs.CoordinateReferenceSystem crs, double x, double y)
crs
- The coordinate reference system, or null
.x
- The x value.y
- The y value.public DirectPosition2D(java.awt.geom.Point2D point)
Point2D
.
point
- The point to copy.public DirectPosition2D(org.opengis.geometry.DirectPosition point)
point
- The point to copy.Method Detail |
---|
@Deprecated public org.opengis.geometry.DirectPosition getPosition()
getDirectPosition()
.
getPosition
in interface org.opengis.geometry.coordinate.Position
public org.opengis.geometry.DirectPosition getDirectPosition()
this
, the direct position for this
position.
getDirectPosition
in interface org.opengis.geometry.coordinate.Position
public final org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem()
null
if this particular DirectPosition
is included
in a larger object with such a reference to a coordinate reference system.
getCoordinateReferenceSystem
in interface org.opengis.geometry.DirectPosition
null
.public void setCoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
crs
- The new coordinate reference system, or null
.public final int getDimension()
DirectPosition2D
objects.
getDimension
in interface org.opengis.geometry.DirectPosition
public double[] getCoordinate()
getCoordinate
in interface org.opengis.geometry.DirectPosition
@Deprecated public double[] getCoordinates()
getCoordinate()
for consistency with ISO 19107.
getCoordinates
in interface org.opengis.geometry.DirectPosition
public final double getOrdinate(int dimension) throws java.lang.IndexOutOfBoundsException
getOrdinate
in interface org.opengis.geometry.DirectPosition
dimension
- The dimension in the range 0 to 1 inclusive.
java.lang.IndexOutOfBoundsException
- if the specified dimension is out of bounds.public final void setOrdinate(int dimension, double value) throws java.lang.IndexOutOfBoundsException
setOrdinate
in interface org.opengis.geometry.DirectPosition
dimension
- the dimension for the ordinate of interest.value
- the ordinate value of interest.
java.lang.IndexOutOfBoundsException
- if the specified dimension is out of bounds.public void setLocation(org.opengis.geometry.DirectPosition position) throws org.opengis.geometry.MismatchedDimensionException
position
- The new position for this point.
org.opengis.geometry.MismatchedDimensionException
- if this point doesn't have the expected dimension.public java.awt.geom.Point2D toPoint2D()
Point2D
with the same coordinate as this direct position.
public java.lang.String toString()
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 CoordinateFormat
.
toString
in class java.awt.geom.Point2D.Double
public int hashCode()
DirectPosition.hashCode()
contract, not the Point2D.hashCode()
contract.
hashCode
in interface org.opengis.geometry.DirectPosition
hashCode
in class java.awt.geom.Point2D
public boolean equals(java.lang.Object object)
DirectPosition
interface, then the comparaison is performed as specified in its
DirectPosition.equals(java.lang.Object)
contract. Otherwise the comparaison is performed as specified
in Point2D.equals(java.lang.Object)
.
equals
in interface org.opengis.geometry.DirectPosition
equals
in class java.awt.geom.Point2D
object
- The object to compare with this position.
true
if the given object is equals to this position.public DirectPosition2D clone()
clone
in class java.awt.geom.Point2D
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |