Class DirectionAlongMeridian

java.lang.Object
org.apache.sis.io.wkt.FormattableObject
org.apache.sis.referencing.cs.DirectionAlongMeridian
All Implemented Interfaces:
Comparable<DirectionAlongMeridian>

final class DirectionAlongMeridian extends FormattableObject implements Comparable<DirectionAlongMeridian>
Parses axis direction of the kind "South along 90 deg East". Those directions are used in the EPSG database for polar stereographic projections.

Reference meridian

This class does not know whether the meridian is relative to Greenwich or any other reference meridian. The reference meridian shall be inferred from the geodetic datum of the GeographicCRS instance that contains (through its coordinate system) the axes having those directions. This is consistent with ISO 19162:2015 §7.5.4(iv) - WKT 2 formatting.
Since:
0.4
Version:
1.2
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final org.opengis.referencing.cs.AxisDirection
    The base direction, which must be AxisDirection.NORTH or AxisDirection.SOUTH.
    private org.opengis.referencing.cs.AxisDirection
    The direction.
    private static final org.opengis.referencing.cs.AxisDirection[]
    The base directions we are interested in.
    private static final Pattern
    A parser for EPSG axis names.
    final double
    The meridian in degrees, relative to a unspecified (usually Greenwich) prime meridian.
    private static final org.opengis.referencing.cs.AxisDirection[]
    The base directions we are interested in.
  • Constructor Summary

    Constructors
    Constructor
    Description
    DirectionAlongMeridian(org.opengis.referencing.cs.AxisDirection baseDirection, double meridian)
    Creates a direction.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Returns the arithmetic (counterclockwise) angle from this direction to the specified direction, in degrees.
    int
    Compares this direction with the specified one for order.
    boolean
    equals(Object object)
    Tests this object for equality with the specified one.
    protected String
    formatTo(Formatter formatter)
    Formats this object as a Well Known Text Meridian[…] element.
    org.opengis.referencing.cs.AxisDirection
    Returns the axis direction for this object.
    int
    Returns a hash code value, for consistency with equals(java.lang.Object).
    static boolean
    matches(String direction)
    Returns true if the given direction is non-null and has a name which seems to be a direction along meridian.
    parse(String name)
    If the specified name is a direction along some specific meridian, returns information about that.
    parse(org.opengis.referencing.cs.AxisDirection direction)
    Returns the direction along meridian for the specified axis direction, or null if none.
    Returns a string representation of this direction, using a syntax matching the one used by EPSG.

    Methods inherited from class org.apache.sis.io.wkt.FormattableObject

    print, toString, toWKT

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • EPSG

      private static final Pattern EPSG
      A parser for EPSG axis names. Examples:
      • "South along 180 deg"
      • "South along 90 deg East"
    • NORTH_SOUTH

      private static final org.opengis.referencing.cs.AxisDirection[] NORTH_SOUTH
      The base directions we are interested in. Any direction not in this group will be rejected by our parser.
    • EAST_WEST

      private static final org.opengis.referencing.cs.AxisDirection[] EAST_WEST
      The base directions we are interested in. Any direction not in this group will be rejected by our parser.
    • direction

      private transient org.opengis.referencing.cs.AxisDirection direction
      The direction. Will be created only when first needed.
      See Also:
    • baseDirection

      public final org.opengis.referencing.cs.AxisDirection baseDirection
      The base direction, which must be AxisDirection.NORTH or AxisDirection.SOUTH.
    • meridian

      public final double meridian
      The meridian in degrees, relative to a unspecified (usually Greenwich) prime meridian. Meridians in the East hemisphere are positive and meridians in the West hemisphere are negative.
  • Constructor Details

    • DirectionAlongMeridian

      DirectionAlongMeridian(org.opengis.referencing.cs.AxisDirection baseDirection, double meridian)
      Creates a direction.
      Parameters:
      baseDirection - the base direction, which must be AxisDirection.NORTH or AxisDirection.SOUTH.
      meridian - the meridian in degrees, relative to a unspecified (usually Greenwich) prime meridian. Meridians in the East hemisphere are positive and meridians in the West hemisphere are negative.
  • Method Details

    • matches

      public static boolean matches(String direction)
      Returns true if the given direction is non-null and has a name which seems to be a direction along meridian.
    • parse

      public static DirectionAlongMeridian parse(org.opengis.referencing.cs.AxisDirection direction)
      Returns the direction along meridian for the specified axis direction, or null if none.

      TIP: caller can check AxisDirections.isUserDefined(AxisDirection) before to invoke this method for avoiding DirectionAlongMeridian initialization in the common case where it is not needed.

    • parse

      public static DirectionAlongMeridian parse(String name) throws IllegalArgumentException
      If the specified name is a direction along some specific meridian, returns information about that. Otherwise returns null.
      Parameters:
      name - the name to parse.
      Returns:
      the parsed name, or null if it is not a direction along a meridian.
      Throws:
      IllegalArgumentException - if the given name looks like a direction along a meridian, but an error occurred during parsing.
    • getDirection

      public org.opengis.referencing.cs.AxisDirection getDirection()
      Returns the axis direction for this object. If a suitable axis direction already exists, it will be returned. Otherwise a new one is created and returned.
    • angle

      public double angle(DirectionAlongMeridian other)
      Returns the arithmetic (counterclockwise) angle from this direction to the specified direction, in degrees. This method returns a value between -180° and +180°, or Double.NaN if the base directions don't match. A positive angle denote a right-handed system.
      Example: The angle from "North along 90 deg East" to "North along 0 deg is 90°.
    • compareTo

      public int compareTo(DirectionAlongMeridian that)
      Compares this direction with the specified one for order. This method tries to reproduce the ordering used for the majority of coordinate systems in the EPSG database, i.e. the ordering of a right-handed coordinate system. Examples of ordered pairs that we should get (extracted from the EPSG database):
      Direction name examples
      North along 90° East, North along 0°
      North along 75° West, North along 165° West
      South along 90° West, South along 0°
      South along 180°, South along 90° West
      North along 130° West North along 140° East
      Specified by:
      compareTo in interface Comparable<DirectionAlongMeridian>
    • equals

      public boolean equals(Object object)
      Tests this object for equality with the specified one. This method is used mostly for assertions.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Returns a hash code value, for consistency with equals(java.lang.Object).
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Returns a string representation of this direction, using a syntax matching the one used by EPSG. This string representation will be used for creating a new AxisDirection. The generated name should be identical to EPSG name, but we use the generated one anyway (rather than the one provided by EPSG) in order to make sure that we create a single AxisDirection for a given direction; we avoid potential differences like lower versus upper cases, amount of white space, etc.
      Overrides:
      toString in class FormattableObject
      Returns:
      the Well Known Text (WKT) or an alternative representation of this object.
    • formatTo

      protected String formatTo(Formatter formatter)
      Formats this object as a Well Known Text Meridian[…] element. This element contains the meridian value and the unit of measurement. The unit is currently fixed to degrees, but this may change in any future implementation.
      Compatibility note: Meridian is defined in the WKT 2 specification only.
      Specified by:
      formatTo in class FormattableObject
      Parameters:
      formatter - The formatter where to format the inner content of this WKT element.
      Returns:
      "Meridian".
      See Also: