- All Superinterfaces:
Position
- All Known Implementing Classes:
SimpleDirectPosition
@Classifier(DATATYPE)
@UML(identifier="DirectPosition",
specification=ISO_19107)
public interface DirectPosition
extends Position
Holds the coordinates for a position within some coordinate reference system. Since
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 coordinate reference system is implicitly assumed to take on the value of the containing
object's coordinate reference system.- Since:
- 1.0
- Departure from OGC/ISO abstract specification:
Extension for convenience without introduction of new functionality
The ISO specification defines this interface in thecoordinate
sub-package. GeoAPI moved this interface into theorg.opengis.geometry
root package for convenience, because it is extensively used.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Compares this direct position with the specified object for equality.double[]
A copy of the coordinates presented as an array of double values.The coordinate reference system in which the coordinate tuple is given.int
The length of coordinate sequence (the number of entries).double
getOrdinate
(int dimension) Returns the coordinate at the specified dimension.int
hashCode()
Returns a hash code value for this direct position.void
setOrdinate
(int dimension, double value) Sets the coordinate value along the specified dimension.Methods inherited from interface Position
getDirectPosition
-
Method Details
-
getCoordinateReferenceSystem
@UML(identifier="coordinateReferenceSystem", obligation=MANDATORY, specification=ISO_19107) CoordinateReferenceSystem getCoordinateReferenceSystem()The coordinate reference system in which the coordinate tuple is given. May benull
if this particularDirectPosition
is included in a larger object with such a reference to a coordinate reference system. In this case, the coordinate reference system is implicitly assumed to take on the value of the containing object's coordinate reference system.- Returns:
- the coordinate reference system, or
null
.
-
getDimension
The length of coordinate sequence (the number of entries). This is determined by the coordinate reference system.- Returns:
- the dimensionality of this position.
-
getCoordinate
@UML(identifier="coordinate", obligation=MANDATORY, specification=ISO_19107) double[] getCoordinate()A copy of the coordinates presented as an array of double values. Please note that this is only a copy (the real values may be stored in another format) so changes to the returned array will not affect the source DirectPosition.final int dim = position.getDimension(); for (int i=0; i<dim; i++) { position.getOrdinate(i); // no copy overhead }
position.setOrdinate(i, value); // edit in place
- We want an array of coordinates with the intent to modify it for computation purpose
(without modifying the original
DirectPosition
), or we want to protect the array from futureDirectPosition
changes. - If
DirectPosition.getOrdinates()
is guaranteed to not return the backing array, then we can work directly on this array. If we don't have this guarantee, then we must conservatively clone the array in every cases. - Cloning the returned array is useless if the implementation cloned the array or was forced to returns a new array anyway (for example because the coordinates were computed on the fly)
getOrdinates()
performance. Performance concern can be avoided with usage ofgetOrdinate(int)
.- Returns:
- a copy of the coordinates. Changes in the returned array will not be reflected back
in this
DirectPosition
object. - TODO:
- needs to be renamed
getCoordinates()
.
- We want an array of coordinates with the intent to modify it for computation purpose
(without modifying the original
-
getOrdinate
Returns the coordinate at the specified dimension.- Parameters:
dimension
- the dimension in the range 0 to dimension-1.- Returns:
- the coordinate at the specified dimension.
- Throws:
IndexOutOfBoundsException
- if the given index is negative or is equal or greater than the position dimension.- TODO:
- needs to be renamed
getCoordinate(int)
.
-
setOrdinate
void setOrdinate(int dimension, double value) throws IndexOutOfBoundsException, UnsupportedOperationException Sets the coordinate value along the specified dimension.- Parameters:
dimension
- the dimension for the coordinate of interest.value
- the coordinate value of interest.- Throws:
IndexOutOfBoundsException
- if the given index is negative or is equal or greater than the position dimension.UnsupportedOperationException
- if this direct position is immutable.- TODO:
- needs to be renamed
setCoordinate(int, double)
.
-
equals
Compares this direct position with the specified object for equality. Two direct positions are considered equal if the following conditions are meet:object
is non-null and is an instance ofDirectPosition
.- Both direct positions have the same number of dimensions.
- Both direct positions have the same or equal coordinate reference system.
- For all dimension i, the coordinate value of both
direct positions at that dimension are equals in the sense of
Double.equals(Object)
. In other words,Arrays.equals(getCoordinate(), object.getCoordinate())
returnstrue
.
-
hashCode
int hashCode()Returns a hash code value for this direct position. This method should returns the same value as:Arrays.hashCode(getCoordinate()) + getCoordinateReferenceSystem().hashCode()
where the right hand side of the addition is omitted if the coordinate reference system is null.
-