org.geotools.referencing
Class CRS

java.lang.Object
  extended byorg.geotools.referencing.CRS

public class CRS
extends java.lang.Object

Simple utility class for making use of the CoordinateReferenceSystem and associated Factory implementations.

Other proposals:

Note: this utility class is made up of static final functions, this class is not a Factory or a Builder. It makes use of the GeoAPI Factory interfaces provided by FactoryFinder in the most direct manner possible.

Since:
2.1.0
Version:
$Id$
Author:
Jody Garnett, Refractions Research

Nested Class Summary
static interface CRS.OperationVisitor
          Implement this method to visit each available CoordinateOperationFactory known to FactoryFinder.
 
Constructor Summary
CRS()
           
 
Method Summary
static org.opengis.referencing.crs.CoordinateReferenceSystem decode(java.lang.String code)
          Locate for CoordinateReferenceSystem for specific code.
static double distance(com.vividsolutions.jts.geom.Coordinate p1, com.vividsolutions.jts.geom.Coordinate p2, org.opengis.referencing.crs.CoordinateReferenceSystem crs)
          ESTIMATE the distance between the two points. 1. transforms both points to lat/lon 2. find the distance between the two points NOTE: we're using ellipsoid calculations.
static java.util.Set getSupportedCodes(java.lang.String AUTHORITY)
          Get list of the codes that are supported by the authority.
static org.opengis.referencing.crs.CoordinateReferenceSystem parseWKT(java.lang.String wkt)
          Parse WKT into a CRS object
static org.opengis.referencing.operation.MathTransform transform(org.opengis.referencing.crs.CoordinateReferenceSystem from, org.opengis.referencing.crs.CoordinateReferenceSystem to)
          Grab transform between two CoordianteReference Systems.
static org.opengis.referencing.operation.MathTransform transform(org.opengis.referencing.crs.CoordinateReferenceSystem from, org.opengis.referencing.crs.CoordinateReferenceSystem to, boolean lenientTransforms)
          Grab transform between two CoordianteReference Systems.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CRS

public CRS()
Method Detail

transform

public static org.opengis.referencing.operation.MathTransform transform(org.opengis.referencing.crs.CoordinateReferenceSystem from,
                                                                        org.opengis.referencing.crs.CoordinateReferenceSystem to,
                                                                        boolean lenientTransforms)
                                                                 throws org.opengis.referencing.FactoryException
Grab transform between two CoordianteReference Systems.

Sample use:


 MathTransform transform = CRS.transform( CRS.decode("EPSG:42102"), CRS.decode("EPSG:4326") ); 
 

Parameters:
from -
to -
lenientTransforms - if true then the transforms created will not throw bursa wolf required exception during datum shifts if the bursa wolf paramaters are not specified. Instead it will assume a no datum shift.
Returns:
MathTransform, or null if unavailable
Throws:
org.opengis.referencing.FactoryException - only if MathTransform is unavailable due to error

transform

public static org.opengis.referencing.operation.MathTransform transform(org.opengis.referencing.crs.CoordinateReferenceSystem from,
                                                                        org.opengis.referencing.crs.CoordinateReferenceSystem to)
                                                                 throws org.opengis.referencing.FactoryException
Grab transform between two CoordianteReference Systems.

Sample use:


 MathTransform transform = CRS.transform( CRS.decode("EPSG:42102"), CRS.decode("EPSG:4326") ); 
 

Parameters:
from -
to -
Returns:
MathTransform, or null if unavailable
Throws:
org.opengis.referencing.FactoryException - only if MathTransform is unavailable due to error

getSupportedCodes

public static java.util.Set getSupportedCodes(java.lang.String AUTHORITY)
Get list of the codes that are supported by the authority. For example, "EPSG" --> "EPSG:2000", "EPSG:2001", "EPSG:2002" because we know what they mean.


parseWKT

public static org.opengis.referencing.crs.CoordinateReferenceSystem parseWKT(java.lang.String wkt)
                                                                      throws org.opengis.referencing.FactoryException
Parse WKT into a CRS object

Throws:
org.opengis.referencing.FactoryException

decode

public static org.opengis.referencing.crs.CoordinateReferenceSystem decode(java.lang.String code)
                                                                    throws org.opengis.referencing.NoSuchAuthorityCodeException
Locate for CoordinateReferenceSystem for specific code.

Note the code needs to mention the authority.


 EPSG:1234
 AUTO:42001, ..., ..., ...
 

Parameters:
code -
Returns:
coordinate system for the provided code
Throws:
org.opengis.referencing.NoSuchAuthorityCodeException - If the code could not be understood

distance

public static double distance(com.vividsolutions.jts.geom.Coordinate p1,
                              com.vividsolutions.jts.geom.Coordinate p2,
                              org.opengis.referencing.crs.CoordinateReferenceSystem crs)
                       throws java.lang.Exception
ESTIMATE the distance between the two points. 1. transforms both points to lat/lon 2. find the distance between the two points NOTE: we're using ellipsoid calculations.

Parameters:
p1 - first point
p2 - second point
crs - reference system the two points are in
Returns:
approximate distance between the two points, in meters
Throws:
java.lang.Exception


Copyright © GeoTools. All Rights Reserved.