public class GeneralDirectPosition extends AbstractDirectPosition implements Serializable, Cloneable
DirectPosition
s, 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 known to be always two-dimensional, then DirectPosition2D
provides
a more efficient implementation.
DirectPosition1D
,
DirectPosition2D
,
Serialized FormDefined in the sis-referencing
module
Modifier and Type | Field and Description |
---|---|
double[] |
ordinates
The ordinates of the direct position.
|
Constructor and Description |
---|
GeneralDirectPosition(CharSequence wkt)
Constructs a position initialized to the values parsed
from the given string in Well Known Text (WKT) format.
|
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(int dimension)
Constructs a position with the specified number of dimensions.
|
Modifier and Type | Method and Description |
---|---|
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 ordinate 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 |
setCoordinate(double... ordinates)
Sets the ordinate values along all dimensions.
|
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 |
setOrdinate(int dimension,
double value)
Sets the ordinate value along the specified dimension.
|
String |
toString()
Formats this position in the Well Known Text (WKT) format.
|
equals, getDirectPosition, normalize
public final double[] ordinates
public GeneralDirectPosition(CoordinateReferenceSystem crs)
crs
- The coordinate reference system to be given to this position.public GeneralDirectPosition(int dimension) throws NegativeArraySizeException
dimension
- Number of dimensions.NegativeArraySizeException
- if dimension
is negative.public GeneralDirectPosition(double... ordinates)
ordinates
field.
Consequently, callers shall not recycle the same array for creating many instances.
ordinates
field is public, so cloning the array would not protect the state of this object anyway.ordinates
- The ordinate values. This array is not cloned.public GeneralDirectPosition(DirectPosition point)
point
- The position to copy.public GeneralDirectPosition(CharSequence wkt) throws 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.IllegalArgumentException
- If the given string can not be parsed.toString()
,
org.apache.sis.measure.CoordinateFormat
public final int getDimension()
ordinates
array.getDimension
in interface DirectPosition
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 DirectPosition
null
.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 double[] getCoordinate()
ordinates
, array field, which is public.getCoordinate
in interface DirectPosition
getCoordinate
in class AbstractDirectPosition
public void setCoordinate(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 double getOrdinate(int dimension) throws IndexOutOfBoundsException
ordinates
, array field, which is public.getOrdinate
in interface DirectPosition
dimension
- The dimension in the range 0 to dimension-1.IndexOutOfBoundsException
- if the specified dimension is out of bounds.public void setOrdinate(int dimension, double value) throws IndexOutOfBoundsException
setOrdinate
in interface DirectPosition
dimension
- The dimension for the ordinate of interest.value
- The ordinate value of interest.IndexOutOfBoundsException
- if the specified dimension is out of bounds.public void setLocation(DirectPosition position) throws MismatchedDimensionException
setLocation
in class AbstractDirectPosition
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 String toString()
x₀
, x₁
, x₂
, etc.
are the ordinate values at index 0, 1, 2, etc.:
The string returned by this method can be parsed by thePOINT(x₀ x₁ x₂ …)
GeneralDirectPosition
constructor.toString
in class AbstractDirectPosition
POINT
in Well Known Text (WKT) format.public GeneralDirectPosition clone()
public int hashCode()
DirectPosition.hashCode()
javadoc.
Consequently, it should be possible to mix different DirectPosition
implementations in the same hash map.hashCode
in interface DirectPosition
hashCode
in class AbstractDirectPosition
Copyright © 2010–2014 The Apache Software Foundation. All rights reserved.