org.geotools.geometry.jts
Class JTS

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

public final class JTS
extends java.lang.Object

JTS Geometry utility methods, bringing Geotools to JTS.

Offers geotools based services such as reprojection.

Responsibilities:

Since:
2.2
Version:
$Id: JTS.java 17701 2006-01-23 00:00:51Z desruisseaux $
Author:
Jody Garnett, Martin Desruisseaux

Method Summary
static void copy(com.vividsolutions.jts.geom.Coordinate point, double[] ordinates)
          Copies the ordinates values from the specified JTS coordinates to the specified array.
static double orthodromicDistance(com.vividsolutions.jts.geom.Coordinate p1, com.vividsolutions.jts.geom.Coordinate p2, org.opengis.referencing.crs.CoordinateReferenceSystem crs)
          Computes the orthodromic distance between two points.
static com.vividsolutions.jts.geom.Geometry shapeToGeometry(java.awt.Shape shape, com.vividsolutions.jts.geom.GeometryFactory factory)
          Converts an arbitrary Java2D shape into a JTS geometry.
static com.vividsolutions.jts.geom.Envelope toGeographic(com.vividsolutions.jts.geom.Envelope envelope, org.opengis.referencing.crs.CoordinateReferenceSystem crs)
          Transforms the envelope from its current crs to WGS84 coordinate reference 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 sourceEnvelope, com.vividsolutions.jts.geom.Envelope targetEnvelope, org.opengis.referencing.operation.MathTransform transform, int npoints)
          Transforms the densified envelope using the specified 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 specified math transform.
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 void xform(org.opengis.referencing.operation.MathTransform mt, double[] src, double[] dest)
          Like a transform but eXtreme!
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

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 specified math transform.

Parameters:
envelope - The envelope to transform.
transform - The transform to use.
Returns:
The transformed Envelope
Throws:
org.opengis.referencing.operation.TransformException - if at least one coordinate can't be transformed.

transform

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

If an optional target envelope is provided, this envelope will be expanded with the transformation result. It will not be nullified before the expansion.

Parameters:
sourceEnvelope - The envelope to transform.
targetEnvelope - An envelope to expand with the transformation result, or for returning an new envelope.
transform - The transform to use.
npoints - Densification of each side of the rectange.
Returns:
if it was non-null, or a new envelope otherwise. In all case, the returned envelope fully contains the transformed envelope.
Throws:
org.opengis.referencing.operation.TransformException - if a coordinate can't be transformed.

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 - if the geometry doesn't have the expected dimension for the specified transform.
org.opengis.referencing.operation.TransformException - if a point can't be transformed.

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).
Returns:
the destination coordinate if not null or a new Coordinate.
Throws:
org.opengis.referencing.operation.TransformException - if the coordinate can't be transformed.

toGeographic

public static com.vividsolutions.jts.geom.Envelope toGeographic(com.vividsolutions.jts.geom.Envelope envelope,
                                                                org.opengis.referencing.crs.CoordinateReferenceSystem crs)
                                                         throws org.opengis.referencing.operation.TransformException
Transforms the envelope from its current crs to WGS84 coordinate reference system. If the specified envelope is already in WGS84, then it is returned unchanged.

Parameters:
envelope - 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.TransformException - If at least one coordinate can't be transformed.

xform

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

Parameters:
mt - The math transform to apply.
src - The source coordinates.
dest - The destination array for transformed coordinates.
Throws:
org.opengis.referencing.operation.TransformException - if this method failed to transform any of the points.

orthodromicDistance

public static double orthodromicDistance(com.vividsolutions.jts.geom.Coordinate p1,
                                         com.vividsolutions.jts.geom.Coordinate p2,
                                         org.opengis.referencing.crs.CoordinateReferenceSystem crs)
                                  throws org.opengis.referencing.operation.TransformException
Computes the orthodromic distance between two points. This method:

  1. Transforms both points to geographic coordinates (latitude,longitude).
  2. Computes the orthodromic distance between the two points using ellipsoidal calculations.

The real work is performed by GeodeticCalculator. This convenience method simply manages a pool of pre-defined geodetic calculators for the given coordinate reference system in order to avoid repetitive object creation. If a large amount of orthodromic distances need to be computed, direct use of GeodeticCalculator provides better performance than this convenience method.

Parameters:
p1 - First point
p2 - Second point
crs - Reference system the two points are in.
Returns:
Orthodromic distance between the two points, in meters.
Throws:
org.opengis.referencing.operation.TransformException - if the coordinates can't be transformed from the specified CRS to a geographic CRS.

copy

public static void copy(com.vividsolutions.jts.geom.Coordinate point,
                        double[] ordinates)
Copies the ordinates values from the specified JTS coordinates to the specified array. The destination array can have any length. Only the relevant field of the source coordinate will be copied. If the array length is greater than 3, then all extra dimensions will be set to NaN.

Parameters:
point - The source coordinate.
ordinates - The destination array.

shapeToGeometry

public static com.vividsolutions.jts.geom.Geometry shapeToGeometry(java.awt.Shape shape,
                                                                   com.vividsolutions.jts.geom.GeometryFactory factory)
Converts an arbitrary Java2D shape into a JTS geometry. The created JTS geometry may be any of LineString, LinearRing or MultiLineString.

Parameters:
shape - The Java2D shape to create.
factory - The JTS factory to use for creating geometry.
Returns:
The JTS geometry.


Copyright © GeoTools. All Rights Reserved.