org.geotools.geometry.jts.spatialschema.geometry.geometry
Class PointArrayImpl

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<T>
              extended by org.geotools.geometry.jts.spatialschema.geometry.NotifyingArrayList<org.opengis.geometry.coordinate.Position>
                  extended by org.geotools.geometry.jts.spatialschema.geometry.geometry.PointArrayImpl
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<org.opengis.geometry.coordinate.Position>, java.util.Collection<org.opengis.geometry.coordinate.Position>, java.util.List<org.opengis.geometry.coordinate.Position>, java.util.RandomAccess, JTSGeometry, org.opengis.geometry.coordinate.PointArray

public class PointArrayImpl
extends NotifyingArrayList<org.opengis.geometry.coordinate.Position>
implements org.opengis.geometry.coordinate.PointArray, JTSGeometry

A sequence of points. The PointArray interface outlines a means of efficiently storing large numbers of homogeneous DirectPositions; i.e. all having the same coordinate reference system. Classes implementing the PointArray interface are not required to store only one type of DirectPosition (the benefit of a homogenous collection arises in sub-interfaces). A simple implementation of PointArray will generally be no more efficient than a simple array of DirectPositions.

PointArray is similar to {@link List}&lt;{@link DirectPosition}&gt; from the collection framework. Implementations are free to implement directly the List interface.

Version:
2.0
Author:
ISO/DIS 19107, OpenGIS® consortium
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
PointArrayImpl()
           
PointArrayImpl(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
           
PointArrayImpl(JTSGeometry parent, org.opengis.referencing.crs.CoordinateReferenceSystem crs)
           
 
Method Summary
 org.opengis.geometry.coordinate.Position get(int column)
          Returns the point at the given index.
 org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem()
          Returns the Coordinate Reference System of this array.
 int getDimension()
          Returns the dimensionality of the coordinates in this array.
 org.opengis.geometry.DirectPosition getDirectPosition(int column, org.opengis.geometry.DirectPosition dest)
          Gets the DirectPosition at the particular location in this PointArray.
 com.vividsolutions.jts.geom.Geometry getJTSGeometry()
          Retrieves the equivalent JTS geometry for this object.
 int length()
          Returns the size (the number of elements) of this array.
 java.util.List positions()
          Returns a view of the points in this array as a list of positions.
 void setDirectPosition(int column, org.opengis.geometry.DirectPosition position)
          Set the point at the given index.
 java.lang.Object[] toArray()
          Returns the elements of this PointArray as an array of DirectPositions.
 
Methods inherited from class org.geotools.geometry.jts.spatialschema.geometry.NotifyingArrayList
add, add, addAll, addAll, clear, getJTSParent, invalidateCachedJTSPeer, remove, set, setJTSParent
 
Methods inherited from class java.util.ArrayList
clone, contains, ensureCapacity, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, removeAll, removeRange, retainAll, size, subList, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode
 
Methods inherited from class java.util.AbstractCollection
containsAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, equals, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, subList, toArray
 
Methods inherited from interface org.geotools.geometry.jts.JTSGeometry
invalidateCachedJTSPeer
 

Constructor Detail

PointArrayImpl

public PointArrayImpl()

PointArrayImpl

public PointArrayImpl(org.opengis.referencing.crs.CoordinateReferenceSystem crs)

PointArrayImpl

public PointArrayImpl(JTSGeometry parent,
                      org.opengis.referencing.crs.CoordinateReferenceSystem crs)
Method Detail

length

public int length()
Returns the size (the number of elements) of this array. This is equivalent to getColumns().size().

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

getDimension

public int getDimension()
Returns the dimensionality of the coordinates in this array. This may be less than or equal to the dimensionality of the coordinate reference system for these coordinates.

Specified by:
getDimension in interface org.opengis.geometry.coordinate.PointArray
Returns:
the dimensionality of this array.
See Also:
DirectPosition.getDimension()

getCoordinateReferenceSystem

public org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem()
Returns the Coordinate Reference System of this array.

Specified by:
getCoordinateReferenceSystem in interface org.opengis.geometry.coordinate.PointArray
Returns:
the Coordinate Reference System for this array.
See Also:
DirectPosition.getCoordinateReferenceSystem()

get

public org.opengis.geometry.coordinate.Position get(int column)
                                             throws java.lang.IndexOutOfBoundsException
Returns the point at the given index. This is equivalent to getColumns().get(column).getDirect().

Specified by:
get in interface java.util.List<org.opengis.geometry.coordinate.Position>
Overrides:
get in class java.util.ArrayList<org.opengis.geometry.coordinate.Position>
Parameters:
column - The location in the array, from 0 inclusive to the array's ArrayList.size exclusive.
Returns:
The point at the given location in this array.
Throws:
java.lang.IndexOutOfBoundsException - if the index is out of bounds.
See Also:
List.get(int), #get(int, DirectPosition)

getDirectPosition

public org.opengis.geometry.DirectPosition getDirectPosition(int column,
                                                             org.opengis.geometry.DirectPosition dest)
                                                      throws java.lang.IndexOutOfBoundsException
Gets the DirectPosition at the particular location in this PointArray. If the dest argument is non-null, that object will be populated with the value from the list.

Specified by:
getDirectPosition in interface org.opengis.geometry.coordinate.PointArray
Parameters:
column - The location in the array, from 0 inclusive to the array's ArrayList.size 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 the index is out of bounds.
See Also:
get(int)

setDirectPosition

public void setDirectPosition(int column,
                              org.opengis.geometry.DirectPosition position)
                       throws java.lang.IndexOutOfBoundsException
Set the point at the given index.

Specified by:
setDirectPosition in interface org.opengis.geometry.coordinate.PointArray
Parameters:
column - The location in the array, from 0 inclusive to the array's ArrayList.size exclusive.
position - The point to set at the given location in this array. The point coordinates will be copied, i.e. changes to the given position after the method call will not be reflected to this array.
Throws:
java.lang.IndexOutOfBoundsException - if the index is out of bounds.
See Also:
List.set(int, E)

toArray

public java.lang.Object[] toArray()
Returns the elements of this PointArray as an array of DirectPositions.

Specified by:
toArray in interface java.util.Collection<org.opengis.geometry.coordinate.Position>
Specified by:
toArray in interface java.util.List<org.opengis.geometry.coordinate.Position>
Overrides:
toArray in class java.util.ArrayList<org.opengis.geometry.coordinate.Position>
Returns:
The elements as an array of direct positions.
See Also:
List.toArray()

positions

public java.util.List positions()
Returns a view of the points in this array as a list of positions. The list is backed by this PointArray, so changes to the array are reflected in the list, and vice-versa.

Specified by:
positions in interface org.opengis.geometry.coordinate.PointArray
Returns:
The points in this array.

getJTSGeometry

public com.vividsolutions.jts.geom.Geometry getJTSGeometry()
Description copied from interface: JTSGeometry
Retrieves the equivalent JTS geometry for this object. Note that this operation may be expensive if the geometry must be computed.

Specified by:
getJTSGeometry in interface JTSGeometry


Copyright © 1996-2010 Geotools. All Rights Reserved.