@UML(identifier="DirectPosition", specification=ISO_19107) public interface DirectPosition extends Position
DirectPosition
s, as data types, will often be included in larger objects (such as geometries) that have references to coordinate reference system, the getCoordinateReferenceSystem()
method may returns null
if this particular DirectPosition
is included in a larger
object with such a reference to a coordinate reference
system. In this case, the cordinate reference system is implicitly assumed to take on the value
of the containing object's coordinate reference system.
Note: this interface does not extends Cloneable
on purpose,
since DirectPosition
implementations are most likely to be backed by references to
internal structures of the geometry containing this position. A direct position may or may not be
cloneable at implementor choice.
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object object)
Compares this direct position with the specified object for equality.
|
double[] |
getCoordinate()
A copy of the ordinates presented as an array of double values.
|
CoordinateReferenceSystem |
getCoordinateReferenceSystem()
The coordinate reference system in which the coordinate is given.
|
int |
getDimension()
The length of coordinate sequence (the number of entries).
|
double |
getOrdinate(int dimension)
Returns the ordinate at the specified dimension.
|
int |
hashCode()
Returns a hash code value for this direct position.
|
void |
setOrdinate(int dimension,
double value)
Sets the ordinate value along the specified dimension.
|
getDirectPosition
@UML(identifier="coordinateReferenceSystem", obligation=MANDATORY, specification=ISO_19107) CoordinateReferenceSystem getCoordinateReferenceSystem()
null
if this
particular DirectPosition
is included in a larger object with such a reference to a
coordinate reference system. In this case, the
cordinate reference system is implicitly assumed to take on the value of the containing
object's coordinate reference system.null
.@UML(identifier="dimension", obligation=MANDATORY, specification=ISO_19107) int getDimension()
@UML(identifier="coordinate", obligation=MANDATORY, specification=ISO_19107) double[] getCoordinate()
To manipulate ordinates, the following idiom can be used:final int dim = position.getDimension(); for (int i=0; i<dim; i++) { position.getOrdinate(i); // no copy overhead }
There are a couple reasons for requerying a copy:position.setOrdinate(i, value); // edit in place
DirectPosition
), or we want to protect the
array from future DirectPosition
changes.
DirectPosition.getOrdinates()
is garanteed to not return the backing array,
then we can work directly on this array. If we don't have this garantee, then we must
conservatively clone the array in every cases.
Precedence is given to data integrity over getOrdinates()
performance. Performance
concern can be avoided with usage of getOrdinate(int)
.
DirectPosition
object.double getOrdinate(int dimension) throws IndexOutOfBoundsException
dimension
- The dimension in the range 0 to dimension-1.IndexOutOfBoundsException
- If the given index is negative or is equals or greater than
the envelope dimension.void setOrdinate(int dimension, double value) throws IndexOutOfBoundsException, UnsupportedOperationException
dimension
- the dimension for the ordinate of interest.value
- the ordinate value of interest.IndexOutOfBoundsException
- If the given index is negative or is equals or greater than
the envelope dimension.UnsupportedOperationException
- if this direct position is immutable.boolean equals(Object object)
object
is non-null and is an instance of DirectPosition
.
Double.equals(java.lang.Object)
. In
other words, Arrays.equals(getCoordinate(), object.getCoordinate())
returns
true
.
int hashCode()
Arrays.hashCode(getCoordinate()) + getCoordinateReferenceSystem().hashCode()
where the
right hand side of the addition is omitted if the coordinate reference system is null.Copyright © 1996–2019 Geotools. All rights reserved.