org.geotoolkit.referencing.cs
Class DiscreteReferencingFactory

Object
  extended by Static
      extended by DiscreteReferencingFactory

public final class DiscreteReferencingFactory
extends Static

Factory methods for creating DiscreteCoordinateSystemAxis and derived objects. Every createXXX(...) methods provided in this class wrap an existing referencing object and add discrete behavior to it.

IMPORTANT NOTE:
In current implementation, every factory methods defined in this class do not clone the given ordinate arrays, because those arrays may be potentially large and the caller way want to share the reference to some of them. It is caller responsibility to not change the ordinate arrays after they have been passed to factory methods.

Since:
3.15
Version:
3.16
Author:
Martin Desruisseaux (Geomatys)
Module:
coverage/geotk-coverage (download)    View source code for this class

Method Summary
static DiscreteCoordinateSystemAxis createDiscreteAxis(CoordinateSystemAxis axis, double... ordinates)
          Creates a new discrete axis wrapping the given axis with the given ordinate values.
static CoordinateReferenceSystem createDiscreteCRS(CoordinateReferenceSystem crs, double[]... ordinates)
          Returns a CRS instance wrapping the given CRS with the given ordinate values for each axis.
static CoordinateSystem createDiscreteCS(CoordinateSystem cs, double[]... ordinates)
          Returns a CS instance wrapping the given CS with the given ordinate values for each axis.
static Matrix getAffineTransform(CoordinateReferenceSystem crs)
          Computes a grid to CRS affine transform for the given CRS, mapping cell center.
static XMatrix getAffineTransform(DiscreteCoordinateSystemAxis... axes)
          Computes a grid to CRS affine transform for the given axes, mapping cell center.
static Matrix getAffineTransform(GridGeometry geometry, PixelInCell pixelInCell)
          Returns the grid to CRS affine transform for the given grid geometry.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createDiscreteAxis

public static DiscreteCoordinateSystemAxis createDiscreteAxis(CoordinateSystemAxis axis,
                                                              double... ordinates)
Creates a new discrete axis wrapping the given axis with the given ordinate values. If the given axis is already an instance of DiscreteCoordinateSystemAxis having the given ordinates values (or the ordinates array is null), then that instance is returned directly.

Parameters:
axis - The axis to wrap.
ordinates - The ordinate values. This array is not cloned.
Returns:
A discrete coordinate system axis wrapping the given axis.

createDiscreteCS

public static CoordinateSystem createDiscreteCS(CoordinateSystem cs,
                                                double[]... ordinates)
                                         throws IllegalArgumentException
Returns a CS instance wrapping the given CS with the given ordinate values for each axis. If the given CS already have discrete axes with the given ordinate values, then it is returned directly.

Grid geometry
The instance returned by this method implements the GridGeometry interface. However the grid to CRS transform is meaningful only if the ordinate values in the given arrays are regularly spaced. This is not verified because the criterion for deciding if an axis is "regular" is arbitrary.

Parameters:
cs - The coordinate system to wrap.
ordinates - The ordinate values for each axis. The arrays are not cloned.
Returns:
A new coordinate system wrapping the given one with discrete axes.
Throws:
IllegalArgumentException - If the length of the ordinates array is not equals to the dimension of the given coordinate system.

createDiscreteCRS

public static CoordinateReferenceSystem createDiscreteCRS(CoordinateReferenceSystem crs,
                                                          double[]... ordinates)
                                                   throws IllegalArgumentException
Returns a CRS instance wrapping the given CRS with the given ordinate values for each axis. If the coordinate system of the given CRS already have discrete axes with the given ordinate values, then the CRS is returned directly.

Grid geometry
The instance returned by this method implements the GridGeometry interface. However the grid to CRS transform is meaningful only if the ordinate values in the given arrays are regularly spaced. This is not verified because the criterion for deciding if an axis is "regular" is arbitrary.

Parameters:
crs - The coordinate reference system to wrap.
ordinates - The ordinate values for each axis. The arrays are not cloned.
Returns:
A new coordinate reference system wrapping the given one with discrete axes.
Throws:
IllegalArgumentException - If the length of the ordinates array is not equals to the coordinate system dimension.

getAffineTransform

public static XMatrix getAffineTransform(DiscreteCoordinateSystemAxis... axes)
Computes a grid to CRS affine transform for the given axes, mapping cell center. Callers shall ensure that the following conditions are meet (they are not verified by this method, because the threshold for considering an axis as "regular" is arbitrary and at caller choice):

Parameters:
axes - The axes to use for computing the transform.
Returns:
The grid to CRS transform mapping cell centers for the given axes as a matrix, or null if such matrix can not be computed.

getAffineTransform

public static Matrix getAffineTransform(CoordinateReferenceSystem crs)
Computes a grid to CRS affine transform for the given CRS, mapping cell center. This method processes with the following steps:

  1. If the given CRS implements the GridGeometry interface, then this method checks the value returned by the GridGeometry.getGridToCRS() method. If that value is a linear transform, then its matrix is returned.
  2. Otherwise if the given CRS is an instance of CompoundCRS, then the above check is performed for each component and the component matrix are assembled in a single matrix.
  3. Otherwise if all axes in the given CRS are discrete, then this method gets those axes and delegates to the getAffineTransform(DiscreteCoordinateSystemAxis[]) method. Note that the conditions documented in the above method apply.
  4. Otherwise this method returns null.

Parameters:
crs - The Coordinate Reference System for which to get the grid to CRS affine transform.
Returns:
The grid to CRS transform mapping cell centers for the CRS axes as a matrix, or null if such matrix can not be computed.
Since:
3.16

getAffineTransform

public static Matrix getAffineTransform(GridGeometry geometry,
                                        PixelInCell pixelInCell)
Returns the grid to CRS affine transform for the given grid geometry.

  1. First, this method invokes one of the following getGridToCRS() methods:
  2. If the transform returned in the above step is linear, then its matrix is returned.
  3. Otherwise if the given geometry is also a CRS with discrete axes (for example NetcdfCRS), then this method performs the same calculation than getAffineTransform(CoordinateReferenceSystem).
  4. Otherwise this method returns null.

Parameters:
geometry - The geometry for which to get the grid to CRS affine transform.
pixelInCell - Whatever the transform should map the cell center or corner, or null for the default (typically cell center).
Returns:
The grid to CRS transform mapping cell centers for the CRS axes as a matrix, or null if such matrix can not be computed.
Since:
3.16
See Also:
GeneralGridGeometry.getGridToCRS(PixelInCell), PixelTranslation


Copyright © 2009-2012 Geotoolkit.org. All Rights Reserved.