Class AbstractProjection

  • All Implemented Interfaces:
    Projecting, Projection
    Direct Known Subclasses:
    CustomProjection

    public abstract class AbstractProjection
    extends java.lang.Object
    implements Projection
    Implementation of the Projection interface that represents a coordinate reference system and delegates the real projection and datum conversion to other classes. It handles false easting and northing, central meridian and general scale factor before calling the delegate projection. Forwards lat/lon values to the real projection in units of radians. The fields are named after Proj.4 parameters. Subclasses of AbstractProjection must set ellps and proj to a non-null value. In addition, either datum or nadgrid has to be initialized to some value.
    • Method Detail

      • getDatum

        public final Datum getDatum()
        Gets the datum this projection is based on.
        Returns:
        The datum
      • getProj

        public final Proj getProj()
        Replies the projection (in the narrow sense)
        Returns:
        The projection object
      • getFalseEasting

        public final double getFalseEasting()
        Gets an east offset that gets applied when converting the coordinate
        Returns:
        The offset to apply in meter
      • getFalseNorthing

        public final double getFalseNorthing()
        Gets an north offset that gets applied when converting the coordinate
        Returns:
        The offset to apply in meter
      • getCentralMeridian

        public final double getCentralMeridian()
        Gets the meridian that this projection is centered on.
        Returns:
        The longitude of the meridian.
      • getToMeter

        public final double getToMeter()
        Get the factor that converts meters to intended units of east/north coordinates. For projected coordinate systems, the semi-major axis of the ellipsoid is always given in meters, which means the preliminary projection result will be in meters as well. This factor is used to convert to the intended units of east/north coordinates (e.g. feet in the US). For geographic coordinate systems, the preliminary "projection" result will be in degrees, so there is no reason to convert anything and this factor will by 1 by default.
        Returns:
        factor that converts meters to intended units of east/north coordinates
      • eastNorth2latlon

        public LatLon eastNorth2latlon​(EastNorth en)
        Description copied from interface: Projection
        Convert from easting/norting to lat/lon.
        Specified by:
        eastNorth2latlon in interface Projection
        Parameters:
        en - the geographical point to convert (in projected coordinates)
        Returns:
        the corresponding lat/lon (WGS84)
      • getProjectingsForArea

        public java.util.Map<ProjectionBounds,​ProjectinggetProjectingsForArea​(ProjectionBounds area)
        Description copied from interface: Projecting
        Returns an map or (subarea, projecting) paris that contains projecting instances to convert the coordinates inside the given area. This can be used by projections to support continuous projections. It is possible that the area covered by the map is bigger than the one given as area. There may be holes.
        Specified by:
        getProjectingsForArea in interface Projecting
        Parameters:
        area - The base area
        Returns:
        a map of non-overlapping ProjectionBounds instances mapped to the Projecting object to use for that area.
      • getEpsgCode

        public abstract java.lang.Integer getEpsgCode()
        Returns The EPSG Code of this CRS.
        Returns:
        The EPSG Code of this CRS, null if it doesn't have one.
      • toCode

        public java.lang.String toCode()
        Default implementation of toCode(). Should be overridden, if there is no EPSG code for this CRS.
        Specified by:
        toCode in interface Projection
        Returns:
        the projection identifier
      • convertMinuteSecond

        protected static final double convertMinuteSecond​(double minute,
                                                          double second)
      • convertDegreeMinuteSecond

        protected static final double convertDegreeMinuteSecond​(double degree,
                                                                double minute,
                                                                double second)
      • getBaseProjection

        public Projection getBaseProjection()
        Description copied from interface: Projecting
        Gets the base projection instance used. This may be the same as this one or a different one if this one is translated in east/north space.
        Specified by:
        getBaseProjection in interface Projecting
        Returns:
        The projection.
      • visitOutline

        public void visitOutline​(Bounds b,
                                 java.util.function.Consumer<EastNorth> visitor)
        Description copied from interface: Projection
        Visit points along the edge of this bounds instance.

        Depending on the shape in east/north space, it may simply visit the 4 corners or (more generally) several points along the curved edges.

        Specified by:
        visitOutline in interface Projection
        Parameters:
        b - the lat/lon rectangle to trace
        visitor - a function to call for the points on the edge.