Package org.geotools.referencing.util
Class CRSUtilities
- Object
- 
- CRSUtilities
 
- 
 public final class CRSUtilities extends Object A set of static methods working on OpenGIS® coordinate reference system objects. Some of those methods are useful, but not really rigorous. This is why they do not appear in the "official" package, but instead in this private one. Do not rely on this API! It may change in incompatible way in any future release.- Since:
- 2.0
- Author:
- Martin Desruisseaux (IRD)
 
- 
- 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static Map<String,?>changeDimensionInName(IdentifiedObject object, String search, String replace)Changes the dimension declared in the name.static Point2DdeltaTransform(MathTransform2D transform, Point2D origin, Point2D source, Point2D dest)Transforms the relative distance vector specified bysourceand stores the result indest.static PositiondeltaTransform(MathTransform transform, Position origin, Position source)Transforms the relative distance vector specified bysourceand stores the result indest.static intdimensionColinearWith(CoordinateSystem cs, CoordinateSystemAxis axis)Returns the dimension within the coordinate system of the first occurrence of an axis colinear with the specified axis.static CoordinateReferenceSystemgetCRS2D(CoordinateReferenceSystem crs)Returns a two-dimensional coordinate reference system representing the two first dimensions of the specified coordinate reference system.static DatumgetDatum(CoordinateReferenceSystem crs)Returns the datum of the specified CRS, ornullif none.static intgetDimensionOf(CoordinateReferenceSystem crs, Class<? extends CoordinateReferenceSystem> type)Returns the dimension of the first coordinate reference system of the given type.static EllipsoidgetHeadGeoEllipsoid(CoordinateReferenceSystem crs)Returns the ellipsoid used by the specified coordinate reference system, providing that the two first dimensions use an instance ofGeographicCRS.static GeographicCRSgetStandardGeographicCRS2D(CoordinateReferenceSystem crs)Derives a geographic CRS with (longitude, latitude) axis order in decimal degrees, relative to Greenwich.static CoordinateReferenceSystemgetSubCRS(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 StringtoWGS84String(CoordinateReferenceSystem crs, Rectangle2D bounds)Returns a character string for the specified geographic area.
 
- 
- 
- 
Method Detail- 
dimensionColinearWithpublic 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. If an axis with the same direction or an opposite direction thanaxisocurs 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-1is returned.For example, dimensionColinearWith(CoordinateSystemAxis.TIME)returns the dimension number of time axis.- Parameters:
- cs- The coordinate system to examine.
- axis- The axis to look for.
- Returns:
- The dimension number of the specified axis, or -1if none.
 
 - 
getUnitpublic static Unit<?> getUnit(CoordinateSystem cs) Returns the unit used for all axis in the specified coordinate system. If not all axis uses the same unit, then this method returnsnull. This convenience method is often used for Well Know Text (WKT) formatting.- Parameters:
- cs- The coordinate system for which to get the unit.
- Returns:
- The unit for all axis in the given coordinate system, or null.
- Since:
- 2.2
 
 - 
getDimensionOfpublic static int getDimensionOf(CoordinateReferenceSystem crs, Class<? extends CoordinateReferenceSystem> type) throws IllegalArgumentException Returns the dimension of the first coordinate reference system of the given type. Thetypeargument must be a subinterface ofCoordinateReferenceSystem. If no such dimension is found, then this method returns-1.- Parameters:
- crs- The coordinate reference system (CRS) to examine.
- type- The CRS type to look for. Must be a subclass of- CoordinateReferenceSystem.
- Returns:
- The dimension range of the specified CRS type, or -1if none.
- Throws:
- IllegalArgumentException- if the- typeis not legal.
 
 - 
getSubCRSpublic static CoordinateReferenceSystem getSubCRS(CoordinateReferenceSystem crs, int lower, int upper) Returns a sub-coordinate reference system for the specified dimension range.- Parameters:
- crs- The coordinate reference system to decompose.
- lower- The first dimension to keep, inclusive.
- upper- The last dimension to keep, exclusive.
- Returns:
- The sub-coordinate system, or nullifcrscan't be decomposed for dimensions in the range[lower..upper].
 
 - 
getCRS2Dpublic static CoordinateReferenceSystem getCRS2D(CoordinateReferenceSystem crs) throws TransformException Returns a two-dimensional coordinate reference system representing the two first dimensions of the specified coordinate reference system. Ifcrsis already a two-dimensional CRS, then it is returned unchanged. Otherwise, if it is aCompoundCRS, then the head coordinate reference system is examined.- Parameters:
- crs- The coordinate system, or- null.
- Returns:
- A two-dimensional coordinate reference system that represents the two first dimensions of crs, ornullifcrswasnull.
- Throws:
- TransformException- if- crscan'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.
 
 - 
changeDimensionInNamepublic static Map<String,?> changeDimensionInName(IdentifiedObject object, String search, String replace) Changes the dimension declared in the name. For example ifnameis "WGS 84 (geographic 3D)",searchis "3D" andreplaceis "2D", then this method returns "WGS 84 (geographic 2D)". If the string to search is not found, then it is concatenated to the name.- Parameters:
- object- The identified object having the original name.
- search- The dimension token to search in the- objectname.
- replace- The new token to substitute to the one we were looking for.
- Returns:
- The name with the substitution performed.
- Since:
- 2.6
 
 - 
getDatumpublic static Datum getDatum(CoordinateReferenceSystem crs) Returns the datum of the specified CRS, ornullif none.- Parameters:
- crs- The coordinate reference system for which to get the datum. May be- null.
- Returns:
- The datum in the given CRS, or nullif none.
 
 - 
getHeadGeoEllipsoidpublic static Ellipsoid getHeadGeoEllipsoid(CoordinateReferenceSystem crs) Returns the ellipsoid used by the specified coordinate reference system, providing that the two first dimensions use an instance ofGeographicCRS. Otherwise (i.e. if the two first dimensions are not geographic), returnsnull.- Parameters:
- crs- The coordinate reference system for which to get the ellipsoid.
- Returns:
- The ellipsoid in the given CRS, or nullif none.
 
 - 
getStandardGeographicCRS2Dpublic static GeographicCRS getStandardGeographicCRS2D(CoordinateReferenceSystem crs) Derives a geographic CRS with (longitude, latitude) axis order in decimal degrees, relative to Greenwich. If no such CRS can be obtained of created, returnsDefaultGeographicCRS.WGS84.- Parameters:
- crs- A source CRS.
- Returns:
- A two-dimensional geographic CRS with standard axis. Never null.
 
 - 
deltaTransformpublic static Position deltaTransform(MathTransform transform, Position origin, Position source) throws TransformException Transforms the relative distance vector specified bysourceand stores the result indest. A relative distance vector is transformed without applying the translation components.- Parameters:
- 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 transformed
- Returns:
- The result of the transformation.
- Throws:
- TransformException- if the transformation failed.
- Since:
- 2.3
 
 - 
deltaTransformpublic static Point2D deltaTransform(MathTransform2D transform, Point2D origin, Point2D source, Point2D dest) throws TransformException Transforms the relative distance vector specified bysourceand stores the result indest. A relative distance vector is transformed without applying the translation components.- Parameters:
- 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 transformed
- dest- The resulting transformed distance vector, or- null
- Returns:
- The result of the transformation.
- Throws:
- TransformException- if the transformation failed.
- See Also:
- AffineTransform.deltaTransform(Point2D,Point2D)
 
 - 
toWGS84Stringpublic static String toWGS84String(CoordinateReferenceSystem crs, Rectangle2D bounds) Returns a character string for the specified geographic area. The string will have the form "45°00.00'N-50°00.00'N 30°00.00'E-40°00.00'E". If a map projection is required in order to obtain this representation, it will be automatically applied. This string is mostly used for debugging purpose.- Parameters:
- crs- The coordinate reference system of the bounding box.
- bounds- The bounding box to format.
- Returns:
- The bounding box formatted as a string.
 
 
- 
 
-