Package org.geotools.coverage.grid
Class GeneralGridCoordinates
- Object
-
- GeneralGridCoordinates
-
- All Implemented Interfaces:
Serializable
,Cloneable
,GridCoordinates
,Cloneable
- Direct Known Subclasses:
GeneralGridCoordinates.Immutable
public class GeneralGridCoordinates extends Object implements GridCoordinates, Serializable
Holds the set of grid coordinates that specifies the location of the grid point within the grid.- Since:
- 2.4
- Author:
- Martin Desruisseaux
- See Also:
GridCoordinates2D
, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GeneralGridCoordinates.Immutable
An immutableGridCoordinates
.
-
Constructor Summary
Constructors Constructor Description GeneralGridCoordinates(int dimension)
Creates a grid coordinates of the specified dimension.GeneralGridCoordinates(int[] coordinates)
Creates a grid coordinates initialized to the specified values.GeneralGridCoordinates(int[] coordinates, int lower, int upper)
Creates a grid coordinates initialized to the specified values in the specified range.GeneralGridCoordinates(GridCoordinates coordinates)
Creates a grid coordinates which is a copy of the specified one.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GeneralGridCoordinates
clone()
Returns a clone of this grid coordinates.boolean
equals(Object object)
Compares this grid coordinates with the specified object for equality.int
getCoordinateValue(int dimension)
Returns the coordinate value at the specified dimension.int[]
getCoordinateValues()
Returns one integer value for each dimension of the grid.int
getDimension()
Returns the number of dimensions.int
hashCode()
Returns a hash code value for this object.void
setCoordinateValue(int dimension, int value)
Sets the coordinate value at the specified dimension (optional operation).String
toString()
Returns a string representation of this grid coordinates.
-
-
-
Constructor Detail
-
GeneralGridCoordinates
public GeneralGridCoordinates(int dimension)
Creates a grid coordinates of the specified dimension. All coordinates are initially set to 0.- Parameters:
dimension
- The number of dimension.
-
GeneralGridCoordinates
public GeneralGridCoordinates(int[] coordinates)
Creates a grid coordinates initialized to the specified values.- Parameters:
coordinates
- The grid coordinates to copy.
-
GeneralGridCoordinates
public GeneralGridCoordinates(int[] 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.- Since:
- 2.5
-
GeneralGridCoordinates
public GeneralGridCoordinates(GridCoordinates coordinates)
Creates a grid coordinates which is a copy of the specified one.- Parameters:
coordinates
- The grid coordinates to copy.- Since:
- 2.5
-
-
Method Detail
-
getDimension
public int getDimension()
Returns the number of dimensions. This method is equivalent togetCoordinateValues().length
. It is provided for efficienty.- Specified by:
getDimension
in interfaceGridCoordinates
- Returns:
- The number of dimensions.
-
getCoordinateValues
public int[] 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:
getCoordinateValues
in interfaceGridCoordinates
- Returns:
- A copy of the coordinates. Changes in the returned array will not be reflected back
in this
GeneralGridCoordinates
object.
-
getCoordinateValue
public int getCoordinateValue(int dimension) throws ArrayIndexOutOfBoundsException
Returns the coordinate value at the specified dimension. This method is equivalent togetCoordinateValues()[i]
. It is provided for efficienty.- Specified by:
getCoordinateValue
in 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, int value) throws ArrayIndexOutOfBoundsException, UnsupportedOperationException
Sets the coordinate value at the specified dimension (optional operation).- Specified by:
setCoordinateValue
in interfaceGridCoordinates
- Parameters:
dimension
- The index of the value to set.value
- The new value.- Throws:
ArrayIndexOutOfBoundsException
- if the specified dimension is out of bounds.UnsupportedOperationException
- if this grid coordinates is not modifiable.
-
toString
public String toString()
Returns a string representation of this grid coordinates.
-
hashCode
public int hashCode()
Returns a hash code value for this object.
-
equals
public boolean equals(Object object)
Compares this grid coordinates with the specified object for equality.
-
clone
public GeneralGridCoordinates clone()
Returns a clone of this grid coordinates.- Specified by:
clone
in interfaceCloneable
- Overrides:
clone
in classObject
- Returns:
- A clone of this grid coordinates.
- See Also:
Object.clone()
-
-