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.AxisDirection
The base direction, which must beAxisDirection.NORTH
orAxisDirection.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
ConstructorsConstructorDescriptionDirectionAlongMeridian
(org.opengis.referencing.cs.AxisDirection baseDirection, double meridian) Creates a direction. -
Method Summary
Modifier and TypeMethodDescriptiondouble
angle
(DirectionAlongMeridian other) 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
Tests this object for equality with the specified one.protected String
Formats this object as a Well Known TextMeridian[…]
element.org.opengis.referencing.cs.AxisDirection
Returns the axis direction for this object.int
hashCode()
Returns a hash code value, for consistency withequals(java.lang.Object)
.static boolean
Returnstrue
if the given direction is non-null and has a name which seems to be a direction along meridian.static DirectionAlongMeridian
If the specified name is a direction along some specific meridian, returns information about that.static DirectionAlongMeridian
parse
(org.opengis.referencing.cs.AxisDirection direction) Returns the direction along meridian for the specified axis direction, ornull
if 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.NORTH
orAxisDirection.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.NORTH
orAxisDirection.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
Returnstrue
if 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, ornull
if none.TIP: caller can check
AxisDirections.isUserDefined(AxisDirection)
before to invoke this method for avoidingDirectionAlongMeridian
initialization 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
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
Returns the arithmetic (counterclockwise) angle from this direction to the specified direction, in degrees. This method returns a value between -180° and +180°, orDouble.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
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 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 singleAxisDirection
for a given direction; we avoid potential differences like lower versus upper cases, amount of white space, etc.- Overrides:
toString
in 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:Meridian
is defined in the WKT 2 specification only.- Specified by:
formatTo
in classFormattableObject
- Parameters:
formatter
- The formatter where to format the inner content of this WKT element.- Returns:
"Meridian"
.- See Also:
-