public final class CRSUtilities extends Object
Modifier and Type | Method and Description |
---|---|
static Map<String,?> |
changeDimensionInName(IdentifiedObject object,
String search,
String replace)
Changes the dimension declared in the name.
|
static Point2D |
deltaTransform(MathTransform2D transform,
Point2D origin,
Point2D source,
Point2D dest)
Transforms the relative distance vector specified by
source and stores the result in
dest . |
static DirectPosition |
deltaTransform(MathTransform transform,
DirectPosition origin,
DirectPosition source)
Transforms the relative distance vector specified by
source and stores the result in
dest . |
static int |
dimensionColinearWith(CoordinateSystem cs,
CoordinateSystemAxis axis)
Returns the dimension within the coordinate system of the first occurrence of an axis
colinear with the specified axis.
|
static CoordinateReferenceSystem |
getCRS2D(CoordinateReferenceSystem crs)
Returns a two-dimensional coordinate reference system representing the two first dimensions
of the specified coordinate reference system.
|
static Datum |
getDatum(CoordinateReferenceSystem crs)
Returns the datum of the specified CRS, or
null if none. |
static int |
getDimensionOf(CoordinateReferenceSystem crs,
Class<? extends CoordinateReferenceSystem> type)
Returns the dimension of the first coordinate reference system of the given type.
|
static Ellipsoid |
getHeadGeoEllipsoid(CoordinateReferenceSystem crs)
Returns the ellipsoid used by the specified coordinate reference system, providing that the
two first dimensions use an instance of
GeographicCRS . |
static GeographicCRS |
getStandardGeographicCRS2D(CoordinateReferenceSystem crs)
Derives a geographic CRS with (longitude, latitude) axis order in
decimal degrees, relative to Greenwich.
|
static CoordinateReferenceSystem |
getSubCRS(CoordinateReferenceSystem crs,
int lower,
int upper)
Returns a sub-coordinate reference system for the specified dimension range.
|
static Unit<?> |
getUnit(CoordinateSystem cs)
Returns the unit used for all axis in the specified coordinate system.
|
static String |
toWGS84String(CoordinateReferenceSystem crs,
Rectangle2D bounds)
Returns a character string for the specified geographic area.
|
public static int dimensionColinearWith(CoordinateSystem cs, CoordinateSystemAxis axis)
axis
ocurs in the coordinate system, then the dimension of
the first such occurrence is returned. That is, the a value k such that:
iscs.getAxis(k).getDirection().absolute() == axis.getDirection().absolute()
true
. If no such axis occurs in this coordinate system, then -1
is
returned.
For example, dimensionColinearWith(CoordinateSystemAxis.TIME)
returns the
dimension number of time axis.
cs
- The coordinate system to examine.axis
- The axis to look for.-1
if none.public static Unit<?> getUnit(CoordinateSystem cs)
null
. This convenience method is often used
for Well Know Text (WKT) formatting.cs
- The coordinate system for which to get the unit.null
.public static int getDimensionOf(CoordinateReferenceSystem crs, Class<? extends CoordinateReferenceSystem> type) throws IllegalArgumentException
type
argument must be a subinterface of CoordinateReferenceSystem
. If no such
dimension is found, then this method returns -1
.crs
- The coordinate reference system (CRS) to examine.type
- The CRS type to look for. Must be a subclass of CoordinateReferenceSystem
.-1
if none.IllegalArgumentException
- if the type
is not legal.public static CoordinateReferenceSystem getSubCRS(CoordinateReferenceSystem crs, int lower, int upper)
crs
- The coordinate reference system to decompose.lower
- The first dimension to keep, inclusive.upper
- The last dimension to keep, exclusive.null
if crs
can't be decomposed for
dimensions in the range [lower..upper]
.public static CoordinateReferenceSystem getCRS2D(CoordinateReferenceSystem crs) throws TransformException
crs
is already a two-dimensional
CRS, then it is returned unchanged. Otherwise, if it is a CompoundCRS
, then the head
coordinate reference system is examined.crs
- The coordinate system, or null
.crs
, or null
if crs
was null
.TransformException
- if crs
can't be reduced to a two-coordinate system. We use
this exception class since this method is usually invoked in the context of a
transformation process.public static Map<String,?> changeDimensionInName(IdentifiedObject object, String search, String replace)
name
is "WGS 84
(geographic 3D)", search
is "3D" and replace
is "2D", then this method
returns "WGS 84 (geographic 2D)". If the string to search is not found, then it is
concatenated to the name.object
- The identified object having the original name.search
- The dimension token to search in the object
name.replace
- The new token to substitute to the one we were looking for.public static Datum getDatum(CoordinateReferenceSystem crs)
null
if none.crs
- The coordinate reference system for which to get the datum. May be null
.null
if none.public static Ellipsoid getHeadGeoEllipsoid(CoordinateReferenceSystem crs)
GeographicCRS
. Otherwise (i.e. if the two
first dimensions are not geographic), returns null
.crs
- The coordinate reference system for which to get the ellipsoid.null
if none.public static GeographicCRS getStandardGeographicCRS2D(CoordinateReferenceSystem crs)
DefaultGeographicCRS.WGS84
.crs
- A source CRS.null
.public static DirectPosition deltaTransform(MathTransform transform, DirectPosition origin, DirectPosition source) throws TransformException
source
and stores the result in
dest
. A relative distance vector is transformed without applying the translation
components.transform
- The transform to apply.origin
- The position where to compute the delta transform in the source CS.source
- The distance vector to be delta transformedTransformException
- if the transformation failed.public static Point2D deltaTransform(MathTransform2D transform, Point2D origin, Point2D source, Point2D dest) throws TransformException
source
and stores the result in
dest
. A relative distance vector is transformed without applying the translation
components.transform
- The transform to apply.origin
- The position where to compute the delta transform in the source CS.source
- The distance vector to be delta transformeddest
- The resulting transformed distance vector, or null
TransformException
- if the transformation failed.AffineTransform.deltaTransform(Point2D,Point2D)
public static String toWGS84String(CoordinateReferenceSystem crs, Rectangle2D bounds)
crs
- The coordinate reference system of the bounding box.bounds
- The bounding box to format.Copyright © 1996–2019 Geotools. All rights reserved.