Class MapProjection

All Implemented Interfaces:
Cloneable, ProjectionConstants
Direct Known Subclasses:
GCTPProjection, GCTPStyleProjection

public abstract class MapProjection extends EarthTransform2D implements ProjectionConstants
The MapProjection class is the abstract parent of all map projections that implement coordinate conversions for the projection systems listed in ProjectionConstants.
Since:
3.2.1
Author:
Peter Hollemans
  • Field Details

    • DESCRIPTION

      public static final String DESCRIPTION
      Projection description string.
      See Also:
    • system

      protected int system
      The map projection system.
    • zone

      protected int zone
      The map projection system zone.
    • spheroid

      protected int spheroid
      The map projection spheroid code.
    • inverseAffine

      protected AffineTransform inverseAffine
      Data [row, column] to map [x, y] affine transform. By inverse, we mean that the affine is used in the inverse mapping transformation.
    • forwardAffine

      protected AffineTransform forwardAffine
      Map [x, y] to data [row, column] affine transform. By forward, we mean that the affine is used in the forward mapping transformation.
    • datum

      protected Datum datum
      The map projection datum.
  • Constructor Details

    • MapProjection

      protected MapProjection(int system, int zone, int spheroid, int[] dimensions, AffineTransform affine) throws NoninvertibleTransformException
      Constructs a map projection from the specified projection and affine transform. The SpheroidConstants and ProjectionConstants class should be consulted for valid parameter constants.
      Parameters:
      system - the map projection system.
      zone - the map projection zone for State Plane and UTM projections.
      spheroid - the spheroid code or -1 for user-defined. If the spheroid is user-defined, the datum should be set manually by the subclass.
      dimensions - the dimensions of the data grid as [rows, columns].
      affine - the affine transform for translating data [row, column] to map [x, y].
      Throws:
      NoninvertibleTransformException - if the map projection to data coordinate affine transform is not invertible.
  • Method Details

    • isOrientable

      public boolean isOrientable()
      Description copied from class: EarthTransform2D
      Gets the orientation hint. If a transform is orientable, then it may be better for the user to have it rotated for display so that northerly locations occur where data locations have smaller row values and southerly locations occur where data locations have larger row values. If a transform is not orientable, then it should be presented to the user exactly as-is.
      Overrides:
      isOrientable in class EarthTransform2D
      Returns:
      true if the transform is orientable, or false if not. Unless overridden by the subclass, this method returns true.
    • getSystemName

      public String getSystemName()
      Gets the projection system name.
    • getSystem

      public int getSystem()
      Gets the projection system.
    • getZone

      public int getZone()
      Gets the projection zone.
    • getSpheroidName

      public String getSpheroidName()
      Gets the projection spheroid name.
    • getSpheroid

      public int getSpheroid()
      Gets the projection spheroid code.
    • getDatum

      public Datum getDatum()
      Gets the projection datum.
      Overrides:
      getDatum in class EarthTransform
      Returns:
      the geodetic datum.
    • getAffine

      public AffineTransform getAffine()
      Gets the data [row, column] to map [x, y] affine transform.
    • describe

      public String describe()
      Description copied from class: EarthTransform
      Gets a string describing the earth transform type.
      Specified by:
      describe in class EarthTransform
    • getModified

      public MapProjection getModified(EarthLocation centerLoc, double[] pixelDims) throws NoninvertibleTransformException
      Gets a modified version of this map projection.
      Parameters:
      centerLoc - the new earth center location of the map center.
      pixelDims - the new pixel dimensions in meters at the projection reference point as [height, width].
      Returns:
      the modified version of this projection.
      Throws:
      NoninvertibleTransformException - if the map projection to data coordinate affine transform is not invertible.
    • setAffine

      protected void setAffine(EarthLocation centerLoc, double[] pixelDims) throws NoninvertibleTransformException
      Sets the affines for this projection based on center and pixel dimensions.
      Parameters:
      centerLoc - the earth location at the map center.
      pixelDims - the pixel dimensions in meters at the projection reference point as [height, width].
      Throws:
      NoninvertibleTransformException - if the map projection to data coordinate affine transform is not invertible.
    • getPixelSize

      public double getPixelSize()
      Gets the pixel size indicated by the affine transform. The returned pixel size is only valid for square pixels.
      Returns:
      the pixel size in meters.
    • getPixelDimensions

      public double[] getPixelDimensions()
      Gets the pixel dimensions. The returned pixel dimensions are only valid for non-rotation data to map affine transforms.
      Returns:
      the pixel dimensions in meters at the projection reference point as [height, width].
    • getSubset

      public EarthTransform getSubset(DataLocation newOrigin, int[] newDims)
      Description copied from class: EarthTransform
      Creates and returns a new subset transform. The new transform is arranged with the specified new origin and dimensions. For example, if the transform maps the data location (100,100) to earth location (40N, 120W), and a translated transform is created with (100,100) as the new origin, then the new transform will map (0,0) to (40N, 120W). Note that not all transforms support subsets.
      Overrides:
      getSubset in class EarthTransform
      Parameters:
      newOrigin - the new data location origin.
      newDims - the new data location dimensions.
    • getSubset

      public MapProjection getSubset(int[] start, int[] stride, int[] length)
      Creates a subset version of this map projection.
      Parameters:
      start - the 2D starting data coordinates.
      stride - the 2D data stride.
      length - the total number of values in each dimension.
      Returns:
      the subset and/or subsampled transform.
    • clone

      public Object clone()
      Description copied from class: EarthTransform
      Creates and returns a copy of this object.
      Overrides:
      clone in class EarthTransform
    • transformImpl

      protected void transformImpl(DataLocation dataLoc, EarthLocation earthLoc)
      Description copied from class: EarthTransform
      Implements the data to geographic transform.
      Specified by:
      transformImpl in class EarthTransform
      See Also:
    • transformImpl

      protected void transformImpl(EarthLocation earthLoc, DataLocation dataLoc)
      Description copied from class: EarthTransform
      Implements the geographic to data transform.
      Specified by:
      transformImpl in class EarthTransform
      See Also:
    • mapTransformFor

      public abstract void mapTransformFor(double[] lonLat, double[] xy)
      Performs a forward map transformation from (latitude, longitude) coordinates to map (x, y).
      Parameters:
      lonLat - the longitude and latitude in radians.
      xy - the x and y in meters or Double.NaN if the transform could not be computed (modified).
    • mapTransformInv

      public abstract void mapTransformInv(double[] xy, double[] lonLat)
      Performs an inverse map transformation from map (x, y) coordinates to (latitude, longitude).
      Parameters:
      xy - the x and y in meters.
      lonLat - the longitude and latitude in radians or Double.NaN if the transform could not be computed (modified).
    • setPositiveLon

      @Deprecated public void setPositiveLon(boolean flag)
      Deprecated.
      As of 3.5.1, correct longitude interpretation in geographic projections are handled internally by the GeographicProjection class.
      Sets the positive longitude flag for geographic projections. When true, longitudes are converted to be positive only in calls to transform(EarthLocation). By default, the positive longitude flag is false and longitudes are not modified.
      Parameters:
      flag - the positive longitude flag.
    • getParameters

      public double[] getParameters()
      Gets a set of GCTP-style projection parameters if available.
      Returns:
      the parameters array.
      Throws:
      UnsupportedOperationException - if the map projection properties cannot be represented using GCTP parameters.
    • getProjection

      public static int getProjection(String name)
      Gets the projection system that matches the specified name.
      Parameters:
      name - the projection system name.
      Returns:
      the matching projection code or -1 if none found.
    • equals

      public boolean equals(Object obj)
      Compares the specified object with this map projection for equality. The GCTP-style projection parameters and affine transforms are compared value by value.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to be compared for equality.
      Returns:
      true if the map projections are equivalent, or false if not.
      See Also: