Class AxisDirections
java.lang.Object
org.apache.sis.util.Static
org.apache.sis.internal.referencing.AxisDirections
Utilities methods related to
AxisDirection.- Since:
- 0.4
- Version:
- 1.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionProposed abbreviations for some axis directions.static final org.opengis.referencing.cs.AxisDirectionDistance from the origin in a polar coordinate system.static final org.opengis.referencing.cs.AxisDirectionDirection of geographic angles (bearing).static final intNumber of directions like "North", "North-North-East", "North-East", etc.static final org.opengis.referencing.cs.AxisDirectionDirection of arithmetic angles.static final intNumber of directions like "Display right", "Display down", etc.private static final byte[]Maps RIGHT, LEFT, UP, DOWN display order to UP, RIGHT, DOWN, LEFT.static final org.opengis.referencing.cs.AxisDirectionForward direction.static final intNumber of geocentric directions.private static final intOrdinal of the last element in theAxisDirectioncode list.private static final Map<org.opengis.referencing.cs.AxisDirection,org.opengis.referencing.cs.AxisDirection> For each direction, the opposite direction.static final org.opengis.referencing.cs.AxisDirectionStarboard direction. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.opengis.referencing.cs.AxisDirectionabsolute(org.opengis.referencing.cs.AxisDirection dir) Returns the "absolute" direction of the given direction.static intangleForCompass(org.opengis.referencing.cs.AxisDirection source, org.opengis.referencing.cs.AxisDirection target) Arithmetic angle between compass directions only (not for angle between direction along meridians).static intangleForDisplay(org.opengis.referencing.cs.AxisDirection source, org.opengis.referencing.cs.AxisDirection target) Arithmetic angle between display directions only.static intangleForGeocentric(org.opengis.referencing.cs.AxisDirection source, org.opengis.referencing.cs.AxisDirection target) Angle between geocentric directions only.static intangleForVehicle(org.opengis.referencing.cs.AxisDirection source, org.opengis.referencing.cs.AxisDirection target) Arithmetic angle between forward/aft/port/starboard directions only.static StringappendTo(StringBuilder buffer, org.opengis.referencing.cs.CoordinateSystemAxis[] axes) Builds a coordinate system name from the given array of axes.private static booleanReturnstrueif the given name starts or ends with the given keyword, ignoring case.private static booleanequalsIgnoreCase(String name, int lower, int upper, String keyword) Returnstrueif the given sub-sequence is equal to the given keyword, ignoring case.static org.opengis.referencing.cs.AxisDirectionSearches for an axis direction having the given name in the specified list of directions.static org.opengis.referencing.cs.AxisDirectionfromAbbreviation(char abbreviation) Returns an axis direction for the given abbreviation.static javax.measure.Unit<javax.measure.quantity.Angle>getAngularUnit(org.opengis.referencing.cs.CoordinateSystem cs, javax.measure.Unit<javax.measure.quantity.Angle> fallback) Returns the angular unit of the specified coordinate system.static intindexOfColinear(org.opengis.referencing.cs.CoordinateSystem cs, org.opengis.referencing.cs.AxisDirection direction) Finds the dimension of an axis having the given direction or its opposite.static intindexOfColinear(org.opengis.referencing.cs.CoordinateSystem cs, org.opengis.referencing.cs.CoordinateSystem subCS) Returns the index of the first dimension incswhere axes are colinear with thesubCSaxes.static int[]indicesOfLenientMapping(org.opengis.referencing.cs.CoordinateSystem cs, org.opengis.referencing.cs.CoordinateSystem subCS) Returns the indices ofcsaxes presumed covariant withsubCSaxes.static booleanisCardinal(org.opengis.referencing.cs.AxisDirection dir) Returnstrueif the specified direction is cardinal direction.static booleanisColinear(org.opengis.referencing.cs.AxisDirection d1, org.opengis.referencing.cs.AxisDirection d2) Returns whether the second axis is colinear with the first axis.static booleanisCompass(org.opengis.referencing.cs.AxisDirection dir) Returnstrueif the specified direction is a compass direction.static booleanisGeocentric(org.opengis.referencing.cs.AxisDirection dir) Returnstrueif the given direction isGEOCENTRIC_X,GEOCENTRIC_YorGEOCENTRIC_Z.static booleanisGrid(org.opengis.referencing.cs.AxisDirection dir) Returnstrueif the given direction isCOLUMN_POSITIVE,COLUMN_NEGATIVE,ROW_POSITIVEorROW_NEGATIVE.static booleanisIntercardinal(org.opengis.referencing.cs.AxisDirection dir) Returnstrueif the specified direction is an inter-cardinal direction.static booleanisOpposite(org.opengis.referencing.cs.AxisDirection dir) Returnstrueif the given direction is an "opposite" direction.static booleanisSpatialOrUserDefined(org.opengis.referencing.cs.AxisDirection dir, boolean image) Returnstrueif the given direction is a spatial axis direction (including vertical and geocentric axes).static booleanisTemporal(org.opengis.referencing.cs.AxisDirection dir) Returnstrueif the given direction isFUTUREorPAST.static booleanisUserDefined(org.opengis.referencing.cs.AxisDirection dir) Returnstrueif the given direction is a user-defined direction (i.e.static booleanisVertical(org.opengis.referencing.cs.AxisDirection dir) Returnstrueif the given direction isUPorDOWN.static org.opengis.referencing.cs.AxisDirectionopposite(org.opengis.referencing.cs.AxisDirection dir) Returns the opposite direction of the given direction.private static voidput(org.opengis.referencing.cs.AxisDirection dir, org.opengis.referencing.cs.AxisDirection opposite) Stores the given directions in theOPPOSITESarray.static StringsuggestAbbreviation(String name, org.opengis.referencing.cs.AxisDirection direction, javax.measure.Unit<?> unit) Suggests an abbreviation for the given axis direction.static org.opengis.referencing.cs.AxisDirectionSearches predefinedAxisDirectionfor a given name.
-
Field Details
-
COMPASS_COUNT
public static final int COMPASS_COUNTNumber of directions like "North", "North-North-East", "North-East", etc. The first of those directions isAxisDirection.NORTH.- See Also:
-
GEOCENTRIC_COUNT
public static final int GEOCENTRIC_COUNTNumber of geocentric directions. The first of those directions isAxisDirection.GEOCENTRIC_X.- See Also:
-
DISPLAY_COUNT
public static final int DISPLAY_COUNTNumber of directions like "Display right", "Display down", etc. The first of those directions isAxisDirection.DISPLAY_RIGHT.- See Also:
-
LAST_ORDINAL
private static final int LAST_ORDINALOrdinal of the last element in theAxisDirectioncode list. This is used for differentiating the standard codes from the user-defined ones.- See Also:
-
FORWARD
@UML(identifier="forward", obligation=CONDITIONAL, specification=UNSPECIFIED) public static final org.opengis.referencing.cs.AxisDirection FORWARDForward direction. For an observer at the centre of the object this is will be towards its front, bow or nose. Added in ISO 19111:2019 (was not in ISO 19111:2007).- Since:
- 1.3
-
STARBOARD
@UML(identifier="starboard", obligation=CONDITIONAL, specification=UNSPECIFIED) public static final org.opengis.referencing.cs.AxisDirection STARBOARDStarboard direction. For an observer at the centre of the object this will be towards its right. Added in ISO 19111:2019 (was not in ISO 19111:2007).- Since:
- 1.3
-
CLOCKWISE
@UML(identifier="clockwise", obligation=CONDITIONAL, specification=UNSPECIFIED) public static final org.opengis.referencing.cs.AxisDirection CLOCKWISEDirection of geographic angles (bearing). Added in ISO 19111:2019 (was not in ISO 19111:2007).- Since:
- 0.7
-
COUNTER_CLOCKWISE
@UML(identifier="counterClockwise", obligation=CONDITIONAL, specification=UNSPECIFIED) public static final org.opengis.referencing.cs.AxisDirection COUNTER_CLOCKWISEDirection of arithmetic angles. Used in polar coordinate systems. Added in ISO 19111:2019 (was not in ISO 19111:2007).- Since:
- 0.7
-
AWAY_FROM
@UML(identifier="awayFrom", obligation=CONDITIONAL, specification=UNSPECIFIED) public static final org.opengis.referencing.cs.AxisDirection AWAY_FROMDistance from the origin in a polar coordinate system. Added in ISO 19111:2019 (was not in ISO 19111:2007).- Since:
- 0.7
-
OPPOSITES
private static final Map<org.opengis.referencing.cs.AxisDirection,org.opengis.referencing.cs.AxisDirection> OPPOSITESFor each direction, the opposite direction. This map shall be immutable after construction. -
ABBREVIATIONS
Proposed abbreviations for some axis directions. This map shall be immutable after construction. -
DISPLAY_ORDER
private static final byte[] DISPLAY_ORDERMaps RIGHT, LEFT, UP, DOWN display order to UP, RIGHT, DOWN, LEFT.
-
-
Constructor Details
-
AxisDirections
private AxisDirections()Do not allow instantiation of this class.
-
-
Method Details
-
put
private static void put(org.opengis.referencing.cs.AxisDirection dir, org.opengis.referencing.cs.AxisDirection opposite) Stores the given directions in theOPPOSITESarray. -
absolute
public static org.opengis.referencing.cs.AxisDirection absolute(org.opengis.referencing.cs.AxisDirection dir) Returns the "absolute" direction of the given direction. This "absolute" operation is similar to theMath.abs(int)method in that "negative" directions like (SOUTH,WEST,DOWN,PAST) are changed for their "positive" counterparts (NORTH,EAST,UP,FUTURE). More specifically, the following conversion table is applied:Mapping to "absolute" directions Directions Absolute value NORTH,SOUTHNORTHEAST,WESTEASTUP,DOWNUPFUTURE,PASTFUTURECOLUMN_POSITIVE,COLUMN_NEGATIVECOLUMN_POSITIVEROW_POSITIVE,ROW_NEGATIVEROW_POSITIVEDISPLAY_RIGHT,DISPLAY_LEFTDISPLAY_RIGHTDISPLAY_UP,DISPLAY_DOWNDISPLAY_UPCLOCKWISE,COUNTERCLOCKWISECOUNTERCLOCKWISEOTHEROTHER- Parameters:
dir- the direction for which to return the absolute direction, ornull.- Returns:
- the direction from the above table, or
nullif the given direction was null.
-
opposite
public static org.opengis.referencing.cs.AxisDirection opposite(org.opengis.referencing.cs.AxisDirection dir) Returns the opposite direction of the given direction. The opposite direction ofNORTHisSOUTH, and the opposite direction ofSOUTHisNORTH. The same applies toEAST-WEST,UP-DOWNandFUTURE-PAST, etc. If the given axis direction has no opposite, then this method returnsnull.- Parameters:
dir- the direction for which to return the opposite direction, ornull.- Returns:
- the opposite direction, or
nullif none or unknown.
-
isOpposite
public static boolean isOpposite(org.opengis.referencing.cs.AxisDirection dir) Returnstrueif the given direction is an "opposite" direction. If the given argument isnullor is not a known direction, then this method conservatively returnsfalse.- Parameters:
dir- the direction to test, ornull.- Returns:
trueif the given direction is an "opposite".
-
isCompass
public static boolean isCompass(org.opengis.referencing.cs.AxisDirection dir) Returnstrueif the specified direction is a compass direction. Compass directions areNORTH,EAST,NORTH_EAST, etc.- Parameters:
dir- the direction to test, ornull.- Returns:
trueif the given direction is a compass direction.- See Also:
-
isCardinal
public static boolean isCardinal(org.opengis.referencing.cs.AxisDirection dir) Returnstrueif the specified direction is cardinal direction. Cardinal directions areNORTH,SOUTH,EASTandWEST.- Parameters:
dir- the direction to test, ornull.- Returns:
trueif the given direction is a cardinal direction.- Since:
- 0.8
-
isIntercardinal
public static boolean isIntercardinal(org.opengis.referencing.cs.AxisDirection dir) Returnstrueif the specified direction is an inter-cardinal direction. Inter-cardinal directions areNORTH_EAST,SOUTH_SOUTH_EAST, etc.- Parameters:
dir- the direction to test, ornull.- Returns:
trueif the given direction is an inter-cardinal direction.
-
isVertical
public static boolean isVertical(org.opengis.referencing.cs.AxisDirection dir) Returnstrueif the given direction isUPorDOWN.- Parameters:
dir- the direction to test, ornull.- Returns:
trueif the direction is vertical, orfalseotherwise.
-
isTemporal
public static boolean isTemporal(org.opengis.referencing.cs.AxisDirection dir) Returnstrueif the given direction isFUTUREorPAST.- Parameters:
dir- the direction to test, ornull.- Returns:
trueif the direction is temporal, orfalseotherwise.
-
isGeocentric
public static boolean isGeocentric(org.opengis.referencing.cs.AxisDirection dir) Returnstrueif the given direction isGEOCENTRIC_X,GEOCENTRIC_YorGEOCENTRIC_Z.- Parameters:
dir- the direction to test, ornull.- Returns:
trueif the given direction is one of geocentric directions.
-
isSpatialOrUserDefined
public static boolean isSpatialOrUserDefined(org.opengis.referencing.cs.AxisDirection dir, boolean image) Returnstrueif the given direction is a spatial axis direction (including vertical and geocentric axes). The current implementation conservatively returnstruefor every non-null directions except a hard-coded set of directions which are known to be non-spatial. We conservatively accept unknown axis directions because some of them are created from strings like "South along 90°E".If the
imageargument istrue, then this method additionally accepts grid and display axis directions.The rules implemented by this method may change in any future SIS version.
- Parameters:
dir- the direction to test, ornull.image-truefor accepting grid and image axis directions in addition to spatial ones.- Returns:
trueif the given direction is presumed for spatial CS.
-
isUserDefined
public static boolean isUserDefined(org.opengis.referencing.cs.AxisDirection dir) Returnstrueif the given direction is a user-defined direction (i.e. is not defined by GeoAPI).- Parameters:
dir- the direction to test, ornull.- Returns:
trueif the given direction is user-defined.
-
isGrid
public static boolean isGrid(org.opengis.referencing.cs.AxisDirection dir) Returnstrueif the given direction isCOLUMN_POSITIVE,COLUMN_NEGATIVE,ROW_POSITIVEorROW_NEGATIVE.- Parameters:
dir- the direction to test, ornull.- Returns:
trueif the given direction is presumed for grid CS.
-
angleForVehicle
public static int angleForVehicle(org.opengis.referencing.cs.AxisDirection source, org.opengis.referencing.cs.AxisDirection target) Arithmetic angle between forward/aft/port/starboard directions only. This is the angle as viewed from above the vehicle.- Parameters:
source- the start direction.target- the final direction.- Returns:
- the angle as a multiple of 90°, or
Integer.MIN_VALUEif none.
-
angleForGeocentric
public static int angleForGeocentric(org.opengis.referencing.cs.AxisDirection source, org.opengis.referencing.cs.AxisDirection target) Angle between geocentric directions only.- Parameters:
source- the start direction.target- the final direction.- Returns:
- the angle as a multiple of 90°, or
Integer.MIN_VALUEif none.
-
angleForCompass
public static int angleForCompass(org.opengis.referencing.cs.AxisDirection source, org.opengis.referencing.cs.AxisDirection target) Arithmetic angle between compass directions only (not for angle between direction along meridians).- Parameters:
source- the start direction.target- the final direction.- Returns:
- the arithmetic angle as a multiple of 360/
COMPASS_COUNT, orInteger.MIN_VALUEif none. - See Also:
-
angleForDisplay
public static int angleForDisplay(org.opengis.referencing.cs.AxisDirection source, org.opengis.referencing.cs.AxisDirection target) Arithmetic angle between display directions only.- Parameters:
source- the start direction.target- the final direction.- Returns:
- the arithmetic angle as a multiple of 360/
DISPLAY_COUNT, orInteger.MIN_VALUEif none.
-
getAngularUnit
public static javax.measure.Unit<javax.measure.quantity.Angle> getAngularUnit(org.opengis.referencing.cs.CoordinateSystem cs, javax.measure.Unit<javax.measure.quantity.Angle> fallback) Returns the angular unit of the specified coordinate system. The preference will be given to the longitude axis, if found.- Parameters:
cs- the coordinate system from which to get the angular unit, ornull.fallback- the default unit to return if no angular unit is found.- Returns:
- the angular unit, of
unitif no angular unit was found. - Since:
- 0.6
- See Also:
-
indexOfColinear
public static int indexOfColinear(org.opengis.referencing.cs.CoordinateSystem cs, org.opengis.referencing.cs.AxisDirection direction) Finds the dimension of an axis having the given direction or its opposite. If more than one axis has the given direction, only the first occurrence is returned. If both the given direction and its opposite exist, then the dimension for the given direction has precedence over the opposite direction.- Parameters:
cs- the coordinate system to inspect, ornull.direction- the direction of the axis to search.- Returns:
- the dimension of the axis using the given direction or its opposite, or -1 if none.
-
indexOfColinear
public static int indexOfColinear(org.opengis.referencing.cs.CoordinateSystem cs, org.opengis.referencing.cs.CoordinateSystem subCS) Returns the index of the first dimension incswhere axes are colinear with thesubCSaxes. If no such dimension is found, returns -1. If more than one sequence ofcsaxes are colinear with allsubCSaxes, then the following rules apply:- If a sequence of
csaxes are equal to thesubCSaxes, that sequence has precedence. - Otherwise if a sequence of
csaxes have similar names than thesubCSaxes (as determined by heuristic match, that sequence has precedence. - Otherwise the index of the first sequence is returned, regardless axis names.
TemporalCRSwhen one time axis is the runtime (the date where a numerical model has been executed) and the other time axis is the forecast time (the date at which a prevision is made).- Parameters:
cs- the coordinate system which contains all axes, ornull.subCS- the coordinate system to search intocs.- Returns:
- the first dimension of a sequence of axes colinear with
subCSaxes, or-1if none. - Since:
- 0.5
- If a sequence of
-
isColinear
public static boolean isColinear(org.opengis.referencing.cs.AxisDirection d1, org.opengis.referencing.cs.AxisDirection d2) Returns whether the second axis is colinear with the first axis. This method returnstrueif the absolute direction of the given directions are equal. For example, "down" is considered colinear with "up".- Parameters:
d1- the first axis direction to compare.d2- the second axis direction to compare.- Returns:
trueif both directions are colinear.
-
indicesOfLenientMapping
public static int[] indicesOfLenientMapping(org.opengis.referencing.cs.CoordinateSystem cs, org.opengis.referencing.cs.CoordinateSystem subCS) Returns the indices ofcsaxes presumed covariant withsubCSaxes. The mapping is based on axis directions only, with colinear axes mapped in priority. If some axes cannot be mapped using collinearity criterion, then directions from poles (e.g. "South along 90°E") are arbitrarily handled as if they were covariant with East and North directions, in that order.- Parameters:
cs- the coordinate system which contains all axes, ornull.subCS- the coordinate system for which to search axes intocs.- Returns:
- indices in
csof axes covariant withsubCSaxes in the order they appear insubCS, ornullif at least onesubCSaxis cannot be mapped to acsaxis. - Since:
- 1.2
- See Also:
-
find
public static org.opengis.referencing.cs.AxisDirection find(String name, org.opengis.referencing.cs.AxisDirection[] directions) Searches for an axis direction having the given name in the specified list of directions. This method compares the given name with the name of eachAxisDirectionin a lenient way:- Comparisons are case-insensitive.
- Any character which is not a letter or a digit is ignored. For example,
"NorthEast","North-East"and"NORTH_EAST"are considered equivalent. - This method accepts abbreviations as well, for example if the given
nameis"W", then it will be considered equivalent to"WEST".
- Parameters:
name- the name of the axis direction to search.directions- the list of axis directions in which to search.- Returns:
- the first axis direction having a name matching the given one, or
nullif none.
-
valueOf
Searches predefinedAxisDirectionfor a given name. This method searches for a match in the set of known axis directions as returned byAxisDirection.values(), plus a few special cases like "Geocentre > equator/90°E". The latter are used in the EPSG database for geocentric CRS.This method does not know about
org.apache.sis.referencing.cs.DirectionAlongMeridian. The latter is a parser which may create new directions, while this method searches only in a set of predefined directions and never create new ones.- Parameters:
name- the name of the axis direction to search.- Returns:
- the first axis direction having a name matching the given one, or
nullif none.
-
equalsIgnoreCase
Returnstrueif the given sub-sequence is equal to the given keyword, ignoring case. -
contains
Returnstrueif the given name starts or ends with the given keyword, ignoring case.- Parameters:
end-falseif the given keyword is expected at the beginning of the name, ortrueif expected at the end.
-
suggestAbbreviation
public static String suggestAbbreviation(String name, org.opengis.referencing.cs.AxisDirection direction, javax.measure.Unit<?> unit) Suggests an abbreviation for the given axis direction. The unit of measurement may be used for resolving some ambiguities like whetherAxisDirection.EASTis for "x" (Easting) or "λ" (Longitude).- Parameters:
name- the axis name for which to suggest an abbreviation.direction- the axis direction for which to suggest an abbreviation.unit- the axis unit of measurement, for disambiguation.- Returns:
- a suggested abbreviation.
- Since:
- 0.6
-
fromAbbreviation
public static org.opengis.referencing.cs.AxisDirection fromAbbreviation(char abbreviation) Returns an axis direction for the given abbreviation. This method is (partially) the converse ofsuggestAbbreviation(String, AxisDirection, Unit). Current implementation does not recognize all abbreviation generated by above method, but only the main ones. This method is defined here for making easier to maintain consistency withsuggestAbbreviation(…).- Parameters:
abbreviation- the abbreviation.- Returns:
- axis direction for the given abbreviation, or
nullif unrecognized.
-
appendTo
public static String appendTo(StringBuilder buffer, org.opengis.referencing.cs.CoordinateSystemAxis[] axes) Builds a coordinate system name from the given array of axes. This method expects aStringBuilderpre-filled with the coordinate system name. The axis directions and abbreviations will be appended after the CS name. Examples:- Ellipsoidal CS: North (°), East (°).
- Cartesian CS: East (km), North (km).
- Compound CS: East (km), North (km), Up (m).
- Parameters:
buffer- a buffer pre-filled with the name header.axes- the axes to append in the given buffer.- Returns:
- a name for the given coordinate system type and axes.
- Since:
- 0.6
-