public final class CRS extends Static
forCode(String)
.isHorizontalCRS(CoordinateReferenceSystem)
.getSingleComponents(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 by
instanceof
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.Defined in the sis-referencing
module
Modifier and Type | Method and Description |
---|---|
static CoordinateReferenceSystem |
forCode(String code)
Returns the Coordinate Reference System for the given authority code.
|
static GeographicBoundingBox |
getGeographicBoundingBox(CoordinateReferenceSystem crs)
Returns the valid geographic area for the given coordinate reference system, or
null if unknown. |
static SingleCRS |
getHorizontalComponent(CoordinateReferenceSystem crs)
Returns the first horizontal coordinate reference system found in the given CRS, or
null if there is
none. |
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, or
null if there is none. |
static VerticalCRS |
getVerticalComponent(CoordinateReferenceSystem crs,
boolean allowCreateEllipsoidal)
Returns the first vertical coordinate reference system found in the given CRS, or
null if there is none. |
static boolean |
isHorizontalCRS(CoordinateReferenceSystem crs)
Returns
true if the given CRS is horizontal. |
public static CoordinateReferenceSystem forCode(String code) throws NoSuchAuthorityCodeException, FactoryException
CRSAuthorityFactory
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 version 0.4 or above:
This method accepts also the URN and URL syntax. For example the following codes are considered equivalent to
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:5715 DEPTH
Vertical Mean Sea Level depth EPSG:5714 MEAN_SEA_LEVEL
Vertical Mean Sea Level height
"EPSG:4326"
:
"urn:ogc:def:crs:EPSG::4326"
"http://www.opengis.net/gml/srs/epsg.xml#4326"
code
- The authority code.NoSuchAuthorityCodeException
- If there is no known CRS associated to the given code.FactoryException
- if the CRS creation failed for an other reason.public static GeographicBoundingBox getGeographicBoundingBox(CoordinateReferenceSystem crs)
null
if unknown.
This method explores the domain of validity
associated with the given CRS. If more than one geographic bounding box is found, then they will be
added together.crs
- The coordinate reference system, or null
.null
if none.#getEnvelope(CoordinateReferenceSystem)
,
Extents.getGeographicBoundingBox(Extent)
public static boolean isHorizontalCRS(CoordinateReferenceSystem crs)
true
if the given CRS is horizontal. The current implementation considers a
CRS as horizontal if it is two-dimensional and comply with one of the following conditions:
GeographicCRS
.ProjectedCRS
.false
.crs
- The coordinate reference system, or null
.true
if the given CRS is non-null and comply with one of the above conditions,
or false
otherwise.getHorizontalComponent(CoordinateReferenceSystem)
DerivedCRS
instance based on a projected CRS.
See SIS-161.public static SingleCRS getHorizontalComponent(CoordinateReferenceSystem crs)
null
if there is
none. If the given CRS is already horizontal according isHorizontalCRS(CoordinateReferenceSystem)
,
then this method returns it as-is. 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 three-dimensional geographic CRS is found, this method will create a two-dimensional geographic CRS without the vertical axis.
crs
- The coordinate reference system, or null
.null
if none.public static VerticalCRS getVerticalComponent(CoordinateReferenceSystem crs, boolean allowCreateEllipsoidal)
null
if there is none.
If the given CRS is already an instance of VerticalCRS
, then this method returns it as-is.
Otherwise if the given CRS is compound, then this method searches for the first vertical component
in the order of the single components list.
null
when asked for the VerticalCRS
component of a geographic CRS. This is what getVerticalComponent(…)
does when the
allowCreateEllipsoidal
argument is false
.
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 the
allowCreateEllipsoidal
argument to true
. In such case, this getVerticalComponent(…)
method will create a temporary VerticalCRS
from the first three-dimensional GeographicCRS
in last resort, only if it can not find an existing VerticalCRS
instance.
Note that this is not a valid CRS according ISO 19111 — use with care.
crs
- The coordinate reference system, or null
.allowCreateEllipsoidal
- true
for allowing the creation of orphan CRS for ellipsoidal heights.
The recommended value is false
.null
if none.public static TemporalCRS getTemporalComponent(CoordinateReferenceSystem crs)
null
if there is none.
If the given CRS is already an instance of TemporalCRS
, then this method returns it as-is.
Otherwise if the given CRS is compound, then this method searches for the first temporal component
in the order of the single components list.crs
- The coordinate reference system, or null
.null
if none.public static List<SingleCRS> getSingleComponents(CoordinateReferenceSystem crs)
SingleCRS
, returns that instance in a singleton list.CompoundCRS
, returns a flattened list of its
components. Some components may themselves be
other CompoundCRS
instances, in which case those compound CRS are also expanded in their
list of SingleCRS
components.ClassCastException
.Hierarchical structure | Flat list |
---|---|
|
|
crs
- The coordinate reference system, or null
.null
.ClassCastException
- if a CRS is neither a SingleCRS
or a CompoundCRS
.DefaultCompoundCRS.getSingleComponents()
Copyright © 2010–2014 The Apache Software Foundation. All rights reserved.