Package org.apache.sis.referencing.cs
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 theGeographicCRS 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
FieldsModifier and TypeFieldDescriptionfinal org.opengis.referencing.cs.AxisDirectionThe base direction, which must beAxisDirection.NORTHorAxisDirection.SOUTH.private org.opengis.referencing.cs.AxisDirectionThe direction.private static final org.opengis.referencing.cs.AxisDirection[]The base directions we are interested in.private static final PatternA parser for EPSG axis names.final doubleThe 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
ConstructorsConstructorDescriptionDirectionAlongMeridian(org.opengis.referencing.cs.AxisDirection baseDirection, double meridian) Creates a direction. -
Method Summary
Modifier and TypeMethodDescriptiondoubleangle(DirectionAlongMeridian other) Returns the arithmetic (counterclockwise) angle from this direction to the specified direction, in degrees.intCompares this direction with the specified one for order.booleanTests this object for equality with the specified one.protected StringFormats this object as a Well Known TextMeridian[…]element.org.opengis.referencing.cs.AxisDirectionReturns the axis direction for this object.inthashCode()Returns a hash code value, for consistency withequals(java.lang.Object).static booleanReturnstrueif the given direction is non-null and has a name which seems to be a direction along meridian.static DirectionAlongMeridianIf the specified name is a direction along some specific meridian, returns information about that.static DirectionAlongMeridianparse(org.opengis.referencing.cs.AxisDirection direction) Returns the direction along meridian for the specified axis direction, ornullif none.toString()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
-
Field Details
-
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_SOUTHThe 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_WESTThe 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 directionThe direction. Will be created only when first needed.- See Also:
-
baseDirection
public final org.opengis.referencing.cs.AxisDirection baseDirectionThe base direction, which must beAxisDirection.NORTHorAxisDirection.SOUTH. -
meridian
public final double meridianThe 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 beAxisDirection.NORTHorAxisDirection.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
Returnstrueif the given direction is non-null and has a name which seems to be a direction along meridian. -
parse
Returns the direction along meridian for the specified axis direction, ornullif none.TIP: caller can check
AxisDirections.isUserDefined(AxisDirection)before to invoke this method for avoidingDirectionAlongMeridianinitialization in the common case where it is not needed. -
parse
If the specified name is a direction along some specific meridian, returns information about that. Otherwise returnsnull.- Parameters:
name- the name to parse.- Returns:
- the parsed name, or
nullif 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
Returns the arithmetic (counterclockwise) angle from this direction to the specified direction, in degrees. This method returns a value between -180° and +180°, orDouble.NaNif 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
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:
compareToin interfaceComparable<DirectionAlongMeridian>
-
equals
Tests this object for equality with the specified one. This method is used mostly for assertions. -
hashCode
public int hashCode()Returns a hash code value, for consistency withequals(java.lang.Object). -
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 newAxisDirection. 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 singleAxisDirectionfor a given direction; we avoid potential differences like lower versus upper cases, amount of white space, etc.- Overrides:
toStringin classFormattableObject- Returns:
- the Well Known Text (WKT) or an alternative representation of this object.
-
formatTo
Formats this object as a Well Known TextMeridian[…]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:Meridianis defined in the WKT 2 specification only.- Specified by:
formatToin classFormattableObject- Parameters:
formatter- The formatter where to format the inner content of this WKT element.- Returns:
"Meridian".- See Also:
-