Class CRS

public final class CRS extends Static
Static methods working on Coordinate Reference Systems. The methods defined in this class can be grouped in three categories: Factory methods, the most notable one being
forCode(String)
.  Methods providing information, like
isHorizontalCRS(CoordinateReferenceSystem)
.  Finding coordinate operations between a source and a target CRS.
Usage exampleThe most frequently used methods in this class areforCode(…)
,fromWKT(…)
andfindOperation(…)
. An usage example is like below (see the Apache SIS™ Coordinate Reference System (CRS) codes page for the complete list of EPSG codes):CoordinateReferenceSystem source = CRS.forCode("EPSG:4326"); // WGS 84 CoordinateReferenceSystem target = CRS.forCode("EPSG:3395"); // WGS 84 / World Mercator CoordinateOperation operation = CRS.findOperation(source, target, null); if (CRS.getLinearAccuracy(operation) > 100) { // If the accuracy is coarser than 100 metres (or any other threshold at application choice) // maybe the operation is not suitable. Decide here what to do (throw an exception, etc). } MathTransform mt = operation.getMathTransform(); DirectPosition position = new DirectPosition2D(20, 30); // 20°N 30°E (watch out axis order!) position = mt.transform(position, position); System.out.println(position);
Note on kinds of CRSThegetSingleComponents(CoordinateReferenceSystem)
method decomposes an arbitrary CRS into a flat list of single components. In such flat list, vertical and temporal components can easily be identified byinstanceof
checks. But identifying the horizontal component is not as easy. The list below suggests ways to classify the components:if (crs instanceof TemporalCRS)
determines if the CRS is for the temporal component.if (crs instanceof VerticalCRS)
determines if the CRS is for the vertical component.if (CRS.isHorizontalCRS(crs))
determines if the CRS is for the horizontal component.
 Since:
 0.3
Defined in the
sisreferencing
module  Factory methods, the most notable one being


Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static CoordinateReferenceSystem
compound(CoordinateReferenceSystem... components)
Creates a compound coordinate reference system from an ordered list of CRS components.static CoordinateOperation
findOperation(CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, GeographicBoundingBox areaOfInterest)
Finds a mathematical operation that transforms or converts coordinates from the given source to the given target coordinate reference system.static List<CoordinateOperation>
findOperations(CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, GeographicBoundingBox areaOfInterest)
Finds mathematical operations that transform or convert coordinates from the given source to the given target coordinate reference system.static CoordinateReferenceSystem
forCode(String code)
Returns the Coordinate Reference System for the given authority code.static CoordinateReferenceSystem
fromAuthority(CoordinateReferenceSystem crs, CRSAuthorityFactory factory, Filter warningFilter)
Replaces the given coordinate reference system by an authoritative description, if one can be found.static CoordinateReferenceSystem
fromAuthority(CoordinateReferenceSystem crs, CRSAuthorityFactory factory, WarningListener<?> listener)
Deprecated.WarningListener
argument replaced byjava.util.logging.Filter
.static CoordinateReferenceSystem
fromWKT(String text)
Creates a Coordinate Reference System object from a Well Known Text (WKT).static CoordinateReferenceSystem
fromXML(String xml)
Creates a coordinate reference system object from a XML string.static CRSAuthorityFactory
getAuthorityFactory(String authority)
Returns the systemwide authority factory used byforCode(String)
and other SIS methods.static CoordinateReferenceSystem
getComponentAt(CoordinateReferenceSystem crs, int lower, int upper)
Returns the coordinate reference system in the given range of dimension indices.static Envelope
getDomainOfValidity(CoordinateReferenceSystem crs)
Returns the domain of validity of the specified coordinate reference system, ornull
if unknown.static GeographicBoundingBox
getGeographicBoundingBox(CoordinateReferenceSystem crs)
Returns the valid geographic area for the given coordinate reference system, ornull
if unknown.static GeographicBoundingBox
getGeographicBoundingBox(CoordinateOperation operation)
Returns the valid geographic area for the given coordinate operation, ornull
if unknown.static double
getGreenwichLongitude(GeodeticCRS crs)
Returns the Greenwich longitude of the prime meridian of the given CRS in degrees.static SingleCRS
getHorizontalComponent(CoordinateReferenceSystem crs)
Returns the first horizontal coordinate reference system found in the given CRS, ornull
if there is none.static double
getLinearAccuracy(CoordinateOperation operation)
Returns a positional accuracy estimation in metres for the given operation, orNaN
if unknown.static List<SingleCRS>
getSingleComponents(CoordinateReferenceSystem crs)
Returns the ordered list of single coordinate reference systems for the specified CRS.static TemporalCRS
getTemporalComponent(CoordinateReferenceSystem crs)
Returns the first temporal coordinate reference system found in the given CRS, ornull
if there is none.static VerticalCRS
getVerticalComponent(CoordinateReferenceSystem crs, boolean allowCreateEllipsoidal)
Returns the first vertical coordinate reference system found in the given CRS, ornull
if there is none.static boolean
isHorizontalCRS(CoordinateReferenceSystem crs)
Returnstrue
if the given CRS is horizontal.static CoordinateReferenceSystem
reduce(CoordinateReferenceSystem crs, int... dimensions)
Gets or creates a coordinate reference system with a subset of the dimensions of the given CRS.static CoordinateReferenceSystem
suggestCommonTarget(GeographicBoundingBox regionOfInterest, CoordinateReferenceSystem... sourceCRS)
Suggests a coordinate reference system which could be a common target for coordinate operations having the given sources.



Method Detail

forCode
public static CoordinateReferenceSystem forCode(String code) throws NoSuchAuthorityCodeException, FactoryException
Returns the Coordinate Reference System for the given authority code. The set of available codes depends on theCRSAuthorityFactory
instances available on the classpath. There is many thousands of CRS defined by EPSG authority or by other authorities. The following table lists a very small subset of codes which are guaranteed to be available on any installation of Apache SIS:
This method accepts also the URN and URL syntaxes. For example the following codes are considered equivalent toMinimal set of supported authority codes Code Enum CRS Type Description CRS:27 NAD27
Geographic Like EPSG:4267 except for (longitude, latitude) axis order CRS:83 NAD83
Geographic Like EPSG:4269 except for (longitude, latitude) axis order CRS:84 WGS84
Geographic Like EPSG:4326 except for (longitude, latitude) axis order EPSG:4047 SPHERE
Geographic GRS 1980 Authalic Sphere EPSG:4230 ED50
Geographic European Datum 1950 EPSG:4258 ETRS89
Geographic European Terrestrial Reference Frame 1989 EPSG:4267 NAD27
Geographic North American Datum 1927 EPSG:4269 NAD83
Geographic North American Datum 1983 EPSG:4322 WGS72
Geographic World Geodetic System 1972 EPSG:4326 WGS84
Geographic World Geodetic System 1984 EPSG:4936 ETRS89
Geocentric European Terrestrial Reference Frame 1989 EPSG:4937 ETRS89
Geographic 3D European Terrestrial Reference Frame 1989 EPSG:4978 WGS84
Geocentric World Geodetic System 1984 EPSG:4979 WGS84
Geographic 3D World Geodetic System 1984 EPSG:4984 WGS72
Geocentric World Geodetic System 1972 EPSG:4985 WGS72
Geographic 3D World Geodetic System 1972 EPSG:5041 WGS84
Projected WGS 84 / UPS North (E,N) EPSG:5042 WGS84
Projected WGS 84 / UPS South (E,N) EPSG:322## WGS72
Projected WGS 72 / UTM zone ##N EPSG:323## WGS72
Projected WGS 72 / UTM zone ##S EPSG:326## WGS84
Projected WGS 84 / UTM zone ##N EPSG:327## WGS84
Projected WGS 84 / UTM zone ##S EPSG:5715 DEPTH
Vertical Mean Sea Level depth EPSG:5714 MEAN_SEA_LEVEL
Vertical Mean Sea Level height "EPSG:4326"
:"EPSG::4326"
"urn:ogc:def:crs:EPSG::4326"
"http://www.opengis.net/def/crs/epsg/0/4326"
"http://www.opengis.net/gml/srs/epsg.xml#4326"
"urn:ogc:def:crs,crs:EPSG::4326,crs:EPSG::5714"
"http://www.opengis.net/def/crscompound?
1=http://www.opengis.net/def/crs/epsg/0/4326&
2=http://www.opengis.net/def/crs/epsg/0/5714"
URNs (but not URLs) can also combine a geodetic datum with an ellipsoidal coordinate system for creating a new geographic CRS, or a base geographic CRS with a conversion and a Cartesian coordinate system for creating a new projected coordinate reference system.
Note that theIdentifiedObjects.lookupURN(IdentifiedObject, Citation)
method can be seen as a converse of this method. More codes may also be supported depending on which extension modules are available. Parameters:
code
 the authority code. Returns:
 the Coordinate Reference System for the given authority code.
 Throws:
NoSuchAuthorityCodeException
 if there is no known CRS associated to the given code.FactoryException
 if the CRS creation failed for an other reason. See Also:
getAuthorityFactory(String)
,GeodeticAuthorityFactory
, EPSG Geodetic Registry

fromWKT
public static CoordinateReferenceSystem fromWKT(String text) throws FactoryException
Creates a Coordinate Reference System object from a Well Known Text (WKT). The default Apache SIS parser understands both version 1 (a.k.a. OGC 01009) and version 2 (a.k.a. ISO 19162) of the WKT format.Example: below is a slightly simplified WKT 2 string for a Mercator projection. For making this example smaller, some optionalIf the parsing produced warnings, they will be reported in a logger namedUNIT[…]
andORDER[…]
elements have been omitted.ProjectedCRS["SIRGAS 2000 / Brazil Mercator", BaseGeodCRS["SIRGAS 2000", Datum["Sistema de Referencia Geocentrico para las Americas 2000", Ellipsoid["GRS 1980", 6378137, 298.257222101]]], Conversion["Petrobras Mercator", Method["Mercator (variant B)", Id["EPSG",9805]], Parameter["Latitude of 1st standard parallel", 2], Parameter["Longitude of natural origin", 43], Parameter["False easting", 5000000], Parameter["False northing", 10000000]], CS[cartesian,2], Axis["easting (E)", east], Axis["northing (N)", north], LengthUnit["metre", 1], Id["EPSG",5641]]
"org.apache.sis.io.wkt"
. In particular, this method verifies if the description provided by the WKT matches the description provided by the authority ("EPSG:5641"
in above example) and reports discrepancies. Note that this comparison between parsed CRS and authoritative CRS is specific to this convenience method; other APIs documented in see also section do not perform this comparison automatically. Should the WKT description and the authoritative description be in conflict, the WKT description prevails as mandated by ISO 19162 standard (seefromAuthority(…)
if a different behavior is needed).Usage and performance considerationsThis convenience method delegates toGeodeticObjectFactory.createFromWKT(String)
using a default factory instance. This is okay for occasional use, but has the following limitations: Performance may be suboptimal in a multithread environment.
 No control on the WKT conventions in use.
 No control on the handling of warnings.
WKTFormat
class instead than this method. Parameters:
text
 coordinate system encoded in WellKnown Text format (version 1 or 2). Returns:
 the parsed Coordinate Reference System.
 Throws:
FactoryException
 if the given WKT can not be parsed. Since:
 0.6
 See Also:
WKTFormat
,GeodeticObjectFactory.createFromWKT(String)
,Envelopes.fromWKT(CharSequence)
, WKT 2 specification

fromXML
public static CoordinateReferenceSystem fromXML(String xml) throws FactoryException
Creates a coordinate reference system object from a XML string. Note that the given argument is the XML document itself, not a URL to a XML document. For reading XML documents from readers or input streams, see static methods in theXML
class.If the unmarshalling produced warnings, they will be reported in a logger named
"org.apache.sis.xml"
. In particular, this method verifies if the description provided by the XML matches the description provided by the authority code given in<gml:identifier>
element, and reports discrepancies. Note that this comparison between unmarshalled CRS and authoritative CRS is specific to this convenience method; other APIs documented in see also section do not perform this comparison automatically. Should the XML description and the authoritative description be in conflict, the XML description prevails (seefromAuthority(…)
if a different behavior is needed). Parameters:
xml
 coordinate reference system encoded in XML format. Returns:
 the unmarshalled Coordinate Reference System.
 Throws:
FactoryException
 if the object creation failed. Since:
 0.7
 See Also:
GeodeticObjectFactory.createFromXML(String)
,XML.unmarshal(String)

fromAuthority
public static CoordinateReferenceSystem fromAuthority(CoordinateReferenceSystem crs, CRSAuthorityFactory factory, Filter warningFilter) throws FactoryException
Replaces the given coordinate reference system by an authoritative description, if one can be found. This method can be invoked after constructing a CRS in a context where the EPSG (or other authority) code is suspected more reliable than the rest of the description. A common case is a Well Known Text (WKT) string declaring wrong projection method or parameter values for the EPSG code that it pretends to describe. For example:PROJCS["WGS 84 / PseudoMercator",
PROJECTION["Mercator (variant A)"],
— wrong: shall be "Popular Visualisation Pseudo Mercator"
AUTHORITY["EPSG", "3857"]]
fromWKT(String)
,fromXML(String)
and other methods is conform to the ISO 19162 specification:"Should any attributes or values given in the cited identifier be in conflict with attributes or values given explicitly in the WKT description, the WKT values shall prevail."
In situations where the opposite behavior is desired (i.e. to make the authority identifier prevails), this method can be invoked. This method performs the following actions: If the given CRS has an identifier and if the authority factory can
create a CRS
for that identifier, then:
 If the CRS defined by the authority is equal, ignoring metadata, to the given CRS, then this method returns silently the authoritative CRS.
 Otherwise if the CRS defined by the authority is equal, ignoring axis order and units, to the given CRS, then this method returns a new CRS derived from the authoritative one but with same axes convention than the given CRS. A warning is emitted.
 Otherwise this method discards the given CRS and returns the authoritative CRS. A warning is emitted with a message indicating where a difference has been found.
 Otherwise if the given CRS does not have identifier, then this method
searches for an equivalent CRS
defined by the authority factory. If such CRS is found, then:
 If the CRS defined by the authority is equal, ignoring metadata, to the given CRS, then this method returns silently the authoritative CRS.
 Otherwise if the CRS defined by the authority is equal, ignoring axis order and units, to the given CRS, then this method returns silently a new CRS derived from the authoritative one but with same axes convention than the given CRS.
 Otherwise this method silently returns the given CRS asis.
Avoiding warning redundanciesThe warnings logged by this method are redundant with warnings logged by other methods in this class, in particularfromWKT(String)
andfromXML(String)
methods. For avoiding this annoyance, anull
value for thewarningFilter
argument means to shut off those redundant loggings. A nonnullwarningFilter
argument is more useful for CRS parsed by methods outside this class, for exampleWKTFormat
orXML.unmarshal(String)
. Parameters:
crs
 the CRS to replace by an authoritative CRS, ornull
.factory
 the factory where to search for authoritative definitions, ornull
for the default.warningFilter
 whether to log warnings, ornull
for the default behavior (which is to filter out the warnings that are redundant with warnings emitted by other methods in this class). Returns:
 the suggested CRS to use (may be the
crs
argument itself), ornull
if the given CRS was null.  Throws:
FactoryException
 if an error occurred while querying the authority factory. Since:
 1.0
 If the given CRS has an identifier and if the authority factory can
create a CRS
for that identifier, then:

fromAuthority
@Deprecated public static CoordinateReferenceSystem fromAuthority(CoordinateReferenceSystem crs, CRSAuthorityFactory factory, WarningListener<?> listener) throws FactoryException
Deprecated.WarningListener
argument replaced byjava.util.logging.Filter
. Throws:
FactoryException

suggestCommonTarget
public static CoordinateReferenceSystem suggestCommonTarget(GeographicBoundingBox regionOfInterest, CoordinateReferenceSystem... sourceCRS)
Suggests a coordinate reference system which could be a common target for coordinate operations having the given sources. This method compares the domain of validity of all given CRSs. If a CRS has a domain of validity that contains the domain of all other CRS, than that CRS is returned. Otherwise this method verifies if a base CRS (usually a geographic CRS instance) would be suitable. If no suitable CRS is found, then this method returnsnull
.Use case: before to test if two arbitrary envelopes intersect each other, they need to be transformed in the same CRS. However if one CRS is a Transverse Mercator projection while the other CRS is a worldwide geographic CRS, then attempts to use the Transverse Mercator projection as the common CRS is likely to fail since the geographic envelope may span an area far outside the projection domain of validity. ThissuggestCommonTarget(…)
method can used for choosing a common CRS which is less likely to fail. Parameters:
regionOfInterest
 the geographic area for which the coordinate operations will be applied, ornull
if unknown. Will be intersected with CRS domains of validity.sourceCRS
 the coordinate reference systems for which a common target CRS is desired. May containnull
elements, in which case this method returnsnull
. Returns:
 a CRS that may be used as a common target for all the given source CRS in the given region of interest,
or
null
if this method did not find a common target CRS. The returned CRS may be different than all given CRS.  Since:
 0.8

findOperation
public static CoordinateOperation findOperation(CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, GeographicBoundingBox areaOfInterest) throws FactoryException
Finds a mathematical operation that transforms or converts coordinates from the given source to the given target coordinate reference system. If an estimation of the geographic area containing the points to transform is known, it can be specified for helping this method to find a better suited operation. If no area of interest is specified, then the current default is the widest domain of validity. A future Apache SIS version may also take the country of current locale in account.Note: the area of interest is just one aspect that may affect the coordinate operation. Other aspects are the time of interest (because some coordinate operations take in account the plate tectonics movement) or the desired accuracy. For more control on the coordinate operation to create, seeAfter the caller received aCoordinateOperationContext
.CoordinateOperation
instance, the following methods can be invoked for checking if the operation suits the caller's needs:getGeographicBoundingBox(CoordinateOperation)
for checking if the operation is valid in the caller's area of interest.getLinearAccuracy(CoordinateOperation)
for checking if the operation has sufficient accuracy for caller's purpose.
OperationNotFoundException
. Parameters:
sourceCRS
 the CRS of source coordinates.targetCRS
 the CRS of target coordinates.areaOfInterest
 the area of interest, ornull
if none. Returns:
 the mathematical operation from
sourceCRS
totargetCRS
.  Throws:
OperationNotFoundException
 if no operation was found between the given pair of CRS.FactoryException
 if the operation can not be created for another reason. Since:
 0.7
 See Also:
Envelopes.findOperation(Envelope, Envelope)
,DefaultCoordinateOperationFactory.createOperation(CoordinateReferenceSystem, CoordinateReferenceSystem, CoordinateOperationContext)

findOperations
public static List<CoordinateOperation> findOperations(CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, GeographicBoundingBox areaOfInterest) throws FactoryException
Finds mathematical operations that transform or convert coordinates from the given source to the given target coordinate reference system. If at least one operation exists, they are returned in preference order: the operation having the widest intersection between its domain of validity and the given area of interest are returned first. Parameters:
sourceCRS
 the CRS of source coordinates.targetCRS
 the CRS of target coordinates.areaOfInterest
 the area of interest, ornull
if none. Returns:
 mathematical operations from
sourceCRS
totargetCRS
.  Throws:
OperationNotFoundException
 if no operation was found between the given pair of CRS.FactoryException
 if the operation can not be created for another reason. Since:
 1.0
 See Also:
DefaultCoordinateOperationFactory.createOperations(CoordinateReferenceSystem, CoordinateReferenceSystem, CoordinateOperationContext)

getLinearAccuracy
public static double getLinearAccuracy(CoordinateOperation operation)
Returns a positional accuracy estimation in metres for the given operation, orNaN
if unknown. This method applies the following heuristics: If the given operation is an instance of
AbstractCoordinateOperation
, then delegate to the operationgetLinearAccuracy()
method.  Otherwise if at least one quantitative result is found with a linear unit, then return the largest value converted to metres.
 Otherwise if the operation is a conversion, then returns 0 since a conversion is by definition accurate up to rounding errors.
 Otherwise if the operation is a transformation, then the returned value depends on whether the datum shift were applied with the help of BursaWolf parameters of not.
AbstractCoordinateOperation.getLinearAccuracy()
for more details on the above heuristic rules. Parameters:
operation
 the coordinate operation for which to get the accuracy estimation, ornull
. Returns:
 the accuracy estimation (always in meters), or NaN if unknown.
 Since:
 0.7
 See Also:
findOperation(CoordinateReferenceSystem, CoordinateReferenceSystem, GeographicBoundingBox)
 If the given operation is an instance of

getGeographicBoundingBox
public static GeographicBoundingBox getGeographicBoundingBox(CoordinateOperation operation)
Returns the valid geographic area for the given coordinate operation, ornull
if unknown. This method explores the domain of validity associated with the given operation. If more than one geographic bounding box is found, then this method computes their union.Fallback: if the given operation does not declare explicitly a domain of validity, then this method computes the intersection of the domain of validity declared by source and target CRS. If no CRS declare a domain of validity, then this method returns
null
. Parameters:
operation
 the coordinate operation for which to get the domain of validity, ornull
. Returns:
 the geographic area where the operation is valid, or
null
if unspecified.  Since:
 0.7
 See Also:
findOperation(CoordinateReferenceSystem, CoordinateReferenceSystem, GeographicBoundingBox)
,Extents.getGeographicBoundingBox(Extent)

getGeographicBoundingBox
public static GeographicBoundingBox getGeographicBoundingBox(CoordinateReferenceSystem crs)
Returns the valid geographic area for the given coordinate reference system, ornull
if unknown. This method explores the domain of validity associated with the given CRS. If more than one geographic bounding box is found, then this method computes their union. together. Parameters:
crs
 the coordinate reference system for which to get the domain of validity, ornull
. Returns:
 the geographic area where the coordinate reference system is valid, or
null
if unspecified.  See Also:
getDomainOfValidity(CoordinateReferenceSystem)
,Extents.getGeographicBoundingBox(Extent)

getDomainOfValidity
public static Envelope getDomainOfValidity(CoordinateReferenceSystem crs)
Returns the domain of validity of the specified coordinate reference system, ornull
if unknown. If nonnull, then the returned envelope will use the same coordinate reference system them the given CRS argument. Parameters:
crs
 the coordinate reference system, ornull
. Returns:
 the envelope with coordinates in the given CRS, or
null
if none.  Since:
 0.8
 See Also:
getGeographicBoundingBox(CoordinateReferenceSystem)

compound
public static CoordinateReferenceSystem compound(CoordinateReferenceSystem... components) throws FactoryException
Creates a compound coordinate reference system from an ordered list of CRS components. A CRS is inferred from the given components and the domain of validity is set to the intersection of the domain of validity of all components.Ellipsoidal heightIf a twodimensional geographic or projected CRS if followed or preceded by a vertical CRS with ellipsoidal datum type, then this method combines them in a single threedimensional geographic or projected CRS. Note that standalone ellipsoidal heights are not allowed according ISO 19111. But if such situation is nevertheless found, then the action described here fixes the issue. This is the reverse ofgetVerticalComponent(crs, true)
.Components orderApache SIS is permissive on the order of components that can be used in a compound CRS. However for better interoperability, users are encouraged to follow the order mandated by ISO 19162: A mandatory horizontal CRS (only one of twodimensional
GeographicCRS
orProjectedCRS
orEngineeringCRS
).  Optionally followed by a
VerticalCRS
or aParametricCRS
(but not both).  Optionally followed by a
TemporalCRS
.
 Parameters:
components
 the sequence of coordinate reference systems making the compound CRS. Returns:
 the compound CRS, or
components[0]
if the given array contains only one component.  Throws:
IllegalArgumentException
 if the given array is empty or if the array contains incompatible components.FactoryException
 if the geodetic factory failed to create the compound CRS. Since:
 0.8
 See Also:
DefaultCompoundCRS
,GeodeticObjectFactory.createCompoundCRS(Map, CoordinateReferenceSystem...)
,Envelopes.compound(Envelope...)
,MathTransforms.compound(MathTransform...)
 A mandatory horizontal CRS (only one of twodimensional

reduce
public static CoordinateReferenceSystem reduce(CoordinateReferenceSystem crs, int... dimensions) throws FactoryException
Gets or creates a coordinate reference system with a subset of the dimensions of the given CRS. This method can be used for dimensionality reduction, but not for changing axis order. The specified dimensions are used as if they were in strictly increasing order without duplicated values.Ellipsoidal heightThis method can transform a threedimensional geographic CRS into a twodimensional geographic CRS. In this aspect, this method is the converse ofcompound(CoordinateReferenceSystem...)
. This method can also extract the ellipsoidal height from a threedimensional geographic CRS, but this is generally not recommended since ellipsoidal heights make little sense without their (latitude, longitude) locations. Parameters:
crs
 the CRS to reduce the dimensionality, ornull
if none.dimensions
 the dimensions to retain. The dimensions will be taken in increasing order, ignoring duplicated values. Returns:
 a coordinate reference system for the given dimensions. May be the given
crs
, which may benull
.  Throws:
IllegalArgumentException
 if the given array is empty or if the array contains invalid indices.FactoryException
 if the geodetic factory failed to create a compound CRS. Since:
 1.0
 See Also:
getComponentAt(CoordinateReferenceSystem, int, int)
,compound(CoordinateReferenceSystem...)

isHorizontalCRS
public static boolean isHorizontalCRS(CoordinateReferenceSystem crs)
Returnstrue
if the given CRS is horizontal. The current implementation considers a CRS as horizontal if it is twodimensional and comply with one of the following conditions: is an instance of
GeographicCRS
(or an equivalentGeodeticCRS
), or  is an instance of
ProjectedCRS
, or  is an instance of
EngineeringCRS
(following ISO 19162 §16.1 definition of <horizontal crs>).
false
. Parameters:
crs
 the coordinate reference system, ornull
. Returns:
true
if the given CRS is nonnull and likely horizontal, orfalse
otherwise. See Also:
getHorizontalComponent(CoordinateReferenceSystem)
 TODO:
 Future SIS implementation may extend the above conditions list. For example a radar station could
use a polar coordinate system in a
DerivedCRS
instance based on a projected CRS. Conversely, a future SIS versions may impose more conditions onEngineeringCRS
. See SIS161.
 is an instance of

getHorizontalComponent
public static SingleCRS getHorizontalComponent(CoordinateReferenceSystem crs)
Returns the first horizontal coordinate reference system found in the given CRS, ornull
if there is none. If the given CRS is already horizontal accordingisHorizontalCRS(CoordinateReferenceSystem)
, then this method returns it asis. Otherwise if the given CRS is compound, then this method searches for the first horizontal component in the order of the single components list.In the special case where a threedimensional geographic or projected CRS is found, this method will create a twodimensional geographic or projected CRS without the vertical axis.
 Parameters:
crs
 the coordinate reference system, ornull
. Returns:
 the first horizontal CRS, or
null
if none.

getVerticalComponent
public static VerticalCRS getVerticalComponent(CoordinateReferenceSystem crs, boolean allowCreateEllipsoidal)
Returns the first vertical coordinate reference system found in the given CRS, ornull
if there is none. If the given CRS is already an instance ofVerticalCRS
, then this method returns it asis. Otherwise if the given CRS is compound, then this method searches for the first vertical component in the order of the single components list.Height in a threedimensional geographic CRSIn ISO 19111 model, ellipsoidal heights are indissociable from geographic CRS because such heights without their (latitude, longitude) locations make little sense. Consequently a standardconformant library should returnnull
when asked for theVerticalCRS
component of a geographic CRS. This is whatgetVerticalComponent(…)
does when theallowCreateEllipsoidal
argument isfalse
.However in some exceptional cases, handling ellipsoidal heights like any other kind of heights may simplify the task. For example when computing difference between heights above the same datum, the impact of ignoring locations may be smaller (but not necessarily canceled). Orphan
VerticalCRS
may also be useful for information purpose like labeling a plot axis. If the caller feels confident that ellipsoidal heights are safe for his task, he can set theallowCreateEllipsoidal
argument totrue
. In such case, thisgetVerticalComponent(…)
method will create a temporaryVerticalCRS
from the first threedimensionalGeographicCRS
in last resort, only if it can not find an existingVerticalCRS
instance. Note that this is not a valid CRS according ISO 19111 — use with care. Parameters:
crs
 the coordinate reference system, ornull
.allowCreateEllipsoidal
true
for allowing the creation of orphan CRS for ellipsoidal heights. The recommended value isfalse
. Returns:
 the first vertical CRS, or
null
if none.  See Also:
compound(CoordinateReferenceSystem...)

getTemporalComponent
public static TemporalCRS getTemporalComponent(CoordinateReferenceSystem crs)
Returns the first temporal coordinate reference system found in the given CRS, ornull
if there is none. If the given CRS is already an instance ofTemporalCRS
, then this method returns it asis. Otherwise if the given CRS is compound, then this method searches for the first temporal component in the order of the single components list. Parameters:
crs
 the coordinate reference system, ornull
. Returns:
 the first temporal CRS, or
null
if none.

getSingleComponents
public static List<SingleCRS> getSingleComponents(CoordinateReferenceSystem crs)
Returns the ordered list of single coordinate reference systems for the specified CRS. This method performs the following choices: If the given CRS is null, returns an empty list.
 If the given CRS is an instance of
SingleCRS
, returns that instance in a singleton list.  If the given CRS is an instance of
CompoundCRS
, returns a flattened list of its components. Some components may themselves be otherCompoundCRS
instances, in which case those compound CRS are also flattened in their list ofSingleCRS
components.  Otherwise throws a
ClassCastException
.
Example: Apache SIS allows 4dimensional (x,y,z,t) coordinate reference system to be built in two different ways as shown below:Hierarchical structure
CompoundCRS
— (x, y, z, t)
├─CompoundCRS
— (x, y, z)
│ ├─ProjectedCRS
— (x, y)
│ └─VerticalCRS
— (z)
└─TemporalCRS
— (t)Flat list
CompoundCRS
— (x, y, z, t)
├─ProjectedCRS
— (x, y)
├─VerticalCRS
— (z)
└─TemporalCRS
— (t) Parameters:
crs
 the coordinate reference system, ornull
. Returns:
 the single coordinate reference systems, or an empty list if the given CRS is
null
.  Throws:
ClassCastException
 if a CRS is neither aSingleCRS
or aCompoundCRS
. See Also:
DefaultCompoundCRS.getSingleComponents()

getComponentAt
public static CoordinateReferenceSystem getComponentAt(CoordinateReferenceSystem crs, int lower, int upper)
Returns the coordinate reference system in the given range of dimension indices. This method processes as below: If the given
crs
isnull
, then this method returnsnull
.  Otherwise if
lower
is 0 andupper
is the number of CRS dimensions, then this method returns the given CRS unchanged.  Otherwise if the given CRS is an instance of
CompoundCRS
, then this method searches for a component where: The number of dimensions
is equals to
upper  lower
;  The sum of the number of dimensions of all previous CRS is equals to
lower
.
 The number of dimensions
is equals to
 Otherwise (i.e. no component match), this method returns
null
.
CompoundCRS
or a threedimensional CRS if the given range spans more than one component. Parameters:
crs
 the coordinate reference system to decompose, ornull
.lower
 the first dimension to keep, inclusive.upper
 the last dimension to keep, exclusive. Returns:
 the subcoordinate system, or
null
if the givencrs
wasnull
or can not be decomposed for dimensions in the [lower
…upper
] range.  Throws:
IndexOutOfBoundsException
 if the given index are out of bounds. Since:
 0.5
 See Also:
reduce(CoordinateReferenceSystem, int...)
,GeneralEnvelope.subEnvelope(int, int)
 If the given

getGreenwichLongitude
public static double getGreenwichLongitude(GeodeticCRS crs)
Returns the Greenwich longitude of the prime meridian of the given CRS in degrees. If the prime meridian uses an other unit than degrees, then the value will be converted. Parameters:
crs
 the coordinate reference system from which to get the prime meridian. Returns:
 the Greenwich longitude (in degrees) of the prime meridian of the given CRS.
 Since:
 0.5
 See Also:
DefaultPrimeMeridian.getGreenwichLongitude(Unit)

getAuthorityFactory
public static CRSAuthorityFactory getAuthorityFactory(String authority) throws FactoryException
Returns the systemwide authority factory used byforCode(String)
and other SIS methods. If the given authority is nonnull, then this method returns a factory specifically for that authority. Otherwise, this method returns theMultiAuthoritiesFactory
instance that manages all other factories.The
authority
argument can be"EPSG"
,"OGC"
or any other authority found on the classpath. In the"EPSG"
case, whether the full set of EPSG codes is supported or not depends on whether a connection to the database can be established. If no connection can be established, then this method returns a small embedded EPSG factory containing at least the CRS defined in theforCode(String)
method javadoc.Userdefined authorities can be added to the SIS environment by creating a
CRSAuthorityFactory
implementation with a public noargument constructor, and declaring the fullyqualified name of that class in a file at the following location:METAINF/services/org.opengis.referencing.crs.CRSAuthorityFactory
 Parameters:
authority
 the authority of the desired factory (typically"EPSG"
or"OGC"
), ornull
for theMultiAuthoritiesFactory
instance that manage all factories. Returns:
 the systemwide authority factory used by SIS for the given authority.
 Throws:
FactoryException
 if no factory can be returned for the given authority. Since:
 0.7
 See Also:
forCode(String)
,MultiAuthoritiesFactory

