org.geotools.geometry.jts.spatialschema.geometry.geometry
Class PointGridImpl

java.lang.Object
  extended by org.geotools.geometry.jts.spatialschema.geometry.geometry.PointGridImpl
All Implemented Interfaces:
org.opengis.geometry.coordinate.PointGrid

public class PointGridImpl
extends java.lang.Object
implements org.opengis.geometry.coordinate.PointGrid

A grid of points. The grid may be see as a sequences of equal length sequences.

Version:
2.0
Author:
ISO/DIS 19107, OpenGIS® consortium

Constructor Summary
PointGridImpl()
           
 
Method Summary
 org.opengis.geometry.DirectPosition get(int row, int column)
          Returns the point at the given index.
 org.opengis.geometry.DirectPosition get(int row, int column, org.opengis.geometry.DirectPosition dest)
          Gets a copy of the DirectPosition at the particular location in this PointGrid.
 org.opengis.geometry.coordinate.PointArray getRow(int row)
          Returns the row at the given index.
 int height()
          Returns the length of this array.
 java.util.List rows()
          Returns all rows in this array.
 void set(int row, int column, org.opengis.geometry.DirectPosition position)
          Set the point at the given index.
 int width()
          Returns the width of this grid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PointGridImpl

public PointGridImpl()
Method Detail

width

public int width()
Returns the width of this grid. All point array in this grid must have this length.

Specified by:
width in interface org.opengis.geometry.coordinate.PointGrid
Returns:
The grid width.
See Also:
List.size()

height

public int height()
Returns the length of this array. This is equivalent to getRows().size().

Specified by:
height in interface org.opengis.geometry.coordinate.PointGrid
Returns:
The grid height.

get

public org.opengis.geometry.DirectPosition get(int row,
                                               int column)
                                        throws java.lang.IndexOutOfBoundsException
Returns the point at the given index. This is equivalent to getRow(row).get(column).

Specified by:
get in interface org.opengis.geometry.coordinate.PointGrid
Parameters:
row - The row index from 0 inclusive to height() exclusive.
column - The column index from 0 inclusive to width() exclusive.
Returns:
The point at the given index.
Throws:
java.lang.IndexOutOfBoundsException - if an index is out of bounds.

get

public org.opengis.geometry.DirectPosition get(int row,
                                               int column,
                                               org.opengis.geometry.DirectPosition dest)
                                        throws java.lang.IndexOutOfBoundsException
Gets a copy of the DirectPosition at the particular location in this PointGrid. If the dest 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 the PointArray, and vice-versa. Consequently, the same DirectPosition 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...
      }
  }
 

Specified by:
get in interface org.opengis.geometry.coordinate.PointGrid
Parameters:
row - The row index from 0 inclusive to height() exclusive.
column - The column index from 0 inclusive to width() exclusive.
dest - An optionnaly pre-allocated direct position.
Returns:
The dest argument, or a new object if dest was null.
Throws:
java.lang.IndexOutOfBoundsException - if an index is out of bounds.

set

public void set(int row,
                int column,
                org.opengis.geometry.DirectPosition position)
         throws java.lang.IndexOutOfBoundsException,
                java.lang.UnsupportedOperationException
Set the point at the given index. The point coordinates will be copied, i.e. changes to the given position after this method call will not be reflected into this point array. Consequently, the same DirectPosition object can be reused for setting many points in this array.

Specified by:
set in interface org.opengis.geometry.coordinate.PointGrid
Parameters:
row - The row index from 0 inclusive to height() exclusive.
column - The column index from 0 inclusive to width() exclusive.
position - The point to set at the given location in this array.
Throws:
java.lang.IndexOutOfBoundsException - if an index is out of bounds.
java.lang.UnsupportedOperationException - if this grid is immutable.

getRow

public org.opengis.geometry.coordinate.PointArray getRow(int row)
                                                  throws java.lang.IndexOutOfBoundsException
Returns the row at the given index.

Specified by:
getRow in interface org.opengis.geometry.coordinate.PointGrid
Parameters:
row - The index from 0 inclusive to height() exclusive.
Returns:
The row at the given index.
Throws:
java.lang.IndexOutOfBoundsException - if the index is out of bounds.

rows

public java.util.List rows()
Returns all rows in this array.

Specified by:
rows in interface org.opengis.geometry.coordinate.PointGrid
Returns:
The rows in this array.


Copyright © 1996-2010 Geotools. All Rights Reserved.