| java.lang.Object org.geotools.referencing.CRS
CRS | final public class CRS (Code) | | Simple utility class for making use of the
and associated
implementations. 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
ReferencingFactoryFinder .
The following methods may be added in a future version:
-
CoordinateReferenceSystem parseXML(String)
since: 2.1 version: $Id: CRS.java 29058 2008-02-03 17:47:07Z desruisseaux $ author: Jody Garnett (Refractions Research) author: Martin Desruisseaux author: Andrea Aime |
Method Summary | |
public static CoordinateReferenceSystem | decode(String code) Return a Coordinate Reference System for the specified code.
Note that the code needs to mention the authority. | public static CoordinateReferenceSystem | decode(String code, boolean longitudeFirst) Return a Coordinate Reference System for the specified code, maybe forcing the axis order
to (longitude, latitude). | public static boolean | equalsIgnoreMetadata(Object object1, Object object2) Compares the specified objects for equality. | public static MathTransform | findMathTransform(CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS) Grab a transform between two Coordinate Reference Systems. | public static MathTransform | findMathTransform(CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, boolean lenient) Grab a transform between two Coordinate Reference Systems. | public static synchronized CRSAuthorityFactory | getAuthorityFactory(boolean longitudeFirst) Returns the CRS authority factory used by the
CRS.decode(String,boolean) decode methods.
This factory is
,
scans over
and
uses additional factories as
if there is more than one
for the same authority.
This factory can be used as a kind of system-wide factory for all authorities.
However for more determinist behavior, consider using a more specific factory (as returned
by
ReferencingFactoryFinder.getCRSAuthorityFactory when the authority in known.
Parameters: longitudeFirst - true if axis order should be forced to(longitude,latitude). | public static synchronized CoordinateOperationFactory | getCoordinateOperationFactory(boolean lenient) Returns the coordinate operation factory used by
CRS.findMathTransform(CoordinateReferenceSystem,CoordinateReferenceSystem)findMathTransform convenience methods. | public static Ellipsoid | getEllipsoid(CoordinateReferenceSystem crs) Returns the first ellipsoid found in a coordinate reference system,
or
null if there is none. | public static Envelope | getEnvelope(CoordinateReferenceSystem crs) Returns the valid area bounding box for the specified coordinate reference system, or
null if unknown. | public static GeographicBoundingBox | getGeographicBoundingBox(CoordinateReferenceSystem crs) Returns the valid geographic area for the specified coordinate reference system, or
null if unknown. | public static SingleCRS | getHorizontalCRS(CoordinateReferenceSystem crs) Returns the first horizontal coordinate reference system found in the given CRS,
or
null if there is none. | public static ProjectedCRS | getProjectedCRS(CoordinateReferenceSystem crs) Returns the first projected coordinate reference system found in a the given CRS,
or
null if there is none. | public static Set | getSupportedAuthorities(boolean returnAliases) Returns the set of the authority identifiers supported by registered authority factories.
This method search only for
.
Parameters: returnAliases - If true , the set will contain all identifiers for eachauthority. | public static Set | getSupportedCodes(String authority) Get the list of the codes that are supported by the given authority. | public static TemporalCRS | getTemporalCRS(CoordinateReferenceSystem crs) Returns the first temporal coordinate reference system found in the given CRS,
or
null if there is none. | public static Version | getVersion(String authority) Returns the version number of the specified authority database, or
null if
not available.
Parameters: authority - The authority name (typically "EPSG" ). | public static VerticalCRS | getVerticalCRS(CoordinateReferenceSystem crs) Returns the first vertical coordinate reference system found in a the given CRS,
or
null if there is none. | public static String | lookupIdentifier(IdentifiedObject object, boolean fullScan) Looks up an identifier for the specified object. | public static String | lookupIdentifier(CoordinateReferenceSystem crs, Set authorities, boolean fullScan) Looks up an identifier for the specified coordinate reference system.
Parameters: crs - the coordinate reference system looked up. Parameters: authorities - the authority that we should look up the identifier into. | public static void | main(String[] args) Prints to the
some information about
specified by their
authority codes. | public static CoordinateReferenceSystem | parseWKT(String wkt) Parses a
Well
Known Text (WKT) into a CRS object. | public static GeneralEnvelope | transform(MathTransform transform, Envelope envelope) Transforms an envelope using the given
.
The transformation is only approximative. | public static GeneralEnvelope | transform(CoordinateOperation operation, Envelope envelope) Transforms an envelope using the given
.
The transformation is only approximative. | public static Rectangle2D | transform(MathTransform2D transform, Rectangle2D envelope, Rectangle2D destination) Transforms a rectangular envelope using the given
.
The transformation is only approximative. | public static Rectangle2D | transform(CoordinateOperation operation, Rectangle2D envelope, Rectangle2D destination) Transforms a rectangular envelope using the given
. | static void | unexpectedException(String methodName, Exception exception) Invoked when an unexpected exception occured. |
decode | public static CoordinateReferenceSystem decode(String code) throws NoSuchAuthorityCodeException, FactoryException(Code) | | Return a Coordinate Reference System for the specified code.
Note that the code needs to mention the authority. Examples:
EPSG:1234
AUTO:42001, ..., ..., ...
If there is more than one factory implementation for the same authority, then all additional
factories are
to be used only when the first acceptable factory failed to create the requested CRS object.
CRS objects created by previous calls to this method are
using
. Subsequent calls to this
method with the same authority code should be fast, unless the CRS object has been garbage
collected.
Parameters: code - The Coordinate Reference System authority code. The Coordinate Reference System for the provided code. throws: NoSuchAuthorityCodeException - If the code could not be understood. throws: FactoryException - if the CRS creation failed for an other reason. See Also: CRS.getSupportedCodes See Also: org.geotools.referencing.factory.AllAuthoritiesFactory.createCoordinateReferenceSystem |
decode | public static CoordinateReferenceSystem decode(String code, boolean longitudeFirst) throws NoSuchAuthorityCodeException, FactoryException(Code) | | Return a Coordinate Reference System for the specified code, maybe forcing the axis order
to (longitude, latitude). The
code argument value is parsed
as in "
(code) ". The
longitudeFirst argument value controls the hints to be given to the
as in the following pseudo-code:
if (longitudeFirst) {
hints.put(
,
);
} else {
// Do not set the FORCE_LONGITUDE_FIRST_AXIS_ORDER hint to FALSE.
// Left it unset, which means "use system default".
}
The following table compare this method
longitudeFirst argument with the
hint meaning:
This method argument |
value |
Meaning |
true |
Boolean.TRUE TRUE |
All coordinate reference systems are forced to
(longitude, latitude) axis order. |
false |
null |
Coordinate reference systems may or may not be forced to
(longitude, latitude) axis order. The behavior depends on user
setting, for example the value of the
system property. |
|
Boolean.FALSE FALSE |
Forcing (longitude, latitude) axis order is not allowed,
no matter the value of the
system property. |
Parameters: code - The Coordinate Reference System authority code. Parameters: longitudeFirst - true if axis order should be forced to(longitude, latitude). Note that false means"use default", not "latitude first". The Coordinate Reference System for the provided code. throws: NoSuchAuthorityCodeException - If the code could not be understood. throws: FactoryException - if the CRS creation failed for an other reason. See Also: CRS.getSupportedCodes See Also: Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER since: 2.3 |
equalsIgnoreMetadata | public static boolean equalsIgnoreMetadata(Object object1, Object object2)(Code) | | Compares the specified objects for equality. If both objects are Geotools
implementations of class
AbstractIdentifiedObject , then this method
will ignore the metadata during the comparaison.
Parameters: object1 - The first object to compare (may be null). Parameters: object2 - The second object to compare (may be null). true if both objects are equals. since: 2.2 |
findMathTransform | public static MathTransform findMathTransform(CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS) throws FactoryException(Code) | | Grab a transform between two Coordinate Reference Systems. This convenience method is a
shorthand for the following:
FactoryFinder.
(null).
(sourceCRS, targetCRS).
();
Note that some metadata like
are lost by this method. If those metadata are wanted, use the
directly.
Sample use:
transform = CRS.findMathTransform(
CRS.
("EPSG:42102"),
CRS.
("EPSG:4326") );
Parameters: sourceCRS - The source CRS. Parameters: targetCRS - The target CRS. The math transform from sourceCRS to targetCRS . throws: FactoryException - If no math transform can be created for the specified source andtarget CRS. |
findMathTransform | public static MathTransform findMathTransform(CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, boolean lenient) throws FactoryException(Code) | | Grab a transform between two Coordinate Reference Systems. This method is similar to
(sourceCRS, targetCRS) , except that it can optionally tolerate
lenient datum shift. If the
lenient argument is
true ,
then this method will not throw a "Bursa-Wolf parameters required"
exception during datum shifts if the Bursa-Wolf paramaters are not specified.
Instead it will assume a no datum shift.
Parameters: sourceCRS - The source CRS. Parameters: targetCRS - The target CRS. Parameters: lenient - true if the math transform should be created even when there isno information available for a datum shift. The default value is false . The math transform from sourceCRS to targetCRS . throws: FactoryException - If no math transform can be created for the specified source andtarget CRS. See Also: Hints.LENIENT_DATUM_SHIFT |
getAuthorityFactory | public static synchronized CRSAuthorityFactory getAuthorityFactory(boolean longitudeFirst) throws FactoryRegistryException(Code) | | Returns the CRS authority factory used by the
CRS.decode(String,boolean) decode methods.
This factory is
,
scans over
and
uses additional factories as
if there is more than one
for the same authority.
This factory can be used as a kind of system-wide factory for all authorities.
However for more determinist behavior, consider using a more specific factory (as returned
by
ReferencingFactoryFinder.getCRSAuthorityFactory when the authority in known.
Parameters: longitudeFirst - true if axis order should be forced to(longitude,latitude). Note that false means"use default", not "latitude first". The CRS authority factory. throws: FactoryRegistryException - if the factory can't be created. since: 2.3 |
getCoordinateOperationFactory | public static synchronized CoordinateOperationFactory getCoordinateOperationFactory(boolean lenient)(Code) | | Returns the coordinate operation factory used by
CRS.findMathTransform(CoordinateReferenceSystem,CoordinateReferenceSystem)findMathTransform convenience methods.
Parameters: lenient - true if the coordinate operations should be createdeven when there is no information available for a datum shift. since: 2.4 |
getEllipsoid | public static Ellipsoid getEllipsoid(CoordinateReferenceSystem crs)(Code) | | Returns the first ellipsoid found in a coordinate reference system,
or
null if there is none.
since: 2.4 |
getEnvelope | public static Envelope getEnvelope(CoordinateReferenceSystem crs)(Code) | | Returns the valid area bounding box for the specified coordinate reference system, or
null if unknown. This method search in the metadata informations associated with
the given CRS. The returned envelope is expressed in terms of the specified CRS.
Parameters: crs - The coordinate reference system, or null . The envelope in terms of the specified CRS, or null if none. since: 2.2 |
getGeographicBoundingBox | public static GeographicBoundingBox getGeographicBoundingBox(CoordinateReferenceSystem crs)(Code) | | Returns the valid geographic area for the specified coordinate reference system, or
null if unknown. This method search in the metadata informations associated
with the given CRS.
Parameters: crs - The coordinate reference system, or null . The geographic area, or null if none. since: 2.3 |
getHorizontalCRS | public static SingleCRS getHorizontalCRS(CoordinateReferenceSystem crs)(Code) | | Returns the first horizontal coordinate reference system found in the given CRS,
or
null if there is none. A horizontal CRS is usually a two-dimensional
or
CRS.
since: 2.4 |
getProjectedCRS | public static ProjectedCRS getProjectedCRS(CoordinateReferenceSystem crs)(Code) | | Returns the first projected coordinate reference system found in a the given CRS,
or
null if there is none.
since: 2.4 |
getSupportedAuthorities | public static Set getSupportedAuthorities(boolean returnAliases)(Code) | | Returns the set of the authority identifiers supported by registered authority factories.
This method search only for
.
Parameters: returnAliases - If true , the set will contain all identifiers for eachauthority. If false , only the first one The set of supported authorities. May be empty, but never null. since: 2.3.1 |
getSupportedCodes | public static Set getSupportedCodes(String authority)(Code) | | Get the list of the codes that are supported by the given authority. For example
getSupportedCodes("EPSG") may returns
"EPSG:2000" ,
"EPSG:2001" ,
"EPSG:2002" , etc. It may also returns
"2000" ,
"2001" ,
"2002" , etc. without the
"EPSG:" prefix. Whatever the authority
name is prefixed or not is factory implementation dependent.
If there is more than one factory for the given authority, then this method merges the
code set of all of them. If a factory fails to provide a set of supported code, then
this particular factory is ignored. Please be aware of the following potential issues:
- If there is more than one EPSG databases (for example an
and a
ones),
then this method will connect to all of them even if their content are identical.
- If two factories format their codes differently (e.g.
"4326" and
"EPSG:4326" ), then the returned set will contain a lot of synonymous
codes.
- For any code c in the returned set, there is no warranty that
(c) will use the same authority
factory than the one that formatted c.
- This method doesn't report connection problems since it doesn't throw any exception.
FactoryException s are logged as warnings and otherwise ignored.
If a more determinist behavior is wanted, consider the code below instead.
The following code exploit only one factory, the "preferred" one.
factory = FactoryFinder.
(authority, null);
Set<String> codes = factory.
(CoordinateReferenceSystem.class);
String code = ...choose a code here...
crs = factory.createCoordinateReferenceSystem(code);
Parameters: authority - The authority name (for example "EPSG" ). The set of supported codes. May be empty, but never null. |
getTemporalCRS | public static TemporalCRS getTemporalCRS(CoordinateReferenceSystem crs)(Code) | | Returns the first temporal coordinate reference system found in the given CRS,
or
null if there is none.
since: 2.4 |
getVersion | public static Version getVersion(String authority) throws FactoryRegistryException(Code) | | Returns the version number of the specified authority database, or
null if
not available.
Parameters: authority - The authority name (typically "EPSG" ). The version number of the authority database, or null if unknown. throws: FactoryRegistryException - if no CRSAuthorityFactory implementationwas found for the specified authority. since: 2.4 |
getVerticalCRS | public static VerticalCRS getVerticalCRS(CoordinateReferenceSystem crs)(Code) | | Returns the first vertical coordinate reference system found in a the given CRS,
or
null if there is none.
since: 2.4 |
lookupIdentifier | public static String lookupIdentifier(IdentifiedObject object, boolean fullScan) throws FactoryException(Code) | | Looks up an identifier for the specified object. This method searchs in registered factories
for an object
, to the specified
object. If such object is found, then its identifier is returned. Otherwise this method
returns
null .
This convenience method delegates its work to
IdentifiedObjectFinder . Consider using
the later if more control are wanted, for example if the search shall be performed only on
some
instead of all registered onez, or
if the full
is wanted instead of only its
identifier.
Parameters: object - The object (usually a ) looked up. Parameters: fullScan - If true , an exhaustive full scan against all registered objectswill be performed (may be slow). Otherwise only a fast lookup based on embeddedidentifiers and names will be performed. The identifier, or null if not found. throws: FactoryException - if an unexpected failure occured during the search. See Also: AbstractAuthorityFactory.getIdentifiedObjectFinder See Also: IdentifiedObjectFinder.find since: 2.4 |
lookupIdentifier | public static String lookupIdentifier(CoordinateReferenceSystem crs, Set authorities, boolean fullScan)(Code) | | Looks up an identifier for the specified coordinate reference system.
Parameters: crs - the coordinate reference system looked up. Parameters: authorities - the authority that we should look up the identifier into. If null the search will to be performed against all authorities. Parameters: fullScan - if true , an exhaustive full scan against all registered CRSwill be performed (may be slow). Otherwise only a fast lookup based on embeddedidentifiers and names will be performed. The identifier, or null if not found. since: 2.3.1CRS.lookupIdentifier(IdentifiedObject,boolean) |
main | public static void main(String[] args)(Code) | | Prints to the
some information about
specified by their
authority codes. This method can be invoked from the command line in order to test the
content for some specific CRS.
By default, this method prints all enumerated objects as Well Known Text.
However this method can prints different kind of information if an option such as
-factories ,
-codes or
-bursawolfs is provided.
Usage:
java org.geotools.referencing.CRS [options] [codes]
Options:
-authority =name
Uses the specified authority factory, for example
"EPSG" . The authority
name can be any of the authorities listed by the
-factories option. If
this option is not specified, then the default is all factories.
-bursawolfs codes
Lists the Bursa-Wolf parameters for the specified CRS ou datum objects. For some
transformations, there is more than one set of Bursa-Wolf parameters available.
The standard Well Known Text format prints only what look like the
"main" one. This option display all Bursa-Wolf parameters in a table for a given
object.
-codes
Lists all available authority codes. Use the
-authority option if the
list should be restricted to a single authority.
-colors
Enable syntax coloring on ANSI
X3.64 compatible (aka ECMA-48 and ISO/IEC 6429) terminal. This option tries to
highlight most of the elements relevant to the
CRS.equalsIgnoreMetadataequalsIgnoreMetadata method, with the addition of Bursa-Wolf parameters.
-encoding =charset
Sets the console encoding for this application output. This value has no impact
on data, but may improve the output quality. This is not needed on Linux terminal
using UTF-8 encoding (tip: the terminus font gives good results).
Windows users may need to set this encoding to the value returned by the
chcp command line. This parameter need to be specified only once.
-dependencies
Lists authority factory dependencies as a tree.
-factories
Lists all availables CRS authority factories.
-forcexy
Force "longitude first" axis order.
-help
Prints the list of options.
-locale =name
Formats texts in the specified
.
-operations sourceCRS targetCRS
Prints all available coordinate operations between a pair of CRS. This option
prints only the operations explicitly defined in a database like EPSG. There
is sometime many such operations, and sometime none (in which case this option
prints nothing - it doesn't try to find an operation by itself).
-transform sourceCRS targetCRS
Prints the preferred math transform between a pair of CRS. At the difference of
the
"-operations" option, this option pick up only one operation (usually
the most accurate one), inferring it if none were explicitly specified in the
database.
Examples (assuming that
"CRS" is a shortcut for
"java org.geotools.referencing.CRS" ):
CRS EPSG:4181 EPSG:4326 CRS:84 AUTO:42001,30,0
Prints the "Luxembourg 1930" CRS, the "WGS 84" CRS (from EPSG database),
the ""WGS84" CRS (from the Web Map Service specification) and a UTM
projection in WKT format.
CRS -authority=EPSG 4181 4326
Prints the "Luxembourg 1930" and "WGS 84" CRS, looking only in the EPSG
database (so there is no need to prefix the codes with
"EPSG" ).
CRS -colors EPSG:7411
Prints the "NTF (Paris) / Lambert zone II + NGF Lallemand" CRS with syntax
coloring enabled.
CRS -bursawolfs EPSG:4230
Prints three set of Bursa-Wolf parameters for a CRS based on
"European Datum 1950".
CRS -authority=EPSG -operations 4230 4326
Prints all operations declared in the EPSG database from "ED50" to "WGS 84"
geographic CRS. Note that for this particular pair of CRS, there is close
to 40 operations declared in the EPSG database. This method prints only the
ones that Geotools can handle.
CRS -transform EPSG:4230 EPSG:4326
Prints the math transform that Geotools would use by default for coordinate
transformation from "ED50" to "WGS 84".
Parameters: args - Options and list of object codes to display. since: 2.4 |
parseWKT | public static CoordinateReferenceSystem parseWKT(String wkt) throws FactoryException(Code) | | Parses a
Well
Known Text (WKT) into a CRS object. This convenience method is a
shorthand for the following:
FactoryFinder.
(null).
(wkt);
|
transform | public static GeneralEnvelope transform(MathTransform transform, Envelope envelope) throws TransformException(Code) | | Transforms an envelope using the given
.
The transformation is only approximative. Note that the returned envelope may not
have the same number of dimensions than the original envelope.
Note that this method can not handle the case where the envelope contains the North or
South pole, or when it cross the ±180� longitude, because
do not carry suffisient informations. For a more robust envelope
transformation, use
CRS.transform(CoordinateOperation,Envelope) instead.
Parameters: transform - The transform to use. Parameters: envelope - Envelope to transform, or null . This envelope will not be modified. The transformed envelope, or null if envelope was null. throws: TransformException - if a transform failed. since: 2.4 |
transform | public static GeneralEnvelope transform(CoordinateOperation operation, Envelope envelope) throws TransformException(Code) | | Transforms an envelope using the given
.
The transformation is only approximative. Note that the returned envelope may not have the
same number of dimensions than the original envelope.
This method can handle the case where the envelope contains the North or South pole,
or when it cross the ±180� longitude.
Parameters: operation - The operation to use. Source and target dimension must be 2. Parameters: envelope - Envelope to transform, or null . This envelope will not be modified. The transformed envelope, or null if envelope was null. throws: TransformException - if a transform failed. since: 2.4 |
transform | public static Rectangle2D transform(MathTransform2D transform, Rectangle2D envelope, Rectangle2D destination) throws TransformException(Code) | | Transforms a rectangular envelope using the given
.
The transformation is only approximative. Invoking this method is equivalent to invoking the
following:
transform(transform, new GeneralEnvelope(envelope)).toRectangle2D()
Note that this method can not handle the case where the rectangle contains the North or
South pole, or when it cross the ±180� longitude, because
do not carry suffisient informations. For a more robust rectangle
transformation, use
CRS.transform(CoordinateOperation,Rectangle2D,Rectangle2D) instead.
Parameters: transform - The transform to use. Source and target dimension must be 2. Parameters: envelope - The rectangle to transform (may be null ). Parameters: destination - The destination rectangle (may be envelope ).If null , a new rectangle will be created and returned. destination , or a new rectangle if destination was non-nulland envelope was null. throws: TransformException - if a transform failed. since: 2.4 |
transform | public static Rectangle2D transform(CoordinateOperation operation, Rectangle2D envelope, Rectangle2D destination) throws TransformException(Code) | | Transforms a rectangular envelope using the given
. The transformation is only approximative. Invoking this method is equivalent to
invoking the following:
transform(operation, new GeneralEnvelope(envelope)).toRectangle2D()
This method can handle the case where the rectangle contains the North or South pole,
or when it cross the ±180� longitude.
Parameters: operation - The operation to use. Source and target dimension must be 2. Parameters: envelope - The rectangle to transform (may be null ). Parameters: destination - The destination rectangle (may be envelope ).If null , a new rectangle will be created and returned. destination , or a new rectangle if destination was non-nulland envelope was null. throws: TransformException - if a transform failed. since: 2.4 |
unexpectedException | static void unexpectedException(String methodName, Exception exception)(Code) | | Invoked when an unexpected exception occured. Those exceptions must be non-fatal,
i.e. the caller must have a raisonable fallback (otherwise it
should propagate the exception).
|
|
|