Class Mercator.Spherical

All Implemented Interfaces:
Serializable, Parameterized, LenientComparable, org.opengis.referencing.operation.MathTransform, org.opengis.referencing.operation.MathTransform2D
Enclosing class:
Mercator

static final class Mercator.Spherical extends Mercator
Provides the transform equations for the spherical case of the Mercator projection.
Implementation note: this class contains an explicit check for latitude values at a pole. If floating point arithmetic had infinite precision, such checks would not be necessary since the formulas lead naturally to infinite values at poles, which is the correct answer. In practice the infinite value emerges by itself at only one pole, and the other one produces a high value (approximately 1E+16). This is because there is no accurate representation of π/2, and consequently tan(π/2) does not return the infinite value. We workaround this issue with an explicit check for abs(φ) ≊ π/2. Note that:
  • The arithmetic is not broken for values close to pole. We check π/2 because this is the result of converting 90°N to radians, and we presume that the user really wanted to said 90°N. But for most other values we could let the math do their "natural" work.
  • For φ = -π/2 our arithmetic already produces negative infinity.
Since:
0.6
Version:
0.6
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      For cross-version compatibility.
      See Also:
  • Constructor Details

    • Spherical

      Spherical(Mercator other)
      Constructs a new map projection from the parameters of the given projection.
      Parameters:
      other - the other projection (usually ellipsoidal) from which to copy the parameters.
  • Method Details

    • transform

      public org.opengis.referencing.operation.Matrix transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, boolean derivate)
      Projects the specified coordinates (implementation-specific units) and stores the result in dstPts. In addition, opportunistically computes the projection derivative if derivate is true. The results must be multiplied by the denormalization matrix before to get linear distances.
      Overrides:
      transform in class Mercator
      Parameters:
      srcPts - the array containing the source point coordinates, as (longitude, latitude) angles in radians.
      srcOff - the offset of the single coordinate tuple to be converted in the source array.
      dstPts - the array into which the converted coordinates is returned (may be the same than srcPts). Coordinates will be expressed in a dimensionless unit, as a linear distance on a unit sphere or ellipse.
      dstOff - the offset of the location of the converted coordinates that is stored in the destination array.
      derivate - true for computing the derivative, or false if not needed.
      Returns:
      the matrix of the projection derivative at the given source position, or null if the derivate argument is false.
      See Also:
    • transform

      public void transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) throws org.opengis.referencing.operation.TransformException
      Converts a list of coordinate tuples. This method performs the same calculation than above Mercator.transform(double[], int, double[], int, boolean) method, but is overridden for efficiency.
      Note: This method must be overridden because the Mercator class overrides the NormalizedProjection default implementation.
      Specified by:
      transform in interface org.opengis.referencing.operation.MathTransform
      Overrides:
      transform in class Mercator
      Parameters:
      srcPts - the array containing the source point coordinates.
      srcOff - the offset to the first point to be transformed in the source array.
      dstPts - the array into which the transformed point coordinates are returned. May be the same than srcPts.
      dstOff - the offset to the location of the first transformed point that is stored in the destination array.
      numPts - the number of point objects to be transformed.
      Throws:
      org.opengis.referencing.operation.TransformException - if a point cannot be converted.
    • inverseTransform

      protected void inverseTransform(double[] srcPts, int srcOff, double[] dstPts, int dstOff)
      Converts the specified (x,y) coordinates and stores the result in dstPts (angles in radians).
      Overrides:
      inverseTransform in class Mercator
      Parameters:
      srcPts - the array containing the source point coordinates, as linear distance on a unit sphere or ellipse.
      srcOff - the offset of the point to be converted in the source array.
      dstPts - the array into which the converted point coordinates is returned (may be the same than srcPts). Coordinates will be (longitude, latitude) angles in radians.
      dstOff - the offset of the location of the converted point that is stored in the destination array.