org.geotools.resources
Class CRSUtilities

java.lang.Object
  extended byorg.geotools.resources.CRSUtilities

public final class CRSUtilities
extends java.lang.Object

A set of static methods working on OpenGIS® coordinate reference system objects. Some of those methods are useful, but not really rigorous. This is why they do not appear in the "official" package, but instead in this private one. Do not rely on this API! It may change in incompatible way in any future release.

Since:
2.0
Version:
$Id: CRSUtilities.java 17890 2006-02-06 08:46:14Z desruisseaux $
Author:
Martin Desruisseaux

Method Summary
static java.awt.geom.Point2D deltaTransform(org.opengis.referencing.operation.MathTransform2D transform, java.awt.geom.Point2D origin, java.awt.geom.Point2D source, java.awt.geom.Point2D dest)
          Transforms the relative distance vector specified by and stores the result in .
static org.opengis.spatialschema.geometry.DirectPosition deltaTransform(org.opengis.referencing.operation.MathTransform transform, org.opengis.spatialschema.geometry.DirectPosition origin, org.opengis.spatialschema.geometry.DirectPosition source)
          Transforms the relative distance vector specified by and stores the result in .
static int dimensionColinearWith(org.opengis.referencing.cs.CoordinateSystem cs, org.opengis.referencing.cs.CoordinateSystemAxis axis)
          Returns the dimension within the coordinate system of the first occurrence of an axis colinear with the specified axis.
static boolean equalsIgnoreMetadata(java.lang.Object object1, java.lang.Object object2)
          Compare the specified objects for equality.
static org.opengis.referencing.crs.CoordinateReferenceSystem getCRS2D(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
          Returns a two-dimensional coordinate reference system representing the two first dimensions of the specified coordinate reference system.
static org.opengis.referencing.datum.Datum getDatum(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
          Returns the datum of the specified CRS, or if none.
static int getDimensionOf(org.opengis.referencing.crs.CoordinateReferenceSystem crs, java.lang.Class type)
          Returns the dimension of the first coordinate reference system of the given type.
static org.opengis.referencing.datum.Ellipsoid getEllipsoid(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
          Returns the first ellipsoid found in a coordinate reference system, or if there is none.
static org.opengis.spatialschema.geometry.Envelope getEnvelope(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
          Returns the bounding box of the specified coordinate reference system, or if none.
static org.opengis.referencing.datum.Ellipsoid getHeadGeoEllipsoid(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
          Returns the ellipsoid used by the specified coordinate reference system, providing that the two first dimensions use an instance of GeographicCRS.
static org.opengis.referencing.crs.SingleCRS getHorizontalCRS(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
          Returns the first horizontal coordinate reference system found in the given CRS, or if there is none.
static org.opengis.referencing.crs.ProjectedCRS getProjectedCRS(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
          Returns the first projected coordinate reference system found in a the given CRS, or if there is none.
static org.opengis.referencing.crs.CoordinateReferenceSystem getSubCRS(org.opengis.referencing.crs.CoordinateReferenceSystem crs, int lower, int upper)
          Returns a sub-coordinate reference system for the specified dimension range.
static org.opengis.referencing.crs.TemporalCRS getTemporalCRS(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
          Returns the first temporal coordinate reference system found in the given CRS, or if there is none.
static javax.units.Unit getUnit(org.opengis.referencing.cs.CoordinateSystem cs)
          Returns the unit used for all axis in the specified coordinate system.
static org.opengis.referencing.crs.VerticalCRS getVerticalCRS(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
          Returns the first vertical coordinate reference system found in a the given CRS, or if there is none.
static java.lang.String toWGS84String(org.opengis.referencing.crs.CoordinateReferenceSystem crs, java.awt.geom.Rectangle2D bounds)
          Returns a character string for the specified geographic area.
static java.awt.geom.Rectangle2D transform(org.opengis.referencing.operation.MathTransform2D transform, java.awt.geom.Rectangle2D source, java.awt.geom.Rectangle2D dest)
          Transform an envelope.
static GeneralEnvelope transform(org.opengis.referencing.operation.MathTransform transform, org.opengis.spatialschema.geometry.Envelope envelope)
          Transforms an envelope.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

equalsIgnoreMetadata

public static boolean equalsIgnoreMetadata(java.lang.Object object1,
                                           java.lang.Object object2)
Compare the specified objects for equality. If both objects are Geotools implementations of AbstractIdentifiedObject, then this method will ignore the metadata during the comparaison.

Parameters:
object1 - The first object to compare (may be null).
object2 - The second object to compare (may be null).
Returns:
if both objects are equals.
To Do:
Move this method as a static method in CRS. The method signature is already there.

dimensionColinearWith

public static int dimensionColinearWith(org.opengis.referencing.cs.CoordinateSystem cs,
                                        org.opengis.referencing.cs.CoordinateSystemAxis axis)
Returns the dimension within the coordinate system of the first occurrence of an axis colinear with the specified axis. If an axis with the same direction or an opposite direction than ocurs in the coordinate system, then the dimension of the first such occurrence is returned. That is, the a value k such that:
 cs.getAxis(k).getDirection().absolute() == axis.getDirection().absolute()
 
is . If no such axis occurs in this coordinate system, then is returned.

For example, returns the dimension number of time axis.

Parameters:
cs - The coordinate system to examine.
axis - The axis to look for.
Returns:
The dimension number of the specified axis, or if none.

getUnit

public static javax.units.Unit getUnit(org.opengis.referencing.cs.CoordinateSystem cs)
Returns the unit used for all axis in the specified coordinate system. If not all axis uses the same unit, then this method returns . This convenience method is often used for Well Know Text (WKT) formatting.

Since:
2.2

getDimensionOf

public static int getDimensionOf(org.opengis.referencing.crs.CoordinateReferenceSystem crs,
                                 java.lang.Class type)
                          throws java.lang.IllegalArgumentException
Returns the dimension of the first coordinate reference system of the given type. The argument must be a subinterface of CoordinateReferenceSystem. If no such dimension is found, then this method returns .

Parameters:
crs - The coordinate reference system (CRS) to examine.
type - The CRS type to look for. Must be a subclass of CoordinateReferenceSystem.
Returns:
The dimension range of the specified CRS type, or if none.
Throws:
java.lang.IllegalArgumentException - if the is not legal.

getSubCRS

public static org.opengis.referencing.crs.CoordinateReferenceSystem getSubCRS(org.opengis.referencing.crs.CoordinateReferenceSystem crs,
                                                                              int lower,
                                                                              int upper)
Returns a sub-coordinate reference system for the specified dimension range.

Parameters:
crs - The coordinate reference system to decompose.
lower - The first dimension to keep, inclusive.
upper - The last dimension to keep, exclusive.
Returns:
The sub-coordinate system, or if can't be decomposed for dimensions in the range .

getCRS2D

public static org.opengis.referencing.crs.CoordinateReferenceSystem getCRS2D(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
                                                                      throws org.opengis.referencing.operation.TransformException
Returns a two-dimensional coordinate reference system representing the two first dimensions of the specified coordinate reference system. If is already a two-dimensional CRS, then it is returned unchanged. Otherwise, if it is a CompoundCRS, then the head coordinate reference system is examined.

Parameters:
crs - The coordinate system, or .
Returns:
A two-dimensional coordinate reference system that represents the two first dimensions of , or if was .
Throws:
org.opengis.referencing.operation.TransformException - if can't be reduced to a two-coordinate system. We use this exception class since this method is usually invoked in the context of a transformation process.

getHorizontalCRS

public static org.opengis.referencing.crs.SingleCRS getHorizontalCRS(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
Returns the first horizontal coordinate reference system found in the given CRS, or if there is none.

To Do:
Move this method as a static method in CRS.

getProjectedCRS

public static org.opengis.referencing.crs.ProjectedCRS getProjectedCRS(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
Returns the first projected coordinate reference system found in a the given CRS, or if there is none.

To Do:
Move this method as a static method in CRS.

getVerticalCRS

public static org.opengis.referencing.crs.VerticalCRS getVerticalCRS(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
Returns the first vertical coordinate reference system found in a the given CRS, or if there is none.

To Do:
Move this method as a static method in CRS.

getTemporalCRS

public static org.opengis.referencing.crs.TemporalCRS getTemporalCRS(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
Returns the first temporal coordinate reference system found in the given CRS, or if there is none.

To Do:
Move this method as a static method in CRS.

getDatum

public static org.opengis.referencing.datum.Datum getDatum(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
Returns the datum of the specified CRS, or if none.

To Do:
Move this method as a static method in CRS.

getEllipsoid

public static org.opengis.referencing.datum.Ellipsoid getEllipsoid(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
Returns the first ellipsoid found in a coordinate reference system, or if there is none.

To Do:
Move this method as a static method in CRS.

getHeadGeoEllipsoid

public static org.opengis.referencing.datum.Ellipsoid getHeadGeoEllipsoid(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
Returns the ellipsoid used by the specified coordinate reference system, providing that the two first dimensions use an instance of GeographicCRS. Otherwise (i.e. if the two first dimensions are not geographic), returns .


getEnvelope

public static org.opengis.spatialschema.geometry.Envelope getEnvelope(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
Returns the bounding box of the specified coordinate reference system, or if none. This method search in the metadata informations.

Parameters:
crs - The coordinate reference system, or .
Returns:
The envelope, or if none.
To Do:
Move this method as a static method in CRS. The method signature is already there.

transform

public static GeneralEnvelope transform(org.opengis.referencing.operation.MathTransform transform,
                                        org.opengis.spatialschema.geometry.Envelope envelope)
                                 throws org.opengis.referencing.operation.TransformException
Transforms an envelope. The transformation is only approximative. Note that the returned envelope may not have the same number of dimensions than the original envelope.

Parameters:
transform - The transform to use.
envelope - Envelope to transform, or . This envelope will not be modified.
Returns:
The transformed envelope, or if was null.
Throws:
org.opengis.referencing.operation.TransformException - if a transform failed.
To Do:
Move this method as a static method in CRS.

transform

public static java.awt.geom.Rectangle2D transform(org.opengis.referencing.operation.MathTransform2D transform,
                                                  java.awt.geom.Rectangle2D source,
                                                  java.awt.geom.Rectangle2D dest)
                                           throws org.opengis.referencing.operation.TransformException
Transform an envelope. The transformation is only approximative. Invoking this method is equivalent to invoking the following:

transform(transform, new GeneralEnvelope(source)).toRectangle2D()

Parameters:
transform - The transform to use. Source and target dimension must be 2.
source - The rectangle to transform (may be ).
dest - The destination rectangle (may be ). If , a new rectangle will be created and returned.
Returns:
, or a new rectangle if was non-null and was null.
Throws:
org.opengis.referencing.operation.TransformException - if a transform failed.
To Do:
Move this method as a static method in CRS.

deltaTransform

public static org.opengis.spatialschema.geometry.DirectPosition deltaTransform(org.opengis.referencing.operation.MathTransform transform,
                                                                               org.opengis.spatialschema.geometry.DirectPosition origin,
                                                                               org.opengis.spatialschema.geometry.DirectPosition source)
                                                                        throws org.opengis.referencing.operation.TransformException
Transforms the relative distance vector specified by and stores the result in . A relative distance vector is transformed without applying the translation components.

Parameters:
transform - The transform to apply.
origin - The position where to compute the delta transform in the source CS.
source - The distance vector to be delta transformed
Returns:
The result of the transformation.
Throws:
org.opengis.referencing.operation.TransformException - if the transformation failed.
Since:
2.3

deltaTransform

public static java.awt.geom.Point2D deltaTransform(org.opengis.referencing.operation.MathTransform2D transform,
                                                   java.awt.geom.Point2D origin,
                                                   java.awt.geom.Point2D source,
                                                   java.awt.geom.Point2D dest)
                                            throws org.opengis.referencing.operation.TransformException
Transforms the relative distance vector specified by and stores the result in . A relative distance vector is transformed without applying the translation components.

Parameters:
transform - The transform to apply.
origin - The position where to compute the delta transform in the source CS.
source - The distance vector to be delta transformed
dest - The resulting transformed distance vector, or
Returns:
The result of the transformation.
Throws:
org.opengis.referencing.operation.TransformException - if the transformation failed.
See Also:
AffineTransform.deltaTransform(Point2D,Point2D)

toWGS84String

public static java.lang.String toWGS84String(org.opengis.referencing.crs.CoordinateReferenceSystem crs,
                                             java.awt.geom.Rectangle2D bounds)
Returns a character string for the specified geographic area. The string will have the form "45?00.00'N-50?00.00'N 30?00.00'E-40?00.00'E". If a map projection is required in order to obtain this representation, it will be automatically applied. This string is mostly used for debugging purpose.

To Do:
Move this method as a static method in CRS. Or yet better: move formatting code in method, and move the transformation code into constructor.


Copyright © GeoTools. All Rights Reserved.