Package org.opengis.geometry.coordinate
Interface PointGrid
-
@UML(identifier="GM_PointGrid", specification=ISO_19107) public interface PointGrid
A grid of points. The grid may be see as a sequences of equal length point arrays. While a point grid conceptually contains positions, it provides convenience methods for fetching directly the direct positions instead.- Since:
- GeoAPI 1.0
- Author:
- Martin Desruisseaux (IRD)
- See Also:
Position
,PointArray
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description DirectPosition
get(int row, int column)
Returns the point at the given row and column index.DirectPosition
get(int row, int column, DirectPosition dest)
Gets a copy of theDirectPosition
at the particular location in thisPointGrid
.PointArray
getRow(int row)
Returns the row at the given index.int
height()
Returns the length of this array.List<PointArray>
rows()
Returns a view of all rows in this array.void
set(int row, int column, DirectPosition position)
Set the point at the given index.int
width()
Returns the width of this grid.
-
-
-
Method Detail
-
width
@Extension int width()
Returns the width of this grid. All point array in this grid must have this length.- Returns:
- The grid width.
- See Also:
PointArray#length
-
height
@Extension int height()
Returns the length of this array. This is equivalent torows().length()
.- Returns:
- The grid height.
-
get
@Extension DirectPosition get(int row, int column) throws IndexOutOfBoundsException
Returns the point at the given row and column index. This is equivalent togetRow(row).get(column)
.
-
get
@Extension DirectPosition get(int row, int column, DirectPosition dest) throws IndexOutOfBoundsException
Gets a copy of theDirectPosition
at the particular location in thisPointGrid
. If thedest
argument is non-null, that object will be populated with the value from the array. In all cases, the position in insulated from changes in thePointArray
, and vice-versa. Consequently, the sameDirectPosition
object can be reused for fetching many points from this grid. Example:DirectPosition position = null; for (int j=0; j<grid.height(); j++) { for (int i=0; i<grid.width(); i++) { position = array.get(j, i, position); // Do some processing... } }
- Parameters:
row
- The row index from 0 inclusive toheight()
exclusive.column
- The column index from 0 inclusive towidth()
exclusive.dest
- An optionnaly pre-allocated direct position.- Returns:
- The
dest
argument, or a new object ifdest
was null. - Throws:
IndexOutOfBoundsException
- if an index is out of bounds.
-
set
@Extension void set(int row, int column, DirectPosition position) throws IndexOutOfBoundsException, UnsupportedOperationException
Set the point at the given index. The point coordinates will be copied, i.e. changes to the givenposition
after this method call will not be reflected into this point array. Consequently, the sameDirectPosition
object can be reused for setting many points in this array.- Parameters:
row
- The row index from 0 inclusive toheight()
exclusive.column
- The column index from 0 inclusive towidth()
exclusive.position
- The point to set at the given location in this array.- Throws:
IndexOutOfBoundsException
- if an index is out of bounds.UnsupportedOperationException
- if this grid is immutable.
-
getRow
@Extension PointArray getRow(int row) throws IndexOutOfBoundsException
Returns the row at the given index. The row is backed by thisPointGrid
, so changes to the row are reflected in the grid, and vice-versa.- Parameters:
row
- The index from 0 inclusive toheight()
exclusive.- Returns:
- The row at the given index.
- Throws:
IndexOutOfBoundsException
- if the index is out of bounds.
-
rows
@UML(identifier="row", obligation=MANDATORY, specification=ISO_19107) List<PointArray> rows()
Returns a view of all rows in this array. The list is backed by thisPointGrid
, so changes to any point array are reflected in the grid, and vice-versa.- Returns:
- The rows in this grid.
-
-