Package org.geotools.referencing.crs
Class AbstractCRS
-
- All Implemented Interfaces:
Serializable,CoordinateReferenceSystem,IdentifiedObject,ReferenceSystem
- Direct Known Subclasses:
AbstractSingleCRS,DefaultCompoundCRS
public abstract class AbstractCRS extends AbstractReferenceSystem implements CoordinateReferenceSystem
Abstract coordinate reference system, usually defined by a coordinate system and a datum.- Since:
- 2.1
- Author:
- Martin Desruisseaux (IRD)
- See Also:
AbstractCS,AbstractDatum, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected CoordinateSystemcoordinateSystemThe coordinate system.-
Fields inherited from class AbstractIdentifiedObject
EMPTY_ALIAS_ARRAY, EMPTY_IDENTIFIER_ARRAY, IDENTIFIER_COMPARATOR, NAME_COMPARATOR, REMARKS_COMPARATOR
-
Fields inherited from class Formattable
SINGLE_LINE
-
Fields inherited from interface IdentifiedObject
ALIAS_KEY, IDENTIFIERS_KEY, NAME_KEY, REMARKS_KEY
-
Fields inherited from interface ReferenceSystem
DOMAIN_OF_VALIDITY_KEY, SCOPE_KEY
-
-
Constructor Summary
Constructors Constructor Description AbstractCRS(Map<String,?> properties, CoordinateSystem cs)Constructs a coordinate reference system from a set of properties.AbstractCRS(CoordinateReferenceSystem crs)Constructs a new coordinate reference system with the same values than the specified one.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intcalculateHashCode()Subclasses should override and compute hash code.Measuredistance(double[] coord1, double[] coord2)Computes the distance between two points.booleanequals(AbstractIdentifiedObject object, boolean compareMetadata)Compare this coordinate reference system with the specified object for equality.protected StringformatWKT(Formatter formatter)Formats the inner part of a Well Known Text (WKT) element.CoordinateSystemgetCoordinateSystem()Returns the coordinate system.inthashCode()Returns a hash value for this CRS.-
Methods inherited from class AbstractReferenceSystem
getDomainOfValidity, getScope
-
Methods inherited from class AbstractIdentifiedObject
asSet, ensureAngularUnit, ensureLinearUnit, ensureNonNull, ensureNonNull, ensureTimeUnit, equals, equals, equals, equals, getAlias, getIdentifier, getIdentifier, getIdentifiers, getName, getName, getName, getProperties, getProperties, getRemarks, nameMatches, nameMatches, nameMatches
-
Methods inherited from class Formattable
cleanupThreadLocals, toString, toWKT, toWKT, toWKT, toWKT
-
Methods inherited from interface IdentifiedObject
getAlias, getIdentifiers, getName, getRemarks, toWKT
-
Methods inherited from interface ReferenceSystem
getDomainOfValidity, getScope
-
-
-
-
Field Detail
-
coordinateSystem
protected final CoordinateSystem coordinateSystem
The coordinate system.
-
-
Constructor Detail
-
AbstractCRS
public AbstractCRS(CoordinateReferenceSystem crs)
Constructs a new coordinate reference system with the same values than the specified one. This copy constructor provides a way to wrap an arbitrary implementation into a Geotools one or a user-defined one (as a subclass), usually in order to leverage some implementation-specific API. This constructor performs a shallow copy, i.e. the properties are not cloned.- Parameters:
crs- The coordinate reference system to copy.- Since:
- 2.2
-
AbstractCRS
public AbstractCRS(Map<String,?> properties, CoordinateSystem cs)
Constructs a coordinate reference system from a set of properties. The properties are given unchanged to the super-class constructor.- Parameters:
properties- Set of properties. Should contains at least"name".cs- The coordinate system.
-
-
Method Detail
-
getCoordinateSystem
public CoordinateSystem getCoordinateSystem()
Returns the coordinate system.- Specified by:
getCoordinateSystemin interfaceCoordinateReferenceSystem- Returns:
- The coordinate system.
-
distance
public Measure distance(double[] coord1, double[] coord2) throws UnsupportedOperationException, MismatchedDimensionException
Computes the distance between two points. This convenience method delegates the work to the underlyling coordinate system, if possible.- Parameters:
coord1- Coordinates of the first point.coord2- Coordinates of the second point.- Returns:
- The distance between
coord1andcoord2. - Throws:
UnsupportedOperationException- if this coordinate reference system can't compute distances.MismatchedDimensionException- if a coordinate doesn't have the expected dimension.
-
equals
public boolean equals(AbstractIdentifiedObject object, boolean compareMetadata)
Compare this coordinate reference system with the specified object for equality. IfcompareMetadataistrue, then all available properties are compared including AbstractReferenceSystem.getDomainOfValidity() valid area} and scope.- Overrides:
equalsin classAbstractReferenceSystem- Parameters:
object- The object to compare tothis.compareMetadata-truefor performing a strict comparaison, orfalsefor comparing only properties relevant to transformations.- Returns:
trueif both objects are equal.
-
hashCode
public final int hashCode()
Returns a hash value for this CRS. Name, identifiers and remarks are not taken in account. In other words, two CRS objects will return the same hash value if they are equal in the sense of.equals(AbstractIdentifiedObject, false)- Overrides:
hashCodein classAbstractIdentifiedObject- Returns:
- The hash code value. This value doesn't need to be the same in past or future versions of this class.
-
calculateHashCode
protected int calculateHashCode()
Subclasses should override and compute hash code. See alsohashCode().
-
formatWKT
protected String formatWKT(Formatter formatter)
Formats the inner part of a Well Known Text (WKT) element. The default implementation writes the following elements:- The datum, if any.
- The unit if all axis use the same unit. Otherwise the unit is omitted and the WKT format is flagged as invalid.
- All coordinate system's axis.
- Overrides:
formatWKTin classFormattable- Parameters:
formatter- The formatter to use.- Returns:
- The name of the WKT element type (e.g.
"GEOGCS"). - See Also:
Formattable.toWKT(),Formattable.toString()
-
-