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 CoordinateReferenceSystem |
fromWKT(String text)
Creates a Coordinate Reference System object from a Well Known Text (WKT).
|
static CoordinateReferenceSystem |
getComponentAt(CoordinateReferenceSystem crs,
int lower,
int upper)
Returns the coordinate reference system in the given range of dimension indices.
|
static GeographicBoundingBox |
getGeographicBoundingBox(CoordinateReferenceSystem crs)
Returns the valid geographic area for the given coordinate reference system, or
null 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, 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
Minimal set of supported authority codes Code Enum CRS Type Description CRS:27 NAD27Geographic Like EPSG:4267 except for (longitude, latitude) axis order CRS:83 NAD83Geographic Like EPSG:4269 except for (longitude, latitude) axis order CRS:84 WGS84Geographic Like EPSG:4326 except for (longitude, latitude) axis order EPSG:4047 SPHEREGeographic GRS 1980 Authalic Sphere EPSG:4230 ED50Geographic European Datum 1950 EPSG:4258 ETRS89Geographic European Terrestrial Reference Frame 1989 EPSG:4267 NAD27Geographic North American Datum 1927 EPSG:4269 NAD83Geographic North American Datum 1983 EPSG:4322 WGS72Geographic World Geodetic System 1972 EPSG:4326 WGS84Geographic World Geodetic System 1984 EPSG:4936 ETRS89Geocentric European Terrestrial Reference Frame 1989 EPSG:4937 ETRS89Geographic 3D European Terrestrial Reference Frame 1989 EPSG:4978 WGS84Geocentric World Geodetic System 1984 EPSG:4979 WGS84Geographic 3D World Geodetic System 1984 EPSG:4984 WGS72Geocentric World Geodetic System 1972 EPSG:4985 WGS72Geographic 3D World Geodetic System 1972 EPSG:5715 DEPTHVertical Mean Sea Level depth EPSG:5714 MEAN_SEA_LEVELVertical 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 CoordinateReferenceSystem fromWKT(String text) throws FactoryException
UNIT[…] and ORDER[…] 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]]
GeodeticObjectFactory.createFromWKT(String)
using a default factory instance. This is okay for occasional use, but has the following limitations:
WKTFormat class instead than this method.text - Coordinate system encoded in Well-Known Text format (version 1 or 2).FactoryException - if the given WKT can not be parsed.org.apache.sis.io.wkt,
Envelopes.fromWKT(CharSequence),
WKT 2 specificationpublic 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, orProjectedCRS, orEngineeringCRS (following
ISO 19162 §16.1
definition of <horizontal crs>).false.crs - The coordinate reference system, or null.true if the given CRS is non-null and likely horizontal, or false otherwise.getHorizontalComponent(CoordinateReferenceSystem)DerivedCRS instance based on a projected CRS.
Conversely, a future SIS versions may impose more conditions on EngineeringCRS.
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()public static CoordinateReferenceSystem getComponentAt(CoordinateReferenceSystem crs, int lower, int upper)
crs is null, then this method returns null.lower is 0 and upper is the number of CRS dimensions,
then this method returns the given CRS unchanged.CompoundCRS, then this method
searches for a component where:
upper - lower;lower.null.crs - The coordinate reference system to decompose, or null.lower - The first dimension to keep, inclusive.upper - The last dimension to keep, exclusive.null if the given crs was null
or can not be decomposed for dimensions in the [lower … upper] range.IndexOutOfBoundsException - If the given index are out of bounds.GeneralEnvelope.subEnvelope(int, int)public static double getGreenwichLongitude(GeodeticCRS crs)
crs - The coordinate reference system from which to get the prime meridian.DefaultPrimeMeridian.getGreenwichLongitude(Unit)Copyright © 2010–2015 The Apache Software Foundation. All rights reserved.