@Test public void testCompass() { final AxisDirection[] compass = new AxisDirection[] { AxisDirection.NORTH, AxisDirection.NORTH_NORTH_EAST, AxisDirection.NORTH_EAST, AxisDirection.EAST_NORTH_EAST, AxisDirection.EAST, AxisDirection.EAST_SOUTH_EAST, AxisDirection.SOUTH_EAST, AxisDirection.SOUTH_SOUTH_EAST, AxisDirection.SOUTH, AxisDirection.SOUTH_SOUTH_WEST, AxisDirection.SOUTH_WEST, AxisDirection.WEST_SOUTH_WEST, AxisDirection.WEST, AxisDirection.WEST_NORTH_WEST, AxisDirection.NORTH_WEST, AxisDirection.NORTH_NORTH_WEST }; assertEquals(compass.length, COMPASS_DIRECTION_COUNT); final int base = AxisDirection.NORTH.ordinal(); final int h = compass.length / 2; for (int i = 0; i < compass.length; i++) { final String index = "compass[" + i + ']'; final AxisDirection c = compass[i]; double angle = i * (360.0 / compass.length); if (angle > 180) { angle -= 360; } assertEquals(index, base + i, c.ordinal()); assertEquals(index, base + i + (i < h ? h : -h), c.opposite().ordinal()); assertEquals(index, 0, getAngle(c, c), EPS); assertEquals(index, 180, Math.abs(getAngle(c, c.opposite())), EPS); assertEquals(index, angle, getAngle(c, AxisDirection.NORTH), EPS); } }
public static double getAngle(final AxisDirection source, final AxisDirection target) { ensureNonNull("source", source); ensureNonNull("target", target); final int compass = getCompassAngle(source, target); if (compass != Integer.MIN_VALUE) { return compass * (360.0 / COMPASS_DIRECTION_COUNT); } final DirectionAlongMeridian src = DirectionAlongMeridian.parse(source); if (src != null) { final DirectionAlongMeridian tgt = DirectionAlongMeridian.parse(target); if (tgt != null) { return src.getAngle(tgt); } } return Double.NaN; }
DefaultCoordinateSystemAxis extends AbstractIdentifiedObject implements CoordinateSystemAxis { public static double getAngle(final AxisDirection source, final AxisDirection target) { ensureNonNull("source", source); ensureNonNull("target", target); final int compass = getCompassAngle(source, target); if (compass != Integer.MIN_VALUE) { return compass * (360.0 / COMPASS_DIRECTION_COUNT); } final DirectionAlongMeridian src = DirectionAlongMeridian.parse(source); if (src != null) { final DirectionAlongMeridian tgt = DirectionAlongMeridian.parse(target); if (tgt != null) { return src.getAngle(tgt); } } return Double.NaN; } }
DefaultCoordinateSystemAxis extends AbstractIdentifiedObject implements CoordinateSystemAxis { public static double getAngle(final AxisDirection source, final AxisDirection target) { ensureNonNull("source", source); ensureNonNull("target", target); final int compass = getCompassAngle(source, target); if (compass != Integer.MIN_VALUE) { return compass * (360.0 / COMPASS_DIRECTION_COUNT); } final DirectionAlongMeridian src = DirectionAlongMeridian.parse(source); if (src != null) { final DirectionAlongMeridian tgt = DirectionAlongMeridian.parse(target); if (tgt != null) { return src.getAngle(tgt); } } return Double.NaN; } DefaultCoordinateSystemAxis(final CoordinateSystemAxis axis);  DefaultCoordinateSystemAxis(
            final Map<String, ?> properties,
            final String abbreviation,
            final AxisDirection direction,
            final Unit<?> unit,
            final double minimum,
            final double maximum,
            final RangeMeaning rangeMeaning);  DefaultCoordinateSystemAxis(
            final Map<String, ?> properties,
            final String abbreviation,
            final AxisDirection direction,
            final Unit<?> unit);  DefaultCoordinateSystemAxis(
            final String abbreviation, final AxisDirection direction, final Unit<?> unit);  DefaultCoordinateSystemAxis(
            final InternationalString name,
            final String abbreviation,
            final AxisDirection direction,
            final Unit<?> unit); private  DefaultCoordinateSystemAxis(
            final int name,
            final String abbreviation,
            final AxisDirection direction,
            final Unit<?> unit); }
DefaultCoordinateSystemAxis extends AbstractIdentifiedObject implements CoordinateSystemAxis { public static double getAngle(final AxisDirection source, final AxisDirection target) { ensureNonNull("source", source); ensureNonNull("target", target); final int compass = getCompassAngle(source, target); if (compass != Integer.MIN_VALUE) { return compass * (360.0 / COMPASS_DIRECTION_COUNT); } final DirectionAlongMeridian src = DirectionAlongMeridian.parse(source); if (src != null) { final DirectionAlongMeridian tgt = DirectionAlongMeridian.parse(target); if (tgt != null) { return src.getAngle(tgt); } } return Double.NaN; } DefaultCoordinateSystemAxis(final CoordinateSystemAxis axis);  DefaultCoordinateSystemAxis(
            final Map<String, ?> properties,
            final String abbreviation,
            final AxisDirection direction,
            final Unit<?> unit,
            final double minimum,
            final double maximum,
            final RangeMeaning rangeMeaning);  DefaultCoordinateSystemAxis(
            final Map<String, ?> properties,
            final String abbreviation,
            final AxisDirection direction,
            final Unit<?> unit);  DefaultCoordinateSystemAxis(
            final String abbreviation, final AxisDirection direction, final Unit<?> unit);  DefaultCoordinateSystemAxis(
            final InternationalString name,
            final String abbreviation,
            final AxisDirection direction,
            final Unit<?> unit); private  DefaultCoordinateSystemAxis(
            final int name,
            final String abbreviation,
            final AxisDirection direction,
            final Unit<?> unit); static DefaultCoordinateSystemAxis getPredefined(String name, AxisDirection direction); static AxisDirection getDirection(String direction); AxisDirection getDirection(); String getAbbreviation(); Unit<?> getUnit(); double getMinimumValue(); double getMaximumValue(); RangeMeaning getRangeMeaning(); static boolean isCompassDirection(final AxisDirection direction); static double getAngle(final AxisDirection source, final AxisDirection target); static boolean perpendicular(final AxisDirection first, final AxisDirection second); @Override boolean nameMatches(final String name); @Override boolean equals(final AbstractIdentifiedObject object, final boolean compareMetadata); @Override @SuppressWarnings("PMD.OverrideBothEqualsAndHashcode") int hashCode(); }
DefaultCoordinateSystemAxis extends AbstractIdentifiedObject implements CoordinateSystemAxis { public static double getAngle(final AxisDirection source, final AxisDirection target) { ensureNonNull("source", source); ensureNonNull("target", target); final int compass = getCompassAngle(source, target); if (compass != Integer.MIN_VALUE) { return compass * (360.0 / COMPASS_DIRECTION_COUNT); } final DirectionAlongMeridian src = DirectionAlongMeridian.parse(source); if (src != null) { final DirectionAlongMeridian tgt = DirectionAlongMeridian.parse(target); if (tgt != null) { return src.getAngle(tgt); } } return Double.NaN; } DefaultCoordinateSystemAxis(final CoordinateSystemAxis axis);  DefaultCoordinateSystemAxis(
            final Map<String, ?> properties,
            final String abbreviation,
            final AxisDirection direction,
            final Unit<?> unit,
            final double minimum,
            final double maximum,
            final RangeMeaning rangeMeaning);  DefaultCoordinateSystemAxis(
            final Map<String, ?> properties,
            final String abbreviation,
            final AxisDirection direction,
            final Unit<?> unit);  DefaultCoordinateSystemAxis(
            final String abbreviation, final AxisDirection direction, final Unit<?> unit);  DefaultCoordinateSystemAxis(
            final InternationalString name,
            final String abbreviation,
            final AxisDirection direction,
            final Unit<?> unit); private  DefaultCoordinateSystemAxis(
            final int name,
            final String abbreviation,
            final AxisDirection direction,
            final Unit<?> unit); static DefaultCoordinateSystemAxis getPredefined(String name, AxisDirection direction); static AxisDirection getDirection(String direction); AxisDirection getDirection(); String getAbbreviation(); Unit<?> getUnit(); double getMinimumValue(); double getMaximumValue(); RangeMeaning getRangeMeaning(); static boolean isCompassDirection(final AxisDirection direction); static double getAngle(final AxisDirection source, final AxisDirection target); static boolean perpendicular(final AxisDirection first, final AxisDirection second); @Override boolean nameMatches(final String name); @Override boolean equals(final AbstractIdentifiedObject object, final boolean compareMetadata); @Override @SuppressWarnings("PMD.OverrideBothEqualsAndHashcode") int hashCode(); static final DefaultCoordinateSystemAxis GEODETIC_LONGITUDE; static final DefaultCoordinateSystemAxis GEODETIC_LATITUDE; static final DefaultCoordinateSystemAxis LONGITUDE; static final DefaultCoordinateSystemAxis LATITUDE; static final DefaultCoordinateSystemAxis ELLIPSOIDAL_HEIGHT; static final DefaultCoordinateSystemAxis GRAVITY_RELATED_HEIGHT; static final DefaultCoordinateSystemAxis ALTITUDE; static final DefaultCoordinateSystemAxis DEPTH; static final DefaultCoordinateSystemAxis GEOCENTRIC_RADIUS; static final DefaultCoordinateSystemAxis SPHERICAL_LONGITUDE; static final DefaultCoordinateSystemAxis SPHERICAL_LATITUDE; static final DefaultCoordinateSystemAxis X; static final DefaultCoordinateSystemAxis Y; static final DefaultCoordinateSystemAxis Z; static final DefaultCoordinateSystemAxis GEOCENTRIC_X; static final DefaultCoordinateSystemAxis GEOCENTRIC_Y; static final DefaultCoordinateSystemAxis GEOCENTRIC_Z; static final DefaultCoordinateSystemAxis EASTING; static final DefaultCoordinateSystemAxis WESTING; static final DefaultCoordinateSystemAxis NORTHING; static final DefaultCoordinateSystemAxis SOUTHING; static final DefaultCoordinateSystemAxis TIME; static final DefaultCoordinateSystemAxis COLUMN; static final DefaultCoordinateSystemAxis ROW; static final DefaultCoordinateSystemAxis DISPLAY_X; static final DefaultCoordinateSystemAxis DISPLAY_Y; }