org.geotools.geometry

Class DirectPosition3D

• All Implemented Interfaces:
Serializable, Cloneable, Position, DirectPosition

```public class DirectPosition3D
extends Object
implements DirectPosition, Serializable, Cloneable```
Holds the coordinates for a three-dimensional position within some coordinate reference system.
Author:
Niels Charlier
Serialized Form
• Field Summary

Fields
Modifier and Type Field and Description
`double` `x`
`double` `y`
`double` `z`
• Constructor Summary

Constructors
Constructor and Description
`DirectPosition3D()`
Constructs a position initialized to (0,0,0) with a `null` coordinate reference system.
`DirectPosition3D(CoordinateReferenceSystem crs)`
Constructs a position with the specified coordinate reference system.
```DirectPosition3D(CoordinateReferenceSystem crs, double x, double y, double z)```
Constructs a 2D position from the specified ordinates in the specified CRS.
`DirectPosition3D(DirectPosition point)`
Constructs a position initialized to the same values than the specified point.
```DirectPosition3D(double x, double y, double z)```
Constructs a 3D position from the specified ordinates.
• Method Summary

All Methods
Modifier and Type Method and Description
`DirectPosition3D` `clone()`
Returns a clone of this point.
`boolean` `equals(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.
`CoordinateReferenceSystem` `getCoordinateReferenceSystem()`
Returns the coordinate reference system in which the coordinate is given.
`int` `getDimension()`
The length of coordinate sequence (the number of entries).
`DirectPosition` `getDirectPosition()`
Returns always `this`, the direct position for this position.
`double` `getOrdinate(int dimension)`
Returns the ordinate at the specified dimension.
`int` `hashCode()`
Returns a hash value for this coordinate.
`void` `setCoordinateReferenceSystem(CoordinateReferenceSystem crs)`
Set the coordinate reference system in which the coordinate is given.
`void` `setLocation(DirectPosition position)`
Set this coordinate to the specified direct position.
`void` ```setOrdinate(int dimension, double value)```
Sets the ordinate value along the specified dimension.
`String` `toString()`
Returns a string representation of this coordinate.
• Methods inherited from class Object

`finalize, getClass, notify, notifyAll, wait, wait, wait`
• Field Detail

• x

`public double x`
• y

`public double y`
• z

`public double z`
• Constructor Detail

• DirectPosition3D

`public DirectPosition3D()`
Constructs a position initialized to (0,0,0) with a `null` coordinate reference system.
• DirectPosition3D

`public DirectPosition3D(CoordinateReferenceSystem crs)`
Constructs a position with the specified coordinate reference system.
Parameters:
`crs` - The coordinate reference system, or `null`.
• DirectPosition3D

```public DirectPosition3D(double x,
double y,
double z)```
Constructs a 3D position from the specified ordinates.
Parameters:
`x` - The x value.
`y` - The y value.
`z` - The z value.
• DirectPosition3D

```public DirectPosition3D(CoordinateReferenceSystem crs,
double x,
double y,
double z)```
Constructs a 2D position from the specified ordinates in the specified CRS.
Parameters:
`crs` - The coordinate reference system, or `null`.
`x` - The x value.
`y` - The y value.
`z` - The z value.
• DirectPosition3D

`public DirectPosition3D(DirectPosition point)`
Constructs a position initialized to the same values than the specified point.
Parameters:
`point` - The point to copy.
• Method Detail

• getDirectPosition

`public DirectPosition getDirectPosition()`
Returns always `this`, the direct position for this position.
Specified by:
`getDirectPosition` in interface `Position`
Returns:
The direct position (may be `this`).
• getCoordinateReferenceSystem

`public final CoordinateReferenceSystem getCoordinateReferenceSystem()`
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 coordinate reference system.
Specified by:
`getCoordinateReferenceSystem` in interface `DirectPosition`
Returns:
The coordinate reference system, or `null`.
• setCoordinateReferenceSystem

`public void setCoordinateReferenceSystem(CoordinateReferenceSystem crs)`
Set the coordinate reference system in which the coordinate is given.
Parameters:
`crs` - The new coordinate reference system, or `null`.
• getDimension

`public final int getDimension()`
The length of coordinate sequence (the number of entries). This is always 3 for ``` DirectPosition3D``` objects.
Specified by:
`getDimension` in interface `DirectPosition`
Returns:
The dimensionality of this position.
• getCoordinate

`public double[] getCoordinate()`
Returns a sequence of numbers that hold the coordinate of this position in its reference system.
Specified by:
`getCoordinate` in interface `DirectPosition`
Returns:
The coordinates
• getOrdinate

```public final double getOrdinate(int dimension)
throws IndexOutOfBoundsException```
Returns the ordinate at the specified dimension.
Specified by:
`getOrdinate` in interface `DirectPosition`
Parameters:
`dimension` - The dimension in the range 0 to 2 inclusive.
Returns:
The coordinate at the specified dimension.
Throws:
`IndexOutOfBoundsException` - if the specified dimension is out of bounds.
• setOrdinate

```public final void setOrdinate(int dimension,
double value)
throws IndexOutOfBoundsException```
Sets the ordinate value along the specified dimension.
Specified by:
`setOrdinate` in interface `DirectPosition`
Parameters:
`dimension` - the dimension for the ordinate of interest.
`value` - the ordinate value of interest.
Throws:
`IndexOutOfBoundsException` - if the specified dimension is out of bounds.
• setLocation

```public void setLocation(DirectPosition position)
throws MismatchedDimensionException```
Set this coordinate to the specified direct position. If the specified position contains a coordinate reference system, 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.
• toString

`public String toString()`
Returns a string representation of this coordinate.
Overrides:
`toString` in class `Object`
• hashCode

`public int hashCode()`
Returns a hash value for this coordinate. This method implements the `DirectPosition.hashCode()` contract.
Specified by:
`hashCode` in interface `DirectPosition`
Overrides:
`hashCode` in class `Object`
Returns:
A hash code value for this position.
• equals

`public boolean equals(Object object)`
Compares this point with the specified object for equality. If the given object implements the `DirectPosition` interface, then the comparison is performed as specified in its `DirectPosition.equals(java.lang.Object)` contract.
Specified by:
`equals` in interface `DirectPosition`
Overrides:
`equals` in class `Object`
Parameters:
`object` - The object to compare with this position.
Returns:
`true` if the given object is equals to this position.
• clone

`public DirectPosition3D clone()`
Returns a clone of this point.
Overrides:
`clone` in class `Object`
Returns:
A clone of this position.
`Object.clone()`