Class CRS
ReferencingFactoryFinder.
The following methods may be added in a future version:
CoordinateReferenceSystem parseXML(String)
When using CoordinateReferenceSystem matching methods of this class (equalsIgnoreMetadata(Object, Object),lookupIdentifier(IdentifiedObject, boolean), lookupEpsgCode(CoordinateReferenceSystem, boolean), lookupIdentifier(IdentifiedObject, boolean), lookupIdentifier(Citation, CoordinateReferenceSystem, boolean)) against objects derived from a database other than the official EPSG one it may
be advisable to set a non zero comparison tolerance with Hints.putSystemDefault(java.awt.RenderingHints.Key, Object) using the Hints.COMPARISON_TOLERANCE key. A value of 10e-9 has proved to give satisfactory results
with definitions commonly found in .prj files accompaining shapefiles and georeferenced images.
Warning: the tolerance value is used in all internal comparison, this will also change the way math transforms
are setup. Use with care.
- Since:
- 2.1
- Author:
- Jody Garnett (Refractions Research), Martin Desruisseaux, Andrea Aime
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumeration describing axis order for geographic coordinate reference systems. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidCleans up the thread local set in this thread.static CoordinateReferenceSystemReturn a Coordinate Reference System for the specified code.static CoordinateReferenceSystemReturn a Coordinate Reference System for the specified code, maybe forcing the axis order to (longitude, latitude).static booleanequalsIgnoreMetadata(Object object1, Object object2) Compares the specified objects for equality.static MathTransformfindMathTransform(CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS) Grab a transform between two Coordinate Reference Systems.static MathTransformfindMathTransform(CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, boolean lenient) Grab a transform between two Coordinate Reference Systems.static MathTransformfindMathTransform(CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, String transformCode) Grab a transform between two Coordinate Reference Systems with the required transformation being used.static CRSAuthorityFactorygetAuthorityFactory(boolean longitudeFirst) Returns the CRS authority factory used by thedecodemethods.static CRS.AxisOrderDetermines the axis ordering of a specified crs object.static CRS.AxisOrdergetAxisOrder(CoordinateReferenceSystem crs, boolean useBaseGeoCRS) Determines the axis ordering of a specified crs object.static CoordinateOperationFactorygetCoordinateOperationFactory(boolean lenient) Returns the coordinate operation factory used byfindMathTransformconvenience methods.static EllipsoidReturns the first ellipsoid found in a coordinate reference system, ornullif there is none.static BoundsReturns the domain of validity for the specified coordinate reference system, ornullif unknown.static GeographicBoundingBoxReturns the valid geographic area for the specified coordinate reference system, ornullif unknown.static SingleCRSReturns the first horizontal coordinate reference system found in the given CRS, ornullif there is none.static MapProjectionReturns theMapProjectiondriving the specified crs, ornullif none could be found.static ProjectedCRSReturns the first projected coordinate reference system found in a the given CRS, ornullif there is none.getSupportedAuthorities(boolean returnAliases) Returns the set of the authority identifiers supported by registered authority factories.getSupportedCodes(String authority) Get the list of the codes that are supported by the given authority.static TemporalCRSReturns the first temporal coordinate reference system found in the given CRS, ornullif there is none.static Map<String,AbstractCoordinateOperation> getTransforms(CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS) List the availableDefaultConcatenatedOperationfrom sourceCRS to targetCRSstatic VersiongetVersion(String authority) Returns the version number of the specified authority database, ornullif not available.static VerticalCRSReturns the first vertical coordinate reference system found in a the given CRS, ornullif there is none.static booleanisCompatible(CoordinateReferenceSystem sourceCrs, CoordinateReferenceSystem targetCrs, boolean allowDifferentDimension) Determines if one coordinate reference system is compatible with another, i.e. can be transformed to the otherstatic booleanisEquivalent(CoordinateReferenceSystem source, CoordinateReferenceSystem target) This method is checking if the 2 CRSs are equivalent by first using the equalsIgnoreMetadata approach and then looking for an identity transformation between the 2 CRSs if the first check fails.static booleanChecks if a transformation is required to go from source to target.static IntegerlookupEpsgCode(CoordinateReferenceSystem crs, boolean fullScan) Looks up an EPSG code for the given coordinate reference system).static StringlookupIdentifier(Citation authority, CoordinateReferenceSystem crs, boolean fullScan) Looks up an identifier of the specified authority for the given coordinate reference system).static StringlookupIdentifier(IdentifiedObject object, boolean fullScan) Looks up an identifier for the specified object.static voidPrints to the standard output stream some information about coordinate reference systems specified by their authority codes.static CoordinateReferenceSystemParses a Well Known Text (WKT) into a CRS object.static voidResets some aspects of the referencing system.static StringReturns the Spatial Reference System identifier, ornullif none.static StringtoSRS(CoordinateReferenceSystem crs, boolean codeOnly) Returns the Spatial Reference System identifier, ornullif none.static GeneralBoundstransform(Bounds envelope, CoordinateReferenceSystem targetCRS) Transforms the given envelope to the specified CRS.static Rectangle2Dtransform(CoordinateOperation operation, Rectangle2D envelope, Rectangle2D destination) Transforms a rectangular envelope using the given coordinate operation.static GeneralBoundstransform(CoordinateOperation operation, Bounds envelope) Transforms an envelope using the given coordinate operation.static Rectangle2Dtransform(MathTransform2D transform, Rectangle2D rectangle) Transforms an rectangular envelope using the given math transform.static Rectangle2Dtransform(MathTransform2D transform, Rectangle2D envelope, Rectangle2D destination) Transforms a rectangular envelope using the given math transform.static GeneralBoundstransform(MathTransform transform, Bounds envelope) Transforms an envelope using the given math transform.
-
Method Details
-
getAuthorityFactory
public static CRSAuthorityFactory getAuthorityFactory(boolean longitudeFirst) throws FactoryRegistryException Returns the CRS authority factory used by thedecodemethods. This factory is buffered, scans over all factories and uses additional factories as fallbacks if there is more than one registered factory 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(java.lang.String, org.geotools.util.factory.Hints)when the authority in known.- Parameters:
longitudeFirst-trueif axis order should be forced to (longitude,latitude). Note thatfalsemeans "use default", not "latitude first".- Returns:
- The CRS authority factory.
- Throws:
FactoryRegistryException- if the factory can't be created.- Since:
- 2.3
-
isCompatible
public static boolean isCompatible(CoordinateReferenceSystem sourceCrs, CoordinateReferenceSystem targetCrs, boolean allowDifferentDimension) Determines if one coordinate reference system is compatible with another, i.e. can be transformed to the other- Parameters:
sourceCrs- the source CRStargetCrs- the target CRSallowDifferentDimension- if true, returns false if CRS's have different dimensions regardless of the ability to transform.- Returns:
- compatibility as boolean
-
getCoordinateOperationFactory
Returns the coordinate operation factory used byfindMathTransformconvenience methods.- Parameters:
lenient-trueif the coordinate operations should be created even when there is no information available for a datum shift.- Since:
- 2.4
-
getVersion
Returns the version number of the specified authority database, ornullif not available.- Parameters:
authority- The authority name (typically"EPSG").- Returns:
- The version number of the authority database, or
nullif unknown. - Throws:
FactoryRegistryException- if noCRSAuthorityFactoryimplementation was found for the specified authority.- Since:
- 2.4
-
getSupportedCodes
Get the list of the codes that are supported by the given authority. For examplegetSupportedCodes("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 Access and a PostgreSQL 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
decode(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.
FactoryExceptions 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.
CRSAuthorityFactory factory = FactoryFinder.getCRSAuthorityFactory(authority, null);
Set<String> codes = factory.getAuthorityCodes(CoordinateReferenceSystem.class);
String code = ...choose a code here...
CoordinateReferenceSystem crs = factory.createCoordinateReferenceSystem(code);- Parameters:
authority- The authority name (for example"EPSG").- Returns:
- The set of supported codes. May be empty, but never null.
-
getSupportedAuthorities
Returns the set of the authority identifiers supported by registered authority factories. This method search only for CRS authority factories.- Parameters:
returnAliases- Iftrue, the set will contain all identifiers for each authority. Iffalse, only the first one- Returns:
- The set of supported authorities. May be empty, but never null.
- Since:
- 2.3.1
-
decode
public static CoordinateReferenceSystem decode(String code) throws NoSuchAuthorityCodeException, FactoryException Return a Coordinate Reference System for the specified code. Note that the code needs to mention the authority. Examples:
If there is more than one factory implementation for the same authority, then all additional factories are fallbacks to be used only when the first acceptable factory failed to create the requested CRS object.EPSG:1234 AUTO:42001, ..., ..., ...
CRS objects created by previous calls to this method are cached in a buffer using weak references. 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.- Returns:
- The Coordinate Reference System for the provided code.
- Throws:
NoSuchAuthorityCodeException- If the code could not be understood.FactoryException- if the CRS creation failed for an other reason.- See Also:
-
decode
public static CoordinateReferenceSystem decode(String code, boolean longitudeFirst) throws NoSuchAuthorityCodeException, FactoryException Return a Coordinate Reference System for the specified code, maybe forcing the axis order to (longitude, latitude). Thecodeargument value is parsed as in "decode(code)". ThelongitudeFirstargument value controls the hints to be given to the factory finder as in the following pseudo-code:
The following table compare this methodif (longitudeFirst) { hints.put(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE); } else { // Do not set the FORCE_LONGITUDE_FIRST_AXIS_ORDER hint to FALSE. // Left it unset, which means "use system default". }longitudeFirstargument with the hint meaning:This method argument Hint value Meaning trueTRUEAll coordinate reference systems are forced to (longitude, latitude) axis order. falsenullCoordinate 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 "org.geotools.referencing.forceXY"system property.FALSEForcing (longitude, latitude) axis order is not allowed, no matter the value of the "org.geotools.referencing.forceXY"system property.- Parameters:
code- The Coordinate Reference System authority code.longitudeFirst-trueif axis order should be forced to (longitude, latitude). Note thatfalsemeans "use default", not "latitude first".- Returns:
- The Coordinate Reference System for the provided code.
- Throws:
NoSuchAuthorityCodeException- If the code could not be understood.FactoryException- if the CRS creation failed for an other reason.- Since:
- 2.3
- See Also:
-
parseWKT
Parses a Well Known Text (WKT) into a CRS object. This convenience method is a shorthand for the following:FactoryFinder.getCRSFactory(null).createFromWKT(wkt);- Throws:
FactoryException
-
getEnvelope
Returns the domain of validity for the specified coordinate reference system, ornullif unknown.This method fetchs the domain of validity associated with the given CRS. geographic bounding boxes are used as a fallback.
The returned envelope is expressed in terms of the specified CRS.
- Parameters:
crs- The coordinate reference system, ornull.- Returns:
- The envelope in terms of the specified CRS, or
nullif none. - Since:
- 2.2
- See Also:
-
getGeographicBoundingBox
Returns the valid geographic area for the specified coordinate reference system, ornullif unknown.This method fetchs the domain of validity associated with the given CRS. Only geographic extents of kind geographic bounding box are taken in account.
- Parameters:
crs- The coordinate reference system, ornull.- Returns:
- The geographic area, or
nullif none. - Since:
- 2.3
- See Also:
-
getHorizontalCRS
Returns the first horizontal coordinate reference system found in the given CRS, ornullif there is none. A horizontal CRS is usually a two-dimensional geographic or projected CRS.- Parameters:
crs- The coordinate reference system, ornull.- Returns:
- The horizontal CRS, or
nullif none. - Since:
- 2.4
-
getProjectedCRS
Returns the first projected coordinate reference system found in a the given CRS, ornullif there is none.- Parameters:
crs- The coordinate reference system, ornull.- Returns:
- The projected CRS, or
nullif none. - Since:
- 2.4
-
getMapProjection
Returns theMapProjectiondriving the specified crs, ornullif none could be found.- Parameters:
crs- The coordinate reference system, ornull.- Returns:
- The
MapProjection, ornullif none.
-
getVerticalCRS
Returns the first vertical coordinate reference system found in a the given CRS, ornullif there is none.- Parameters:
crs- The coordinate reference system, ornull.- Returns:
- The vertical CRS, or
nullif none. - Since:
- 2.4
-
getTemporalCRS
Returns the first temporal coordinate reference system found in the given CRS, ornullif there is none.- Parameters:
crs- The coordinate reference system, ornull.- Returns:
- The temporal CRS, or
nullif none. - Since:
- 2.4
-
getEllipsoid
Returns the first ellipsoid found in a coordinate reference system, ornullif there is none.- Parameters:
crs- The coordinate reference system, ornull.- Returns:
- The ellipsoid, or
nullif none. - Since:
- 2.4
-
equalsIgnoreMetadata
Compares the specified objects for equality. If both objects are Geotools implementations of classAbstractIdentifiedObject, then this method will ignore the metadata during the comparison.- Parameters:
object1- The first object to compare (may be null).object2- The second object to compare (may be null).- Returns:
trueif both objects are equals.- Since:
- 2.2
-
isTransformationRequired
public static boolean isTransformationRequired(CoordinateReferenceSystem source, CoordinateReferenceSystem target) throws FactoryException Checks if a transformation is required to go from source to target. This method returns true if:- source or target are null
- source or target are a wildcard CRS, see
DefaultEngineeringCRS.isWildcard() - source and target test positively to
equalsIgnoreMetadata(Object, Object) - the transformation between source and target is nevertheless and identity, e.g., same projected CRS based on a geographic one that has straight and flipped axis
- Parameters:
source- The sourceCoordinateReferenceSystemtarget- the targetCoordinateReferenceSystem- Throws:
FactoryException
-
isEquivalent
public static boolean isEquivalent(CoordinateReferenceSystem source, CoordinateReferenceSystem target) This method is checking if the 2 CRSs are equivalent by first using the equalsIgnoreMetadata approach and then looking for an identity transformation between the 2 CRSs if the first check fails.- Parameters:
source- The sourceCoordinateReferenceSystemtarget- the targetCoordinateReferenceSystem
-
toSRS
Returns the Spatial Reference System identifier, ornullif none. OGC Web Services have the concept of a Spatial Reference System identifier used to communicate CRS information between systems.Spatial Reference System (ie SRS) values:
EPSG:4326- this is the usual format understood to mean forceXY order prior to WMS 1.3.0. Note that the axis order is not necessarly (longitude, latitude), but this is the common behavior we observe in practice.AUTO:43200-CRS:84- similar toDefaultGeographicCRS.WGS84(formally defined by CRSAuthorityFactory)ogc:uri:.....- understood to match the EPSG database axis order.- Well Known Text (WKT)
- Parameters:
crs- The coordinate reference system, ornull.- Returns:
- SRS represented as a string for communication between systems, or
null. - Since:
- 2.5
-
toSRS
Returns the Spatial Reference System identifier, ornullif none.Some older web services are unable to deal with the full ogc:uri syntax, set simple to true for force a very simple representation that is just based on the code portion.
- Parameters:
codeOnly- Set to true to force generation of a simple srsName using only the code portion- Returns:
- srsName
-
lookupIdentifier
public static String lookupIdentifier(IdentifiedObject object, boolean fullScan) throws FactoryException Looks up an identifier for the specified object. This method searchs in registered factories for an object equals, ignoring metadata, to the specified object. If such object is found, then its identifier is returned. Otherwise this method returnsnull.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 authority factories instead of all registered onez, or if the full identified object is wanted instead of only its identifier.- Parameters:
object- The object (usually a coordinate reference system) looked up.fullScan- Iftrue, an exhaustive full scan against all registered objects will be performed (may be slow). Otherwise only a fast lookup based on embedded identifiers and names will be performed.- Returns:
- The identifier, or
nullif not found. - Throws:
FactoryException- if an unexpected failure occured during the search.- Since:
- 2.4
- See Also:
-
lookupIdentifier
public static String lookupIdentifier(Citation authority, CoordinateReferenceSystem crs, boolean fullScan) throws FactoryException Looks up an identifier of the specified authority for the given coordinate reference system). This method is similar tolookupIdentifier(object, fullScan)except that the search is performed only among the factories of the given authority.If the CRS does not have an identifier which corresponds to the EPSG authority, then:
- if
fullScanistrue, then this method scans the factories in search for an object equals, ignoring metadata, to the given object. If one is found, its identifier is returned. - Otherwise (if
fullScanisfalseor if no identifier was found in the previous step), this method returnsnull.
- Parameters:
authority- The authority for the code to search.crs- The coordinate reference system instance, ornull.- Returns:
- The CRS identifier, or
nullif none was found. - Throws:
FactoryException- if an error occured while searching for the identifier.- Since:
- 2.5
- if
-
lookupEpsgCode
public static Integer lookupEpsgCode(CoordinateReferenceSystem crs, boolean fullScan) throws FactoryException Looks up an EPSG code for the given coordinate reference system). This is a convenience method forlookupIdentifier(Citations.EPSG, crs, fullScan)except that code is parsed as an integer.- Parameters:
crs- The coordinate reference system instance, ornull.- Returns:
- The CRS identifier, or
nullif none was found. - Throws:
FactoryException- if an error occured while searching for the identifier.- Since:
- 2.5
-
findMathTransform
public static MathTransform findMathTransform(CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS) throws FactoryException Grab a transform between two Coordinate Reference Systems. This convenience method is a shorthand for the following:
Note that some metadata like positional accuracy are lost by this method. If those metadata are wanted, use the coordinate operation factory directly.FactoryFinder.getCoordinateOperationFactory(null).createOperation(sourceCRS, targetCRS).getMathTransform();Sample use:
MathTransform transform = CRS.findMathTransform( CRS.decode("EPSG:42102"), CRS.decode("EPSG:4326") );- Parameters:
sourceCRS- The source CRS.targetCRS- The target CRS.- Returns:
- The math transform from
sourceCRStotargetCRS. - Throws:
FactoryException- If no math transform can be created for the specified source and target CRS.
-
findMathTransform
public static MathTransform findMathTransform(CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, String transformCode) throws FactoryException Grab a transform between two Coordinate Reference Systems with the required transformation being used.Sample use:
MathTransform transform = CRS.findMathTransform( CRS.decode("EPSG:21036"), CRS.decode("EPSG:32736"), "EPSG:1285" );- Parameters:
sourceCRS- The source CRS.targetCRS- The target CRS.transformCode- - the transform operation desired.- Returns:
- The math transform from
sourceCRStotargetCRSusing thetransformCodeif it is found, otherwise the first transform found will be returned. - Throws:
FactoryException- If no math transform can be created for the specified source and target CRS.
-
getTransforms
public static Map<String,AbstractCoordinateOperation> getTransforms(CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS) throws FactoryException List the availableDefaultConcatenatedOperationfrom sourceCRS to targetCRS- Parameters:
sourceCRS- - the starting CRStargetCRS- - the target CRS- Returns:
- - a Map of transforms (
DefaultConcatenatedOperation) keyed by id code which can be used infindMathTransform(CoordinateReferenceSystem, CoordinateReferenceSystem, String) findMathTransform}(sourceCRS, targetCRS, transformCode) - Throws:
FactoryException
-
findMathTransform
public static MathTransform findMathTransform(CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, boolean lenient) throws FactoryException Grab a transform between two Coordinate Reference Systems. This method is similar tofindMathTransform(sourceCRS, targetCRS), except that it can optionally tolerate lenient datum shift. If thelenientargument istrue, 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.targetCRS- The target CRS.lenient-trueif the math transform should be created even when there is no information available for a datum shift. The default value isfalse.- Returns:
- The math transform from
sourceCRStotargetCRS. - Throws:
FactoryException- If no math transform can be created for the specified source and target CRS.- See Also:
-
transform
public static GeneralBounds transform(Bounds envelope, CoordinateReferenceSystem targetCRS) throws TransformException Transforms the given envelope to the specified CRS. If the given envelope is null, or the envelope CRS is null, or the given target CRS is null, or the transform is identity, then the envelope is returned unchanged. Otherwise a new transformed envelope is returned.Don't use this method if there is many envelopes to transform. This method is provided as a convenience when there is only one envelope to transform between CRS that can't be known in advance. If there is many of them or if the CRS are restricted to known values, get the coordinate operation or math transform once for ever and invoke one of the methods below instead (unless if performance is not a concern).
- Parameters:
envelope- The envelope to transform (may benull).targetCRS- The target CRS (may benull).- Returns:
- A new transformed envelope, or directly
envelopeif no transformation was required. - Throws:
TransformException- If a transformation was required and failed.- Since:
- 2.5
-
transform
public static GeneralBounds transform(MathTransform transform, Bounds envelope) throws TransformException Transforms an envelope using the given math transform. 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 math transforms do not carry suffisient informations. For a more robust envelope transformation, use
transform(CoordinateOperation, Bounds)instead.- Parameters:
transform- The transform to use.envelope- Envelope to transform, ornull. This envelope will not be modified.- Returns:
- The transformed envelope, or
nullifenvelopewas null. - Throws:
TransformException- if a transform failed.- Since:
- 2.4
- See Also:
-
transform
public static GeneralBounds transform(CoordinateOperation operation, Bounds envelope) throws TransformException Transforms an envelope using the given coordinate operation. The transformation is only approximative. It may be bigger than the smallest possible bounding box, but should not be smaller. 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.envelope- Envelope to transform, ornull. This envelope will not be modified.- Returns:
- The transformed envelope, or
nullifenvelopewas null. - Throws:
TransformException- if a transform failed.- Since:
- 2.4
- See Also:
-
transform
public static Rectangle2D transform(MathTransform2D transform, Rectangle2D rectangle) throws TransformException Transforms an rectangular envelope using the given math transform. 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 math transforms do not carry suffisient informations. For a more robust envelope transformation, use
transform(CoordinateOperation, Bounds)instead.- Parameters:
transform- The transform to use.rectangle- Rectangle to transform, ornull. This rectangle will not be modified.- Returns:
- The transformed rectangle, or
nullifrectanglewas null. - Throws:
TransformException- if a transform failed.- Since:
- 30
- See Also:
-
transform
public static Rectangle2D transform(MathTransform2D transform, Rectangle2D envelope, Rectangle2D destination) throws TransformException Transforms a rectangular envelope using the given math transform. 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 math transforms do not carry suffisient informations. For a more robust rectangle transformation, use
transform(CoordinateOperation, Rectangle2D, Rectangle2D)instead.- Parameters:
transform- The transform to use. Source and target dimension must be 2.envelope- The rectangle to transform (may benull).destination- The destination rectangle (may beenvelope). Ifnull, a new rectangle will be created and returned.- Returns:
destination, or a new rectangle ifdestinationwas non-null andenvelopewas null.- Throws:
TransformException- if a transform failed.- Since:
- 2.4
- See Also:
-
transform
public static Rectangle2D transform(CoordinateOperation operation, Rectangle2D envelope, Rectangle2D destination) throws TransformException Transforms a rectangular envelope using the given coordinate operation. 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.envelope- The rectangle to transform (may benull).destination- The destination rectangle (may beenvelope). Ifnull, a new rectangle will be created and returned.- Returns:
destination, or a new rectangle ifdestinationwas non-null andenvelopewas null.- Throws:
TransformException- if a transform failed.- Since:
- 2.4
- See Also:
-
reset
Resets some aspects of the referencing system. The aspects to be reset are specified by a space or comma delimited string, which may include any of the following elements:"plugins"for searching the classpath for new plugins."warnings"for re-enabling the warnings to be issued when a coordinate is out of projection valid area.
- Parameters:
aspects- The aspects to reset, or"all"for all of them. Unknown aspects are silently ignored.- Since:
- 2.5
-
cleanupThreadLocals
public static void cleanupThreadLocals()Cleans up the thread local set in this thread. They can prevent web applications from proper shutdown -
getAxisOrder
Determines the axis ordering of a specified crs object.- Parameters:
crs- The coordinate reference system.- Returns:
- One of
CRS.AxisOrder.EAST_NORTH, {@link AxisOrder@NORTH_EAST}, orCRS.AxisOrder.INAPPLICABLE - Since:
- 2.7
- See Also:
-
getAxisOrder
Determines the axis ordering of a specified crs object.The useBaseGeoCRS parameter is used to control behaviour for projected crs. When set to true the comparison will use the coordinate system for the underlying geographic crs object for the comparison. When set to false the comparison will use the coordinate system from projected crs itself.
- Parameters:
crs- The coordinate reference system.useBaseGeoCRS- Controls whether the base geo crs is used for projected crs.- Returns:
- One of
CRS.AxisOrder.EAST_NORTH, {@link AxisOrder@NORTH_EAST}, orCRS.AxisOrder.INAPPLICABLE
-
main
Prints to the standard output stream some information about coordinate reference systems specified by their authority codes. This method can be invoked from the command line in order to test the authority factory 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,-codesor-bursawolfsis provided.Usage:
java org.geotools.referencing.CRS [options] [codes]
Options:
Examples (assuming that-authority=name
Uses the specified authority factory, for example"EPSG". The authority name can be any of the authorities listed by the-factoriesoption. If this option is not specified, then the default is all factories.-bursawolfscodes
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-authorityoption 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 theequalsIgnoreMetadatamethod, 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).-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 locale.-operationssourceCRS 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).-transformsourceCRS 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."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
-