Class AbstractCRS

  • All Implemented Interfaces:
    java.io.Serializable, org.opengis.metadata.Identifier, org.opengis.referencing.crs.CoordinateReferenceSystem, org.opengis.referencing.crs.SingleCRS, org.opengis.referencing.cs.CoordinateSystem, org.opengis.referencing.IdentifiedObject, org.opengis.referencing.ReferenceIdentifier, org.opengis.referencing.ReferenceSystem
    Direct Known Subclasses:
    GeographicCRSWrapper, ProjectedCRSWrapper

    abstract class AbstractCRS
    extends Wrapper
    implements org.opengis.referencing.crs.SingleCRS, org.opengis.referencing.cs.CoordinateSystem, java.io.Serializable
    Wraps a PROJ4J implementation behind the equivalent GeoAPI interface.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private Axis[] axes
      The coordinate system axes, computed and cached when first requested.
      (package private) CoordinateReferenceSystem impl
      The wrapped PROJ4 implementation.
      (package private) boolean is3D
      Whether this CRS is three-dimensional instead of two-dimensional.
      • Fields inherited from interface org.opengis.referencing.IdentifiedObject

        ALIAS_KEY, IDENTIFIERS_KEY, NAME_KEY, REMARKS_KEY
      • Fields inherited from interface org.opengis.metadata.Identifier

        AUTHORITY_KEY, CODE_KEY
      • Fields inherited from interface org.opengis.referencing.ReferenceIdentifier

        CODESPACE_KEY, VERSION_KEY
      • Fields inherited from interface org.opengis.referencing.ReferenceSystem

        DOMAIN_OF_VALIDITY_KEY, SCOPE_KEY
    • Field Detail

      • is3D

        final boolean is3D
        Whether this CRS is three-dimensional instead of two-dimensional.
      • axes

        private transient volatile Axis[] axes
        The coordinate system axes, computed and cached when first requested. This is refreshed every time that getCoordinateSystem() is invoked, for compliance with the documentation saying that this object is a view.
    • Constructor Detail

      • AbstractCRS

        AbstractCRS​(CoordinateReferenceSystem impl,
                    boolean is3D)
        Creates a new wrapper for the given PROJ4J implementation.
    • Method Detail

      • wrap

        static AbstractCRS wrap​(CoordinateReferenceSystem impl,
                                boolean is3D)
        Wraps the given implementation.
        Parameters:
        impl - the implementation to wrap, or null
        is3D - whether to return a three-dimensional CRS instead of a two-dimensional one
        Returns:
        the wrapper, or null if the given implementation was null
      • implementation

        final java.lang.Object implementation()
        {@return the PROJ4J backing implementation}.
        Specified by:
        implementation in class Wrapper
      • getCode

        public final java.lang.String getCode()
        {@return the CRS name}.
        Specified by:
        getCode in interface org.opengis.metadata.Identifier
        Specified by:
        getCode in class Wrapper
      • getDatum

        public final org.opengis.referencing.datum.GeodeticDatum getDatum()
        {@return the PROJ4J datum wrapped behind the GeoAPI interface}.
        Specified by:
        getDatum in interface org.opengis.referencing.crs.SingleCRS
      • getCoordinateSystem

        public org.opengis.referencing.cs.CoordinateSystem getCoordinateSystem()
        {@return the coordinate system, which is implemented by the same class for convenience}.
        Specified by:
        getCoordinateSystem in interface org.opengis.referencing.crs.CoordinateReferenceSystem
        Specified by:
        getCoordinateSystem in interface org.opengis.referencing.crs.SingleCRS
      • getDimension

        public final int getDimension()
        {@return the number of dimensions, which is 2 or 3}.
        Specified by:
        getDimension in interface org.opengis.referencing.cs.CoordinateSystem
      • axesForAllDirections

        abstract Axis[] axesForAllDirections()
        Returns Axis.GEOGRAPHIC and Axis.PROJECTED arrays, depending on whether this CRS is geographic or projected. The returned array is not cloned, the caller shall not modify it.
      • clearAxisCache

        final void clearAxisCache()
        Clears the cache of axes. This method should be invoked by getCoordinateSystem() for compliance with the documentation saying that change in the wrapped object are reflected in the view.
      • getAxis

        public final org.opengis.referencing.cs.CoordinateSystemAxis getAxis​(int dimension)
        Returns the axis in the given dimension.
        Specified by:
        getAxis in interface org.opengis.referencing.cs.CoordinateSystem
        Parameters:
        dimension - the axis index, from 0 to 2 inclusive.
        Returns:
        axis in the specified dimension.
        Throws:
        java.lang.IndexOutOfBoundsException - if the given axis index is out of bounds.