/** * Compares with the specified object. See class javadoc for a description of the sorting order. */ public int compareTo(final Object other) { final ComparableAxisWrapper that = (ComparableAxisWrapper) other; final AxisDirection d1 = this.axis.getDirection(); final AxisDirection d2 = that.axis.getDirection(); final int compass = DefaultCoordinateSystemAxis.getCompassAngle(d2, d1); if (compass != Integer.MIN_VALUE) { return compass; } if (isCompassDirection(d1)) { assert !isCompassDirection(d2) : d2; return -1; } if (isCompassDirection(d2)) { assert !isCompassDirection(d1) : d1; return +1; } if (meridian != null) { if (that.meridian != null) { return meridian.compareTo(that.meridian); } return -1; } else if (that.meridian != null) { return +1; } return 0; }
/** Returns {@code true} if the specified direction is a compass direction. */ private static boolean isCompassDirection(final AxisDirection direction) { int compass = DefaultCoordinateSystemAxis.getCompassAngle(direction, AxisDirection.NORTH); return compass != Integer.MIN_VALUE; }