org.geotools.geometry
Class JTS

java.lang.Object
  extended byorg.geotools.geometry.JTS

public class JTS
extends java.lang.Object

JTS Geometry utility methods, bringing geotools to JTS.

Offers geotools based services such as reprojection.

Responsibilities:

Since:
0.6.0
Author:
jgarnett

Nested Class Summary
static class JTS.ReferencedEnvelope
           
 
Constructor Summary
JTS()
           
 
Method Summary
static JTS.ReferencedEnvelope create(com.vividsolutions.jts.geom.Envelope env, org.opengis.referencing.crs.CoordinateReferenceSystem crs)
           
static GeometryCoordinateSequenceTransformer createGeometryTransformer()
          Creates a GeometryCoordinateSequenceTransformer.
static GeometryCoordinateSequenceTransformer createPreciseGeometryTransformer(double flatness)
          Creates a GeometryCoordinateSequenceTransformer.
static com.vividsolutions.jts.geom.Envelope empty()
           
static com.vividsolutions.jts.geom.Geometry preciseTransform(com.vividsolutions.jts.geom.Geometry geom, double flatness, org.opengis.referencing.operation.MathTransform transform)
          Transforms the geometry using the Precise transformer.
static com.vividsolutions.jts.geom.Envelope toGeographic(com.vividsolutions.jts.geom.Envelope env, org.opengis.referencing.crs.CoordinateReferenceSystem crs)
          Transforms the envelope from its current crs to WGS84 coordinate system.
static com.vividsolutions.jts.geom.Coordinate transform(com.vividsolutions.jts.geom.Coordinate source, com.vividsolutions.jts.geom.Coordinate dest, org.opengis.referencing.operation.MathTransform transform)
          Transforms the coordinate using the provided math transform.
static com.vividsolutions.jts.geom.Envelope transform(com.vividsolutions.jts.geom.Envelope envelope, org.opengis.referencing.operation.MathTransform transform)
          Transforms the Envelope using the MathTransform.
static com.vividsolutions.jts.geom.Envelope transform(com.vividsolutions.jts.geom.Envelope envelope, org.opengis.referencing.operation.MathTransform transform, int npoints)
          Transforms the Envelope using the MathTransform.
static com.vividsolutions.jts.geom.Geometry transform(com.vividsolutions.jts.geom.Geometry geom, org.opengis.referencing.operation.MathTransform transform)
          Transforms the geometry using the default transformer.
static JTS.ReferencedEnvelope transform(JTS.ReferencedEnvelope envelope, org.opengis.referencing.crs.CoordinateReferenceSystem crs, boolean lenient)
           
static void xform(org.opengis.referencing.operation.MathTransform mt, double[] src, double[] dest, int dimensions)
          Like a transform but eXtreme!
static void xform(org.opengis.referencing.operation.MathTransform mt, double[] src, double[] dest, int dimensions, float failureThreshold)
          Like a transform but eXtreme!
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JTS

public JTS()
Method Detail

empty

public static com.vividsolutions.jts.geom.Envelope empty()

create

public static JTS.ReferencedEnvelope create(com.vividsolutions.jts.geom.Envelope env,
                                            org.opengis.referencing.crs.CoordinateReferenceSystem crs)

transform

public static com.vividsolutions.jts.geom.Envelope transform(com.vividsolutions.jts.geom.Envelope envelope,
                                                             org.opengis.referencing.operation.MathTransform transform,
                                                             int npoints)
                                                      throws org.opengis.referencing.operation.TransformException
Transforms the Envelope using the MathTransform. The envelope is densified (extra points put around the outside edge) to provide a 'better' new envelope for high deformed situations.

Parameters:
envelope - the envelope to transform
transform - the transformation to use
npoints - decification of each side of the rectange.
Returns:
a new Envelope
Throws:
org.opengis.referencing.operation.TransformException

xform

public static void xform(org.opengis.referencing.operation.MathTransform mt,
                         double[] src,
                         double[] dest,
                         int dimensions)
                  throws org.opengis.referencing.operation.TransformException
Like a transform but eXtreme! Transforms an array of coordinate using the provided math transform. Each Coordinate is transformed seperately. In case of a transform exception then the new value of the coordinate is the last coordinate correctly transformed.

Parameters:
mt -
src -
dest -
Throws:
org.opengis.referencing.operation.TransformException

xform

public static void xform(org.opengis.referencing.operation.MathTransform mt,
                         double[] src,
                         double[] dest,
                         int dimensions,
                         float failureThreshold)
                  throws org.opengis.referencing.operation.TransformException
Like a transform but eXtreme! Transforms an array of coordinate using the provided math transform. Each Coordinate is transformed seperately. In case of a transform exception then the new value of the coordinate is the last coordinate correctly transformed.

Parameters:
mt -
src -
dest -
Throws:
org.opengis.referencing.operation.TransformException

transform

public static com.vividsolutions.jts.geom.Envelope transform(com.vividsolutions.jts.geom.Envelope envelope,
                                                             org.opengis.referencing.operation.MathTransform transform)
                                                      throws org.opengis.referencing.operation.TransformException
Transforms the Envelope using the MathTransform.

Parameters:
envelope - the envelope to transform
transform - the transformation to use
Returns:
a new Envelope
Throws:
org.opengis.referencing.operation.TransformException

transform

public static JTS.ReferencedEnvelope transform(JTS.ReferencedEnvelope envelope,
                                               org.opengis.referencing.crs.CoordinateReferenceSystem crs,
                                               boolean lenient)
                                        throws org.opengis.referencing.operation.TransformException,
                                               org.opengis.referencing.operation.OperationNotFoundException,
                                               java.util.NoSuchElementException,
                                               org.opengis.referencing.FactoryException
Throws:
org.opengis.referencing.operation.TransformException
org.opengis.referencing.operation.OperationNotFoundException
java.util.NoSuchElementException
org.opengis.referencing.FactoryException

createGeometryTransformer

public static GeometryCoordinateSequenceTransformer createGeometryTransformer()
Creates a GeometryCoordinateSequenceTransformer. This basic transformer transforms the vertices and assumes that the underlying data structure is an array of Coordinate objects.

Returns:
a GeometryCoordinateSequenceTransformer

createPreciseGeometryTransformer

public static GeometryCoordinateSequenceTransformer createPreciseGeometryTransformer(double flatness)
Creates a GeometryCoordinateSequenceTransformer. This transformer is more accurate than the basic geometry transformer. It assumes that the underlying data structure is an array of Coordinate objects.

Parameters:
flatness - The error in the transform is linked to the "flattening", the higher the flattening, the bigger the error, but also, the lesser the number of points that will be used to represent the resulting coordinate sequence.
Returns:
a GeometryCoordinateSequenceTransformer

transform

public static com.vividsolutions.jts.geom.Geometry transform(com.vividsolutions.jts.geom.Geometry geom,
                                                             org.opengis.referencing.operation.MathTransform transform)
                                                      throws org.opengis.spatialschema.geometry.MismatchedDimensionException,
                                                             org.opengis.referencing.operation.TransformException
Transforms the geometry using the default transformer.

Parameters:
geom - The geom to transform
transform - the transform to use during the transformation.
Returns:
the transformed geometry. It will be a new geometry.
Throws:
org.opengis.spatialschema.geometry.MismatchedDimensionException
org.opengis.referencing.operation.TransformException

preciseTransform

public static com.vividsolutions.jts.geom.Geometry preciseTransform(com.vividsolutions.jts.geom.Geometry geom,
                                                                    double flatness,
                                                                    org.opengis.referencing.operation.MathTransform transform)
                                                             throws org.opengis.spatialschema.geometry.MismatchedDimensionException,
                                                                    org.opengis.referencing.operation.TransformException
Transforms the geometry using the Precise transformer.

Parameters:
geom - The geom to transform
flatness - the "flatness" of the new geometry. Higher is more accurate but has more vertices.
transform - the transform to use during the transformation.
Returns:
the transformed geometry. It will be a new geometry.
Throws:
org.opengis.spatialschema.geometry.MismatchedDimensionException
org.opengis.referencing.operation.TransformException

transform

public static com.vividsolutions.jts.geom.Coordinate transform(com.vividsolutions.jts.geom.Coordinate source,
                                                               com.vividsolutions.jts.geom.Coordinate dest,
                                                               org.opengis.referencing.operation.MathTransform transform)
                                                        throws org.opengis.referencing.operation.TransformException
Transforms the coordinate using the provided math transform.

Parameters:
source - the source coordinate that will be transformed
dest - the coordinate that will be set. May be null or the source coordinate (or new coordinate of course). return the destination coordinate if not null or a new Coordinate.
Throws:
org.opengis.referencing.operation.TransformException

toGeographic

public static com.vividsolutions.jts.geom.Envelope toGeographic(com.vividsolutions.jts.geom.Envelope env,
                                                                org.opengis.referencing.crs.CoordinateReferenceSystem crs)
                                                         throws org.opengis.referencing.operation.OperationNotFoundException,
                                                                java.util.NoSuchElementException,
                                                                org.opengis.referencing.FactoryException,
                                                                org.opengis.referencing.operation.TransformException
Transforms the envelope from its current crs to WGS84 coordinate system.

Parameters:
env - The envelope to transform.
crs - The CRS the envelope is currently in.
Returns:
The envelope transformed to be in WGS84 CRS.
Throws:
org.opengis.referencing.operation.OperationNotFoundException
java.util.NoSuchElementException
org.opengis.referencing.FactoryException
org.opengis.referencing.operation.TransformException
To Do:
We may catch some exceptions and rethrown them in a simplier one. After all, this is a convenience method (not an "official" one).


Copyright © GeoTools. All Rights Reserved.