org.geotools.geometry

## Class GeneralDirectPosition

• ### Field Detail

• #### ordinates

public final double[] ordinates
The ordinates of the direct position.
• ### Constructor Detail

• #### GeneralDirectPosition

public GeneralDirectPosition(CoordinateReferenceSystem crs)
Constructs a position using the specified coordinate reference system. The number of dimensions is inferred from the coordinate reference system.
Parameters:
crs - The coordinate reference system to be given to this position.
Since:
2.2
• #### GeneralDirectPosition

public GeneralDirectPosition(int numDim)
throws NegativeArraySizeException
Constructs a position with the specified number of dimensions.
Parameters:
numDim - Number of dimensions.
Throws:
NegativeArraySizeException - if numDim is negative.
• #### GeneralDirectPosition

public GeneralDirectPosition(double[] ordinates)
Constructs a position with the specified ordinates. The ordinates array will be copied.
Parameters:
ordinates - The ordinate values to copy.
• #### GeneralDirectPosition

public GeneralDirectPosition(double x,
double y)
Constructs a 2D position from the specified ordinates. Despite their name, the (x,y) coordinates don't need to be oriented toward (East, North). See the DirectPosition2D javadoc for details.
Parameters:
x - The first ordinate value.
y - The second ordinate value.
• #### GeneralDirectPosition

public GeneralDirectPosition(double x,
double y,
double z)
Constructs a 3D position from the specified ordinates. Despite their name, the (x,y,z) coordinates don't need to be oriented toward (East, North, Up).
Parameters:
x - The first ordinate value.
y - The second ordinate value.
z - The third ordinate value.
• #### GeneralDirectPosition

public GeneralDirectPosition(Point2D point)
Constructs a position from the specified Point2D.
Parameters:
point - The position to copy.
• #### GeneralDirectPosition

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

• #### setCoordinateReferenceSystem

public void setCoordinateReferenceSystem(CoordinateReferenceSystem crs)
throws MismatchedDimensionException
Set the coordinate reference system in which the coordinate is given.
Parameters:
crs - The new coordinate reference system, or null.
Throws:
MismatchedDimensionException - if the specified CRS doesn't have the expected number of dimensions.
• #### getDimension

public final int getDimension()
The length of coordinate sequence (the number of entries). This may be less than or equal to the dimensionality of the coordinate reference system.
Specified by:
getDimension in interface DirectPosition
Returns:
The dimensionality of this position.
• #### 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 dimension-1.
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 final 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.
Since:
2.2
• #### toPoint2D

public Point2D toPoint2D()
throws IllegalStateException
Returns a Point2D with the same coordinate as this direct position. This is a convenience method for interoperability with Java2D.
Returns:
This position as a two-dimensional point.
Throws:
IllegalStateException - if this coordinate point is not two-dimensional.