Package org.opengis.example.coverage
Class SimpleGridCoordinates
- Object
-
- SimpleGridCoordinates
-
- All Implemented Interfaces:
Serializable,GridCoordinates
public class SimpleGridCoordinates extends Object implements GridCoordinates, Serializable
AGridCoordinatesimplementation which store value in aint[]array. This class holds the set of grid coordinates that specifies the location of the grid point within the grid.- Since:
- 3.1
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected long[]coordinatesThe grid coordinates.
-
Constructor Summary
Constructors Constructor Description SimpleGridCoordinates(int dimension)Creates a grid coordinates of the specified dimension.SimpleGridCoordinates(long[] coordinates)Creates a grid coordinates initialized to the specified values.SimpleGridCoordinates(long[] coordinates, int lower, int upper)Creates a grid coordinates initialized to the specified values in the specified range.
-
Method Summary
Modifier and Type Method Description booleanequals(Object object)Compares this grid coordinates with the specified object for equality.longgetCoordinateValue(int dimension)Returns the coordinate value at the specified dimension.long[]getCoordinateValues()Returns one integer value for each dimension of the grid.intgetDimension()Returns the number of dimensions.inthashCode()Returns a hash code value for this object.voidsetCoordinateValue(int dimension, long value)Sets the coordinate value at the specified dimension (optional operation).StringtoString()Returns a string representation of this grid coordinates.
-
-
-
Constructor Detail
-
SimpleGridCoordinates
public SimpleGridCoordinates(int dimension)
Creates a grid coordinates of the specified dimension. All coordinates are initially set to 0.- Parameters:
dimension- the number of dimension.
-
SimpleGridCoordinates
public SimpleGridCoordinates(long[] coordinates)
Creates a grid coordinates initialized to the specified values.- Parameters:
coordinates- the grid coordinates to copy.
-
SimpleGridCoordinates
public SimpleGridCoordinates(long[] coordinates, int lower, int upper)Creates a grid coordinates initialized to the specified values in the specified range.- Parameters:
coordinates- the coordinates to copy.lower- index of the first value to copy, inclusive.upper- index of the last value to copy, exclusive.
-
-
Method Detail
-
getDimension
public int getDimension()
Returns the number of dimensions. This method is equivalent togetCoordinateValues().length. It is provided for efficiency.- Specified by:
getDimensionin interfaceGridCoordinates
-
getCoordinateValues
public long[] getCoordinateValues()
Returns one integer value for each dimension of the grid. The ordering of these coordinate values shall be the same as that of the elements ofGrid.getAxisNames(). The value of a single coordinate shall be the number of offsets from the origin of the grid in the direction of a specific axis.- Specified by:
getCoordinateValuesin interfaceGridCoordinates- Returns:
- a copy of the coordinates. Changes in the returned array will not be reflected
back in this
SimpleGridCoordinatesobject.
-
getCoordinateValue
public long getCoordinateValue(int dimension) throws ArrayIndexOutOfBoundsExceptionReturns the coordinate value at the specified dimension. This method is equivalent togetCoordinateValues()[i]. It is provided for efficiency.- Specified by:
getCoordinateValuein interfaceGridCoordinates- Parameters:
dimension- the dimension from 0 inclusive togetDimension()exclusive.- Returns:
- the value at the requested dimension.
- Throws:
ArrayIndexOutOfBoundsException- if the specified dimension is out of bounds.
-
setCoordinateValue
public void setCoordinateValue(int dimension, long value) throws ArrayIndexOutOfBoundsExceptionSets the coordinate value at the specified dimension (optional operation).- Specified by:
setCoordinateValuein interfaceGridCoordinates- Parameters:
dimension- the index of the value to set.value- the new value.- Throws:
ArrayIndexOutOfBoundsException- if the specified dimension is out of bounds.
-
equals
public boolean equals(Object object)
Compares this grid coordinates with the specified object for equality.
-
hashCode
public int hashCode()
Returns a hash code value for this object.
-
-