org.deegree.geometry
Class GeometryTransformer

java.lang.Object
  extended by org.deegree.cs.Transformer
      extended by org.deegree.geometry.GeometryTransformer
Direct Known Subclasses:
XMLTransformer

public class GeometryTransformer
extends Transformer

Transforms a geometry defined in a CRS into a geometry defined in another CRS

Version:
$Revision: 31641 $, $Date: 2011-08-24 21:24:55 +0200 (Wed, 24 Aug 2011) $
Author:
Rutger Bezema, last edited by: $Author: mschneider $

Constructor Summary
GeometryTransformer(ICRS targetCRS)
          Creates a new GeometryTransformer object.
GeometryTransformer(String targetCRS)
          Creates a new GeometryTransformer object, with the given id as the target CRS.
GeometryTransformer(Transformation definedTransformation)
           
 
Method Summary
static Envelope createValidDomain(ICRS sourceCRS)
          Creates an envelope in the given CRS of the Area of Use (defined in WGS84) of the given Coordinate System.
 Geometry transform(Geometry geo, boolean testValidDomain)
          transforms the coordinates of a deegree geometry to the target coordinate reference system.
 Geometry transform(Geometry geo, String sourceCRS)
          transforms the coordinates of a deegree geometry to the target coordinate reference system.
<T extends Geometry>
T
transform(T geo)
          transforms the coordinates of a deegree geometry to the target coordinate reference system.
<T extends Geometry>
T
transform(T geo, ICRS sourceCRS)
          transforms the coordinates of a deegree geometry to the target coordinate reference system.
<T extends Geometry>
T
transform(T geom, ICRS sourceCRS, boolean testValidArea, List<Transformation> toBeUsedTransformations)
          transforms the coordinates of a deegree geometry to the target coordinate reference system.
 
Methods inherited from class org.deegree.cs.Transformer
createCRSTransformation, createCRSTransformation, createCRSTransformation, getTargetCRS
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeometryTransformer

public GeometryTransformer(ICRS targetCRS)
                    throws IllegalArgumentException
Creates a new GeometryTransformer object.

Parameters:
targetCRS -
Throws:
IllegalArgumentException - if the given parameter is null.

GeometryTransformer

public GeometryTransformer(String targetCRS)
                    throws UnknownCRSException,
                           IllegalArgumentException
Creates a new GeometryTransformer object, with the given id as the target CRS.

Parameters:
targetCRS - an identifier to which all other CRS's shall be transformed.
Throws:
UnknownCRSException - if the given crs name could not be mapped to a valid (configured) crs.
IllegalArgumentException - if the given parameter is null.

GeometryTransformer

public GeometryTransformer(Transformation definedTransformation)
                    throws IllegalArgumentException
Parameters:
definedTransformation - to use instead of the CRSFactory.
Throws:
IllegalArgumentException - if the given parameter is null.
Method Detail

transform

public <T extends Geometry> T transform(T geo)
                             throws TransformationException,
                                    IllegalArgumentException,
                                    UnknownCRSException
transforms the coordinates of a deegree geometry to the target coordinate reference system.

Type Parameters:
T -
Parameters:
geo - to be transformed
Returns:
the same geometry in a different crs.
Throws:
TransformationException - if the transformation between the source and target crs cannot be created.
IllegalArgumentException - if the coordinates system of the geometry is null
UnknownCRSException

transform

public Geometry transform(Geometry geo,
                          boolean testValidDomain)
                   throws TransformationException,
                          IllegalArgumentException,
                          UnknownCRSException
transforms the coordinates of a deegree geometry to the target coordinate reference system. Optionally tests whether the given Geometry lies within the source crs' valid domain.

Parameters:
geo - to be transformed
testValidDomain - true if the incoming geometry should be checked against the domain of validity of the CoordinateSystem it is defined in.
Returns:
the same geometry in a different crs.
Throws:
TransformationException - if the transformation between the source and target crs cannot be created.
IllegalArgumentException - if the coordinates system of the geometry is null
UnknownCRSException

createValidDomain

public static Envelope createValidDomain(ICRS sourceCRS)
Creates an envelope in the given CRS of the Area of Use (defined in WGS84) of the given Coordinate System.

Parameters:
sourceCRS - to get the area of use from.
Returns:
an Envelope with corresponding ordinates of the area of use BBox of the given Coordinate system, if the AreaOfUse was defined as -180,-90,180,90 BBox or if the envelope could not be transformed null will be returned.

transform

public Geometry transform(Geometry geo,
                          String sourceCRS)
                   throws TransformationException,
                          IllegalArgumentException,
                          UnknownCRSException
transforms the coordinates of a deegree geometry to the target coordinate reference system.

Parameters:
geo - to be transformed
sourceCRS - the source CRS for the geometry. overwrites the CRS of the geometry.
Returns:
the same geometry in a different crs.
Throws:
TransformationException - if the transformation between the source and target crs cannot be created.
IllegalArgumentException - if the coordinates system of the geometry is null
UnknownCRSException - if the given CRS is not found

transform

public <T extends Geometry> T transform(T geo,
                                        ICRS sourceCRS)
                             throws TransformationException,
                                    IllegalArgumentException
transforms the coordinates of a deegree geometry to the target coordinate reference system.

Parameters:
geo - to be transformed
sourceCRS - the source CRS for the geometry. overwrites the CRS of the geometry.
Returns:
the same geometry in a different crs.
Throws:
TransformationException - if the transformation between the source and target crs cannot be created.
IllegalArgumentException - if the coordinates system of the geometry is null

transform

public <T extends Geometry> T transform(T geom,
                                        ICRS sourceCRS,
                                        boolean testValidArea,
                                        List<Transformation> toBeUsedTransformations)
                             throws IllegalArgumentException,
                                    TransformationException
transforms the coordinates of a deegree geometry to the target coordinate reference system.

Type Parameters:
T -
Parameters:
geom - to be transformed
sourceCRS - the source CRS for the geometry. overwrites the CRS of the geometry.
testValidArea - true if the geometry should be be checked of the valid area of the source crs.
toBeUsedTransformations -
Returns:
the same geometry in a different crs.
Throws:
IllegalArgumentException - if the coordinates system of the geometry is null
TransformationException - if the transformation between the source and target crs cannot be created.


Copyright © 2011. All Rights Reserved.